I test a prog on 2 computers.
One is very old - win7 - resolution 1024x768.
The other one has a larger resolution.
The program window is 620x480 px.
So the looks on the displays are quite different.
I want to check the Displaysize (resolution) before the start.
;---
Get_My_Window proc
INVOKE GetWindowDC,0 ;0 = whole desktop ?
mov hdc,eax
INVOKE ReleaseDC,0,hdc ;for further use
INVOKE GetWindowExtEx,hdc,offset _SIZE ;without ReleaseDC the prog goes down
;result here is 0 = wrong
;_SIZE.x = 0
;_SIZE.y = 4
ret
Get_My_Window endp
;---
Is GetWindowExtEx the correct function to check the resolution ?
Someone please can help me.
There are various options, here are two:
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
SetGlobals rc:RECT
Init
lea eax, rc
push eax
push rv(GetDesktopWindow)
call GetClientRect
Print Str$("Width=%i", rc.right), Str$(", Height=%i\n", rc.bottom)
invoke SystemParametersInfo, SPI_GETWORKAREA, 0, addr rc, 0 ; fills a RECT
pop ecx
pop eax
Inkey Str$("Width=%i", rc.right), Str$(", Height=%i\n", rc.bottom)
EndOfCode
Output:
Width=1366, Height=768
Width=1366, Height=740
Hello clamicun,
Can you test the example below?
include \masm32\include\masm32rt.inc
.data
str1 db 'Width = %u',13,10,'Height = %u',0
.code
start:
call main
invoke ExitProcess,0
main PROC USES esi
LOCAL rect:RECT
invoke GetDesktopWindow
lea esi,rect
invoke GetWindowRect,eax,esi
invoke crt_printf,ADDR str1,\
RECT.right[esi],\
RECT.bottom[esi]
ret
main ENDP
END start
JJ and vortex,
yes, the 2 progs do the job.
so I do not need to use "GetWindowDC and GetWindowExtex".
GetDesktopWindow is the choice. Easier than I thought.
Thank you both.
Clamicun