Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 13th, 2005, 6:53 PM   #1
dc2000
Newbie
 
Join Date: Jun 2005
Location: Portland, OR
Posts: 12
Rep Power: 0 dc2000 is on a distinguished road
Center MessageBox() in Win32

Hi everyone:

I seem to be stumped by the simplest -- I have a Win32 program and I need to display a message box centered by the parent window. Here's the example:

MessageBox(hParentWnd, "Message to display", "Program Name", MB_ICONERROR | MB_OK);

Well, the problem is that it is centered in the middle of the screen and it's position has nothing to do with the parent window. I stepped through the entire AfxMessageBox() in MFC, which by the way places it's message box in the middle of a parent window, and found absolutely nothing.

Can someone tell me what am I doing wrong?
dc2000 is offline   Reply With Quote
Old Jul 13th, 2005, 7:51 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Are you passing a parent window handle, or NULL? If NULL, it has no parent window. At any rate, if you get the handle to it, you should be able to use MoveWindow. When you first display it, you should be able to get its handle by one of several mechanisms.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 13th, 2005, 8:10 PM   #3
dc2000
Newbie
 
Join Date: Jun 2005
Location: Portland, OR
Posts: 12
Rep Power: 0 dc2000 is on a distinguished road
Quote:
Originally Posted by DaWei
Are you passing a parent window handle, or NULL
I'm using a handle to a parent window that is not NULL.

Quote:
Originally Posted by DaWei
if you get the handle to it, you should be able to use MoveWindow.
DaWei, it's a message box, I can't have a handle to it's window, nor I have access to it's message handling WndProc. The whole implementation resides in user32.dll.

Please don't tell me that I'll have to subclass MessageBox?
dc2000 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:13 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC