click required to exit a context menu

Hello

Design :
I have two buttons. Everytime I move my mouse over their reigion ( mouseenter event) , a context menu pops up . Each button has a different context menu .

problem scenario:
Move mouse over button1 , context menu pops up. Now when I move to button2 the mouseevent for that button wont trigger unless or until I click on the previous context menu selction or Click somewhere outside i.e a click event is required for me to close the context menu. I want to change this to mouseenter or something which would prevent the above

Please let me know asap. I dont want to use a usercontrol

Thanks
jbajajAsked:
Who is Participating?
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
<I am new to VB.net>

This is an area for C++ not VB - is that why you are having problems following the code?
0
 
jbajajAuthor Commented:
So I want a way in which my mouseevent can trigger once I have left the context menu
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
<I dont want to use a usercontrol>

I think you are left with writing a mouse hook  BUT consider.
Menu appears, user moves mouse a little off menu in process of selecting the desired action and menu disappears.  It could prove to be annoying behaviour to the user.  (And you have to make sure that the mouse is actually over the menu when it appears else the user can't use the mouse to make a selection).
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
jbajajAuthor Commented:
Well then how is the menu in start of XP implemented

When I move the cursor over PROGRAMS, the menu pops up and  then move the cursor over  DOCUMENTS and anotehr menu pops up.

In my case, moving the mouse over  DOCUMENTS does not trigger any mouse events  
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
That is standard menu behaviour when there is a child menu at the mouse position.

Win XP - mouse over programs and a sub menu appears, move mouse away (off menu completely) and sub menu stays visible.
0
 
jbajajAuthor Commented:
This does not answer my question .

I have two buttons associated with 2 different context menus. When one pops up and I move the mouse to the other button., I want the previous context menu toclose and the new context menu to show

Please help
 
0
 
jbajajAuthor Commented:
Ok if the above cannot be resolved or is a bit complicated

Here is what might be more helpful for me

Can I have a main menu embedded in my tabpage , on the left side of the tabpage

I guess then I dont need to worry about the above . Also how do I then change the color of the main menu

thank you
Jayesh
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Unfortunately AFAIK changing the background colour of a menu isn't trivial either.

My thoughts at this point is that the simplest way would be to create your own control - which you said you didn't want.
0
 
jbajajAuthor Commented:
Thanks for the quick responses

I managed to change the color of the context menu . Would it be similar ?
Can we align the main menu to the left of the tabpage?
I dont mind writing my owncontrol, but dont know how to ?

Please let me know asap. Would be highly appreciated
0
 
jbajajAuthor Commented:
Hello , so i have options here

1.> have a main menu implemented on the left side of the tabpage and have it work like thePROGRAMS , DOCUMENTS etc menu in windows. If I need to add my own control, please send me the code how to do so

OR

2.> Have a mouse hook in such a way that when I move my mouse over button2, the context menu opened by button1 closes and the context menu associated with button2 opens. Currently the mouseenter evnt on moving the mouse over button2 doesnt fire when the context menu associated with button1 is opened. I need to 'click'

Please help asap

Thank you
 
0
 
jbajajAuthor Commented:
Helloo, could someone please provide me some code for option 2
0
 
jbajajAuthor Commented:
Well,

I want a way to hide the popup menu ( context menu) when I move my mouse over a button , and not on left click

Please help

thank you
0
 
jbajajAuthor Commented:
Hello

I saw a discussion for this on
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_20990107.html?query=hiding+context+menu&clearTAFilter=true

But this 2 doesnt give me the answer. lease provide me the code to so

Thank you
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
I am in a different time zone to you, I've not been neglecting this.
0
 
jbajajAuthor Commented:
Oh, I never meant that way :)...I was just updating my finding to make things more clear. I am new to VB.net
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
<Currently the mouseenter evnt on moving the mouse over button2 doesnt fire when the context menu associated with button1 is opened. I need to 'click'>

I think that the menu has 'captured' the mouse - hence the need for a hook to see any mouse messages.  Have a look at
http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_10040679.html
which may help.


Also the DestroyMenu and GetSafeHMenu functions of CMenu will probably be required for you to test if a menu exists and to destroy it.  You will need the CMenu to be a member variable of the class, not a local variable in the mouseover event handler
0
 
jbajajAuthor Commented:
Can you please send me a sample application doing this. I am unable to follow this...Thanks
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
<Can you please send me a sample application doing this. >
No.  I get paid to write code, here I will give advice and comments.  Also it is better for you in the end to learn how to do it, just copying a piece of code doesn't make one understand the techniques.

Exactly what bit is giving you a problem?
0
 
jbajajAuthor Commented:
OK here you go... I have 2 buttons index_futures and index_options...and here is the code I am trying
index_futures_cm and index_options_cm are the two context menus assocaited with them


  Private Sub index_futures_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles index_futures.MouseEnter

        index_futures.BackColor = Color.DarkBlue
        index_futures.ForeColor = Color.White

        index_options.BackColor = Color.WhiteSmoke
        index_options.ForeColor = Color.Black

        pos = New Point(index_futures.Width + 1)
        index_futures_cm.Show(index_futures, pos)
        '  index_futures.BackColor = Color.DarkBlue
        ' index_futures.ForeColor = Color.White


    End Sub

 Private Sub index_options_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles index_options.MouseEnter

        index_options.BackColor = Color.DarkBlue
        index_options.ForeColor = Color.White

        index_futures.BackColor = Color.WhiteSmoke
        index_futures.ForeColor = Color.Black

        pos = New Point(index_options.Width + 1)
        index_options_cm.Show(index_options, pos)


    End Sub

Now can you please give me pointers based on the above code....where do i add events . I am totally confused ????
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.