PopUp רק ב Api

PopUp רק ב Api

Const MF_CHECKED = &H8& Const MF_UNCHECKED = &H0& Const MF_APPEND = &H100& Const TPM_LEFTALIGN = &H0& Const TPM_RIGHTALIGN = &H8& Const MF_DISABLED = &H2& Const MF_GRAYED = &H1& Const MF_SEPARATOR = &H800& Const MF_STRING = &H0& Const TPM_RETURNCMD = &H100& Const TPM_RIGHTBUTTON = &H2& Const TPM_LEFTBUTTON = &H0& Private Type POINTAPI x As Long y As Long End Type Private Declare Function CreatePopupMenu Lib "user32" () As Long Private Declare Function TrackPopupMenuEx Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal HWnd As Long, ByVal lptpm As Any) 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 Private Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Dim hMenu As Long Dim chack As Boolean Private Sub Form_Load() chack = True End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) Dim Pt As POINTAPI Dim ret As Long hMenu = CreatePopupMenu() AppendMenu hMenu, MF_STRING, 1, "שלום" AppendMenu hMenu, MF_GRAYED Or MF_DISABLED, 2, "בדיקה..." AppendMenu hMenu, MF_SEPARATOR, 3, 0& If chack = True Then AppendMenu hMenu, MF_CHECKED, 4, "בחירה 1" Else AppendMenu hMenu, MF_UNCHECKED, 4, "בחירה 1" End If GetCursorPos Pt ret = TrackPopupMenuEx(hMenu, TPM_RIGHTALIGN Or TPM_RETURNCMD Or TPM_LEFTBUTTON, Pt.x, Pt.y, Me.HWnd, ByVal 0&) DestroyMenu hMenu Debug.Print ret If ret = 4 Then If chack = True Then chack = False Check1.Value = 0 Else chack = True Check1.Value = 1 End If End If End Sub
 
למעלה