04-13-2015, 01:02 PM
Sorry, this problem is difficult to explain for me.
I hope the code makes it clear enough to explain what I want.
Is it possible to uncheck a menu item rendered with "ShowMenu".
In other words, is it possible to toggle it's checked/unchecked state?
The menu is rendered when the systray icon is right clicked, the whole macro consists of 2 functions
One function is the dialog code which renders an invisible dialog and that dialog code calles the below code under 'MENU CODE'
I have the following code below (under 'MENU CODE') in which the menu item "&Disable hotspot" starts in a checked state.
I want to toggle it's state as soon it is clicked, this I tried to do in the part under "if(i=551)"
But it does not work because of "int hm=GetMenu(dlg_id)" the container "dlg_id" should be "hDlg"
But because the function below is accessed like this:
Function xy_applauncher_dlg
I had to make the dialog ID thread global so that the below function could access it.
MENU CODE
Function xy_applauncher_systray
From the microsoft site:
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
GetMenu does not work on floating menu bars. Floating menu bars are custom controls that mimic standard menus; they are not menus. To get the handle on a floating menu bar, use the Active Accessibility APIs.
Is it even possible?
Other applications for example MalwareBytes have an systray icon in which you can check/uncheck the right click menu items.
(but malwarebytes is a totally different program, programmed in a totally different environment. I just used is an example)
Other example:
I hope the code makes it clear enough to explain what I want.
Is it possible to uncheck a menu item rendered with "ShowMenu".
In other words, is it possible to toggle it's checked/unchecked state?
The menu is rendered when the systray icon is right clicked, the whole macro consists of 2 functions
One function is the dialog code which renders an invisible dialog and that dialog code calles the below code under 'MENU CODE'
I have the following code below (under 'MENU CODE') in which the menu item "&Disable hotspot" starts in a checked state.
I want to toggle it's state as soon it is clicked, this I tried to do in the part under "if(i=551)"
But it does not work because of "int hm=GetMenu(dlg_id)" the container "dlg_id" should be "hDlg"
But because the function below is accessed like this:
Function xy_applauncher_dlg
I had to make the dialog ID thread global so that the below function could access it.
MENU CODE
Function xy_applauncher_systray
function Tray&tray msg
int- dlg_id
sel msg
,case WM_RBUTTONUP
,,str- default_profile_path_sectioncontent
,,POINT p
,,int px(xm) py(ym)
,,p.x=px
,,p.y=py
,,str md=
,,;BEGIN MENU
,,;&Disable hotspot :551 0 8
,,;&Exit :550
,,;END MENU
,,;; Can add more icons!
,,str s3=
,,;:101 f:\_icons\_systray_test\close.ico
,,
,,SetThreadMenuIcons "550=0" s3
,,int i=ShowMenu(md 0 p)
,,if(i=550)
,,,out
,,,out "EXIT icon clicked (X)"
,,if(i=551)
,,,out
,,,out "'Disable hotspot' clicked"
,,,int hm=GetMenu(dlg_id) ;; => ? WHAT "DIALOG" ID TO USE, TO ACCESS THE RENDERED MENU DEFINED IN 'md' ?
,,,_i=GetMenuState(hm 551 0)&MFS_CHECKED
,,,out F"The retrieved state of the 'Disable hotspot' menu item: {_i}" ;; RETRIEVING THE STATE ALSO DOES NOT WORK CORRECTLY
,,,if(_i=8)
,,,,CheckMenuItem hm 551 MF_UNCHECKED
,,,else
,,,,CheckMenuItem hm 551 MF_CHECKED
From the microsoft site:
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
GetMenu does not work on floating menu bars. Floating menu bars are custom controls that mimic standard menus; they are not menus. To get the handle on a floating menu bar, use the Active Accessibility APIs.
Is it even possible?
Other applications for example MalwareBytes have an systray icon in which you can check/uncheck the right click menu items.
(but malwarebytes is a totally different program, programmed in a totally different environment. I just used is an example)
Other example: