TheSwamp

Code Red => VB(A) => Topic started by: Keith™ on September 22, 2004, 11:48:10 PM

Title: (Challenge) Emulate right click menu in VBA
Post by: Keith™ on September 22, 2004, 11:48:10 PM
Ok, this is another little functionality that SHOULD have been included in VBA but for some reason MS saw fit to exclude it from the mix....

Your task ...
Emulate a popup menu for a right click event in a user form.

Rules are ....

Popup menu must NOT be simply another form
no API calls are allowed
Popup must appear when right click on form and disappear when clicking on an item in the popup menu or when clicking on the form.

It can be done....but how?
Title: (Challenge) Emulate right click menu in VBA
Post by: MP on September 23, 2004, 12:11:56 AM
You could trap the right mouse button up event and then move a control (that's current not visible) to the appropriate coords, set the visible property to true, hiding as appropriate per your latter event descriptions but who would want to do this? Why not just code up a dll that sports the kind of functionality you want instead of trying to duct tape a solution onto anemic vba? I'm all for stretching ones mind, but I just can't see myself wanting or needing to code a solution like this when there are tools available to do it so easily.

/scrooge.
Title: (Challenge) Emulate right click menu in VBA
Post by: Keith™ on September 23, 2004, 12:17:59 AM
Yeah ... be a scrooge ...
[sarcasm]
Ok...so tell me...what IS the API call in VBA for a popup menu?
[/sarcasm]
Title: (Challenge) Emulate right click menu in VBA
Post by: MP on September 23, 2004, 12:41:21 AM
Can't rightly tell you, I rarely use VBA. I would start by searching MSDN (http://search.microsoft.com/search/results.aspx?view=msdn&st=b&na=82&qu=vba+popup+menu&s=1&swc=4), like this link (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modcore/html/deovrgettinginformationaboutcommandbarscontrols.asp).

I use VB a reasonable amount, thus the dll suggestion. I tried VBA when AutoCAD first started to sport it and just went, "Yeck, why'd they make it so wimpy?"

I know, I know: So you'd buy VB if you wanted to do any serious programming. It is cheap compared to the wheel spinning time you spend jury rigging things onto VBA.

Your mileage may vary.

Good night folks. :)