473,396 Members | 1,968 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,396 software developers and data experts.

How do I open an nonmodal owned form over a mdi container ?

Hi guys I am puzzed (???) with a probably stupid problem (VB2003). I
must be doing something dumb ...

I want to open a owned form (must *not* be mdi child) over an Mdi
Container, when the Mdi container starts.

I have a small demo program made of: Form1, Form2 (empty) and a
"StartProgram" class
which contain the following code. The startup object is set to be: Sub
Main

in case you want the source I have place a tiny file here:
http://cam70.sta.uniroma1.it/Technic...w/mditrial.zip

'-----------------------------------------------------------

Public Class Form1
Inherits System.Windows.Forms.Form

'#Region " Windows Form Designer generated code "
'#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.IsMdiContainer = True
Me.WindowState = FormWindowState.Maximized

Me.ShowForm2_NonModal()

End Sub

Sub ShowForm2_NonModal()

Dim Form2 As New Form2
With Form2
.Owner = Me
.Show()
End With

End Sub

End Class
'-----------------------------------------------------------
'-----------------------------------------------------------
Public Class Form2
Inherits System.Windows.Forms.Form

'#Region " Windows Form Designer generated code "
'#End Region

End Class
'-----------------------------------------------------------
'-----------------------------------------------------------
Public Class StartProgram

Shared Function Main(ByVal Argomenti() As String) As Integer

'Get arguments
For Each Argument As String In Argomenti
MsgBox("Found command argument: " & Argument)
Next Argument

'Start main application
Dim Form1 As New Form1
With Form1
.ShowDialog()
.Dispose()
End With

'Exit returning exit code
Return 0

End Function

End Class
'-----------------------------------------------------------

So the Sub Main calles a MDI form (Form1). When the MDI form opens I
also want to open on top of it another owned (not mdi children) form
(Form2) and I want to to that in NONMODAL way.

This does not seem to work because the owned form Form2 remains blocked
in the mdi Container.

My question: How do I fix this ?

Note that: changing .ShowDialog() to would work, but I want Form2
opened in a * non * modal state.

Thank you in advance for any help,

-Pam

Feb 2 '06 #1
6 1604
<pa***********@libero.it> schrieb
With Form1
.ShowDialog()
.Dispose()
End With


Replace this code in Sub Main by

application.run (Form1)

Armin
Feb 2 '06 #2

Hi Armin.... thank you for your help. That solution I have abandoned
some time ago, because I noticed that, if I do that - when there is an
error in the program - the debugger is NO MORE able to go to the line
where the error is (it merely says the file and line where occurred),
which is very very annoying.

Actually, I do not understand why my way does not work. That's really
strange, because if the Me.ShowForm2_NonModal() is called AFTER loading
everything is fine. This doesn't make much sense to me.

Also, I do not understand why if I use the method You suggest, the
debugger is no more able to go to an error line, when an error occurs.
I can vaguely imagine the reason, infact the same happen when an error
occurs, for instance, on a timer event or on a Drag Drop: so must be
related to the fact that it is within a thread different from the main
one. Can you fix this behavour ???

All this is very very annoying...

-PAM

Feb 2 '06 #3
To see that it would work if called after LOAD try this. Place a timer
(Timer1) and replace:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.IsMdiContainer = True
Me.WindowState = FormWindowState.Maximized

Me.Timer1.Enabled = True
Me.Timer1.Interval = 1

End Sub

and add this one:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Me.ShowForm2_NonModal()
Me.Timer1.Enabled = False
Me.Timer1.Dispose()
End Sub

See what happen, Amazing eh? I just can't understand why I doesn't want
it during the load ????

-Pam

Feb 2 '06 #4
<pa***********@libero.it> schrieb

Hi Armin.... thank you for your help. That solution I have
abandoned some time ago, because I noticed that, if I do that - when
there is an error in the program - the debugger is NO MORE able to
go to the line where the error is (it merely says the file and line
where occurred), which is very very annoying.
Hmmm...
Actually, I do not understand why my way does not work. That's
really strange, because if the Me.ShowForm2_NonModal() is called
AFTER loading everything is fine. This doesn't make much sense to
me.
It was never allowed to show a non-modal Form after a modal Form is
displayed.
Also, I do not understand why if I use the method You suggest, the
debugger is no more able to go to an error line, when an error
occurs. I can vaguely imagine the reason, infact the same happen
when an error occurs, for instance, on a timer event or on a Drag
Drop: so must be related to the fact that it is within a thread
different from the main one. Can you fix this behavour ???

All this is very very annoying...

This is indeed a (different) problem. I currently don't know how to solve
it.

I know the problem with the exception in a Timer's Tick event handler: The
exception is not caught but the "JIT debugger" message occurs. This is a bug
fixed in version 2005. Hopefully it will also be fixed in the next VS 2003
SP.
Armin

Feb 2 '06 #5

Armin Zingler ha scritto:
It was never allowed to show a non-modal Form after a modal Form is
displayed.


yes on the same thread. See this:

http://cam70.sta.uniroma1.it/Technic.../mditrial2.zip

-Pam

Feb 2 '06 #6
<pa***********@libero.it> schrieb im Newsbeitrag
news:11**********************@f14g2000cwb.googlegr oups.com...

Armin Zingler ha scritto:
It was never allowed to show a non-modal Form after a modal Form is
displayed.


yes on the same thread. See this:

http://cam70.sta.uniroma1.it/Technic.../mditrial2.zip

Sorry, I was wrong. Back in VB6, it was not allowed.

Well, I still wouldn't use ShowDialog for showing an MDI container.
Armin

Feb 2 '06 #7

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

Similar topics

3
by: Ben | last post by:
Here's my form: <form name="aForm" method='post'> <input type=file name=file1 onkeypress='KeyPress()'><br> <a id='attachMoreLink' href='javascript:AddFileInput()">Attach More Files </a> <input...
1
by: VMI | last post by:
Through my MDI application, I open a FormX that is opened outside of the application (not an MDI child). How can I check if the Form's open so I don't load two instances of the same window? Is it...
2
by: Rob Meade | last post by:
Hi all, I am getting the above error when I try to flick from HTML to Design view in Visual Studio - I get the jist of the error message, and I know the line of code which it refers to which is...
0
by: Ioannis Demetriades | last post by:
Hi On my main form I have a menu with menu shortcuts and I noticed that when I display a new form as an MDIChild form the shortcuts work fine from within the mdi child form. If however i display...
3
by: Jerry Wei | last post by:
Dear all: I have a problem about how to handle the events. For example, there are two forms, Form1 and Form2. Form2 is owned by Form1 and there is a button,Button1, in Form2. It is no problem for...
22
by: Nina | last post by:
While user is working on a windows application, at same time he or she launches another instance of the same application. Will this affect the global variables in the first instance of this...
0
by: Edoardo | last post by:
thanks guys, I was hoping to be able to get the info from some method on oracle's own jdbc implementation classes, as both suggestion to use these view imply another trip to the db from the...
0
by: =?Utf-8?B?SkI=?= | last post by:
I would like to create an owned form that is owned by a modal dialog rather than a modeless form. The idea is the following Dim dlg as new Mydlg with dlg .ShowDialog .Dispose end with ...
1
by: mpathfinder | last post by:
hi everybody i have a MDI form that it shows child forms with the "Show()" method . in one of that child forms i show another form that owned by this form again with the "Show()" method . this...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.