Solved

How to Create Popup Menus during Runtime

Posted on 1998-10-26
5
245 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

831 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