Computing.Net > Forums > Programming > Very Basic C++

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Very Basic C++

Reply to Message Icon

Original Message
Name: unityzero
Date: April 15, 2004 at 14:58:37 Pacific
Subject: Very Basic C++
OS: WinXP
CPU/Ram: 2ghz 1gb
Comment:

Although this is double posting, i have waited a long time for a reply on the other topic and there was none, so i think this is in the right.

Is there a way to position a messagebox window with C++, using the pixel coordinates? if so could someone please add it to the beneath code?


#include <windows.h>

const char Caption[] = "Simple Error Box";

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)

{
MessageBox( NULL,
"Simple.\n"
"Error.\n"
"Box.",
Caption,
MB_OK | MB_ICONERROR);
return 0;
}


Report Offensive Message For Removal


Response Number 1
Name: Fozzie
Date: April 15, 2004 at 20:55:14 Pacific
Reply: (edit)

Since MessageBox() does not return a handle, I don't think there would be any surefire way to reposition one. It might be possible to set a MBox's rectanlge coordinates by asking the Win API to return the handle of the active window immediately after opening the MBox, but it could fail due to other programs or processes making their windows active and that could cause some crazy results. If you want to try it, look at the GetActiveWindow() and the SetWindowRect() functions.

Probably the best thing to do would be to create your own dialog window and place it wherever you want. You could even make it look and perform exactly as a MessageBox would.


Report Offensive Follow Up For Removal

Response Number 2
Name: Fozzie
Date: April 15, 2004 at 22:04:30 Pacific
Reply: (edit)

I read your 1st post a while back but didn't take the time to consult my Win API help file. You are just starting to experiment with Windows programming right?

If so, I recommend the following tutorial site.

http://www.winprog.org/tutorial/



Report Offensive Follow Up For Removal

Response Number 3
Name: unityzero
Date: April 16, 2004 at 05:39:04 Pacific
Reply: (edit)

Ill have a go at the GetActiveWindow() and the SetWindowRect() functions and see what i can come up with, ant winprog is a definately good site to use, id came across it before but couldnt remember the site, thanks.


Report Offensive Follow Up For Removal

Response Number 4
Name: SteveWalsh
Date: April 16, 2004 at 11:54:25 Pacific
Reply: (edit)

i thought you said very basic? this isn't basic. lol basic is cout << "hellow world" << enld; lol ah sorry can't help you, my win32 knowledge is limited but i would recomend you try VC++ 6 MFC those are GREAT very powerful and easy.


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software