hello,
i would to create a menu when my application start. in the form load in fact...
i already use the AppendMenu api and some other... that create the menu but then ? how do i tell my application to know wich item has been selected in the created menu ?
my code :
in a module :
Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Public 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
Public Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Const MF_BYPOSITION = &H400&
Public Const MF_STRING = &H0&
Public fstart As Boolean
Public Function InsertNewSubMenu(hForm As Long, idMenu As Long, lPos As Long, _
sMenuName As String, Optional PopUp As Boolean = False) As Boolean
Dim hMenu As Long
Dim hRet As Long
Dim hSubMenu As Long
Dim hPopUpMenu As Long
hMenu = GetMenu(hForm)
hSubMenu = GetSubMenu(hMenu, idMenu)
'hRet = InsertMenu(hSubMenu, lPos, MF_STRING Or MF_BYPOSITION, 0, sMenuName)
hRet = AppendMenu(hSubMenu, MF_STRING Or MF_BYPOSITION, 0, sMenuName)
If fstart = True Then
hRet = RemoveMenu(hSubMenu, 0, MF_BYPOSITION)
fstart = False
End If
DrawMenuBar hForm 'odwie¿enie menu
InsertNewSubMenu = hRet
End Function
in my form i made a menu like this :
file | links | ?
and i the form_load i have :
For i = 0 To UBound(tab_lnk)
InsertNewSubMenu hwnd, 1, i, tab_lnk(i)
Next i
this add several item in the links menu but then ?
how i tell my app to make something when i click on the first or fird item ?!
normally in the menu creator i have to put somtehing in the 'name' field and then in my form i put a :
private sub something_Click()
my code
end sub
weel... I think i'm not so far from the goal, please help