M
Mark Andrews
I have a Access 2000 form that I want to use a popup menu to display certain
choices. I created the popup menu and it works fine except
for when the mouse is positioned over an ActiveX control.
My goal is really to get the right click popup context menu to work with the
activeX control.
I found some code to simulate a popup menu (see below) which works but since
it uses a form with a listbox you get the look and feel of an Access
listbox.
I would like the popup menu to look like a regular popup menu with the blue
shading, optional images and highlighting as you pick choices.
Note: the activex control is a calendar control and it has an event:
Private Sub CalendarControl_ContextMenu(ByVal x As Long, ByVal y As Long)
that is fired when the user right clicks on an event in the calendar
So my question is:
- Anyway to get regular "out of the box" popup menus to popup via code?
or
- Any other approaches that might work
or
- Anyone know of a good third party listbox control that would allow for
better formatting that the "out of the box" listbox
Thanks in advance,
Mark
----------------------------------------
Option Compare Database
Option Explicit
' NOTE: Some of the following Windows API functions may be
' defined in an existing Microsoft Access library. If so, the new
' declarations would cause a duplication procedure name error. If
' this error occurs, remove the offending declare statement from
' your code or convert the declaration to a comment.
Type POINTAPI
x As Long
y As Long
End Type
Global Const GWL_STYLE = (-16)
Global Const WS_DLGFRAME = &H400000
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) _
As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong _
As Long) As Long
Public Sub ShowPopup()
Dim coord As POINTAPI
Dim attr&
GetCursorPos coord
DoCmd.OpenForm "frmPopupMenu"
attr& = GetWindowLong(Forms![frmPopupMenu].hwnd, GWL_STYLE)
attr& = SetWindowLong(Forms![frmPopupMenu].hwnd, GWL_STYLE, _
attr& And Not WS_DLGFRAME)
DoCmd.MoveSize (coord.x * 14), (coord.y * 14), , 1100
End Sub
Public Function PopupItemSelected(WhichItem As String)
DoCmd.Close
MsgBox "The selected item was " & Trim(WhichItem)
End Function
choices. I created the popup menu and it works fine except
for when the mouse is positioned over an ActiveX control.
My goal is really to get the right click popup context menu to work with the
activeX control.
I found some code to simulate a popup menu (see below) which works but since
it uses a form with a listbox you get the look and feel of an Access
listbox.
I would like the popup menu to look like a regular popup menu with the blue
shading, optional images and highlighting as you pick choices.
Note: the activex control is a calendar control and it has an event:
Private Sub CalendarControl_ContextMenu(ByVal x As Long, ByVal y As Long)
that is fired when the user right clicks on an event in the calendar
So my question is:
- Anyway to get regular "out of the box" popup menus to popup via code?
or
- Any other approaches that might work
or
- Anyone know of a good third party listbox control that would allow for
better formatting that the "out of the box" listbox
Thanks in advance,
Mark
----------------------------------------
Option Compare Database
Option Explicit
' NOTE: Some of the following Windows API functions may be
' defined in an existing Microsoft Access library. If so, the new
' declarations would cause a duplication procedure name error. If
' this error occurs, remove the offending declare statement from
' your code or convert the declaration to a comment.
Type POINTAPI
x As Long
y As Long
End Type
Global Const GWL_STYLE = (-16)
Global Const WS_DLGFRAME = &H400000
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) _
As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong _
As Long) As Long
Public Sub ShowPopup()
Dim coord As POINTAPI
Dim attr&
GetCursorPos coord
DoCmd.OpenForm "frmPopupMenu"
attr& = GetWindowLong(Forms![frmPopupMenu].hwnd, GWL_STYLE)
attr& = SetWindowLong(Forms![frmPopupMenu].hwnd, GWL_STYLE, _
attr& And Not WS_DLGFRAME)
DoCmd.MoveSize (coord.x * 14), (coord.y * 14), , 1100
End Sub
Public Function PopupItemSelected(WhichItem As String)
DoCmd.Close
MsgBox "The selected item was " & Trim(WhichItem)
End Function