473,695 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MDI Child Problem

Hi All,
I'm having a problem with MDI child forms when the
reference to the MDI Parent is set in a Control library.
(Sorry for
the long post)

I have an control library assembly which holds all of my
base classes including my base MDI Container form and my
base MDI child form
the mdi container has a singleton which returns an
instance of an mdi container. The load code of the mdi
child form uses the singleton to set its mdi parent.

I also have an application assemlby which defines an mdi
container which is a subclass of the control library mdi
container and mdi child forms which are sub classes of
the control library mdi child form. When the application
starts it creates a new instance of the application MDI
container and sets the singleton in the control library
to it. By doing this all forms will automatically add
themselves as children of the mdi container as well as
inheriting all of the properties of the control library
forms.

My problem is that when I open one child form and then
open a second form from the first form I cannot highlight
text in a textbox on the second form or click to a mid
point in the text using the mouse(highlight ing and moving
the cursor with the keyboard work). Once the form has
lost focus and regained focus the textboxes return to
their normal behavior for as long as that form is open.
One additional wrinkle is that the forms only recieve
focus and come to the forground when you click on the
titlebar. if you click in a textbox or anything on the
form the cursor moves to it but the form doesn't recieve
focus and come to the foreground.

If I move the Singleton into the application project
everything works fine, but once I have to start pulling
functionality out of the control library its a slipperly
slope.

When compiling the following code the first form that
opens will appear to work ok, click the button and
experiment with the second form. Does anyone know why
this is happening?
Thanks,
Bruin

'Control Library Project Code:

Public Class BaseMDIContaine r
Inherits System.Windows. Forms.Form
Private Shared _MDISingleton As BaseMDIContaine r
Public Shared Property MDISingleton() As
BaseMDIContaine r
Get
Return _MDISingleton
End Get
Set(ByVal Value As BaseMDIContaine r)
_MDISingleton = Value
End Set
End Property

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form
Designer.
InitializeCompo nent()

'Add any initialization after the
InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As
System.Componen tModel.IContain er

'NOTE: The following procedure is required by the
Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnos tics.DebuggerSt epThrough()> Private
Sub InitializeCompo nent()
'
'BaseMDIContain er
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5,
13)
Me.ClientSize = New System.Drawing. Size(292, 266)
Me.IsMdiContain er = True
Me.Name = "BaseMDIContain er"
Me.Text = "BaseMDIContain er"

End Sub

#End Region

End Class
Public Class BaseChildForm
Inherits Windows.Forms.F orm
Private Sub JasmineForm_Loa d(ByVal sender As Object,
ByVal e As System.EventArg s) Handles MyBase.Load
If Not BaseMDIContaine r.MDISingleton Is Nothing
Then
Me.MdiParent = BaseMDIContaine r.MDISingleton
End If

End Sub
End Class

'Windows Application Project Code
Public Class InheritedMDI
Inherits ControlLib.Base MDIContainer

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form
Designer.
InitializeCompo nent()

'Add any initialization after the
InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As
System.Componen tModel.IContain er

'NOTE: The following procedure is required by the
Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnos tics.DebuggerSt epThrough()> Private
Sub InitializeCompo nent()
components = New System.Componen tModel.Containe r
()
Me.Text = "InheritedM DI"
End Sub

#End Region

Protected Overrides Sub OnLoad(ByVal e As
System.EventArg s)
MyBase.OnLoad(e )
Dim firstform As New InheritedChildF orm
firstform.Show( )
End Sub
End Class
Module appstart
Public Sub main()
Dim mdi As New InheritedMDI
ControlLib.Base MDIContainer.MD ISingleton = mdi
Application.Run (mdi)
End Sub
End Module

Public Class InheritedChildF orm
Inherits ControlLib.Base ChildForm

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form
Designer.
InitializeCompo nent()

'Add any initialization after the
InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As
System.Componen tModel.IContain er

'NOTE: The following procedure is required by the
Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As
System.Windows. Forms.TextBox
Friend WithEvents Button1 As
System.Windows. Forms.Button
<System.Diagnos tics.DebuggerSt epThrough()> Private
Sub InitializeCompo nent()
Me.TextBox1 = New System.Windows. Forms.TextBox
Me.Button1 = New System.Windows. Forms.Button
Me.SuspendLayou t()
'
'TextBox1
'
Me.TextBox1.Loc ation = New System.Drawing. Point
(72, 72)
Me.TextBox1.Nam e = "TextBox1"
Me.TextBox1.Tab Index = 0
Me.TextBox1.Tex t = "TextBox"
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point
(96, 160)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 1
Me.Button1.Text = "Click Me!"
'
'InheritedChild Form
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5,
13)
Me.ClientSize = New System.Drawing. Size(292, 266)
Me.Controls.Add (Me.Button1)
Me.Controls.Add (Me.TextBox1)
Me.Name = "InheritedChild Form"
Me.Text = "Form1"
Me.ResumeLayout (False)

End Sub

#End Region

Private Sub Button1_Click(B yVal sender As
System.Object, ByVal e As System.EventArg s) Handles
Button1.Click
Dim anotherform As New InheritedChildF orm
anotherform.Sho w()
End Sub
End Class


Nov 20 '05 #1
0 1870

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

Similar topics

0
1381
by: CoolPint | last post by:
I am trying to write a generic heapsort (of course as a self-exercise) with Iterator interface: something like blow.... But I got into trouble finding out the Iterator to the Child node. If indexing was used, I could do something like child = hole * 2 + 1; but since only thing the function accepts are random access Iterators, how do I calculate the Iterator to the child node? template <typename Iterator, typename Functor> void...
7
2002
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. Currently, I am allowing the parent to be edited by itself. In order to get to a child table, a user needs to select a specific parent table ID. I have set this up using panels, and putting a drop-down list in the first panel, with its contents...
10
4016
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
3
4733
by: Zack Sessions | last post by:
I am using VB.NET 2003. I have read the threads concerning the problem where the FormStartPosition of CenterParent is ignored if the form is displayed with the Show method as opposed to the ShowDialog method. I am having a similar problem and I found a thread that had the following code in the child form's Load event: Me.Location = New Point(( _ Me.MdiParent.ClientSize.Width - Me.Width) * 0.5,
5
3537
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I do the update the changed parentid in the child table fails to change. No error is given its just that the change is not written to the Database. When I step through the records for the child table the one I would expect to be changed has a row...
2
2158
by: Lenster | last post by:
Environment --------------- Visual Studio.NET 2003 Version 7.1.3088 ..NET Framework 1.1 Version 1.1.4322 SP1 XP Professional 5.1.2600 SP2 Build 2600 Problem Description ----------------------- I have an mdi parent form.
2
2441
by: Matt | last post by:
Ok here is my problem: I have a MDI parent form called "Main" that I declare in a public module when I start up my program. This form holds the drop down menu that allows my users to access all of the child forms. Now lets say I have a child form called "Child." When I open up that child form from "Main" I shut off the menu on "Main" so that the user cannot open up any other forms while they are in the "Child" form.
4
3560
by: Richard Lewis Haggard | last post by:
What is the mechanism by which a child window can notify its parent that it has been clicked on? -- Richard Lewis Haggard www.Haggard-And-Associates.com
3
6325
by: Tom | last post by:
I am having a serious issue with my MDI child windows. This is with a large VB.NET application that I ported over to VS 2005 from VS 2003. The problem is that, if the child window is maximized and then closed, it produces the following error message: Cannot access a disposed object Object name:'icon' in source System.Drawing And then the whole system crashes. Again, this ONLY occurs if the MDI child window is maximized within the MDI...
3
9663
by: Adam Right | last post by:
Hi, I am developing an application which has established on MDI Form and there are many MDI Child forms. My problem is starting when i close the mdi child forms. They are not disposed from the virtual memory, so it wastes much memory for the clients. I trigger GC.Collect and i also implemet IDisposable method for all object that i have created. But when i use a memory profiler that shows the status of the current object for my...
0
8649
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
8838
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4351
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
4592
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3025
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
2289
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1986
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.