PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] Right CLick Task Bar Menu-VBForums
Results 1 to 3 of 3

Thread: [RESOLVED] Right CLick Task Bar Menu

  1. #1

    Thread Starter
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Resolved [RESOLVED] Right CLick Task Bar Menu

    How would you make a specific menu (e.g., the file menu) appear when the tab in the task bar is right clicked (yes, the task bar, not the tray). I want to be able to access anything in my FIle menu from the task bar. Thx in advance!
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Access your Form's menu from System Menu

    First, it is not hard. But if you have many menus (and submenus), things can get complicated.
    Try this:
    VB Code:
    1. '[b][color=red]Inside a form[/color][/b]
    2. Option Explicit
    3. ' Create a form with following menus: (keep the order)
    4. ' mnuFile
    5. '   |
    6. '   |--> mnuNew
    7. '   |--> mnuOpen
    8. '   |--> mnuClose
    9.  
    10. Private Sub Form_Load()
    11.   AddToSystemMenu Me.hwnd
    12. End Sub
    13.  
    14. Public Sub mnuNew_Click() '[b]Must be public[/b]
    15.   MsgBox "mnuNew_Click"
    16. End Sub
    17.  
    18. Public Sub mnuOpen_Click() '[b]Must be public[/b]
    19.   MsgBox "mnuOpen_Click"
    20. End Sub
    21.  
    22. Public Sub mnuClose_Click() '[b]Must be public[/b]
    23.   MsgBox "mnuClose_Click"
    24. End Sub
    VB Code:
    1. '[b][color=red]Inside a module[/color][/b]
    2. Option Explicit
    3.  
    4. Private OriginalWindowProc As Long
    5. Public Const MF_STRING = &H0&
    6. Public Const MF_ENABLED = &H0&
    7. Public Const MF_POPUP As Long = &H10&
    8. Public Const MF_SEPARATOR As Long = &H800&
    9. '
    10. Public Const IDM_MYMENUITEM = 2003
    11. Public Const WM_SYSCOMMAND = &H112
    12. Public Const GWL_WNDPROC = (-4)
    13.  
    14. Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
    15. Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
    16. Public Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wflags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As String) As Long
    17. Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    18. Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    19. '
    20. Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    21. Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    22. Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    23. Declare Function CreatePopupMenu Lib "user32" () As Long
    24.  
    25. Public lNewPopupMenu As Long
    26.  
    27. Public Sub AddToSystemMenu(ByVal hwnd As Long)
    28.  
    29.   Dim hSystemMenu As Long
    30.   ' Get the system menu's handle.
    31.   hSystemMenu = GetSystemMenu(hwnd, False)
    32.  
    33.   'Get the form's File PopUp menu
    34.   lNewPopupMenu = GetSubMenu(GetMenu(hwnd), 0)
    35.  
    36.   '-------------------------------------------
    37.   AppendMenu hSystemMenu, MF_SEPARATOR, ByVal 0&, ByVal 0& 'A separetor
    38.   AppendMenu hSystemMenu, MF_POPUP, lNewPopupMenu, "File"  'File
    39.   '-------------------------------------------
    40.  
    41.   ' Tell Windows to call MyMenuProc when a system
    42.   ' menu command is selected.
    43.   OriginalWindowProc = SetWindowLong(hwnd, GWL_WNDPROC, _
    44.      AddressOf MyMenuProc)
    45.  
    46. End Sub
    47.  
    48. Public Function MyMenuProc(ByVal hwnd As Long, ByVal msg As Long, _
    49.      ByVal wParam As Long, ByVal lParam As Long) As Long
    50.  
    51.   ' If the custom menu item was selected display a message.
    52.  
    53.   If msg = WM_SYSCOMMAND Then 'System menu clicked
    54.  
    55.     Select Case wParam
    56.    
    57.       Case GetMenuItemID(lNewPopupMenu, 0): '1st item of the menu - New
    58.         Form1.mnuNew_Click
    59.            
    60.       Case GetMenuItemID(lNewPopupMenu, 1): '2nd item of the menu - Open
    61.         Form1.mnuOpen_Click
    62.    
    63.       Case GetMenuItemID(lNewPopupMenu, 2): '3rd item of the menu - Close
    64.         Form1.mnuClose_Click
    65.         Exit Function
    66.     End Select
    67.  
    68.   End If
    69.  
    70.   ' Otherwise pass the command on for normal processing.
    71.   MyMenuProc = CallWindowProc(OriginalWindowProc, hwnd, msg, _
    72.      wParam, lParam)
    73.  
    74. End Function
    Modified form this code.
    Last edited by iPrank; Jun 28th, 2006 at 04:50 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3

    Thread Starter
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Talking Re: Right CLick Task Bar Menu

    SWEET!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    This is just what I've been waiting for! Thank you so much!
    Visit here to learn to make the VB interface fit you!.
    "I have not failed 10,000 times. I have successfully identified 10,000 ways that will not work" Thomas Edison
    "The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners" -- Ernst Jan Plugge

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width