Checks if the current code is executing in a ViewPortChanged event.
This is to help preventing "event looping" in complicated GUI designs in which multiple controls can update the viewport and indirectly update each others.
For example, suppose in a scrollable chart design, the x-axis can be scrolled by both a scroll bar control and a date/time picker control. That means both scroll bar and date/time picker events may update the viewport.
The following sequence of events may happen:
- User changes the start date on the x-axis using the date/time picker control.
- The viewport is updated, so CChartViewer.updateViewPort is called, triggering a CVN_ViewPortChanged message.
- In the ViewPortChanged event handler, the scroll bar position needs to be updated to reflect that the viewport has moved.
- As the scroll bar has changed, a scroll bar event occurs. The scroll bar event handler may update the viewport and call CChartViewer.updateViewPort again.
The above is potentially an infinite loop as the ViewPortChanged event will keep firing again and again. To avoid this,
CChartViewer.updateViewPort will perform no action if it is called within ViewPortChanged event. So the last step above cannot actually trigger another ViewPortChanged event. This avoids the infinite loop.
Internally, CChartViewer.updateViewPort use this method to checks if it is called within a ViewPortChanged event, and ignores the request if it is already in the event. This method allows external code to also change behaviour in a ViewPortChanged event.
True if the current code is executing in a
CVN_ViewPortChanged message, otherwise false.
© 2023 Advanced Software Engineering Limited. All rights reserved.