cjwares
Dec 14th, 1999, 10:35 PM
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
Aaron Young
Dec 15th, 1999, 01:42 AM
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..
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..
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
aarony@redwingsoftware.com
adyoung@win.bright.net