PopMenu
[syntax="ls"]Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type POINTAPI
x As Long
y As Long
End Type
Type MSG
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Declare Function CreatePopupMenu Lib "user32" Alias "CreatePopupMenu" () As Long
Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (Byval hMenu As Long, Byval wFlags As Long, Byval wIDNewItem As Integer, Byval lpNewItem As Any) As Long
Declare Function TrackPopupMenu Lib "user32" Alias "TrackPopupMenu" (Byval hMenu As Long, Byval wFlags As Long, Byval x As Long, Byval y As Long, Byval nReserved As Long, Byval hwnd As Long, lprc As Rect) As Long
Declare Function DestroyMenu Lib "user32" Alias "DestroyMenu" (Byval hMenu As Long) As Long
Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As MSG, Byval hwnd As Long, Byval wMsgFilterMin As Long, Byval wMsgFilterMax As Long) As Long
Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Long
Function PopMenu (pstrItem As String, mx As Long, my As Long) As Long
Const MF_ENABLED = &H0
Const TPM_LEFTALIGN = &H0
Const MF_SEPARATOR = &H800
Const SEP = ";"
Dim msgdata As MSG
Dim rectdata As RECT
Dim Cursor As POINTAPI
Redim strItem(1 To 20) As String
Dim i As Long
Dim j As Long
Dim last As Long
Dim hMenu As Long
Dim id As Integer
Dim junk As Long
If Right$(pstrItem, 1) <> SEP Then pstrItem = pstrItem + SEP
j = 1
Do
i = Instr(j, pstrItem, SEP)
If i Then
last = last + 1
strItem(last) = Mid$(pstrItem, j, i - j)
j = i + 1
End If
Loop Until i = 0
hMenu = CreatePopupMenu()
id = 1
For i = 1 To last
If strItem(i) <> "-" Then
junk = AppendMenu(hMenu, MF_ENABLED, id, strItem(i))
id = id + 1
Else
junk = AppendMenu(hMenu, MF_SEPARATOR, 0, "")
End If
Next
If mx = 0 And my = 0 Then
Call GetCursorPos(Cursor)
mx = Cursor.x
my = Cursor.y
End If
junk = TrackPopupMenu(hMenu, TPM_LEFTALIGN, mx, my, 0, GetActiveWindow(), rectdata)
junk = GetMessage(msgdata, GetActiveWindow(), 0, 0)
i = Abs(msgdata.wparam)
If msgdata.message = 273 Then
PopMenu = i
End If
Call DestroyMenu(hMenu)
End Function[/syntax]
[syntax="ls"]Sub Click(Source As Button)
Dim sess As New NotesSession
Dim ws As New NotesUIWorkspace
Select Case PopMenu("Memo;Répondre;Répondre avec historique",0,0)
Case 1
Call ws.ComposeDocument(sess.CurrentDatabase.Server, sess.CurrentDatabase.FilePath , "Memo",)
Case 2
Call ws.ComposeDocument(sess.CurrentDatabase.Server, sess.CurrentDatabase.FilePath , "Répondre",)
Case 3
Call ws.ComposeDocument(sess.CurrentDatabase.Server, sess.CurrentDatabase.FilePath , "Répondre avec historique")
End Select
End Sub[/syntax]Utilisation :
PopMenu( TexteMenu , position X , position Y) as Long
Elements :
TexteMenu
Chaîne de caractère. Séparateur de menu ";". Ligne de séparation "-". Raccourci "&".
ex. "&Memo;&Répondre;Répondre avec historique;-;Fermer la base"
position X
Coordonnées X
y position
Coordonnées Y.
Valeur retournée
Le long correspond à la sélection de l'utilisateur. Si aucun élément sélectionner la fonction retourne 0.
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type POINTAPI
x As Long
y As Long
End Type
Type MSG
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Declare Function CreatePopupMenu Lib "user32" Alias "CreatePopupMenu" () As Long
Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (Byval hMenu As Long, Byval wFlags As Long, Byval wIDNewItem As Integer, Byval lpNewItem As Any) As Long
Declare Function TrackPopupMenu Lib "user32" Alias "TrackPopupMenu" (Byval hMenu As Long, Byval wFlags As Long, Byval x As Long, Byval y As Long, Byval nReserved As Long, Byval hwnd As Long, lprc As Rect) As Long
Declare Function DestroyMenu Lib "user32" Alias "DestroyMenu" (Byval hMenu As Long) As Long
Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As MSG, Byval hwnd As Long, Byval wMsgFilterMin As Long, Byval wMsgFilterMax As Long) As Long
Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Long
Function PopMenu (pstrItem As String, mx As Long, my As Long) As Long
Const MF_ENABLED = &H0
Const TPM_LEFTALIGN = &H0
Const MF_SEPARATOR = &H800
Const SEP = ";"
Dim msgdata As MSG
Dim rectdata As RECT
Dim Cursor As POINTAPI
Redim strItem(1 To 20) As String
Dim i As Long
Dim j As Long
Dim last As Long
Dim hMenu As Long
Dim id As Integer
Dim junk As Long
If Right$(pstrItem, 1) <> SEP Then pstrItem = pstrItem + SEP
j = 1
Do
i = Instr(j, pstrItem, SEP)
If i Then
last = last + 1
strItem(last) = Mid$(pstrItem, j, i - j)
j = i + 1
End If
Loop Until i = 0
hMenu = CreatePopupMenu()
id = 1
For i = 1 To last
If strItem(i) <> "-" Then
junk = AppendMenu(hMenu, MF_ENABLED, id, strItem(i))
id = id + 1
Else
junk = AppendMenu(hMenu, MF_SEPARATOR, 0, "")
End If
Next
If mx = 0 And my = 0 Then
Call GetCursorPos(Cursor)
mx = Cursor.x
my = Cursor.y
End If
junk = TrackPopupMenu(hMenu, TPM_LEFTALIGN, mx, my, 0, GetActiveWindow(), rectdata)
junk = GetMessage(msgdata, GetActiveWindow(), 0, 0)
i = Abs(msgdata.wparam)
If msgdata.message = 273 Then
PopMenu = i
End If
Call DestroyMenu(hMenu)
End Function[/syntax]
[syntax="ls"]Sub Click(Source As Button)
Dim sess As New NotesSession
Dim ws As New NotesUIWorkspace
Select Case PopMenu("Memo;Répondre;Répondre avec historique",0,0)
Case 1
Call ws.ComposeDocument(sess.CurrentDatabase.Server, sess.CurrentDatabase.FilePath , "Memo",)
Case 2
Call ws.ComposeDocument(sess.CurrentDatabase.Server, sess.CurrentDatabase.FilePath , "Répondre",)
Case 3
Call ws.ComposeDocument(sess.CurrentDatabase.Server, sess.CurrentDatabase.FilePath , "Répondre avec historique")
End Select
End Sub[/syntax]Utilisation :
PopMenu( TexteMenu , position X , position Y) as Long
Elements :
TexteMenu
Chaîne de caractère. Séparateur de menu ";". Ligne de séparation "-". Raccourci "&".
ex. "&Memo;&Répondre;Répondre avec historique;-;Fermer la base"
position X
Coordonnées X
y position
Coordonnées Y.
Valeur retournée
Le long correspond à la sélection de l'utilisateur. Si aucun élément sélectionner la fonction retourne 0.