Rubrik: Oberfläche · Menüs | VB-Versionen: VB4, VB5, VB6 | 16.04.01 |
Systemmenü beliebig anzeigen Dieser Tipp zeigt, wie das Systemmenü an einer beliebiger Stelle als PopUp-Menü angezeigt werden kann. | ||
Autor: Heinz Prelle | Bewertung: | Views: 12.889 |
www.visual-basic5.de | System: Win9x, WinNT, Win2k, WinXP, Win7, Win8, Win10, Win11 | Beispielprojekt auf CD |
Das Systemmenü einer Form wird bekanntlich nur angezeigt, wenn man auf das Icon links oben in der Titelleiste klickt. Der nachfolgende Tipp zeigt, wie das Systemmenü an einer x-beliebigen Stelle innerhalb der Form als PopUp-Menü angezeigt werden kann.
' zunächst die benötigten API-Deklarationen Private Declare Function GetCursorPos Lib "user32" ( _ lpPoint As POINTAPI) As Long Private Declare Function SendMessage Lib "user32" _ Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Private Const WM_GETSYSMENU = &H313 Private Type POINTAPI X As Long Y As Long End Type ' Rechtsklick auf die Form zeigt das ' Systemmenü als PopUp-Menü Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _ X As Single, Y As Single) Dim lpPointApi As POINTAPI Call GetCursorPos(lpPointApi) If Button = vbRightButton Then Call SendMessage(Me.hwnd, WM_GETSYSMENU, 0, _ ByVal fLongVal(lpPointApi.Y, lpPointApi.X)) End If End Sub Public Function fLongVal(ByVal vHeightWord As Variant, _ ByVal iLowWord As Integer) As Long fLongVal = (vHeightWord * &H10000) + (iLowWord And &HFFFF&) End Function