DigiPara Liftdesigner LDX API
Loading...
Searching...
No Matches
Fine Grained Event Locks

API method: ILDXApplication5.LockEventsEx

Treename: Document.

 ' from Samples/Src/LDXAPIExamples/Example_LDXApplication.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXApp, APIHelpModes.InputParaLDXDoc}, "Document.", "LDXApplication~LockEventsEx", "Fine Grained Event Locks")>
 Public Shared Sub EventLock_Sample(ByRef ldxApplication As DigiPara.LDX.LDXApplication, ByRef ldxDocument As DigiPara.LDX.LDXDocument)
     ' it is now possible to block individual LDX Application events from firing. This is mostly useful from UI code
     ' where premature event firing would cause flicker, back-and-forth updates and uneccesary work.

     ' fetch two frames from two different sheets
     Dim sheet1 = ldxDocument.Sheets.Item(0)
     Dim frame1 = sheet1.Item(0)
     Dim sheet2 = ldxDocument.Sheets.Item(1)
     Dim frame2 = sheet2.Item(0)
     frame1.Activate()
     sheet1.Activate()

     Try
         ' register events
         AddHandler ldxApplication.ActiveFrameChanged, AddressOf EventLock_ActiveFrameChanged
         AddHandler ldxApplication.ActiveSheetChanged, AddressOf EventLock_ActiveSheetChanged

         MsgBox("Activating sheet and frame without event locks, expect two event message boxes and a sheet switch in the UI.")
         frame2.Activate()
         sheet2.Activate()

         ' lock sheet change event (keep return value for later)
         Dim restore As DigiPara.LDX.EventTypeFlags = ldxApplication.LockEventsEx(ldxDocument, DigiPara.LDX.EventTypeFlags.etfActiveSheetChanged)

         MsgBox("Activating sheet and frame with event lock, expect only the frame change message box and no UI switch yet.")
         frame1.Activate()
         sheet1.Activate()

         ' unlock events with saved restore information
         MsgBox("Unlocking events, expect the sheet change message box and the sheet switch in the UI.")
         ldxApplication.UnlockEventsEx(ldxDocument, restore)
     Finally
         ' deregister events
         RemoveHandler ldxApplication.ActiveFrameChanged, AddressOf EventLock_ActiveFrameChanged
         RemoveHandler ldxApplication.ActiveSheetChanged, AddressOf EventLock_ActiveSheetChanged
     End Try




 End Sub