IIyx
IIyx

Reputation: 11

InsertMenuItem for popup in textbox

I'm trying to create popup menu for textbox in vba form use AddRightClickMenu as souce so i've tryed this:

  Private Type MENUITEMINFO
    cbSize As Long
    fMask As Long
    fType As Long
    fState As Long
    wID As Long
    hSubMenu As Long
    hbmpChecked As Long
    hbmpUnchecked As Long
    dwItemData As Long
    dwTypeData As String
    cch As Long
    hbmpItem As Variant
  End Type

and this:

    With oMenuItemInfo4
            .cbSize = Len(oMenuItemInfo4)
            .fMask = MIIM_FTYPE
            .fType = MFT_SEPARATOR
    End With
    
    Dim ff As Variant, fg As Variant
    ff = InsertMenuItemA(menu_hwnd, 0, True, oMenuItemInfo4)
    fg = Err.LastDllError

but menu didn't created and it return error 87 - invalid parameter As I understand there is error in type definition, but I cannot find where is it..

Upvotes: 0

Views: 125

Answers (1)

IIyx
IIyx

Reputation: 11

Found it! Should change the MENUITEMINFO declaration:

Private Type MENUITEMINFOA
    cbSize As Long
    fMask As Long
    fType As Long
    fState As Long
    wID As Long
    hSubMenu As LongPtr
    hbmpChecked As LongPtr
    hbmpUnchecked As LongPtr
    dwItemData As LongPtr
    dwTypeData As String
    cch As Long
    hbmpItem As LongPtr
End Type

Upvotes: 1

Related Questions