Chriss said:
I'm sure there is some much simpler way to have the UI you want.
I agree. My preference would be to use the built-in shortcuts (CTRL+C, etc.) as per my previous post. That way, you give the user the interface that they are already familiar with. And you can easily make it generic, so that it works the same with all your editable controls, with no extra effort on your part.
In summary, here is what I suggest:
1. Create a new shortcut menu. For example, from the Project Manger, select Other -> Menus -> New.
2. When prompted, choose Shortcut rather than Menu.
3. In the menu designer, click on the first row under "Prompt", then click on Insert Bar.
4. In the next dialogue, choose Copy.
5. Go to the next row. Repeat the above, but this time choose Cut.
6. Repeat, choosing Paste.
7. Repeat for any other items you would like to have in the menu.
8. From the main VFP menu bar, choose Menu -> Generate.
9. When prompted, save the menu. Name it, say, EditMenu.
10. Confirm that you want to generate the menu. It will be named, for example, EditMenu.MPR.
11. Open your form in the form designer. In the right-click event of your text box, write this code: [tt]DO EditMenu.MPR[/tt] (or whatever you named it; if the MPR file is not in the search path, precede its name with its path).
12. Now, when you run the form, the user will be able to right-click on the textbox and choose to cut, copy, paste, etc. Better still, they will also be able to use the standard shortcut keys (CTRL+C, etc.) without having to right-click.
13. Ideally, the final step will be to place the code (as per Step 11, above) in the right-click event of your base textbox class. That way,
every textbox in your application will inherit the behaviour.
Although this means more steps than your existing method, I think you will agree that the result will be a better UI, and more in line with what the user expects from Windows applications.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads