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

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(highlighting 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 BaseMDIContainer
Inherits System.Windows.Forms.Form
Private Shared _MDISingleton As BaseMDIContainer
Public Shared Property MDISingleton() As
BaseMDIContainer
Get
Return _MDISingleton
End Get
Set(ByVal Value As BaseMDIContainer)
_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.
InitializeComponent()

'Add any initialization after the
InitializeComponent() 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.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As
System.ComponentModel.IContainer

'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.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
'
'BaseMDIContainer
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.IsMdiContainer = True
Me.Name = "BaseMDIContainer"
Me.Text = "BaseMDIContainer"

End Sub

#End Region

End Class
Public Class BaseChildForm
Inherits Windows.Forms.Form
Private Sub JasmineForm_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles MyBase.Load
If Not BaseMDIContainer.MDISingleton Is Nothing
Then
Me.MdiParent = BaseMDIContainer.MDISingleton
End If

End Sub
End Class

'Windows Application Project Code
Public Class InheritedMDI
Inherits ControlLib.BaseMDIContainer

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

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

'Add any initialization after the
InitializeComponent() 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.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As
System.ComponentModel.IContainer

'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.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
components = New System.ComponentModel.Container
()
Me.Text = "InheritedMDI"
End Sub

#End Region

Protected Overrides Sub OnLoad(ByVal e As
System.EventArgs)
MyBase.OnLoad(e)
Dim firstform As New InheritedChildForm
firstform.Show()
End Sub
End Class
Module appstart
Public Sub main()
Dim mdi As New InheritedMDI
ControlLib.BaseMDIContainer.MDISingleton = mdi
Application.Run(mdi)
End Sub
End Module

Public Class InheritedChildForm
Inherits ControlLib.BaseChildForm

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

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

'Add any initialization after the
InitializeComponent() 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.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As
System.ComponentModel.IContainer

'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.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point
(72, 72)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "TextBox"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point
(96, 160)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "Click Me!"
'
'InheritedChildForm
'
Me.AutoScaleBaseSize = 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 = "InheritedChildForm"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim anotherform As New InheritedChildForm
anotherform.Show()
End Sub
End Class


Nov 20 '05 #1
0 1833

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

Similar topics

0
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...
7
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. ...
10
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...
3
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...
5
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...
2
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...
2
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...
4
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
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...
3
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...
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
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.