on 07-29-2009 11:14 AM
Hi, is it possible to show an own context menu (like the right-click-menu) after clicking on a button in a Form?
Regards Philipp
Hmmmm. What about the following:
1) Write your own 'generic' form to represent a set of commands (in a matrix, for example).
2) Create a wrapper class for this form that will be able to show this form with a specified set of actions and handle events of the form.
3) Every time the button is pressed:
a) Disable event handling of the main form (because the context menu must be 'modal' in respect to the form from which it has been invoked)
b) Use the above class to Show the menu and handle the user choice.
Of course, this class should treat event-handling code in a generic way. Using delegates, for example, so you can write custom handlers for every option in your context menu and initialize with them every instance of your class. Such handlers might accept the main form and the user choice as parameters.
Anton
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I thought about firing the event when i handle the click event.
if (pVal.ItemUID == "cmdButton" && pVal.EventType == SAPbouiCOM.BoEventTypes.et_CLICK)
{
if ((pVal.BeforeAction == true))
{
oForm = SBO_Application.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount);
try{
SAPbouiCOM.ContextMenuInfo cn = new SAPbouiCOM.ContextMenuInfo();
Test(ref cn, out BubbleEvent);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
but then i have the problem with the ContextMenuInfo object. how can i generate that? the line with the new contextmenuinfo generates an error!
Yes, this solution is quite laborous to implement, but then you'll have a generic, reusable class... Write once, use everywhere.
but then i have the problem with the ContextMenuInfo object. how can i generate that? the line with the new contextmenuinfo generates an error!
I don't know. Some objects just won't work this way, 'cause such usage is not intended. It sounds like hacking, interfering with the event-handling mechanism by "faking" events. I think UI Api has been protected from such 'unsafe' usage.
Anton
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.