News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How to draw fullscreen in GDI and change screen res temporarily?

Started by kroz, July 24, 2012, 06:56:01 PM

Previous topic - Next topic

kroz



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 :)

Bill Cravener

How too:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd183411(v=vs.85).aspx

Example:
http://www.quickersoft.com/examples/Resolution.zip

kroz

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

If you mean full screen as in no window, I think you are restricted to directx.

dedndave

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

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.

kroz

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

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

you may also have a condition where the machine in question cannot keep up with the code   :P

Farabi

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
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

hfheatherfox07

@ 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

thanks all :)
problem fixed.
not that i understood that code ... :P

kroz

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

For CreateWindowEx:
style=WS_OVERLAPPED or WS_CAPTION or WS_SYSMENU or WS_MINIMIZEBOX or WS_CLIPCHILDREN or WS_VISIBLE

dedndave

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