masoud_sedighy
Registered User.
- Local time
- Today, 11:18
- Joined
- Dec 10, 2011
- Messages
- 132
In the main form I have a list box, when I right click on each item on list box another form "frmshortcut" (pop up) will be open in the position of mouse that shows a list box for selecting items according to below code, now I would like when select another place (except "frmshortcut"), this form automatically will be close, like what we have in shortcut list of windows.
Now when right click it is opened in the location of mouse click, but problem is, it is not closed automatically when click in other places of main form.
Option Explicit
[FONT="][/FONT]
Private Type POINTAPI
x As Long
y As Long
End Type
[FONT="][/FONT]
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private mp As [*clsMousePosition]
[FONT="] [/FONT]
Private Sub ItemList_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Const RIGHTBUTTON = 2
Dim udtPos As POINTAPI
Dim frm As Access.Form
[FONT="][/FONT]
If Button = RIGHTBUTTON Then
[FONT="][/FONT]
Set mp = New [*clsMousePosition]
GetCursorPos udtPos
[FONT="][/FONT]
[FONT="][/FONT]
DoCmd.OpenForm "frmshortcut"
DoCmd.MoveSize udtPos.x * mp.TwipsPerPixelX, udtPos.y * mp.TwipsPerPixelY
[FONT="][/FONT]
[FONT="][/FONT]
End If
[FONT="][/FONT]
End Sub