cScreen PROC USES esi edi hWnd:DWORD
LOCAL wRect:RECT
push 0
lea eax, [ebp-16]
push eax
push hWnd
call GetWindowRect
mov esi, wRect.bottom
sub esi, wRect.top
push esi
shr esi, 1
mov edi, wRect.right
sub edi, wRect.left
push edi
shr edi, 1
push SM_CYSCREEN
call GetSystemMetrics
shr eax, 1
sub eax, esi
push eax
push SM_CXSCREEN
call GetSystemMetrics
shr eax, 1
sub eax, edi
push eax
push hWnd
call MoveWindow
ret
cScreen ENDP
A different variation than the one on the snippets library. :) Feel free to optimize it but I won't join in the brain storming...`cause I won't be here for a long time.
Posted on 2002-05-16 21:40:03 by stryker


invoke GetSystemMetrics, SM_CXSCREEN
mov esi,eax
invoke GetSystemMetrics, SM_CYSCREEN
shr esi, 1
shr eax, 1
sub eax, 456/2 ; x of window
sub esi, 264/2 ; y of window

invoke CreateWindowEx, WS_EX_TOPMOST or WS_EX_TOOLWINDOW,
addr szClassName,
addr szAppName,
WS_SYSMENU or WS_VISIBLE,
esi, eax, 456, 264, 0, 0, 400000h, 0


:)
Posted on 2002-05-16 23:39:46 by bazik
cScreen:

mov eax,[esp+4] ; hWnd
push 0 ; bRepaint
sub esp,SIZEOF RECT
mov edx,esp
push eax ; hWnd

push SM_CXSCREEN
push SM_CYSCREEN

push edx ; pRECT
push eax ; hWnd
call GetWindowRect

mov eax,[4][esp].RECT.top
mov edx,[4][esp].RECT.left
sub [4][esp].RECT.bottom,eax
sub [4][esp].RECT.right,edx

call GetSystemMetrics
sub eax,[8][esp].RECT.bottom
shr eax,1
mov [8][esp].RECT.top,eax

call GetSystemMetrics
sub eax,[4][esp].RECT.right
shr eax,1
mov [4][esp].RECT.left,eax

call MoveWindow
ret 4
No PROC stuff. :)
Untested.
Posted on 2002-05-17 00:19:06 by bitRAKE
bitRake, i saw a line
mov	eax,[4][esp].RECT.top
. [4] is strange for me. What does it mean?
Thanks
Posted on 2002-05-22 13:29:54 by yoursguideline
Would be same as:

mov eax,.RECT.top
mov eax,.RECT.top + 4

hWnd is on the top of the stack, so four is added to get to the RECT - then I still use the STRUCT values to make things easier on myself - MASM is very flexible in this reguard.
Posted on 2002-05-22 13:35:49 by bitRAKE
Hey, I'm back. Here's another one


CenterWindow PROC USES ebx esi edi mainWndHndl:DWORD, targetWndHndl:DWORD

LOCAL mainWnd :RECT
LOCAL targetWnd :RECT

xor eax, eax
push eax
lea eax, DWORD PTR [ebp-20h]
push eax
mov edx, DWORD PTR [ebp+0Ch]
push edx
call GetWindowRect ;MROM Penalty
mov esi, targetWnd.bottom
mov edi, targetWnd.right
sub esi, targetWnd.top
sub edi, targetWnd.left
push esi
push edi
shr esi, 1
shr edi, 1
lea eax, DWORD PTR [ebp-10h]
push eax
mov edx, DWORD PTR [ebp+8]
push edx
call GetWindowRect ;MROM Penalty
mov eax, mainWnd.bottom ;Bank Conflict
mov ecx, mainWnd.right
sub eax, mainWnd.top
sub ecx, mainWnd.left
shr eax, 1
shr ecx, 1
sub eax, esi
sub ecx, edi
mov ebx, mainWnd.top
mov edx, mainWnd.left
add ebx, eax
add edx, ecx
push ebx
push edx
mov eax, targetWndHndl
push eax
call MoveWindow ;MROM Penalty

ret

;pop edi ;MROM Penalty
;pop esi ;MROM Penalty
;pop ebx ;MROM Penalty
;+ leave ;MROM Penalty
; - pop ebp ;...
; - mov esp, ebp ;...
;retn 8 ;Branch Misprediction, MROM Penalty

CenterWindow ENDP

this one will center a window based from another window. :)
Posted on 2002-06-07 01:32:56 by stryker