Does anyone know a simple way to center a dialog on screen which is created using by DialogBoxParamA.
I am new to win32asm and I hope you can help me out a bit
sign CyBerian
Hellau,
Yep.. I "borrowed" this proc from Iczelion's Splash Screen tut once. Just call the procedure at
WM_INITDIALOG with invoke CenterWindow,hWnd
CenterWindow 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
CenterWindow endp
thx. a lot :) exactly what I searched for.
I should probably read the complete set of Iczelion's tuts
sign CyB
Hi,
There is another way easier than the one (better I don't know, but easier & shorter):
In the rc file, as style for the dialog, just simply add:
DS_CENTER
and your dialog will be centered.
hope this will help you.
Vom-bonjour:-()
Hey thx. nice to know that :)