Skip to Content
author's profile photo Former Member
Former Member

Menu only work once!

Hello All:

Have a UI add-on that have menu button that opens a user form... It works great first time you click it, and everything the buttons text combo...etc works fine. But when you click cancel ITEMUID = "2" The menu wouldn't pop up again. I try-catch the entire thing couldn't find where it failed. BTW, this is still in debug mode. I think the thing is dead, because it doesn't recognized any other events or action after it is closed. But I am not sure why!

I have my

        static void Main()
        {
            try
            {
                AutoSalesOrder oload = new AutoSalesOrder();

                System.Windows.Forms.Application.Run();
            }
            catch (Exception ex)
            {
                Global.oapplication.MessageBox(ex.Message.ToString(), 1, "OK", "", "");
            }
        }

// Event handling

                Global.oapplication.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(SBO_Application_MenuEvent);
                Global.oapplication.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(SBO_Application_AppEvent);
                Global.oapplication.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent);

Even put in these things to make sure I closed it properly...

                    case SAPbouiCOM.BoEventTypes.et_FORM_CLOSE:
                        BubbleEvent = true;
                        Global.oapplication.StatusBar.SetText("Form Closed", SAPbouiCOM.BoMessageTime.bmt_Short,
                            (SAPbouiCOM.BoStatusBarMessageType.smt_None));
                        break;
                    case SAPbouiCOM.BoEventTypes.et_CLICK:
                        if (pVal.ItemUID == "2" && pVal.BeforeAction == false)
                        {
                            BubbleEvent = false;
                            Global.oapplication.Forms.Item(FormUID).Close();
                        }
                        break;

Still not sure what's wrong with it..

Edited by: Bo Peng on May 16, 2008 2:40 AM

Edited by: Bo Peng on May 16, 2008 2:58 AM

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 02:29 AM

    Anyone??? It's kind of urgent situation!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 01:02 AM

    Appearantly there is a unhandled error

                            case SAPbouiCOM.BoEventTypes.et_CLICK:
                                if (pVal.ItemUID == "cancel" && pVal.BeforeAction == true)
                                {
                                    BubbleEvent = false;
                                    try
                                    {
                                        Global.oapplication.Forms.Item(FormUID).Close();
                                    }
                                    catch(Exception ex)
                                    {
    
                                    }
                                }
                                break;
    

    It says "invalid form" but I check the form.. it is still my form's UID. and form is still up there, as I am using beforeaction = true there. I even changed the button UID from "2" to "cancel"

    See the below attached picture... It's the evenlog I ran.. Before it try to close the form. it went and et_validate whole bunch of stuff.. and then when it time to close error pop up says FORM- invalid form..

    Can someone help?

    http://imageshack.us">[IMG]http://img341.imageshack.us/img341/9265/resultpicgj7.jpg[/IMG]>

    Edited by: Bo Peng on May 16, 2008 3:29 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 12:45 PM

    Hello Petr:

    I have no problem open the form, and do anything with the form! The problem only happens when I close the form!

    At the time I close the form, I still have valid FormUID. the statement before oform.close() I can still use oform to do something with the form! But as soon as it get to .close() it says invalid form...

    BTW, this is SBO2005A SDK..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 16, 2008 at 01:01 PM

    Found out what's wrong, and really really embarrased at this point!

    To get lazy, I put

                   if (FormUID == "Zautoso")
                    {
                          Global.oForm = Global.oapplication.Forms.Item("Zautoso");     ---->>
                        switch (pVal.EventType)
                        {
                            case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED:
                                if ((pVal.ItemUID == "runreport") & (pVal.BeforeAction == false))
                                {
                                .......
                                }
                        }
                      }
    

    on top of all the event swtichs and if / else if statement. Of course there are multiple itemevent go after this at the time of close. So first itemevent look at that statement and can't find form (because form already closed).. and output the error...

    I am curious as why the debug stayed on the Global.ofrm.close() statement instead of above statement!!

    Edited by: Bo Peng on May 16, 2008 3:01 PM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.