Author Topic: How to draw fullscreen in GDI and change screen res temporarily?  (Read 10820 times)

kroz

  • Guest


I've made a small gdi proggie and would like to make it run fullscreen
in 640x480 mode.

i would like to know how to :

(A) make the program run in fullscreen

(B) how to set the screen-res to 640x480 so the program is not just
    a tiny square on a nice 1024x768 screen ( kinda like stretch-to-fit, except not changing the aspect ratio )

any help/code/(ranting?) would be appreciated very much :)


kroz

  • Guest
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #2 on: July 25, 2012, 06:35:55 PM »
thanks. unfortunately - it doesnt look like I can get 640x480 in Win7 :( bummer.
and any examples on creating a fullscreen window?
and can it be done from a DialogBox? (i.e the kind that's in the resources called by DialogBoxParam )

sinsi

  • Member
  • *****
  • Posts: 1182
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #3 on: July 25, 2012, 07:07:37 PM »
If you mean full screen as in no window, I think you are restricted to directx.
I can walk on water but stagger on beer bourbon.

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #4 on: July 25, 2012, 09:15:47 PM »
you can use a window handle of HWND_DESKTOP, which is 0
of course, you mess up their desktop - lol

or - you can create a borderless window that is the size of the screen at coord 0,0

you can get the window size with GetSystemMetrics
but - if you want the workspace - SystemParametersInfo has that
the workspace excludes things like taskbars

then, there is always a borderless, captionless window that is maximized

oh - and you can use EnumDisplaySettings to get the supported screen resolutions

Bill Cravener

  • Guest
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #5 on: July 25, 2012, 10:24:14 PM »
thanks. unfortunately - it doesnt look like I can get 640x480 in Win7 :( bummer.

On both my Win7 and XP boxes 800x600 is the minimum resolution. I run both my machines in 1920x1080 resolution.

kroz

  • Guest
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #6 on: July 27, 2012, 03:56:21 PM »
Hrmmm...
Yes, GDI can be done fullscreen i think, but getting fullscreen at 768p brings up lots of complications with the demo i'm making :/

and another question to save starting another thread,
if i create a timer using SetTimer to tick every 1000ms or whatever,
will the tick time be the same on all (or 99.9%) of computers?
(since one of my computers seems to be running too fast with a timer-operated animation)

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #7 on: July 27, 2012, 04:39:00 PM »
I have never seen a system where the timer frequencies were off by any noticeable amount. I think there could be conditions where the timers might be slowed, for example a single-core system where the core is being monopolized by a very high-priority process, but I can’t think of any conditions where the timers would speed up.
Well Microsoft, here’s another nice mess you’ve gotten us into.

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #8 on: July 28, 2012, 12:51:38 AM »
you may also have a condition where the machine in question cannot keep up with the code   :P

Farabi

  • Member
  • ****
  • Posts: 969
  • Neuroscience Fans
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #9 on: August 04, 2012, 11:04:34 AM »
Try this code, it worked on my XP, Visa and 7

Code: [Select]
Change_Screen_Resolution proc w:dword, h:dword, bitsPerPixel:dword
invoke RtlZeroMemory, addr _dmScreenSettings, sizeof DEVMODE
mov _dmScreenSettings.dmSize, sizeof DEVMODE
mov _dmScreenSettings.dmPelsWidth, CMEM(w)
mov _dmScreenSettings.dmPelsHeight, CMEM(h)
mov _dmScreenSettings.dmBitsPerPel, CMEM(bitsPerPixel)
mov _dmScreenSettings.dmFields, DM_BITSPERPEL or DM_PELSWIDTH or DM_PELSHEIGHT or DM_DISPLAYFREQUENCY
mov _dmScreenSettings.dmDisplayFrequency, 60
invoke ChangeDisplaySettings, addr _dmScreenSettings, 000000004h
.if eax != DISP_CHANGE_SUCCESSFUL
xor eax, eax
.else
mov eax, TRUE
.endif
ret
Change_Screen_Resolution endp
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

hfheatherfox07

  • Member
  • ***
  • Posts: 464
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #10 on: August 05, 2012, 07:51:43 AM »
@ kroz I think we covered this in the old masm forum here http://www.masmforum.com/board/index.php?topic=17221.0

with this attachments you can go to either full desk top or window  F1 to toggle in between them
I think this is what you are asking for  :t
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

kroz

  • Guest
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #11 on: August 05, 2012, 08:19:17 PM »
thanks all :)
problem fixed.
not that i understood that code ... :P

kroz

  • Guest
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #12 on: August 08, 2012, 08:17:12 PM »
Oh yes , How can I set the window to be a fixed size (not user-changeable) when in windowed mode ?
i.e - if you choose NO for fullscreen then you cannot resize window.
(BlankWindow5) :)

jj2007

  • Member
  • *****
  • Posts: 9687
  • Assembler is fun ;-)
    • MasmBasic
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #13 on: August 08, 2012, 08:28:53 PM »
For CreateWindowEx:
style=WS_OVERLAPPED or WS_CAPTION or WS_SYSMENU or WS_MINIMIZEBOX or WS_CLIPCHILDREN or WS_VISIBLE

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: How to draw fullscreen in GDI and change screen res temporarily?
« Reply #14 on: August 08, 2012, 09:10:29 PM »
i think WS_OVERLAPPEDWINDOW includes the WS_THICKFRAME bit
WS_THICKFRAME means the window has a sizing border around it

but - if you want to keep the border - and still disable sizing...
you can respond to the WM_GETMINMAXINFO messages in the main window WndProc

Code: [Select]
    .elseif eax==WM_GETMINMAXINFO
        mov     edx,lParam
        mov     [edx].MINMAXINFO.ptMinTrackSize.x,MainWidth
        mov     [edx].MINMAXINFO.ptMinTrackSize.y,MainHeight
        mov     [edx].MINMAXINFO.ptMaxTrackSize.x,MainWidth
        mov     [edx].MINMAXINFO.ptMaxTrackSize.y,MainHeight
        xor     eax,eax
        ret

i normally only use the "Min" sizes to set minimum window dimensions
but, if you set the "Min"s = "Max"s, the window is stuck at that size

EDIT: changed WS_BORDER to WS_THICKFRAME per Jochen   :P
« Last Edit: August 08, 2012, 10:27:55 PM by dedndave »