Click to See Complete Forum and Search --> : Center Win32 Window. ?
AAG
Mar 10th, 2001, 11:19 PM
How Do You Center A Win32 Window ? I use borland c++, and do not use MFC, Pure API. Thanx. Please only reply if you really know how to center a win32 window. I'm sorry i had to post again, but somebody had replied to my other request thinking they knew and they really didn't. I mean no disrespect for the help offered by the other person, but i mean come on, if your gonna reply to someones question, at least by half sure and not just go out on a wimb. thanx :)
AAG
parksie
Mar 11th, 2001, 06:56 AM
RECT r, desk;
GetWindowRect(hWnd, &r);
GetWindowRect(GetDesktopWindow(), &desk);
int wa,ha,wb,hb;
wa = (r.right - r.left) / 2;
ha = (r.bottom - r.top) / 2;
wb = (desk.right - desk.left) / 2;
hb = (desk.bottom - desk.top) / 2;
SetWindowPos(hWnd, wb - wa, hb - ha, wa*2, ha*2);
I'm sure there are better ways...but I couldn't find anything automatic...I'm sure you can tidy this up a bit. It's not been tested, BTW :eek:
SteveCRM
Mar 11th, 2001, 11:45 AM
I remember using somehting like WS_CENTERED....it is almost that...I'll look around for it. :)
I checked in MSDN and it was unlisted.
SteveCRM
Mar 11th, 2001, 05:39 PM
Yeah I could have sworn I saw it somewhere but can't find it...I guess there isn't any :confused:
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.