April 17, 2024, 09:28:00 PM

News:

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


Detecting when a context menu is open

Started by Andy, October 25, 2017, 01:07:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

I'm just trying to tidy a few thing up in my reg viewer program and I'm wondering how you detect if a context menu is open or not.

So is there a way to detect if a context menu is open / showing on screen, and likewise if it's been closed i.e. by moving away / clicking elsewhere?

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

Andy

It's okay,

I found a way via the timer section of the window's handler.

if mousedown(1) then CMenu = 0

'Right click on registry path description
IF ControlRClick(win,12) and WindowHasFocus(win)
CMenu = 1
POINT cursor3
GetCursorPos(cursor3)
ScreenToClient(win.hwnd, cursor3)
CONTEXTMENU win,cursor3.x, cursor3.y
  MENUITEM "Export key",0,2002
  separator
  MENUITEM "Copy key name",0,110
  separator
  MENUITEM "Copy key details",0,111
ENDMENU
endif


The variable CMenu remain at 1 until you click on anything else, then it goes back to zero.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

Maybe I'm missing something Andy, but I do not understand why you have to make things so complicated.
The few times I have used contextmenues myself, the menues has closed by itself as soon as I clicked on a menu choise or clicked somewhere else in the main window.

Here is an example, it is called from the main loop using this code:

CASE @IDRBUTTONUP
CMenu(win)



And then the sub:

SUB CMenu(wnd:window)
'-------------------------------------------------------------------------------- 
' Context menu   
'--------------------------------------------------------------------------------
CONTEXTMENU win,@MOUSEX,@MOUSEY
menuitem "Start UDP Receive",1,30
menuitem "Stop  UDP Receive",1,31
SEPARATOR
' menuitem "Change Map",1,10
' SEPARATOR
menuitem "Set PC-HFDL log Directory",1,20
menuitem "Set Home position",1,22
menuitem "Set Ground Station Positions",1,23
menuitem "Set UDP Port",1,24
BEGINPOPUP "Adjust Brightness"
menuitem "Darker",1,30
menuitem "Brighter",1,31
ENDPOPUP
SEPARATOR
menuitem "Save Setup",1,40
SEPARATOR
menuitem "About",1,50
menuitem "Help",0,51
SEPARATOR
menuitem "Start DEMO",1,90
menuitem "End Program",0,99
ENDMENU
RETURN
ENDSUB



So why do you have to check if it is still open?


Egil

Support Amateur Radio  -  Have a ham  for dinner!

Andy

October 25, 2017, 05:31:16 AM #3 Last Edit: October 25, 2017, 05:34:53 AM by Andy
Egil,

I'm using my mouse over controls include file to make buttons slightly larger when the mouse is over any of them.

Now when I added in a right click on a static (which gives you the full path of the registry key you are viewing) I found the context menu was over some of the buttons. If you then moved the mouse up or down the context menu to a position where (although the context menu was over these buttons), the mouse was over any of these buttons location they enlarged - and I wanted to disable that situation.

In other words, although the context menu was masking the buttons, the buttons were still enlarging and I wanted to stop that when the context menu was open.

Sounds complicated I know.

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

Egil

QuoteSounds complicated I know.

Think I wait and see what you post when you have finished the program....


Egil
Support Amateur Radio  -  Have a ham  for dinner!

ckoehn

QuoteIn other words, although the context menu was masking the buttons, the buttons were still enlarging

I know what you mean Andy.  I have a program where a menu is dropped down and when I click a menu item, it clicks the form underneath the menu item.  Quite frustrating. I have not figured out how to stop it.  I am drawing to the form underneath it and it looks like the form is selected to receive the mouse click instead of the menu that is dropped down.

I think what you are experiencing is the same thing I am.  If you figure out how to fix it, please post what you did.  :)

Later,
Clint

Andy

Clint,

Yes I have found a solution (at least for me).

Can you give me a day or so and I'll publish something on here for you.

Just a bit busy today and tomorrow - but looking into it for you.

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

Andy

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

jalih

From MSDN using C:

FindWindowEx( NULL, NULL, MAKEINTATOM(0x8000), NULL );

Note that 0x8000 is the atom for a menu class. When an application calls this function, the function checks whether a context menu is being displayed that the application created.

You might need to substitute MAKEINTATOM macro with your own code when converting to IWB.

Have fun!

Andy

Jalih,

Yes, there are other ways to do it, the point about the mouse over controls file is that it makes it very easy to do other things with controls.

The commands are already there for you, so with just a little bit of time learning them can save you lots of time.

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