AndyK
November 17th, 1999, 10:24 PM
Thank You
|
Click to See Complete Forum and Search --> : How to display system menu with VB when you click on picturebox(when you press with right mouse butt AndyK November 17th, 1999, 10:24 PM Thank You Lothar Haensler November 18th, 1999, 02:23 AM this code displays the system menu in the upper left corner upon click of the button option Explicit private Type RECT Left as Long Top as Long Right as Long Bottom as Long End Type private Type TPMPARAMS cbSize as Long rcExclude as RECT End Type private Declare Function TrackPopupMenuEx Lib "user32" (byval hMenu as Long, byval un as Long, byval n1 as Long, byval n2 as Long, byval hwnd as Long, lpTPMParams as Any) as Long private Declare Function GetSystemMenu Lib "user32" (byval hwnd as Long, byval bRevert as Long) as Long private Sub Command1_Click() Dim hsys as Long Dim tp as TPMPARAMS hsys = GetSystemMenu(me.hwnd, 0) If hsys then Call TrackPopupMenuEx(hsys, 0, 0, 0, Command1.hwnd, byval 0&) End If End Sub Lothar Haensler November 18th, 1999, 03:06 AM OK, this one might be more useful: it places the systemmenu directly below the commnd button and if traps the selected menu choice option Explicit private Type RECT Left as Long Top as Long Right as Long Bottom as Long End Type private Type TPMPARAMS cbSize as Long rcExclude as RECT End Type Const TPM_RETURNCMD as Long = &H100 private Declare Function TrackPopupMenuEx Lib "user32" (byval hMenu as Long, byval un as Long, byval n1 as Long, byval n2 as Long, byval hwnd as Long, lpTPMParams as Any) as Long private Declare Function GetSystemMenu Lib "user32" (byval hwnd as Long, byval bRevert as Long) as Long private Const SC_CLOSE = &HF060& private Type POINTAPI x as Long y as Long End Type private Declare Function ClientToScreen Lib "user32" (byval hwnd as Long, lpPoint as POINTAPI) as Long private Declare Function GetWindowRect Lib "user32" (byval hwnd as Long, lpRect as RECT) as Long private Sub Command1_Click() Dim hsys as Long Dim tp as TPMPARAMS hsys = GetSystemMenu(me.hwnd, 0) If hsys then Dim lcmd as Long Dim rc as RECT GetWindowRect Command1.hwnd, rc lcmd = TrackPopupMenuEx(hsys, TPM_RETURNCMD, rc.Left + 10, rc.Bottom, Command1.hwnd, byval 0&) Select Case lcmd Case SC_CLOSE MsgBox "close selected" End Select End If End Sub codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |