Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ContextMenu in VFP 9 SP

Status
Not open for further replies.

ameedoo3000

IS-IT--Management
Sep 20, 2016
233
EG
hi all
Is it possible to do ContextMenu in Visual Fox Pro v9 SP2 ?
If possible, what is the appropriate version?
Because the version that I have running on FVP v7 though windows XP.
 
A context menu is a shortcut menu, so you already know how to do that, you showed a screenshot of your context menu in your own thread184-1776138
That even is a two level context menu.

So maybe it's just the name "context" menu, that's new to you. The name is a Windows term, in VFP terminology it's a POPUP menu with the SHORTCUT option, means it appears on mouse right click at mouse position. The term context determines, that it should offer menu items, that are useful in the context of the clicked item/control/form, which your context menu does.

Another reason to not name it shortcut in Windows terminology also is perhaps, because in Windows a shortcut is the term for a lnk file, a shortcut icon on the desktop, to start up something.

Shortcut or context menus are done the same way in VFP7 and VFP9 and also didn't change from XP to Win10.

Bye, Olaf.


 
I just remembered some very very old code that I wrote more than a decade ago to generate context menues.
There were 3 Functions: makepopup, add2popup and showpopup

Code:
FUNCTION makepopup
LPARAMETERS lirow, licol
LOCAL ARRAY laMaus(1)
	IF VARTYPE(lirow) = [N] AND VARTYPE(licol) = [N] ;
	AND CAST(lirow AS INTEGER) > 0 AND CAST(licol AS INTEGER) > 0
		DEFINE POPUP Pop1 shortcut relative from INT(lirow / FONTMETRIC(1)), INT(licol / FONTMETRIC(6))
	ELSE
		DEFINE POPUP Pop1 shortcut relative from mrow(), mcol()
	ENDIF
	PUBLIC PopupMenueSelection
ENDFUNC 
FUNCTION add2popup
LPARAMETERS vPrompt, vValue, vMessage, vPicture, vKey
	vKey		= EVL( vKey , [] )
	vPicture	= EVL( vPicture , [] )
	DO CASE 
	CASE EMPTY( vKey ) AND EMPTY( vPicture )
		DEFINE BAR (vValue) OF Pop1 PROMPT vPrompt MESSAGE vPrompt
	CASE EMPTY( vKey ) AND NOT EMPTY( vPicture )
		DEFINE BAR (vValue) OF Pop1 PROMPT vPrompt MESSAGE vPrompt PICTURE vPicture
	CASE NOT EMPTY( vKey ) AND EMPTY( vPicture )
		DEFINE BAR (vValue) OF Pop1 PROMPT vPrompt MESSAGE vPrompt KEY vKey
	CASE NOT EMPTY( vKey ) AND NOT EMPTY( vPicture )
		DEFINE BAR (vValue) OF Pop1 PROMPT vPrompt MESSAGE vPrompt KEY vKey PICTURE vPicture
	ENDCASE 
ENDFUNC 
FUNCTION showpopup
	ON SELECTION popup pop1 PopupMenueSelection = BAR()
	ACTIVATE POPUP Pop1
	RELEASE POPUP Pop1 extended 
ENDFUNC

These three functions could be used like this:

Code:
MakePopup()
Add2Popup([\<1 Item Number One],  1,[-])
Add2Popup([\<2 Item Number Two],  2,[-])
Add2Popup([\-],                  98,[-])
Add2Popup([\<0 close menue],     99,[-])
ShowPopup()
IF VARTYPE(PopUpMenueSelection) = [N]
	DO CASE
	CASE PopUpMenueSelection = 1
		* Call a method that shall be activated via Item One
	CASE PopUpMenueSelection = 2
		* Call a method that shall be activated via Item Two
	ENDCASE 
ENDIF

The generated popup menue looks like this:
popupmenue_demo_a6yfhp.png


I haven't used this code for a long time, but it should still run fine.
Meanwhile my popup menues are generated by a class and are much more flexible. But the above code should run with older VFP versions, too.



-Tom
 
Another way of producing a context menu is to use VFP's menu designer:

1. Type CREATE MENU in the command window.

2. Select "Shortcut".

3. Use the interactive design tool to create your menu.

3. Save the menu.

4. From the (delightfully named) Menu menu, select Generate Menu.

But I suspect that neither the above steps nor the code that Tom posted directly answers the question. I think Olaf is right in thinking that the questioner didn't realise that a context menu is the same as a shortcut menu. We know that he already knows how to create a shortcut menu.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
contextmenu is meant to be a handy wizard in creating menus, aesthetically more than usual and more than usual. But this processor is only used on Fox Pro 7 and on Windows XP only. So I'm asking if there is a copy of it running on Windows 10 and on Fox Pro 9 it would be better.
1_ma7paf.png

2_l5yfr8.png
3_jvq2fa.png

 
What you are talking about is an activeX control, so why do you think, it only runs on VFP7 and WindowsXP? Did you test it already?
activeX doesn't rely on your VFP version and usually also not on the Windows version.
OTOH, this is an activeX provided by Anatoliy Mogylevets (=news2news.com), so you could ask him directly?

On fox.wikis.com there is a link to a demo version of this activeX, so (if the link isn't broken) just download the demo and give it a try.
-> Context Menu ActiveX Control

Or are you looking for a free tool like this activex that has to be bought from news2news? There is a OOP based menu available of vfpx.codeplex.com ups sorry, not anymore. VFPX switches to github so it is availlable here: VFP OOP menu



-Tom
 
i have download "Context Menu ActiveX Control" and i didnot know how to use it in VFP 9.0 SP2.
 
After a download you install. Read the _readme1st.txt

Two additional hints in rgeard of Win10:

a) the correct version of regsvr32 for 32bit is in SysWow64, not in System32.
b) You better run anything needing elevation - as regsvr32 does - from the command prompt (Admin):

650x249xWindows_01.jpg

Right click on the Windows Icon/Start menu, then you get there.

Bye, Olaf.
 
How on earth should Tom know where you have your full version?

If you have a PC with a fully licensed version of the ContextMenuLib.dll, then take that from there.

If you paid for a software download, it's not the responsibility of a forum to tell you where you got that from and where you find your license, is it?

Bye, Olaf.
 
Well, and without your anger, all I want is to try to attach a picture to each item of the menu, as in Contextmenu, and also act as a separator between items. In this case I do not use additional external software for Fox Pro, but I'm trying to use the possibilities of Fox Pro.
Is this possible or beyond the Possibilities of Fox Pro?

Nothing in the whole life worthy of emotion or anger. Life is expensive, age is limited, and loss of time is lost in anything other than happiness, even a fraction of a second.
 
I have been using Anatoliy Mogylevets' Context Menu ActiveX control since 2012. It is a great product. Cheap too, like 20-30 bucks. Before that, I spent a lot of time researching context menus - VFP solutions and other 3rd party solutions. This was and, in my opinion, is the best solution.

Once you learn how to use it (based on XML), you can then customize it to fit your needs. It works fine on Windows 7 and 10.


 
It is unclear exactly what you are trying to achieve, and what question you are asking.

You started by saying you wanted to create a context menu. We explained that a context menu is the same as a shortcut menu which you already know how to create.

It was only later that you mentioned that you were using a particular ActiveX control. We then gave you some advice for using that control. But then you went on to say that you were using a demo version of the control, which we had no way of knowing previously.

Now you say:

... all I want is to try to attach a picture to each item of the menu, as in Contextmenu, and also act as a separator between items.

Well, you can do that in a native VFP menu. Again, it is evident that you already know how to do this.

Finally, I don't know why you thought there was any anger in Olaf's reply to your comment about the demo version. He gave you useful information in a perfectly reasonable tone of voice.

We really do want to help you, but we can only do so if you tell us clearly and unambiguously what you need to know.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
This is not about anger, amedoo, if so, rather your own. All I say is you should be better organized and manage your owned items, including software.
If you have the full version of this DLL on a XP machine, the download of the full version including license key most probably should be somewhere, so just be better organized.

I just used the demo and it's nice, okay, it is just one thing to customize this with some themes, which will not help make the whole application in that look, but if you already are at that stage, nothing else will help you better, then geting it back. If you - or the employees buying that software componnent years ago - are too unorganised, then the price to pay is buying another full version of it.

I'm not angry, I'm also not picking on you, I just point you to the facts and straighten any understandings you have.

Fair enough, isn't it?

Remember you were the one pointing out "but this version is demo only!". Tom gave you a link to the fox wiki article about this, which has a link to the ContextMenuCtl_Demo.zip, so surely he was already very aware to "only" point you to a demo of the component you search. You are so unthankful for this, that it really hurts my understanding of politeness. At least now you know what to look for on the XP machine, you need to look for the ContextMenuLib.dll you have there, which doesn't display what's called a "nag screen". In itself it's a totally fair way to give anybody a fully functional version to evaluate the software and see and decide, whether it works and gives you, what you want and still be paid for your commercial usage of it. Again and clearly said my understanding is it's a componenent you are used to, you seem so used to it, that you think it is a VFP7 or XP component, no it's not, it's something third party to both VFP and Windows. If you know and vlaue it and are used to it and your projects depend on it, you should better know where your license of it is. I pointed out the _readme1st.txt within the zip and that has the contact to Anatoliy Mogylevets via email. Contact him to ask for how to (re)buy this.

Overall this seems to me about a different understanding of fairness and politeness in different western, eastern, southern or northern cultures. But you could do much more than come back and complain this only is the demo. You're not writing it out, but the exclamation point (!) state to me, that you are saying "how dare you, Tom, to only tell me where to get a demo!". This is rude.

Bye, Olaf.
 
OK . Anyway,I know what I'm looking for.
1 - canceled the idea of using the contextmenu and turned to use the features of menus in the Fox Pro.
2 - I am trying to find out if it is possible to insert an image or icon next to each menu item or not.
3 - I try to figure out if a possible make separator between each set of items or not.
many thanks for all.

Bye,Ahmed.
 
I am trying to find out if it is possible to insert an image or icon next to each menu item or not.

Yes, this is possible. You use the PICTURE clause of the DEFINE BAR command. For example:

[tt]DEFINE BAR MyMenuBar PROMPT "Do something" PICTURE MyPic.bmp[/tt]

If you are using the menu designer, click the Option button to the right of the bar name. In the resulting dialogue, under Picture, select File, and specify the image's filename.

I try to figure out if a possible make separator between each set of items or not.

Again, this is possible. Just create a new bar, and put \- as the prompt (that's a backslash followed by a hyphen).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, if you want to skip the ContextMenuLib.dll and redo things in a similar fashion, a better starting piont than using the native commands and designers is using the VFPX OOP Menu Tom also pointed you too, already. This is adding some classes around VFPs menu capabilities, making it better, more "discoverable" than the native commands and making some aspects of usual functionalities easier. See the described project goals...

Bye, Olaf.

 
yes.very very good and nice.
Your answer has achieved many of my goals and opened the doors of hope and optimism.
I thought the possibilities of Fox Pro were limited or poor. But it turned out to be the exact opposite.
Thank you very much, my dear Mike and dear Olaf. I am really helpless to thank you. and Your thanks are not enough.

Bye,Ahmed
 
Glad to hear you've got a solution at last, Ahmed.

FoxPro really does have a lot of possibilities. In fact, it is unusual to find anything that can be done in other programming languages that cannot be done in VFP. It's just a question of discovering how to do so. I admit that can be challenging.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top