Solved

MDIParent Form Double-Click Event Does Not Fire - VB.NET

Posted on 2010-08-17
5
709 Views
Last Modified: 2013-11-27
Hi

I hope somebody can assist Me with the following problem:

My startup form is my MDIParent form named FrmMain. After this form shows I have a Timer Control which executes the Following code and works as I want it to:

Timer_Click .........................................

   Dim Myform As New FrmLogo
   MyForm.MDIParent = Me
   MyForm.Show

End Sub

The above works perfectly.

The User now closes this Logo Form when he is sick and tired of it.

Now I want to recall this form with the same logic as above but in FrmMain's Double-Click Event.
Amazingly enough, nothing happens.

Can somebody please provide me with a pointer as to what I am doing wrong. I am using VB.NET in Visual Studio 2008 under Windows XP Professional.

Thanks.
0
Comment
Question by:Nolanc
5 Comments
 
LVL 17

Accepted Solution

by:
Zhaolai earned 50 total points
ID: 33455721
Interesting..
It's said that this is by design.

Check out this link for an alternative:

http://social.msdn.microsoft.com/Forums/en/vbinterop/thread/b498ac7b-9fc5-43cd-9b35-84a3518875c0
0
 
LVL 16

Expert Comment

by:13598
ID: 33456090
You could try using just forms but show the forms you want to act as children by using showdialog instead of show, as in:
MyForm.ShowDialog
That shows MyForm as a modal form with the main form set as its owner.
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 50 total points
ID: 33459009
Here's something to get you started...
Public Class Form1



    Private WithEvents mf As MyFilter



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

        For Each ctl As Control In Me.Controls

            If TypeOf ctl Is MdiClient Then

                mf = New MyFilter(ctl.Handle)

                Application.AddMessageFilter(mf)

                Exit For

            End If

        Next

    End Sub



    Private Sub mf_DoubleClick() Handles mf.DoubleClick

        Debug.Print("Double Click on MdiClient")

    End Sub



    Private Class MyFilter

        Implements IMessageFilter



        Private mc As IntPtr

        Private SW As New Stopwatch



        Private Const WM_LBUTTONDOWN As Integer = &H201



        Public Event DoubleClick()



        Public Sub New(ByVal handle As IntPtr)

            Me.mc = handle

        End Sub



        Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage

            Select Case m.Msg

                Case WM_LBUTTONDOWN

                    If m.HWnd.Equals(Me.mc) Then

                        If Not SW.IsRunning Then

                            SW.Start()

                        Else

                            SW.Stop()

                            If SW.ElapsedMilliseconds <= SystemInformation.DoubleClickTime Then

                                RaiseEvent DoubleClick()

                            End If

                            SW.Reset()

                            SW.Start()

                        End If

                    End If



            End Select

            Return False

        End Function



    End Class



End Class

Open in new window

0
 

Author Closing Comment

by:Nolanc
ID: 33462942
Hi

Thanks for your contributions. They have at least provided a way around a poor showing from Microsoft. How can you provide events that are in 'Sleep" mode.

Many thanks.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 33464177
What did you mean by this question?

    "How can you provide events that are in 'Sleep" mode."
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now