Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Centering Messageboxes

rswy
Beginner
925 Views
Hi,
By default,message boxes appear at the center of the screen. Is it possible to center message boxes with respect to the parent window?
Dialog boxes have the option DS_CENTER to do the same.Can something similar be done for message boxes?
--rswy
0 Kudos
4 Replies
Steven_L_Intel1
Employee
925 Views
Sure - just pass your window's handle as the hwnd argument. If you don't have it "handy", use GetForegroundWindow.

Steve
0 Kudos
rswy
Beginner
925 Views
Hi,
I tried the following code and the message box still remained in the center of the screen and not my window.

hwnd = GetForegroundWindow()
DUMMYI=MESSAGEBOX(hwnd,text1,text2,MB_OK)
Do i have to change any other option?
I also noticed that the DS_CENTER option centers the dialog box on the screen and not with respect to the parent window.
Can that be changed too?
--rswy
0 Kudos
james1
Beginner
925 Views
Yes, you can hook WH_CBT and change the position there.

James
0 Kudos
Intel_C_Intel
Employee
925 Views
For all of posterity. If you know your code is correct
(ie have sent the correct parent window handle to the
Messagebox function) & you find your Messageboxes
still remain in the center of your desktop, you may
try checking the display properties of your video card/
display driver.

In my case, (I have 2 monitors - w/ a M*trox Millenium G550)
I right-clicked on my M*trox Qu*ckdesk system tray icon,
selected "Multi-Display Controls", & toggled "Use CenterPOPUP"
checkbox & then toggled the "In parent program window" radio
button.

more keywords:
multi-monitor
multi-display
centering

HTH somebody
0 Kudos
Reply