Microsoft KB Archive/85757

= Microsoft Knowledge Base =

WCheckCheck/WCheckUnCheck Do Not Cause Click for Check Box
Last reviewed: October 19, 1994

Article ID: Q85757

The information in this article applies to:

- Microsoft Test for Windows, version 1.0

SUMMARY
The WCheckCheck and WCheckUnCheck procedures (located in TESTCTRL.DLL) are used to place a check in a check box or to remove a check from a check box, respectively. However, these procedures do not generate a click for the check box; they just place a check in an indicated check box, or remove a check from an indicated check box. To generate a Click event, use the WCheckClick procedure.

MORE INFORMATION
The following code will place a check in a check box with the caption &quot;Test&quot;, and remove a check from a check box captioned &quot;Change&quot;. (This code assumes you have a Windows-based application program running with two check boxes using the captions listed below. It also assumes that the &quot;Test&quot; and &quot;Change&quot; check boxes are unchecked):

'$DEFINE W_CHECK '$INCLUDE 'MSTEST.INC' WCheckCheck(&quot;Test&quot;) WCheckUnCheck(&quot;Change&quot;) (Note: This example will not work for Visual Basic applications, because Visual Basic check boxes are not of the standard Windows class &quot;Button&quot;.)

If your application performs some action based on the Click of either of these check boxes, you will notice that the check either appears or disappears from the check box as expected, but no Click event is issued. The same is also true for the WOptionSelect procedure.

The reason for this is that WCheckCheck, WCheckUnCheck, and WOptionSelect send the specified control a BM_SETCHECK message. The BM_SETCHECK message does not generate a WM_COMMAND message to the control's parent, which is what happens when you click on a check box or option button. The benefit of this is that a test can be set up to simulate a user's input without it actually affecting the host program's operation.

To generate a Click event on a check box after checking it, use the WCheckClick procedure directly after the WCheckCheck / WCheckUnCheck procedure. The WCheckClick performs the equivalent of a left mouse button click on the specified check box within the active window. The code below is the same as above, with this modification to send a Click event after the check box has been checked:

'$DEFINE W_CHECK '$INCLUDE 'MSTEST.INC' WCheckCheck(&quot;Test&quot;) WCheckClick(&quot;Test&quot;) WCheckUnCheck(&quot;Change&quot;) WCheckClick(&quot;Change&quot;) This information also applies to WOptionSelect. Use WOptionClick to generate a Click event for the indicated option button in the same manner as the above example.