set the color to a Button
-
Hi, Is it possible to set the color to a button in a dialog based application? I tried using CTLCOLOR_BTN unsuccessfully. The code which i tried is given below.. HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (CTLCOLOR_BTN == nCtlColor) // It worked when i used CTLCOLOR_DLG to change the color of the DialogBox { hbr = ::GetSysColorBrush(1); } return hbr; } Thanks in Adavance.. Chetan. Helping others satisfies you...
-
Hi, Is it possible to set the color to a button in a dialog based application? I tried using CTLCOLOR_BTN unsuccessfully. The code which i tried is given below.. HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (CTLCOLOR_BTN == nCtlColor) // It worked when i used CTLCOLOR_DLG to change the color of the DialogBox { hbr = ::GetSysColorBrush(1); } return hbr; } Thanks in Adavance.. Chetan. Helping others satisfies you...
I think you want to change color from button you need to derived from CButton and use WM_DRAWITEM But for best way you can go examples in CodeProject and you find your answer
-
Hi, Is it possible to set the color to a button in a dialog based application? I tried using CTLCOLOR_BTN unsuccessfully. The code which i tried is given below.. HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (CTLCOLOR_BTN == nCtlColor) // It worked when i used CTLCOLOR_DLG to change the color of the DialogBox { hbr = ::GetSysColorBrush(1); } return hbr; } Thanks in Adavance.. Chetan. Helping others satisfies you...
You will get a good knowledge about button costumization from http://www.codeproject.com/useritems/HyperButtonEx.asp - NS -
-
Hi, Is it possible to set the color to a button in a dialog based application? I tried using CTLCOLOR_BTN unsuccessfully. The code which i tried is given below.. HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (CTLCOLOR_BTN == nCtlColor) // It worked when i used CTLCOLOR_DLG to change the color of the DialogBox { hbr = ::GetSysColorBrush(1); } return hbr; } Thanks in Adavance.. Chetan. Helping others satisfies you...
-
Hi, Is it possible to set the color to a button in a dialog based application? I tried using CTLCOLOR_BTN unsuccessfully. The code which i tried is given below.. HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (CTLCOLOR_BTN == nCtlColor) // It worked when i used CTLCOLOR_DLG to change the color of the DialogBox { hbr = ::GetSysColorBrush(1); } return hbr; } Thanks in Adavance.. Chetan. Helping others satisfies you...
The documentation states that
WM_CTLCOLORBTN
(which you're handling indirectly via the MFC plumbing when you handle theWM_CTLCOLOR
message) only works you owner drawn controls - Which basically makes it useless as then you have to draw it yourself. You’re not doing anything wrong; this technique simply doesn’t work. Steve -
Hi, Is it possible to set the color to a button in a dialog based application? I tried using CTLCOLOR_BTN unsuccessfully. The code which i tried is given below.. HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (CTLCOLOR_BTN == nCtlColor) // It worked when i used CTLCOLOR_DLG to change the color of the DialogBox { hbr = ::GetSysColorBrush(1); } return hbr; } Thanks in Adavance.. Chetan. Helping others satisfies you...
simplest way is to Inherit a CButton then darw it on WM_PAINT or OnPaint(...), very easy.
A nice tool for optimizing your Microsoft html-help contents. Includeh10
-
Hi, Is it possible to set the color to a button in a dialog based application? I tried using CTLCOLOR_BTN unsuccessfully. The code which i tried is given below.. HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (CTLCOLOR_BTN == nCtlColor) // It worked when i used CTLCOLOR_DLG to change the color of the DialogBox { hbr = ::GetSysColorBrush(1); } return hbr; } Thanks in Adavance.. Chetan. Helping others satisfies you...
chetan210183 wrote:
I tried using CTLCOLOR_BTN unsuccessfully.
Button Doesn't support Changing color through WM_CTLCOLOR Message!.. you need to handle WM_DRAWITEM MESSAGE by Subclassing the Button... look for exmple for same here http://www.codeproject.com/button
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
I think you want to change color from button you need to derived from CButton and use WM_DRAWITEM But for best way you can go examples in CodeProject and you find your answer
Thanks a lot for your suggestion. Helping others satisfies you...
-
Hi, Is it possible to set the color to a button in a dialog based application? I tried using CTLCOLOR_BTN unsuccessfully. The code which i tried is given below.. HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if (CTLCOLOR_BTN == nCtlColor) // It worked when i used CTLCOLOR_DLG to change the color of the DialogBox { hbr = ::GetSysColorBrush(1); } return hbr; } Thanks in Adavance.. Chetan. Helping others satisfies you...
Thanks a lot. Helping others satisfies you...