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 3 Years Ago by Ancient Dragon

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()

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 3 Years Ago by Begginnerdev

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

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.