Teen Programmers Unite  
 

 

Return to forum top

Win32 help

Posted by faust9 [send private reply] at August 16, 2002, 07:06:08 PM

Howdy,

Well, this is another newbie question (or two). I just started learning the win32 API... I'm trying to make a popup window that centers itself on the screen no matter what the screen resolution is. Is there a function already available to do this, and if not how do I ready the screen resolution so I can write my own.

Another question; how do I us the BS_OWNERDRAWN button? I'd like to make some custom buttons.

Thanks foar any assistance.

Posted by CViper [send private reply] at August 17, 2002, 05:00:54 AM

You can get the screen res with GetSystemMetrics(); the parameters would be SM_CYSCREEN and SM_CXSCREEN (if i remember that correctly)

i'd suggest you check the MSDN anyway (msdn.microsoft.com/library); all the stuff is documented there.

Posted by faust9 [send private reply] at August 17, 2002, 01:51:21 PM

Hey thanks for the help. This is what I ended up doing for future reference.

//get screen dimensions
int xPosition = GetSystemMetrics(SM_CXSCREEN);
int yPosition = GetSystemMetrics(SM_CYSCREEN);

//set desired height & width
int nWidth=500;
int nHeight=375;

//calculate window position
xPosition =(xPosition-nWidth)/2;
yPosition =(yPosition-nHeight)/2;


.
.
.


hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Windows App", /* Title Text */
WS_POPUP , /* default window */
xPosition, /* Windows decides the position */
yPosition, /* where the window ends up on the screen */
500, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.