|
-
Sep 18th, 2014, 06:51 AM
#8
Re: Modify right-click context menu in standard controls
 Originally Posted by fafalone
is there any way you could elaborate a bit on the code flow?
1) Wait for a WM_ContextMenu message
2) When received, start a hook to look for newly created windows
3) Forward the WM_ContextMenu message
4) In hook procedure, look for #32768 creation and keep monitoring its messages until the menu is created
5) When menu created, append/modify menu items, stop hook
6) After WM_ContextMenu finishes being forwarded, stop hook just in case it wasn't stopped earlier
7) When user selects a menu item, a message is forwarded to the textbox
Limitations: This method should work well for menus created via the TrackPopupMenu API. Many, if not most, context menus are done this way. If the desired menu isn't part of a #32768 window class, then the above won't work for that particular menu. For example, standard menus (at top of window) and system menus generally won't use that method.
P.S. I rarely handle any subclassing/hooking procedures within the actual procedure and NEVER callback directly to a form. Did so here just because it was a 'simple' workup. Personally, I use classes. The procedures make calls to the classes and the classes do the work or forward the messages via Public Events or via Implements. Each subclassed window has its own class. Each hook type has its own class. The idea is that your subclass/hook procedure remains generic, just a repeater. This allows each class, or form via Implements, to customize responses to the messages.
Last edited by LaVolpe; Sep 18th, 2014 at 08:08 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|