Solved

How to Create Popup Menus during Runtime

Posted on 1998-10-26
5
241 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
On the VBDiamond Website (see my profile), you will find code to create completelly dynamically popup menu at runtime.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now