Win32 / MFC mixing TRUE / BST_CHECK for SetCheck function
-
I have done some mistakes regarding of using TRUE / FALSE for SetCheck / GetCheck method of CButton (they have to use BST_CHECK/BST_UNCHECK,I've got it mixed up with GetCheck/SetCheck of CListCtrl). But It run ok since both TRUE/BST_CHECK are definced as 1 and FALSE/BST_CHECK are defined as 0 Is this considered a serious bug ? Should I make a patch ? Sometime I wish they could use an enum for these parameters in stead of just defined value.
-
I have done some mistakes regarding of using TRUE / FALSE for SetCheck / GetCheck method of CButton (they have to use BST_CHECK/BST_UNCHECK,I've got it mixed up with GetCheck/SetCheck of CListCtrl). But It run ok since both TRUE/BST_CHECK are definced as 1 and FALSE/BST_CHECK are defined as 0 Is this considered a serious bug ? Should I make a patch ? Sometime I wish they could use an enum for these parameters in stead of just defined value.
What was error you got?
-
What was error you got?
Actually there was no error. I use the wrong parameter for SetCheck function. I wrote : m_comboButton.SetCheck(TRUE); m_comboButton.SetCheck(FALSE); while I should write m_comboButton.SetCheck(BST_CHECK); m_comboButton.SetCheck(BST_UNCHECK); The program has already been shipped and I fear that it might cause a problem In the future (I test it on xp/vista and it work fine)
-
Actually there was no error. I use the wrong parameter for SetCheck function. I wrote : m_comboButton.SetCheck(TRUE); m_comboButton.SetCheck(FALSE); while I should write m_comboButton.SetCheck(BST_CHECK); m_comboButton.SetCheck(BST_UNCHECK); The program has already been shipped and I fear that it might cause a problem In the future (I test it on xp/vista and it work fine)
You mean, BST_CHECKED and BST_UNCHECKED. Although, for the sake of good programming style and code readability, it's good to use those constants when calling CButton::SetCheck (may be also the third value BST_INDETERMINATE for three-state button), that is not a reason to worry in your particular case. BST_CHECKED and BST_UNCHECKED constants have the same values like TRUE and FALSE respectively:
#define BST_UNCHECKED 0x0000 #define BST_CHECKED 0x0001
#define FALSE 0 #define TRUE 1
Ovidiu Cucu Microsoft MVP - Visual C++
-
I have done some mistakes regarding of using TRUE / FALSE for SetCheck / GetCheck method of CButton (they have to use BST_CHECK/BST_UNCHECK,I've got it mixed up with GetCheck/SetCheck of CListCtrl). But It run ok since both TRUE/BST_CHECK are definced as 1 and FALSE/BST_CHECK are defined as 0 Is this considered a serious bug ? Should I make a patch ? Sometime I wish they could use an enum for these parameters in stead of just defined value.
xanagan666 wrote:
Is this considered a serious bug ?
IMHO NO! (1) Probably MS developers defined the MACROs keeping an eye on compatibility with TRUE/FALSE pair. (2) Probably They will never change that values.
xanagan666 wrote:
Should I make a patch ?
IMHO you'll include these minor fixes in a patch addressing major ones (maybe never?). :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
You mean, BST_CHECKED and BST_UNCHECKED. Although, for the sake of good programming style and code readability, it's good to use those constants when calling CButton::SetCheck (may be also the third value BST_INDETERMINATE for three-state button), that is not a reason to worry in your particular case. BST_CHECKED and BST_UNCHECKED constants have the same values like TRUE and FALSE respectively:
#define BST_UNCHECKED 0x0000 #define BST_CHECKED 0x0001
#define FALSE 0 #define TRUE 1
Ovidiu Cucu Microsoft MVP - Visual C++
ovidiucucu wrote:
BST_CHECKED and BST_UNCHECKED constants have the same values like TRUE and FALSE respectively: #define BST_UNCHECKED 0x0000 #define BST_CHECKED 0x0001 #define FALSE 0 #define TRUE 1
I think he alread knows... :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
I have done some mistakes regarding of using TRUE / FALSE for SetCheck / GetCheck method of CButton (they have to use BST_CHECK/BST_UNCHECK,I've got it mixed up with GetCheck/SetCheck of CListCtrl). But It run ok since both TRUE/BST_CHECK are definced as 1 and FALSE/BST_CHECK are defined as 0 Is this considered a serious bug ? Should I make a patch ? Sometime I wish they could use an enum for these parameters in stead of just defined value.
Thank everyone for your answer/solution :). I will be more careful in the future.