Center a Message Box

Jarod

Regular
Joined
Feb 5, 2003
Messages
82
Location
Bruxelles
Can we decide of the starting position of the message boxes ?

In fact my soft runs on a dual screen configuration and so all my messagebox are shown at the center of the screen resolution that is to say between my two screens... a little bit annoying...

So is there a way to ask a Message Box to pop up centered in a parent window or giving it a special position ?

(Of course it is possible to reimplement it with the forms, but I would prefer to avoid that...)

Thanks,
 
Constructors 7 to 12 of the MessageBox class have the first parameter being the windows form for which the message box will be displayed in front of
 
Yes but these constructers are only used to construct an owned dialog box (so minimize and maximize with its parent, no specific task icon, ...)
But the dialog box still appears at the center of the screen
 
Search for "SetWindowsHookEx MessageBox" in Google, you'll find lots of answers. But overriding the position of the MessageBox is not simple as it involves windows hooks. Most of the articles you'll find will give good sample code though, so you don't have to worry too much.

-nerseus
 
Ok one question however !
SetWindowsHookEx ask for a procedure address
In an exemple I found :
lgHook = SetWindowsHookEx(WH_CBT, AddressOf WinProc, lgInst, lgId)
But this doesn't work, seems to be VB code and not VB.NET
In my Case, I have a cast error
So how can we "translate" the address of a procedure into a long ?
 
Back
Top