Solved

How to Create Popup Menus during Runtime

Posted on 1998-10-26
5
246 Views
Last Modified: 2010-04-30
Does anyone know if it's possible to create Popup menus during Runtime, if the form doesn't have any popup menus at all. and doesn't have a Title.
the form is actually round
  Theos
0
Comment
Question by:JavaJester
5 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1441652
Yes, it is possible, but you must have at least one menu already defined.

Create a top level menu called mnuMenu.
Set it's visible property to false
Create a sub menu under this called mnuSub
Set it's index = 0
set it's visible property = false

in your form load, you can add menu items like this:
Private Sub Load()
  Load mnuSub(1)
  mnuSub(1).Caption = "Sub 1"
  mnuSub(1).Visible = True
  Load mnuSub(2)
  mnuSub(2).Caption = "Sub 2"
  mnuSub(2).Visible = True
End Sub

Then you can call the popup menu like this:
Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = 2 Then
    PopupMenu mnuMenu
  End If
End Sub
0
 
LVL 1

Author Comment

by:JavaJester
ID: 1441653
I Know that but i can't have any menus to begin with cause the form is not square...
and if you put a menu and make it invis it screws up the form shape that i need....
0
 
LVL 15

Accepted Solution

by:
ameba earned 300 total points
ID: 1441654
You can use menu from your other, invisible form (frmPops).

' Add this to your oval form - declarations section
Public menuselected as integer

menuselected = 0
PopupMenu frmPops.mnuMenu' show popup
Select Case menuselected
Case 0 ' nothing selected
    ' do nothing
    msgbox "nothing selected"
Case 1 ' first submenu selected
    ' do something useful
    msgbox "first submenu"
Case 2 ' second submenu selected
    ' do something useful
    msgbox "second submenu"
End Select

in you popup menu_click events use:
frmOval.menuselected=1 ' for first submenu
frmOval.menuselected=2 ...
Move your other code from menu click event to select case code portion in your frmOval.

Don't forget to unload frmPops in Form_unload event of frmOval.
0
 
LVL 15

Expert Comment

by:ameba
ID: 1441655
The code for oval form can be used in MouseUp event of a blue label. If you need clarification, let me know.
0
 
LVL 14

Expert Comment

by:waty
ID: 1441656
On the VBDiamond Website (see my profile), you will find code to create completelly dynamically popup menu at runtime.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question