Assembly code snippets
Details
Title | New CenterWindow |
---|---|
Author | Joshua |
Submitted by: | Joshua |
Date added: | 2003-12-13 03:09:26 |
Date modified: | 2003-12-13 03:51:29 |
Comments
New version of CenterWindow originally by QvasiModo
Centers a window relative to it's owner window.
Tipically used to center a dialog box to it's parent window, or a main window to the desktop.
Size 79 bytes (QvasiModo's: 112 bytes)
Snippet
; CenterWindow
; original by QvasiModo
; new version by Joshua
; Centers a window relative to it's owner window.
; Tipically used to center a dialog box to it's parent window, or a main window to the desktop.
CenterWindow proto :dword
.code
option prologue:none
option epilogue:none
CenterWindow proc hwnd:dword
push ebx
push esi
mov esi,[esp+12]
push 1
sub esp,16
push esp
push esi
call GetWindowRect
pop eax
pop ecx
sub [esp],eax
sub [esp+4],ecx
push GW_OWNER
push esi
call GetWindow
sub esp,16
push esp
push eax
call GetWindowRect
pop ebx
pop edx
pop eax
pop ecx
add eax,ebx
add ecx,edx
sub eax,[esp]
sub ecx,[esp+4]
sar eax,1
sar ecx,1
push ecx
push eax
push esi
call MoveWindow
pop esi
pop ebx
ret
CenterWindow endp
option prologue:PrologueDef
option epilogue:EpilogueDef
; original by QvasiModo
; new version by Joshua
; Centers a window relative to it's owner window.
; Tipically used to center a dialog box to it's parent window, or a main window to the desktop.
CenterWindow proto :dword
.code
option prologue:none
option epilogue:none
CenterWindow proc hwnd:dword
push ebx
push esi
mov esi,[esp+12]
push 1
sub esp,16
push esp
push esi
call GetWindowRect
pop eax
pop ecx
sub [esp],eax
sub [esp+4],ecx
push GW_OWNER
push esi
call GetWindow
sub esp,16
push esp
push eax
call GetWindowRect
pop ebx
pop edx
pop eax
pop ecx
add eax,ebx
add ecx,edx
sub eax,[esp]
sub ecx,[esp+4]
sar eax,1
sar ecx,1
push ecx
push eax
push esi
call MoveWindow
pop esi
pop ebx
ret
CenterWindow endp
option prologue:PrologueDef
option epilogue:EpilogueDef