|
-
Mar 10th, 2001, 07:37 PM
#1
Thread Starter
Hyperactive Member
Can Anybody Tell Me How To Center A Win32 Form On Startup. I don't know if your supposed to get the width of the desktop and subtract the width of the appwindow, and divide by 2, and then do the same for the height. i would appreciate any code on centering my appwindow. it doesn't have a titlebar, so i would like for it to be centered as i haven't made an option to move it. thanx for any input on the subject.
AAG
-
Mar 10th, 2001, 09:03 PM
#2
Hyperactive Member
Possible Answer
Don't quote me on this, but I'm pretty sure you can Pass either WS_CENTERED or WS_CENTER when using CreateWindowEx and the window will be centered. Hope it works.
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Mar 10th, 2001, 09:51 PM
#3
Thread Starter
Hyperactive Member
Already tried that.
i had already tried WS_CENTER and WS_CENTERED. The function is unkown. thanx for the effort though. Can somebody please tell me the correct way to center a window. thanx
-
Mar 11th, 2001, 12:31 AM
#4
Hyperactive Member
Maybe this then
If you use a resource, it has a flag there that you can add, which is Center form?? Tick it, then open the resource in note pad, and see how it works. Just a suggestion.
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Mar 11th, 2001, 12:44 AM
#5
Thread Starter
Hyperactive Member
already tried that.
thanx for the help though
-
Mar 11th, 2001, 01:19 AM
#6
Fanatic Member
Use the GetSystemMetrics function and use the formula you stated above, i.e.....
PHP Code:
int wdth;
int hgt;
int x;
int y;
//other code here
wdth = 420;
hgt = 300;
x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (wdth / 2);
y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (hgt / 2);
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"The title of my window",
WS_OVERLAPPEDWINDOW,
x, y, wdth, hgt,
NULL, NULL, g_hInst, NULL);
// rest of the code here
WOW! I think I answered a C++ question. WOO-HOO!!
Last edited by YoungBuck; Mar 11th, 2001 at 01:29 AM.
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Mar 11th, 2001, 02:04 AM
#7
Thread Starter
Hyperactive Member
-
Mar 11th, 2001, 06:03 AM
#8
Hyperactive Member
KULE
How bout this one then.
How do I get what would be equivalent to Me.Left in vb??
Thanx in advance...
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Mar 11th, 2001, 10:37 AM
#9
Fanatic Member
GetWindowRect retrieves the coordinates of a window as it relates to the screen....
PHP Code:
RECT me;
GetWindowRect(hwnd, me);
cout << me.left << endl;
2 in 24 hours YEE-HAW!! hehe
Last edited by YoungBuck; Mar 11th, 2001 at 10:58 AM.
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Mar 11th, 2001, 11:02 AM
#10
Monday Morning Lunatic
Code:
RECT me;
GetWindowRect(hwnd, &me);
cout << me.left << endl;
Two minor problems...it must be the address of me, and since you're in a window you don't have a console 
Code:
char buf[40];
MessageBox(hwnd, itoa(me.left, buf, 10), "Left!", MB_OK);
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Mar 11th, 2001, 11:17 AM
#11
Fanatic Member
LOL Thanks for stealing my thunder parksie
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Mar 11th, 2001, 06:17 PM
#12
Thread Starter
Hyperactive Member
thanx for your replies.
thankx again 
AAG
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|