April 24, 2024, 10:36:07 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Context menu detect

Started by Andy, May 22, 2021, 04:59:33 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

May 22, 2021, 04:59:33 AM Last Edit: May 22, 2021, 05:38:52 AM by Andy
Hi,

Here's another one, how can I (if possible) detect that a right click context menu is showing / exists?

I have several controls close to each other an I am monitoring which control the mouse is over, however the context menu can "spill" over another control.

In the above case, when you move the mouse across the context menu to select an option the mouse is actually over a different control.

The bottom line is that the monitoring of which control I am over is done in a timer and I would simply like to stop the timer when the context menu is showing & restart the timer when it has gone.

Any ideas please?
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

What comes to mind is this scheme:
you need to have a global flag to enable/disable the timer

So, in your menu where you activate the context menu set the global flag and disable the timer
Then, in each  of the context menu item handlers(which will close the context menu) reset the global flag allowing the timer to be restarted again.


you may want to to consider a slight delay in resetting the flag so you don't immediately select the control under the context menu option you selected.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

May 23, 2021, 03:45:31 AM #2 Last Edit: May 23, 2021, 04:10:50 AM by Andy
Thanks Larry,

That gave me all sorts of ideas and in the end the answer was quite simple.

I have a global UINT called hPopup (handle for the context menu).

The main window (w1) is sub classed so I was able to add in its sub class handler under the case WM_LBUTTONDOWN just hPopup = 0

The context menu can call cases 101 & 102 in the window's main handler, so when any of these are selected before the end of each of the case's code I have

STOPTIMER w1
Do whatever...
hPopup = 0.    (set hPopup back to zero)
STARTTIMER w1,TimerSpeed


Finally in my timer I have:

IF hPopup  (context menu is showing)....
  RETURN 0
ENDIF

Nice one Larry!

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.