Post by R.WieserJJ,
Post by JJI've tested as a console application, and sure enough, it still works.
It does, as long as you are in GUI mode (a windowed console). It doesn't
(at least at my end) when you switch to full-screen text-mode. In my case I
always start with "MODE CON COLS=80 LINES=25".
And I realized just now that that is what makes it extra strange : The app
is a console app one in both cases, but in the full-screen mode it suddenly
looses track of its (GUI) desktop DC.
I just test to ask for the DC twice (and destroy it) ihn the same thread,
but in between switch from fullscreen console to GUI (windowed) mode (using
ALT-tab). I get two different DC results. As a test I also just ran it
fully in GUI and after in console mode. In the former I get the same DC
back twice. In the latter I get two different ones.
Judging from what I can see from my (further) tests, either DC or its
geometry, becomes wonky in fullscreen text mode. It's exactly as what you've
experienced.
The cause is probably because GDI is not applicable for text video mode,
where the screen "window", is not graphical. However, `GetDC(0)` returns a
valid handle regardless. That confuses me.
Here's my result if I tested it as a console application, without and with
fullscreen mode. The output was done in a single console window created by
CMD. Test #1 is in windowsed mode, #2 is in fullscreen, and #3 is back to
windowed mode.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\user>cd Desktop
C:\Documents and Settings\user\Desktop>Project2.exe
enum#1: dc=none, rect=none
mon:0010008F, dc:00000000, rect:(0,0)-(1032,702)=1032x702
mon:00020001, dc:00000000, rect:(1032,1032)-(1832,600)=800x600
enum#2: dc=getdc(0)=01010052, rect=none
mon:0010008F, dc:AC0102B9, rect:(0,0)-(1032,702)=1032x702
mon:00020001, dc:BE010299, rect:(1032,1032)-(1832,600)=800x600
enum#3: dc=none, rect=(100,100)-(110,110)
mon:0010008F, dc:00000000, rect:(100,100)-(110,110)=10x10
enum#4: dc=getdc(0)=01010052, rect=(100,100)-(110,110)
mon:0010008F, dc:AC0102B9, rect:(100,100)-(110,110)=10x10
enum#5: dc=getdc(0)=01010052, rect=(1400,100)-(1410,110)
mon:00020001, dc:BE010299, rect:(1400,1400)-(1410,110)=10x10
C:\Documents and Settings\user\Desktop>Project2.exe
enum#1: dc=none, rect=none
mon:0010008F, dc:00000000, rect:(0,0)-(1032,702)=1032x702
mon:00020001, dc:00000000, rect:(1032,1032)-(1832,600)=800x600
enum#2: dc=getdc(0)=01010055, rect=none
enum#3: dc=none, rect=(100,100)-(110,110)
mon:0010008F, dc:00000000, rect:(100,100)-(110,110)=10x10
enum#4: dc=getdc(0)=01010055, rect=(100,100)-(110,110)
enum#5: dc=getdc(0)=01010055, rect=(1400,100)-(1410,110)
C:\Documents and Settings\user\Desktop>Project2.exe
enum#1: dc=none, rect=none
mon:0010008F, dc:00000000, rect:(0,0)-(1032,702)=1032x702
mon:00020001, dc:00000000, rect:(1032,1032)-(1832,600)=800x600
enum#2: dc=getdc(0)=01010051, rect=none
mon:0010008F, dc:AC0102B9, rect:(0,0)-(1032,702)=1032x702
mon:00020001, dc:BE010299, rect:(1032,1032)-(1832,600)=800x600
enum#3: dc=none, rect=(100,100)-(110,110)
mon:0010008F, dc:00000000, rect:(100,100)-(110,110)=10x10
enum#4: dc=getdc(0)=01010051, rect=(100,100)-(110,110)
mon:0010008F, dc:AC0102B9, rect:(100,100)-(110,110)=10x10
enum#5: dc=getdc(0)=01010051, rect=(1400,100)-(1410,110)
mon:00020001, dc:BE010299, rect:(1400,1400)-(1410,110)=10x10
C:\Documents and Settings\user\Desktop>