Description
Occurs when a widget instance is created (dragged into the cockpit or created by the
CreateWidgetInstance method of the
Cockpit object).
Syntax
Parameters
Example
| C# | Copy Code |
|---|
//Register event handlers when start add-on program. private void RegisterEnventHandlers() { sbo_Application.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(SBO_Application_ItemEvent); sbo_Application.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(SBO_Application_MenuEvent); sbo_Application.WidgetEvent += new SAPbouiCOM._IApplicationEvents_WidgetEventEventHandler(SBO_Application_WidgetEvent); } //Widget Event handler. private void SBO_Application_WidgetEvent(ref SAPbouiCOM.WidgetData pWidgetData, out bool BubbleEvent) { BubbleEvent = true; if (pWidgetData.EventType == SAPbouiCOM.BoWidgetEventTypes.wet_created || pWidgetData.EventType == SAPbouiCOM.BoWidgetEventTypes.wet_content_save ) { if(pWidgetData.WidgetType == "AddonWidget") { try { //Catch widget event "wet_created" from Infra/App level and assign a form for it. SAPbouiCOM.FormCreationParams oFormParams; oFormParams = (SAPbouiCOM.FormCreationParams)sbo_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams); oFormParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Sizable; //oFormParams.FormType = "WDT_FORM_" + Guid.NewGuid(); //oFormParams.UniqueID = "WDT_FORM_" + Guid.NewGuid(); oFormParams.FormType = "WDT_FORM"; oFormParams.UniqueID = "WDT_FORM_" + iFormCount.ToString(); ++iFormCount; SAPbouiCOM.Form tmpform = sbo_Application.Forms.AddEx(oFormParams); tmpform.ClientHeight = 600; tmpform.ClientWidth = 600; tmpform.Left = pWidgetData.Left; tmpform.Top = pWidgetData.Top; tmpform.Width = pWidgetData.Right - pWidgetData.Left; tmpform.Height = pWidgetData.Bottom - pWidgetData.Top; //User different titles for testing every time. //Or else we will fail to create form with the same names. tmpform.Title = "Addon_Widget_" + Guid.NewGuid(); tmpform.Visible = true; //Assign the form to the add-on widget pWidgetData.Form = tmpform; } catch (Exception ex) { string strErrAlert = "Errors: Unable to create user-defined form for Add-on widget...\n\n"; MessageBox.Show(strErrAlert + ex.Message); } } } }
|
|
See Also