VBA Popup menu???

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
LVL 12
guidwayAsked:
Who is Participating?
 
Richie_SimonettiConnect With a Mentor IT OperationsCommented:
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
 
guidwayAuthor Commented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
RichWCommented:
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
 
Richie_SimonettiIT OperationsCommented:
0
 
guidwayAuthor Commented:
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
 
guidwayAuthor Commented:
Correction: Same as the Windows NT Task Manager Icon in the taskbar when you right click on it. Sorry,

guidway
0
 
Richie_SimonettiIT OperationsCommented:
What do you mean by both?
0
 
guidwayAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
I got you!
but... that was not part of primary question :D
I will do a try, anyway...
0
 
guidwayAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
well, at this very moment i can only start the menu checked/not checked and i cannot toggle it but i am trying...
0
 
Richie_SimonettiIT OperationsCommented:
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
 
guidwayAuthor Commented:
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
 
guidwayAuthor Commented:
I'm trying your code now...

guidway
0
 
guidwayAuthor Commented:
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
 
guidwayAuthor Commented:
RichW,

Here is the link to your points:

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

Thanks again,

guidway
0
 
Richie_SimonettiIT OperationsCommented:
Thanks for "A" grade!
Then, i can think that it works, can i?
0
 
guidwayAuthor Commented:
It works for me. :-D
guidway
0
 
Richie_SimonettiIT OperationsCommented:
Cool!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.