Jump to content

Need help: how to get the handle of a context-menu?


CatchFish
 Share

Recommended Posts

I need the handle of a context-menu created by GuiCtrlCreateContextMenu() for use in an API function (that is, TrackPopupMenu() of user32.dll). however, ControlGetHandle() returns null for the menu created. Is there any tricky way to do that?

EDITED: implemented in v3.1.1.93 with GuiCtrlGetHandle()

Edited by CatchFish
Link to comment
Share on other sites

I need the handle of a context-menu created by GuiCtrlCreateContextMenu() for use in an API function (that is, TrackPopupMenu() of user32.dll). however, ControlGetHandle() returns null for the menu created. Is there any tricky way to do that?

Not sure why you would need that, and why you would want to do the TrackPopMenu.

Context Menu is handled the same as Menu's, buttons etc...

for example

$lv_services_contextmenu = GUICtrlCreateContextMenu($lv_services)

$lv_service_stop = GUICtrlCreateMenuItem("Stop Service", $lv_services_contextmenu)

$lv_service_start = GUICtrlCreateMenuItem("Start Service", $lv_services_contextmenu)

and in the same select section as any buttons on the form

Case $msg = $lv_service_stop

_SetServiceState($lv_pcs, $lv_services, "Stop", $Status)

Case $msg = $lv_service_start

_SetServiceState($lv_pcs, $lv_services, "Start", $Status)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I completed it so far (GUICtrlGetHandle).

Maybe it will be buildin in one of the next beta updates (let's hope the best) :P

So you could create a contextmenu for a dummy control and then use this menu later for 'Trackking' it up.

So long...

Holger

Edited by Holger
Link to comment
Share on other sites

I completed it so far (GUICtrlGetHandle).

Maybe it will be buildin in one of the next beta updates (let's hope the best) :P

So you could create a contextmenu for a dummy control and then use this menu later for 'Trackking' it up.

So long...

Holger

@Holger

Hi Holger, please explain to me, what is diference between

ControlGetHandle() and your new GUICtrlGetHandle()

EDIT: I mean ControlGetHandle("","",control_id)

In my example I have this code and it works fine:

$treeview = GUICtrlCreateTreeView (6,6,200,160,...)
$h_tree = ControlGetHandle("", "", $treeview)

It's from my post about UDF _TreeViewGetItemState.au3

http://www.autoitscript.com/forum/index.php?showtopic=18409

EDIT2: I think it will be enough to mention explicitly in Hepfile at ControlGetHandle() posibility of getting handle also with GUI controls by ControlGetHandle("","",control_id) instead of adding new GUICtrlGetHandle(control_id)

If I'm wrong please tell me the diference...

Thank you

@CatchFish

Try ControlGetHandle() as in my example if it will work also with your popupmenu control...

Edited by Zedna
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...