Results 1 to 18 of 18

Thread: [RESOLVED] Modify right-click context menu in standard controls

Threaded View

  1. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Modify right-click context menu in standard controls

    Quote Originally Posted by fafalone View Post
    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width