0

When my program calls MsgBox it appears in the middle of the monitor. Anyone know how to move it somewhere within the boundries of my program's window?

Edited by Ancient Dragon

3
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by TnTinMN
0

I figured it out. I had to create another Form then call it's ShowDialog() method. I renamed class Form2 to MyMsgBox, and run the code below

                    Dim box As New MyMsgBox()
                    box.lblText.Text = "Division by 0 error"
                    box.ShowDialog()
                    box.Dispose()
0

I am not aware of a way to set the location of a message box, but you can create a custom dialog box to fit your needs.

I have a custom dialog written in WinForms that has a multiline textbox for the data. (Acts just like a JIT messagebox)

Would you like me to post it?

EDIT

Took a while for the site to refresh for me, didn't know it was answered. I'm sorry for the thread revive.

Edited by Begginnerdev

0

I found the solution by googling a bit more than I had before posting the question. I'm just learning vb.net too.

0

Dragon,

The .Net MessageBox is just a wrapper for the Win API MessageBox. You could move it using the API SetWindowPosition function, but retrieving its handle gets a bit messy with enumerating the threadwindows and seeking the dialog class name "#32770".

That said, you went the correct route.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.