Results 1 to 2 of 2

Thread: Taskbar Menus

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    64

    Post

    Ok, if you right click on the program buttons on the taskbar, you get a menu, that says Restore-Minimize-Maximize-etc... how can i modify what it says? or change it all together? thanx

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    The Menu you see is the System Menu the same one you'd get if you Right Click the Top, Left Icon on a Form..

    You can Modify/Add to it by Subclassing the Form and using some Windows API's, here's a quick example I wrote for someone else here a short while back..

    In a Module..
    Code:
    Private Declare Function GetSystemMenu Lib "user32" (ByVal Hwnd As Long, ByVal bRevert As Long) As Long
    Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
    Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private 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
    
    Public Const GWL_WNDPROC = (-4)
    Private Const MF_ENABLED = &H0&
    Private Const MF_STRING = &H0&
    Private Const WM_MENUSELECT = &H11F
    
    Private lMenu As Long
    Public lPrevProc As Long
    
    Public Sub SetupMenu(ByVal lHwnd As Long)
        lMenu = GetSystemMenu(lHwnd, 0)
        Call AppendMenu(lMenu, MF_ENABLED Or MF_STRING, 200, ByVal "Happy Happy Joy Joy!")
    End Sub
    
    Public Function SubWindowProc(ByVal Hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Static lSelected As Long
        Static lSelMenu As Long
        
        If Msg = WM_MENUSELECT Then
            If lParam Then
                lSelected = wParam And &HFF
                lSelMenu = lParam
            Else
                If lSelected = 200 And lSelMenu = lMenu Then MsgBox "Happy Happy Joy Joy!!!", vbSystemModal, "System Menu Popup"
                lSelected = 0
            End If
        End If
        SubWindowProc = CallWindowProc(lPrevProc, Hwnd, Msg, wParam, ByVal lParam)
    End Function
    In the Form..
    Code:
    Private Sub Form_Load()
        Call SetupMenu(Hwnd)
        lPrevProc = SetWindowLong(Hwnd, GWL_WNDPROC, AddressOf SubWindowProc)
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Call SetWindowLong(Hwnd, GWL_WNDPROC, lPrevProc)
    End Sub
    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

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