Problem in Owner Draw Button
-
Hi All, I derived a class from CButton and I'm creating pointers with style BS_OWNERDRAW. This works fine if i give style as WS_CHILD|WS_VISIBLE|BS_OWNERDRAW. But now i want to custom draw my Radio Button, i giving style as WS_CHILD|WS_VISIBLE|BS_OWNERDRAW|BS_AUTORADIOBUTTON. But my DrawItem method is not getting called...if remove the BS_AUTORADIOBUTTON style my DrawItem method is called.. Why is this happing?... How can i custom draw my button as radio button.. Thanx
Do your Duty and Don't expect the Result
-
Hi All, I derived a class from CButton and I'm creating pointers with style BS_OWNERDRAW. This works fine if i give style as WS_CHILD|WS_VISIBLE|BS_OWNERDRAW. But now i want to custom draw my Radio Button, i giving style as WS_CHILD|WS_VISIBLE|BS_OWNERDRAW|BS_AUTORADIOBUTTON. But my DrawItem method is not getting called...if remove the BS_AUTORADIOBUTTON style my DrawItem method is called.. Why is this happing?... How can i custom draw my button as radio button.. Thanx
Do your Duty and Don't expect the Result
http://msdn2.microsoft.com/en-us/library/ms673347.aspx[^] [quote] BS_OWNERDRAW Creates an owner-drawn button. The owner window receives a WM_DRAWITEM message when a visual aspect of the button has changed. Do not combine the BS_OWNERDRAW style with any other button styles. [/quote]
-
http://msdn2.microsoft.com/en-us/library/ms673347.aspx[^] [quote] BS_OWNERDRAW Creates an owner-drawn button. The owner window receives a WM_DRAWITEM message when a visual aspect of the button has changed. Do not combine the BS_OWNERDRAW style with any other button styles. [/quote]
Hi Arends, Thanx.. actually i refered Jan'2005 MSDN.. it says..
Creates an owner-drawn button. The framework calls the DrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class.
Now i'm facing another problem, even though i set the checked state by SetCheck(BST_CHECKED), i'm not getting the BST_CHECKED value while i'm using GetCheck().. Any Idea... Thanx again..
Do your Duty and Don't expect the Result
-
Hi Arends, Thanx.. actually i refered Jan'2005 MSDN.. it says..
Creates an owner-drawn button. The framework calls the DrawItem member function when a visual aspect of the button has changed. This style must be set when using the CBitmapButton class.
Now i'm facing another problem, even though i set the checked state by SetCheck(BST_CHECKED), i'm not getting the BST_CHECKED value while i'm using GetCheck().. Any Idea... Thanx again..
Do your Duty and Don't expect the Result
If you run this code do you get any change or its like your problem
CButton m_Button; myButton.Create("Test", WS_CHILD|WS_VISIBLE|BS_AUTO3STATE, CRect(0,0,100,23), this, 1); m_Button.SetCheck(BST_CHECKED);
WhiteSky
-
If you run this code do you get any change or its like your problem
CButton m_Button; myButton.Create("Test", WS_CHILD|WS_VISIBLE|BS_AUTO3STATE, CRect(0,0,100,23), this, 1); m_Button.SetCheck(BST_CHECKED);
WhiteSky
Hi Whitesky, The above code will work fine.. My problem is i have to draw a custom option(Radio) button. So i derived a class from CButton and i override the DrawItem method... As per MSDN we cannot combine any other style with BS_OWNERDRAW. Always i'm getting BST_UNCHECKED, so i cannot able to draw the checked radio. in DrawItem, DRAWITEMSTRUCT::itemState has no ODS_CHECKED flag and also if i use the GetCheck() API it returns BST_UNCHECKED.
Do your Duty and Don't expect the Result
-
Hi Whitesky, The above code will work fine.. My problem is i have to draw a custom option(Radio) button. So i derived a class from CButton and i override the DrawItem method... As per MSDN we cannot combine any other style with BS_OWNERDRAW. Always i'm getting BST_UNCHECKED, so i cannot able to draw the checked radio. in DrawItem, DRAWITEMSTRUCT::itemState has no ODS_CHECKED flag and also if i use the GetCheck() API it returns BST_UNCHECKED.
Do your Duty and Don't expect the Result
Maybe its not good way but its possible if you use of DrawItem you can imitation behavior of checkbox for radio button (once I tried many years ago with three buttons(checkbox)and it worked)
WhiteSky