The MASM Forum

General => The Campus => Topic started by: kroz on July 24, 2012, 06:56:01 PM

Title: How to draw fullscreen in GDI and change screen res temporarily?
Post by: kroz on July 24, 2012, 06:56:01 PM


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 :)
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: Bill Cravener on July 24, 2012, 08:24:18 PM
How too:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd183411(v=vs.85).aspx

Example:
http://www.quickersoft.com/examples/Resolution.zip
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: kroz 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 )
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: sinsi on July 25, 2012, 07:07:37 PM
If you mean full screen as in no window, I think you are restricted to directx.
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: dedndave 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
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: Bill Cravener on July 25, 2012, 10:24:14 PM
Quote from: kroz on July 25, 2012, 06:35:55 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.
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: kroz 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)
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: MichaelW 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.
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: dedndave 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
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: Farabi on August 04, 2012, 11:04:34 AM
Try this code, it worked on my XP, Visa and 7


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
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: hfheatherfox07 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
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: kroz on August 05, 2012, 08:19:17 PM
thanks all :)
problem fixed.
not that i understood that code ... :P
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: kroz 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) :)
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: jj2007 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
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: dedndave 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

    .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
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: jj2007 on August 08, 2012, 09:53:45 PM
Quote from: dedndave on August 08, 2012, 09:10:29 PM
WS_BORDER means the window has a sizing border around it

That's WS_THICKFRAME, Dave
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: dedndave on August 08, 2012, 10:25:01 PM
oops - right you are   :biggrin:

and i think it's one of the WS_OVERLAPPEDWINDOW bits
WS_OVERLAPPEDWINDOW = 00CF0000h
WS_THICKFRAME       = 00040000h
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: jj2007 on August 09, 2012, 02:05:27 AM
Quote from: dedndave on August 08, 2012, 10:25:01 PM
and i think it's one of the WS_OVERLAPPEDWINDOW bits

Yes it is but note I use WS_OVERLAPPED, not WS_OVERLAPPEDWINDOW ;)
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: dedndave on August 09, 2012, 07:33:33 PM
 :t
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: hfheatherfox07 on August 10, 2012, 01:13:04 AM
Quote from: kroz 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) :)


That is simple! Comment out lines 176, 177, and 179 in BlankWindow5   :t

P.S
I open the assembly file with NOTEPAD2 so much nicer
You can see line #'s
http://www.flos-freeware.ch/notepad2.html
Title: Re: How to draw fullscreen in GDI and change screen res temporarily?
Post by: hfheatherfox07 on August 10, 2012, 01:21:27 AM
By the way Kroz I love intro demos... I assume that is what you are
Making ... Is this something you can share for us to see? :icon_cool: