Search code examples
c#sapb1

How to catch the Font_Change event in SAP SDK


I have built an add on in SAP Business One. However, when I change the font size in Business One, my font size changes but the size of the controls remains the same. I have modified a formula to recalculate the sizes of the controls which works perfectly. However, I need to capture the Font_Change event in Business One so that the formula can only be used when the font is changed. Kindly help on how to achieve this.

There is no documentation that indicates operations done under the event.

I need to use my formula under the Font_Change event.


Solution

  • On your Application object (However you initialize and keep it, via the SAPBusinessOneSDK Application.SBO_Application, or via the SAPbouiCOM, which is what I use, dll) assign an AppEvent

    oApplication.AppEvent += oApplication_AppEvent;
    

    Then assign body to the handler like below:

    public static void oApplication_AppEvent(SAPbouiCOM.BoAppEventTypes EventType)
        {
            switch (EventType)
            {
                case SAPbouiCOM.BoAppEventTypes.aet_ShutDown:
                case SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition:
                case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged:
                    //Exit Add-On
                    System.Windows.Forms.Application.Exit();
                    break;
                    break;
                case SAPbouiCOM.BoAppEventTypes.aet_FontChanged:
                    //Whatever you write here will be executed on Font Change
                    //Call your formula here
                    break;
                case SAPbouiCOM.BoAppEventTypes.aet_LanguageChanged:
                default:
                    break;
            }
        }
    

    Hope this helps