;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 窗口居中过程,调用方法invoke _CenterWindow,hWinMain Hankcs,2010
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_CenterWindow proc uses ebx hWnd
LOCAL @dwSnWidth,@dwSnHeight:dword
LOCAL @dwWndWidth,@dwWndHeight:dword
LOCAL @dwLeft,@dwTop:dword
LOCAL @stRect:RECT
invoke GetSystemMetrics,SM_CXSCREEN
mov @dwSnWidth,eax
invoke GetSystemMetrics,SM_CYSCREEN
mov @dwSnHeight,eax
invoke GetWindowRect,hWnd,addr @stRect
;让窗体居中
;首先是X轴
mov eax,@stRect.right
mov @dwWndWidth,eax
mov eax,@stRect.left
sub @dwWndWidth,eax
mov eax,@stRect.bottom
mov @dwWndHeight,eax
mov eax,@stRect.top
sub @dwWndHeight,eax
mov eax,@dwWndWidth
sub @dwSnWidth,eax
mov edx,0
mov eax,@dwSnWidth
mov ecx,2
div ecx
mov @dwLeft,eax
mov eax,@dwWndHeight
sub @dwSnHeight,eax
mov edx,0
mov eax,@dwSnHeight
mov ecx,2
div ecx
mov @dwTop,eax
invoke SetWindowPos,hWnd,HWND_NOTOPMOST,@dwLeft,@dwTop,0,0,SWP_NOSIZE
ret
_CenterWindow endp