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
Posted on 2001-02-11 12:20:00 by 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,
          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
CenterWindow endp
Posted on 2001-02-11 12:28:00 by JimmyClif
thx. a lot :) exactly what I searched for. I should probably read the complete set of Iczelion's tuts sign CyB
Posted on 2001-02-11 14:50:00 by CyBerian
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:-()
Posted on 2001-02-11 17:13:00 by Vom-bonjour:-()
Hey thx. nice to know that :)
Posted on 2001-02-12 05:17:00 by CyBerian