How to handle mouse events (Enter & Leave) in an mdi?

Posted on 2005-03-25
Medium Priority
Last Modified: 2008-03-17

I have an form with a panel holding a treeview menu, a commandline and a list with the last 20 commands used, on the left hand side.  I use a splitter to resize the panel to allow the user to resize it at will. But i also need to make an autohide function. I adde a Tagpin (button) that resizes the whole panel to a minimum width. Now the panel has to slide open or close when the mouse enters or leaves it.
On a normal form I use the forms mouse enter and leave events to do so and it works like a charm. Now the same form has to be used as an MDI. So setting the mdicontainer = true should be the only thing I have to do However, the mouse events don't seem to happen anymore and the autohide no longer works.
How can I trigger the mouse events To allow my form and panel to work regardless of being an mdi or not?

We need this form ASAP as it is a main part of the framework we are building and without it all other projects based on the framework are on hold.


Alain Boone
Question by:Paybit
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Fenris_Lokisson earned 2000 total points
ID: 13628913
The mdiform has an mdiclient that holds all the childs. It can be found in the forms controlcollection.

By creating an instance of an mdiclient with events and adding an eventhandler handling the mouse enter and mouseleave and linking it to the sub you want to run, you can catch the events.


On the MDIform, create an mdiclient

private withevents fmdiC as mdiclient

In the form load, link it to the mdiclient if there is one

dim i as integer
for i = 0 to mdiform.controls.count-1
  if mdiform.controls(i).gettype.tostring = "mdiclient" then
     fmdiC = mdiform.controls(i) 'if option strict, don't forget to ctype to mdiclient: ctype(mdiform.controls(i),mdiclient)
     addhandler fmdic.mouseenter addressof ... 'the sub or function that has to handle the event. You could for example link it to
                                                                    'the forms mouseenter event by setting addressof mdiform_mouseenter
     exit for
   end if
next i

Author Comment

ID: 13628951
I just had to change the gettype.tostring = "mdiclient" beacause the string returned = "System.Windows.forms.MdiClient" and it has to be exactly the same, including the upper and lower casing.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

771 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