473,778 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form.TopMost Conflicts With MsgBox

Don
I've got a form which (in a roundabout manner) calls a second form into
existence which has its TopMost property set (the first form is not the
parent of this second form because of the roundabout manner in which the
second form is created and displayed). The user can then still work on the
first form while the second form floats around above it.

If the first form displays a messagebox via the MsgBox method, the
messagebox appears behing the second, TopMost form and is unreachable. Is
there anyway around this odd behavior? Does this have something to do with
the second form not having the first as its parent?

- Don
Mar 23 '06 #1
3 2904
Don
Here's some quick code you can try to reproduce the problem.

- First, create a new, blank project.
- Create two forms, named Form1 and Form2.
- On Form1, place two buttons named Button1 and Button2.
- Post the following code into Form1's code module:
Private WithEvents SecondForm As Form2 = New Form2

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

SecondForm.TopM ost = True
SecondForm.Show ()

End Sub
Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click

MsgBox("test")

End Sub
Press Button1 first to bring up the second form, then press Button2. The
messagebox appears behind the second form. :(

- Don
Mar 23 '06 #2
Hi Don, that behaviour is normal, because of TopMost.

See if something like the following can equally fit your needs:

Private WithEvents SecondForm As Form2 = New Form2

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
SecondForm.TopM ost = False
SecondForm.Owne r = Me
SecondForm.Show ()
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
MsgBox("test")
End Sub

-tom

Don ha scritto:
Here's some quick code you can try to reproduce the problem.

- First, create a new, blank project.
- Create two forms, named Form1 and Form2.
- On Form1, place two buttons named Button1 and Button2.
- Post the following code into Form1's code module:
Private WithEvents SecondForm As Form2 = New Form2

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

SecondForm.TopM ost = True
SecondForm.Show ()

End Sub
Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click

MsgBox("test")

End Sub
Press Button1 first to bring up the second form, then press Button2. The
messagebox appears behind the second form. :(

- Don


Mar 23 '06 #3
Don
Oh, that's perfect! Thanks.

- Don

<to************ **@uniroma1.it> wrote in message
news:11******** *************@v 46g2000cwv.goog legroups.com...
Hi Don, that behaviour is normal, because of TopMost.

See if something like the following can equally fit your needs:

Private WithEvents SecondForm As Form2 = New Form2

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
SecondForm.TopM ost = False
SecondForm.Owne r = Me
SecondForm.Show ()
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
MsgBox("test")
End Sub

-tom

Mar 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1995
by: Mathieu Chavoutier | last post by:
Hi. I want to create a kind of configuration window. So, I have a main window, and when I click on a button, it opens a new form. But, because it is a configuration window, I would like that window to be alway on top (of my application). How can I do that ?
5
1730
by: Tamir Khason | last post by:
Is it possible managed detect that one form inaplicationcontext is above other ? -- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
2
3840
by: Max | last post by:
Hello, My VB.NET application displays a Windows form in a panel on my main form. While my application has the focus, I want the form in the panel to have the "topmost" position, even if it is not the active form. Everything works as expected, but if the user selects another application by pressing a tab in the taskbar, then my "topmost" form still occupies the "topmost"
1
6096
by: Kevin | last post by:
Hello, I've seen a couple previous posts about this phenomenon, but none seem to have been resolved. I am using Visual Basic .NET 2003 on Windows 2000 SP 3. Would you mind creating a new project and running this simple test program to see if it happens to you? Please let me know if you have any ideas for a workaround (other than setting the TopMost form to False then back to True every time I show a MessageBox.)
6
1942
by: Jonathan | last post by:
Hi, I have a parent(container) form which opens another form, and that one opens another etc.., each form is open with Form.MdiParent = Me.MdiParent. (apart from the first one which is just "= Me") However, there is one form which is smaller than others, and i have set it to Topmost = TRUE. but the problem is when i click those forms at the background, the smaller
4
2255
by: Bugs | last post by:
Hi, I wonder if anyone can help me out. I'm building a vb.net application that has a form with a panel that contains several other sub forms (as a collection of controls). What I'm wanting to do is call a generically named public sub in the top-most sub form in the panel. I have the name of the top-most form as a string (eg. g_TopForm = "frmCustomers") and I can reference the form with:
1
2046
by: Gary Brown | last post by:
Hi, I have a dialog box that must behave as MessageBox does with regard to the TopMost property. It must be TopMost if and only if the calling form is TopMost. A static method creates the dialog box. Is there a way of determining if the application is TopMost from a static method? There are some inelegant workarounds but I would prefer to do whatever MessageBox does.
6
2238
by: Steve | last post by:
Hi All I have an on-screen keyboard within a POS program I have written in VB.net 2005, for touch screen computers I have it set to 'always on top' so the user can move the cursor to different text boxes and type using the on-screen keyboard The keyboard launches via the mouseclick event for any text box If another form is launched, with the onscreen keyboard still visible, the
17
12634
by: M O J O | last post by:
Hi, How can I force a form to the foreground no matter what application is in front? Thanks! M O J O
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10302
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.