Symptom: When the attribute of the actievx control is variant_bool, the return value of get is always true on the client.
Cause: the MFC is converted during the transfer process, but the variant_boo is short type. The MFC is indeed converted to DWORD, so the conversion is always true. (For details, see the 1100 rows in oledisp1.cpp under vc2003 ). Method: Set the return value of "get" to "DWORD.
In addition, set values are different from those of variant_true and variant_false,
Correct use is shown in the following example:
Declaration: DWORD getflat1 (void );
Void setflat1 (variant_bool newval );
Definition: DWORD cbuttonst1ctrl: getflat1 (void)
{
Afx_manage_state (afxgetstaticmodulestate ());
// Todo: add the scheduling handler code here
If (m_bisflat)
{
Return variant_true;
}
Else
{
Return variant_false;
}
}
Void cbuttonst1ctrl: setflat1 (variant_bool newval)
{
Afx_manage_state (afxgetstaticmodulestate ());
// Todo: add the property handler code here
If (newval = 1)
{
M_bisflat = true;
}
If (newval = 0)
{
M_bisflat = false;
}
Invalidatecontrol ();
Setmodifiedflag ();
}