473,378 Members | 1,426 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 2885
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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

SecondForm.TopMost = True
SecondForm.Show()

End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SecondForm.TopMost = False
SecondForm.Owner = Me
SecondForm.Show()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

SecondForm.TopMost = True
SecondForm.Show()

End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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*********************@v46g2000cwv.googlegro ups.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SecondForm.TopMost = False
SecondForm.Owner = Me
SecondForm.Show()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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
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...
5
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
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...
1
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...
6
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 "=...
4
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...
1
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...
6
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...
17
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.