Newbie Question

  • Thread starter Thread starter jburkle
  • Start date Start date
J

jburkle

I am using MessageBox.Show() to show message boxes throughout my
windows application in VB .NET, and I was wondering what exactly to
pass into the first parameter of the Show() to make sure it is
displayed in front of the parent window and disables all the windows
behind it.

thank you - john b
 
I probably don't understand your question... because the nature of a
"messagebox" disables all windows behind it, and is always in the
front. You cannot continue to use the app until you click the OK, or
Cancel buttons. The first parameter of MessageBox.Show is the string
of the message that you want to appear in the messagebox; or to put
plainly, the "message text". Other parameters control things like what
buttons appear, the icon type, etc.

John
 
One of the overloaded calls to Show() takes the first parameter "owner
as System.Windows.Forms.IWin32Window" which is the parent window, only
I don't know how to reference the parent window in VB .NET..... i tried
"this" like in C# but if didn't work..... i am trying to figure out
what i need to type as the "owner" which is the
System.Windows.Forms.IWin32Window type.

Currently the application displays the MessageBox behind all windows
and is unreachable unless you ALT Tab for it, and once you do that it
freezes up the entire application. I read that setting the first
parameter of the Show() to the parent of the MessageBox would force it
to the front for the user... I think this will solve my problem with
the MessageBox now being reachable and won't cause the user to use ALT
TAB and freeze up the application.
 
I don't know why your messagbox is not always on top. That is strange.
I'm a newby myself, and can't help any further. Hopefully someone
else can jump in on this one!

John
 
yea, it seems this piece of the application acts very strange. i cant
reproduce the problem, it only happens once in a while, it happens on
different computers and with different users logged in... and yet it
always randomly happens no matter how i try to fix it.

also to make things more weird, sometimes the application has 2 message
boxes displayed behind the windows which dumbfounds me since i thought
there could only be one message box displayed at a time.

someone out there who has had this problem also and solved it please
help me. any suggestions for a work around would be great also.
 
I'm not sure about why your messagebox isn't on top or whatever... but I can
tell you this...

The equivalent to "this" in C# is "Me" in VB.NET.

Messagebox.Show(Me, "message", "error!" .... etc.

HTH
________________________________________________________
The Grim Reaper
 
thanks, thats what i was looking for, i will test it with that Me
parameter added and see if it fixes things.
 
I am curious to know what is happening here as well, but as an alternative
to messagebox you might try using the msgbox command instead...

MsgBox("This is a message box.", MsgBoxStyle.AbortRetryIgnore, "Title of
box")
Just and idea regarding the msgbox appearing behind your application... Is
your application opening multiple forms within the same window, or each as a
seperate window? If they are seperate, independent windows, that might
account for the behavior (or not, I am just guessing).
 
jburkle said:
yea, it seems this piece of the application acts very strange. i cant
reproduce the problem, it only happens once in a while, it happens on
different computers and with different users logged in... and yet it
always randomly happens no matter how i try to fix it.

Are you showing the messageboxes from another thread than the main UI
thread?
 
i am not sure, the block of code that is causing all the problems is
being called from the onclick event of a button on a form displayed
from the another form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top