Sign in to follow this  
Followers 0
CatchFish

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

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

Thanks, gafrost & Holger. I wanted to simulate a toolbar button with a pop-up menu. Maybe I shall just keep waiting? :P

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

It's already implemented in v3.1.1.93 with GuiCtrlGetHandle(). Thanks a lot, Holger!

Share this post


Link to post
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
Sign in to follow this  
Followers 0