CStatic-Derived class: painting background
-
Hi all, I need to paint the background of a CStatic control created dynamically this way:
CUnknownCtrl* pUnknown;
pUnknown = new CUnknownCtrl;
pUnknown->Create("Text", SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP, CRect(11,35,360,526), this, 0x31);Notice that CUnknownCtrl is a CStatic-derived mfc class. I can't figure out how to set background color of the label created with this code, someone can help me? Calling OnCtlColor inside CUnknownCtrl won't even be executed and OnPaint fails. Some idea? Thanks for advance
---
-
Hi all, I need to paint the background of a CStatic control created dynamically this way:
CUnknownCtrl* pUnknown;
pUnknown = new CUnknownCtrl;
pUnknown->Create("Text", SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP, CRect(11,35,360,526), this, 0x31);Notice that CUnknownCtrl is a CStatic-derived mfc class. I can't figure out how to set background color of the label created with this code, someone can help me? Calling OnCtlColor inside CUnknownCtrl won't even be executed and OnPaint fails. Some idea? Thanks for advance
---
Hi, Simply handle the WM_CTLCOLORSTATIC message in your class. The WM_CTLCOLORSTATIC is send to a static control when its background color need to drawn. thanks. Nitheesh
-
Hi all, I need to paint the background of a CStatic control created dynamically this way:
CUnknownCtrl* pUnknown;
pUnknown = new CUnknownCtrl;
pUnknown->Create("Text", SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP, CRect(11,35,360,526), this, 0x31);Notice that CUnknownCtrl is a CStatic-derived mfc class. I can't figure out how to set background color of the label created with this code, someone can help me? Calling OnCtlColor inside CUnknownCtrl won't even be executed and OnPaint fails. Some idea? Thanks for advance
---
-
I used OnCtlColor handler, but because my label was created with a CStatic-derived class, the code provided into CMyClass::OnCtlColor won't be executed! OnPaint seemed me a good solution but if I insert the OnPaint handler with Visual Studio, the control won't even show
---
-
I used OnCtlColor handler, but because my label was created with a CStatic-derived class, the code provided into CMyClass::OnCtlColor won't be executed! OnPaint seemed me a good solution but if I insert the OnPaint handler with Visual Studio, the control won't even show
---
-
4288 wrote:
but if I insert the OnPaint handler with Visual Studio, the control won't even show
Did you subclass the control?[^]
led mike
-
Hi, Simply handle the WM_CTLCOLORSTATIC message in your class. The WM_CTLCOLORSTATIC is send to a static control when its background color need to drawn. thanks. Nitheesh
WM_CTLCOLORSTATIC
is sent to the parent window of the static control, not the static control itself.Software Zen:
delete this;
Fold With Us![^] -
Hi all, I need to paint the background of a CStatic control created dynamically this way:
CUnknownCtrl* pUnknown;
pUnknown = new CUnknownCtrl;
pUnknown->Create("Text", SS_CENTER | WS_CHILD | WS_VISIBLE | WS_GROUP, CRect(11,35,360,526), this, 0x31);Notice that CUnknownCtrl is a CStatic-derived mfc class. I can't figure out how to set background color of the label created with this code, someone can help me? Calling OnCtlColor inside CUnknownCtrl won't even be executed and OnPaint fails. Some idea? Thanks for advance
---
-
-
Very good. :-D