Olly
Apr 26th, 2001, 10:47 AM
Does anyone of you guys know how to popup the titlebar menu (the menu that pops up when you click onto the program icon or rightclick onto the taskbar) anywhere on the form, for example under a button when you press it?
thx in advance
gwdash
Apr 26th, 2001, 03:39 PM
Const TPM_LEFTALIGN = &H0&
Const TPM_RETURNCMD = &H100&
Const WM_SYSCOMMAND = &H112
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hwnd As Long, ByVal lprc As Any) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim Pt As POINTAPI
Dim retval As Long
'Get the position of the mouse cursor
GetCursorPos Pt
retval = TrackPopupMenu(GetSystemMenu(Me.hwnd, False), TPM_LEFTALIGN Or TPM_RETURNCMD, Pt.x, Pt.y, 0, Me.hwnd, ByVal 0&)
PostMessage Me.hwnd, WM_SYSCOMMAND, retval, 0&
End Sub
Olly
Apr 26th, 2001, 03:54 PM
excellent! Although I use the api-viewer and know some of these api calls I still need more praxis using them thx :rolleyes: