Need expert help

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
 
D

Dennis

Just as an FYI, you can change all the visual attributes of ANY control in
Access, including listboxes. You can make them look however you wish via the
Properties dialog.
 
M

Mark Andrews

Still looking for any advice on my original question. Where's Steven Leban
when you need him, this question seems right up his
alley (at least the "Anyway to get regular "out of the box" popup menus to
popup via code?" portion).

I wish the Access listbox was fexible enough for me to make it look and
behave any way I wish!!!
I got spoiled using VB6 and C# in .NET and now I'm back to doing more Access
(which has pros and cons).

Mark



Dennis said:
Just as an FYI, you can change all the visual attributes of ANY control in
Access, including listboxes. You can make them look however you wish via
the
Properties dialog.

Mark Andrews said:
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
 
T

Tony Toews [MVP]

Mark Andrews said:
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.

Note: the activex control is a calendar control

Why not use a calendar form instead? Also saves on the distribution
troubles.

See the Calendar Tips page at my website
http://www.granite.ab.ca/access/calendars.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top