Windows Vista Behavior Change that Affects Applications that use .NET along with ActiveX/COM
Primary Software: TestStand
Primary Software Version: 4.1
Primary Software Fixed Version: N/A
Secondary Software: N/A
Problem: Windows Vista introduced a change in behavior that can cause applications to receive WM_PAINT messages unexpectedly while performing ActiveX/COM calls from .NET components or .NET applications. How does this affect applications that I write or modify, including TestStand user interfaces?
Solution: National Instruments has tested the TestStand Sequence Editor and User Interface controls in TestStand 4.1 and fixed instances where the unexpected messages caused incorrect behavior in the Sequence Editor and the VariablesView and InsertionPalette controls. The behavior change does not affect TestStand User Interface applications that you typically write in LabVIEW or LabWindows/CVI.
However, the behavior change can affect any application that uses a “virtual” user interface control. A "virtual" user interface control is one that performs custom draw operations, supports a virtual mode, or uses the OwnerData style. The behavior change can affect an application if all the following conditions apply:
- The application includes a “virtual” control that directly accesses application data or uses callbacks to request application data to draw content inside the control.
- The application or control makes calls to COM API from .NET code while modifying the application data that the control uses.
- A region of the control invalidates, the .NET-to-COM interop layer dispatches a WM_PAINT message to the virtual control, and the control accesses the data prematurely while it is still in an inconsistent state.
Applications that use virtual controls can avoid this problem by ignoring WM_PAINT messages while performing calls to COM API from .NET, and later refreshing the control so that it can repaint correctly. This approach is advisable for .NET code that calls COM APIs, such as the TestStand API, while modifying data that the control uses to paint. Furthermore, the application should be thoroughly tested in scenarios that might cause the virtual control to update its data while being drawn.
Alternatively, you can prevent Windows Vista’s COM interop layer from sending WM_PAINT messages by creating a custom compatibility database for your application by using the Compatibility Administrator utility from the Microsoft Application Compatibility Toolkit for Microsoft Windows. You must enable the DisableNewWMPAINTDispatchInOLE compatibility fix for your application. National Instruments does not recommend this work around because you must manually deploy the compatibility database to a target system and the compatibility database affects only an application at a specific location on the target system.
Related Links: Microsoft How to use the Compatibility Administrator utility in Windows (Article ID: 317510)
Attachments:
Report Date: 04/11/2008
Last Updated: 06/13/2008
Document ID: 4KAD5TT3