 |
|
|
 |
|
 |
Excelente soluci�n, gracias!
|
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Robust, clean, extensible. What more could you ask for? Thanks Vance.
"If the facts don't fit the theory, change the facts."
|
|
|
|
 |
|
 |
Does what it says. First time.
|
|
|
|
 |
|
 |
It's just what I am looking for.
|
|
|
|
 |
|
 |
Big Shout Out to Vance! Quick, Easily modified to add icons, and works like a charm. Thanks!
|
|
|
|
 |
|
|
 |
|
 |
... add a topmostform.ShowInTaskbar = false so that it really cannot be seen.
Isi
|
|
|
|
 |
|
|
 |
|
 |
1) Reference Microsoft.VisualBasic
2) Call Microsoft.VisualBasic.Interaction.MsgBox
3) With MsgBoxStyle of ApplicationModal or SystemModal
Why avoid this namespace just because you are using C#? Both MsgBox and MessageBox do the same thing by wrapping the MessageBox API. MsgBox just gives more flexiblity.
I'll never understand why C# programmers insist on writing so much code.
|
|
|
|
 |
|
 |
This isn't a critical detail at all, but just one thing I noticed.
If I open my program in my right-hand screen the MessageBox would ordinarily have appeared on that same screen (albeit BEHIND the other form!) but now it appears on the left screen. (although it's now in front of everything. )
Does anyone have an idea of how to change this?
I don't want to spend too much time on it because I doubt any of our users will have more than one screen anyway. It's just obvious to me because I remember how it used to show.
- Ken Lyon
"Before you judge a man, walk a mile in his shoes.
By that time, who cares?
You're a mile away, and you've got his shoes."
|
|
|
|
 |
|
 |
I'm glad to have found this solution. My situation was a bit frustrating with my splash screen hiding an important MessageBox. Oddly enough, Visual Studio shows the MessageBox on top, but running the program directly exhibits the problem of the MessageBox being behind.
I noticed something that I thought would be worth pointing out. The topmostForm appears in the task bar by default. The simplest solution to this would be to add the following line:
topMostForm.ShowInTaskbar = false;
An alternative would be to set topMostForm.Text to match the title of the MessageBox. This would create the illusion of the task bar entry corresponding to the MessageBox, although it's really topMostForm. That would be the visual equivalent of showing the MessageBox with no owner.
Maybe all this is too much detail for most people. I just tend to notice these things.
- Ken Lyon
"Before you judge a man, walk a mile in his shoes.
By that time, who cares?
You're a mile away, and you've got his shoes."
|
|
|
|
 |
|
 |
They're annoying, frustrating, in-your-face.
They're a usability nightmare.
Though, good workaround.
Chuck Norris has the greatest Poker-Face of all time. He won the 1983 World Series of Poker, despite holding only a Joker, a Get out of Jail Free Monopoloy card, a 2 of clubs, 7 of spades and a green #4 card from the game UNO. In the movie "The Matrix", Chuck Norris is the Matrix. If you pay close attention in the green "falling code" scenes, you can make out the faint texture of his beard. Chuck Norris actually owns IBM. It was an extremely hostile takeover.
|
|
|
|
 |
|
 |
I tried the two suggested workarounds posted earlier and neither worked. I needed to show a messagebox on startup sometimes from the Main() sub before doing Application.Run(mainform). Vance's hidden form worked perfectly. Otherwise, the messagebox remained hidden behind the last focused app's window, e.g., Windows Explorer. Thanks Vance.
|
|
|
|
 |
|
 |
Dim MessageBoxTopMost As MessageBoxOptions
MessageBoxTopMost = 262144
MessageBox.Show("","",MessageBoxButtons.OKCancel,MessageBoxIcon.Exclamation, _
MessageBoxDefaultButton.Button1, MessageBoxTopMost, False)
|
|
|
|
 |
|
 |
thanks for sharing, but this doesnt seem to work in C#
MessageBoxOptions msb = 262144;
Error: Cannot implicitly convert type 'int' to 'System.Windows.Forms.MessageBoxOptions'. An explicit conversion exists (are you missing a cast?)
|
|
|
|
 |
|
 |
MessageBoxOptions.ServiceNotification is what you are looking for. but be aware of its side effects ...
|
|
|
|
 |
|
 |
Here is a silly yet simple and efficient way to make a MessageBox topmost:
Form f = new Form();
f.TopMost = true;
MessageBox.Show(f,"I'm on top");
All you need to do is create a dummy Form, set it as topmost and send it to the MessageBox as the Parent form. You don't need to display this dummy form.
|
|
|
|
 |
|
 |
Sweeet!!
and with C# 3.0 you can create it as easy as
MessageBox.Show(new Form(){TopMost = true},"I'm still on top, YEAH");
|
|
|
|
 |
|
 |
Oh man, I soo wanted this to work... but it doesn't for me. When I use this, the dialog never shows up. I am creating the dialog in a new thread (I want a *non-modal* topmost dialog!), so maybe that's different than what you're doing.... Just using
MessageBox.Show(myText, myCaption, MessageBoxButtons.OK);
works, but using
MessageBox.Show(new Form(){TopMost = true}, myText, myCaption, MessageBoxButtons.OK);
doesn't... :(
|
|
|
|
 |
|
 |
The message box will not show or behave correctly when spawn from a different thread. In your specific case, you need to invoke (call) the message box on the thread used to create the new form. You do this by calling the Form's Invoke method, which executes a delegate on the thread that owns the control's underlying window handle. This will work:
Dim oForm As New Form
oForm.TopMost = True
oForm.ShowInTaskbar = False
oForm.Invoke(...)
This is the basic idea.
Private Delegate Sub AlarmHandler()
Private Sub DoAlarm()
'message box and other user-interface statements
End Sub
''' <remarks>
''' This method is called from the background thread of a System.Threading.Timer object (non-Form timer).
''' </remarks>
Private Sub CheckForAlarm(ByVal ignoredOnPurpose As Object)
If (App.ReportingDate.CompareTo(moAlarmTime) > 0) And (mfAlarmSet = True) Then
If Me.InvokeRequired Then
Me.Invoke(New AlarmHandler(AddressOf DoAlarm))
Else
DoAlarm
End If
End If
End Sub
See http://msdn.microsoft.com/en-us/library/system.windows.forms.control.invokerequired.aspx[^]
|
|
|
|
 |