Hi,
Can somebody show me how to center a window onto the screen? I would like to know how to get the correct x and y if given the window height and width to place that window onto the center of the screen.
Thanks,
Barry
Can somebody show me how to center a window onto the screen? I would like to know how to get the correct x and y if given the window height and width to place that window onto the center of the screen.
Thanks,
Barry
Do you know the meaning of "search"?
Search for "center window":
http://www.asmcommunity.net/board/index.php?topic=5437&highlight=center+window
Search for "center window":
http://www.asmcommunity.net/board/index.php?topic=5437&highlight=center+window
Taken from www.madwizard.org
My code
CenterScreen proc hwnd:HWND
LOCAL DlgHeight:DWORD
LOCAL DlgWidth:DWORD
LOCAL DlgRect:RECT
LOCAL DesktopRect:RECT
invoke GetWindowRect,hwnd,ADDR DlgRect
invoke GetDesktopWindow
mov ecx,eax
invoke GetWindowRect,ecx,addr DesktopRect
push 0
mov eax,DlgRect.bottom
sub eax,DlgRect.top
mov DlgHeight,eax
push eax
mov eax,DlgRect.right
sub eax,DlgRect.left
mov DlgWidth,eax
push eax
mov eax,DesktopRect.bottom
sub eax,DlgHeight
shr eax,1
push eax
mov eax,DesktopRect.right
sub eax,DlgWidth
shr eax,1
push eax
push hwnd
call MoveWindow
ret
CenterScreen endp
My code
invoke GetSystemMetrics, SM_CXSCREEN
sub eax,800
shr eax,1
xchg eax,ebx
invoke GetSystemMetrics, SM_CYSCREEN
sub eax,600
shr eax,1
invoke CreateWindowEx, NULL,ADDR ClassName, ADDR AppName, WS_BORDER or WS_VISIBLE or WS_OVERLAPPEDWINDOW,\
ebx,eax,800,600, 0, 0, hinst, 0
Hi roticv,
Thanks for the code and showing me where you got it from. I will check out that website as well.
Barry ^_^
Thanks for the code and showing me where you got it from. I will check out that website as well.
Barry ^_^
If you look in the MASM32 subfolders, your will discover many useful functions, the onr roticv posted, for example. :)