Solved

click required to exit a context menu

Posted on 2006-10-22
19
200 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:jbajaj
  • 12
  • 7
19 Comments
 

Author Comment

by:jbajaj
ID: 17787380
So I want a way in which my mouseevent can trigger once I have left the context menu
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 17788477
<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
 

Author Comment

by:jbajaj
ID: 17790259
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
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 17790582
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
 

Author Comment

by:jbajaj
ID: 17790616
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
 

Author Comment

by:jbajaj
ID: 17790654
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
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 17790727
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
 

Author Comment

by:jbajaj
ID: 17790756
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
 

Author Comment

by:jbajaj
ID: 17791028
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:jbajaj
ID: 17792614
Helloo, could someone please provide me some code for option 2
0
 

Author Comment

by:jbajaj
ID: 17792867
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
 

Author Comment

by:jbajaj
ID: 17793208
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
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 17793761
I am in a different time zone to you, I've not been neglecting this.
0
 

Author Comment

by:jbajaj
ID: 17793769
Oh, I never meant that way :)...I was just updating my finding to make things more clear. I am new to VB.net
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 17793786
<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
 

Author Comment

by:jbajaj
ID: 17793798
Can you please send me a sample application doing this. I am unable to follow this...Thanks
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 17793820
<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
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 17793835
<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
 

Author Comment

by:jbajaj
ID: 17793846
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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

16 Experts available now in Live!

Get 1:1 Help Now