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

UI: Messagebox when button is clicked

Hello all

I've created a VERY simple form with a button on it. This is the code:

'Create the form:

frmVareAddOn = SBO_Application.Forms.Add("VareAddOnForm")

frmVareAddOn.Height = 599

frmVareAddOn.Left = 275

frmVareAddOn.Title = "My button-form"

frmVareAddOn.Top = 48

frmVareAddOn.Width = 473

'Create the button

oItem = frmVareAddOn.Items.Add("btnHello", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

oItem.Height = 19

oItem.Left = 365

oItem.Top = 28

oItem.Width = 65

oButton = oItem.Specific

oButton.Caption = "Hello"

When I run the project, the form with the button is shown - but how can I show a MessageBox when the button is clicked?

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 22, 2004 at 06:26 PM

    Thank you for posting.

    I am now catching the events, when my buttons are clicked - I do this with the ITEM_PRESSED event.

    But everytime i click my button - the event happens twice... I get the messagebox two times in a row. How do I solve this?

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Henrik,

      several events will come twice:

      Before and after SBO performs it's own tasks in reaction to the specific event, you are informed about that.

      The property of the ItemEvent object reflecting this is

      "Before_Action". The UI API helpfile states that this "Returns a value specifying if the event was issued before SAP Business One application handled the event."

      To prevent further processing by SBO etc. in case of "Before_Action=True", set "BubbleEvent" to False. (See "Remarks" to the ItemEvent Event)

      Regards,

      Frank

  • Posted on Apr 22, 2004 at 12:07 PM

    Hello Henrik,

    you can catch an item event for this.

    Please

    - check the "Catching events" sample in the "Developer area" for "SAP Business One" for details and/or

    - see the help file for SAP Business One UI API ("Programming with the UI API" / "Event Handling" / ...) or

    - see the help file for SAP Business One UI API ("UI API Reference" / "Overview" / "Events" / "Item Events").

    In VB .NET e.g. the handler looks like this:

    Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

    "pVal" contains all the information you need for your purposes.

    In addition please "search" the UI API helpfile for further information about "MessageBox"...

    Regards,

    Frank

    PS (Just FYI): There's a training course for the SBO SDK (TB1300) that will help you to get started with SDK development.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 22, 2004 at 12:09 PM

    Hello Henrik,

    see then ItemEvent of the Application Object in UI Help-File.

    There is also a sample named "CatchingEvents Sample".

    hth, Stephan

    Add comment
    10|10000 characters needed characters exceeded