?
Solved

VBA Popup menu???

Posted on 2002-04-11
20
Medium Priority
?
1,133 Views
Last Modified: 2012-05-05
I am using VBA and need to be able to right-click on a form and popup a menu of options. In VB they have the menu editor; however I don't see this in VBA. From what I read, it appears it has to be done programmatically through VBA. If someone knows of how to do this this way or another would you please send me sample code of how to do it? For the record: I'm using VBA inside Esri ArcView 8.1.2 ArcMap. Thanks,

Wayne
0
Comment
Question by:guidway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
20 Comments
 
LVL 20

Expert Comment

by:hes
ID: 6934571
0
 
LVL 12

Author Comment

by:guidway
ID: 6934583
thanks for trying, but I just tested it and I don't have the same objects and libraries they do because that is Word and this is ArcMap. VBA is implemented very differently in both. Thanks anyway,

guidway
0
 
LVL 4

Expert Comment

by:RichW
ID: 6934660
http://www.planet-source-code.com/xq/ASP/txtCodeId.14792/lngWId.1/qx/vb/scripts/ShowCode.htm

This zip file has two class module and a regular bas module and a form.  You can use them in VBA.

The module has examples of how to use.

I used this in Excel 97 and VB 6.
RichW
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6934879
0
 
LVL 12

Author Comment

by:guidway
ID: 6935134
Hey fellows,

Thanks for the responses, both of your code work excellent up to a certain point. Now here is my next question (maybe it is already in the code and I'm overlooking it or something.) How would I detect if one of the menu items was checked? Here is what I want to do. Maybe ya'll can give me some more help. I want to right click on a VBA form and pop up a menu that has one value: a checkbox with the phrase "Always on top" that allows the user (when clicked with a check) to make the form stay on top at all times. Else it will be as a normal window. (Same as the Windows NT Task Manager window when you right click on it). Can you show me with one of your code selections (either one) how to do this? Thanks,

guidway
0
 
LVL 12

Author Comment

by:guidway
ID: 6935138
Correction: Same as the Windows NT Task Manager Icon in the taskbar when you right click on it. Sorry,

guidway
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6935287
What do you mean by both?
0
 
LVL 12

Author Comment

by:guidway
ID: 6936624
Meaning that your code and RichW worked as far as showing a menu bar but I don't see how to programmatically check to see if it is checked or unchecked so I can place the window on top or as a normal window. Any clearer now?

guidway
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6936803
I got you!
but... that was not part of primary question :D
I will do a try, anyway...
0
 
LVL 12

Author Comment

by:guidway
ID: 6936855
Richie_Simonetti,

Thanks! You are right about that not being in the primary question. I should have put it. Since it wasn't though (which was my fault) I'm not going to cheat you or RichW out of the points. I'll split it between ya'll even if no one figures out the next thing I asked. I was just wandering if someone knew how to do what I wanted. I can post it as another question if ya'll would like. As long as I get the answer I don't care. ;-) Thanks again,

guidway
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6937521
well, at this very moment i can only start the menu checked/not checked and i cannot toggle it but i am trying...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6937532
Well, to module add a boolean variable:
public FlagChecked as boolean and set it default to false (Just for sure)

In the click event, change the code where you set mii.fState with this

' This item is currently enabled and is the default item.
        If FlagChecked = False Then
            .fState = MFS_ENABLED Or MFS_DEFAULT
            FlagChecked = True
        Else
            .fState = MFS_ENABLED Or MFS_DEFAULT Or M_CHECKED
            FlagChecked = False
        End If

cheers
0
 
LVL 12

Author Comment

by:guidway
ID: 6937534
Thanks, I appreciate you trying. I have been playing with it too for most of today, but not really getting anywhere with it. thanks again,

guidway
0
 
LVL 12

Author Comment

by:guidway
ID: 6937543
I'm trying your code now...

guidway
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 300 total points
ID: 6937600
Sorry, sorry very sorry. It has a little bug:

Change that code to THIS one:
' This item is currently enabled and is the default item.
        If FlagChecked = False Then
            .fState = MFS_ENABLED Or MFS_DEFAULT
        Else
            .fState = MFS_ENABLED Or MFS_DEFAULT Or M_CHECKED
        End If

and in the windowproc fucntion,add the following:
......
......
......
Case ID_ABOUT
            ' Use the VB MsgBox function to display a short message in a dialog
            ' box.  Using the API isn't necessary.
            retval = MsgBox("This example demonstrates how to use the API to " & _
                "display a pop-up menu.", vbOKOnly Or vbInformation, _
                "Windows API Guide")
               FlagChecked = Not FlagChecked    ' this is new code
....
....
....
0
 
LVL 12

Author Comment

by:guidway
ID: 6937652
Excellent! That did it. Thanks. It works very well. Here is what I will do. For Richie_Simonetti I'm giving 75 points total for helping me with this last part and since RichW's code did work (for the question I originally asked anyway) I'm giving you 50 points. RichW, The link to collect your points will be sent on the next comment.

Thanks again for everything!

guidway
0
 
LVL 12

Author Comment

by:guidway
ID: 6937661
RichW,

Here is the link to your points:

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=visualbasic&qid=20288187

Thanks again,

guidway
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6937688
Thanks for "A" grade!
Then, i can think that it works, can i?
0
 
LVL 12

Author Comment

by:guidway
ID: 6937695
It works for me. :-D
guidway
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6992226
Cool!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Suggested Courses

765 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