News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to create a centered window

Started by BlackVortex, August 29, 2008, 12:43:48 AM

Previous topic - Next topic

BlackVortex

I thought this would be trivial, but after a lot of searching around MSDN,google,this forum's search etc I utterly failed !

Here is the situation, I create a dialog with these resource properties :

whatever DIALOGEX 300,150,196,165
FONT 8,"Tahoma",400,0,0
STYLE WS_POPUP+WS_VISIBLE
BEGIN
END


And I use this command to create it :
invoke DialogBoxParam, hInstance, ADDR DlgName,NULL,addr DlgProc,NULL

How can I set it to be created centered to the desktop/screen or as a last resort what's the best way to center it to the screen on init ?

hoverlees

You must calculate the postion yourself when processing WM_INITDIALOG message.

1.Get the screen size using GetSystemMetrics
2.Get the size of your window
3.Calculate the center position
4.Set the window position using SetWindowPos

drizz

The truth cannot be learned ... it can only be recognized.

BlackVortex

Quote from: drizz on August 29, 2008, 01:23:16 AM
+DS_CENTER

YES ! Thank you !

     


P.S.: Thanks hover for the info, I'll keep those APIs in mind.