Mouse events & MDI child forms

G

Guest

I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI container form) or if the MDI child form's Visible property is set to False (after the MDI child form was shown). This is an enormous problem for my app because I must show different MDI child forms based on the state of my application and many of the controls in the MDI child forms are highly interactive (i.e., the controls require mouse events)

1. Is there a work around for this bug
2. Is this bug fixed in the most recent "technology preview" of VS 2005? If so, how can I obtain a DVD of that version? (I don't have a DVD burner so downloading the iso file is useless)

Please note that disposing and recreating instances of the MDI child forms when my app changes states is not a practical solution. Also, I've included some sample code that demonstrates this issue

Thanks for any help
Lanc

Public Class Form
Inherits System.Windows.Forms.For

#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() cal

End Su

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

'Required by the Windows Form Designe
Private components As System.ComponentModel.IContaine

'NOTE: The following procedure is required by the Windows Form Designe
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor
Friend WithEvents _TopPanel As System.Windows.Forms.Pane
Friend WithEvents Button1 As System.Windows.Forms.Butto
Friend WithEvents Label1 As System.Windows.Forms.Labe
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent(
Me._TopPanel = New System.Windows.Forms.Pane
Me.Button1 = New System.Windows.Forms.Butto
Me.Label1 = New System.Windows.Forms.Labe
Me._TopPanel.SuspendLayout(
Me.SuspendLayout(

'_TopPane

Me._TopPanel.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte)
Me._TopPanel.Controls.Add(Me.Label1
Me._TopPanel.Controls.Add(Me.Button1
Me._TopPanel.Dock = System.Windows.Forms.DockStyle.To
Me._TopPanel.Location = New System.Drawing.Point(0, 0
Me._TopPanel.Name = "_TopPanel
Me._TopPanel.Size = New System.Drawing.Size(644, 112
Me._TopPanel.TabIndex =

'Button

Me.Button1.Location = New System.Drawing.Point(12, 12
Me.Button1.Name = "Button1
Me.Button1.TabIndex =
Me.Button1.Text = "Button1

'Label

Me.Label1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left)
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles
Me.Label1.Location = New System.Drawing.Point(8, 40
Me.Label1.Name = "Label1
Me.Label1.Size = New System.Drawing.Size(628, 64
Me.Label1.TabIndex =
Me.Label1.Text = "Move the mouse in and out of the client area of the MDI child form and notice tha" &
"t the MDI child's label raises MouseLeave and MouseEnter events. Then, click Bu" &
"tton1 twice then repeate the previous steps, noticing that now the MDI child's l" &
"abel does not raise MouseLeave and MouseEnter events.

'Form

Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15
Me.ClientSize = New System.Drawing.Size(644, 662
Me.Controls.Add(Me._TopPanel
Me.Name = "Form1
Me.Text = "Form1
Me._TopPanel.ResumeLayout(False
Me.ResumeLayout(False

End Su

#End Regio

Protected WithEvents _MyChild As New Windows.Forms.For
Protected WithEvents _MyChildLabel As New Windows.Forms.Labe

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

Me._MyChildLabel.Dock = DockStyle.Fill
Me._MyChildLabel.BackColor = Drawing.Color.Pink

Me._MyChild.StartPosition = FormStartPosition.Manual
Me._MyChild.Controls.Add(Me._MyChildLabel)

Me._MyChild.MdiParent = Me

Me._MyChild.Show()
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If (Me._MyChild.MdiParent Is Me) Then
Me._MyChild.Visible = False
Me._MyChild.MdiParent = Nothing
Else
Me._MyChild.MdiParent = Me
Me._MyChild.Visible = True
End If
End Sub

Private Sub _MyChildLabel_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles _MyChildLabel.MouseEnter
Static cnt As Integer : cnt += 1
Debug.WriteLine(System.String.Format("{0}: MyChildLabel.MouseEnter", cnt.ToString))
End Sub

Private Sub _MyChildLabel_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles _MyChildLabel.MouseLeave
Static cnt As Integer : cnt += 1
Debug.WriteLine(System.String.Format("{0}: MyChildLabel.MouseLeave", cnt.ToString))
End Sub

End Class
 
P

Peter Huang

Hi Lance,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you when you hide an child form
and re-show the child form, the Mouse Leave Event will not be fired any
more.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I have found similar issue in our database, this is an known issue. So far
we do not have an workaround for the issue. And the issue will be fixed in
the next release version of whidbey. But I think the preview version of VS
2005 did not fix the problem.

As for the DVD of the preview version, I think you can download the ISO
file and use a virtual CD/DVD-ROM emulator software to load the iso as an
driver, so that you can read it. e.g. the Daemon tools, you can download it
at the link below.
http://www.daemon-tools.cc/dtcc/portal/download.php

Thank you for your understanding.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Thank you very much for the info. Not what I wanted to hear, but very useful nonetheless
And the issue will be fixed in the next release version of whidbey

Can you please tell me if you are referring to the next alpha or beta version that (I've heard) is scheduled for release some time in May, or the final version that won't be out until ~Q1 2005

Thanks again
Lanc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Msg Box not displaying messages 2
MDI Child Wrong Event Firing 2
odd behaviour double click label v button 3
Need a palette expert here 17
thread dead lock 2
form inheritence 9
Windows Services Status 1
Bug in IDE? 9

Top