Results 1 to 5 of 5

Thread: Replace Default Popup Menu (without subclassing)

  1. #1

    Thread Starter
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Replace Default Popup Menu (without subclassing)

    VB Code:
    1. ' Create your own menu in the VB menu editor, and then call it on
    2. ' the 'MouseDown' event of your textbox
    3.  
    4. Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    5.     If Button = vbRightButton Then
    6.         Text1.Enabled = False
    7.         DoEvents
    8.         Text1.Enabled = True
    9.         PopupMenu mnuYourMenu
    10.     End If
    11. End Sub

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    But then you lose your highlight selection if you were going to do a
    copy/paste function.





    Also, when the cursor is in the textbox and the user presses the
    menu button on the keyboard, the original edit menu pops up.


    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    And it's only for replacing... Subclassing can disable it completely even on mouseup and not mousedown, and block the keyboard button and the paste message Much more functionality


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Yes, but sub-classing "can" be a pain if not implemented correctly.
    Also, harder to debug while subbing , but best results.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Yes, but this is about as simple as subclassing gets... Subclass the textbox and block the WM_CONTEXT (or WM_CONTEXTMENU, I can't quite remember) and the WM_PASTE if you want... You just take the already made subclassing modules, select the messages you want to block and voila! Nothing to it (at least not much)


    Has someone helped you? Then you can Rate their helpful post.

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