Subclassing ActiveX control
-
I'm Creating an ActiveX subclassing "EDIT". I would like it to be able to change the colour of the background, text or indeed both. I've added the BackColor and ForeColor as Stock implementation. I've changed below:
BEGIN_PROPPAGEIDS(CEditTestCtrl, 1) PROPPAGEID(CEditTestPropPage::guid) END_PROPPAGEIDS(CEditTestCtrl)
to
BEGIN_PROPPAGEIDS(CEditTestCtrl, 2) PROPPAGEID(CEditTestPropPage::guid) PROPPAGEID(CLSID_CColorPropPage) END_PROPPAGEIDS(CEditTestCtrl)
I've also modified the OnDraw method to;
void CEditTestCtrl::OnDraw( CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid) { DoSuperclassPaint(pdc, rcBounds); //added pdc->FillRect(&rcBounds, &CBrush(TranslateColor(GetBackColor()))); }
The Bakground colour changes. The problem lies when enter text in the control, the control reverts back to the orignal colour. The question is what is the correct way in achieving this?:confused::confused: -- modified at 16:03 Tuesday 14th March, 2006
-
I'm Creating an ActiveX subclassing "EDIT". I would like it to be able to change the colour of the background, text or indeed both. I've added the BackColor and ForeColor as Stock implementation. I've changed below:
BEGIN_PROPPAGEIDS(CEditTestCtrl, 1) PROPPAGEID(CEditTestPropPage::guid) END_PROPPAGEIDS(CEditTestCtrl)
to
BEGIN_PROPPAGEIDS(CEditTestCtrl, 2) PROPPAGEID(CEditTestPropPage::guid) PROPPAGEID(CLSID_CColorPropPage) END_PROPPAGEIDS(CEditTestCtrl)
I've also modified the OnDraw method to;
void CEditTestCtrl::OnDraw( CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid) { DoSuperclassPaint(pdc, rcBounds); //added pdc->FillRect(&rcBounds, &CBrush(TranslateColor(GetBackColor()))); }
The Bakground colour changes. The problem lies when enter text in the control, the control reverts back to the orignal colour. The question is what is the correct way in achieving this?:confused::confused: -- modified at 16:03 Tuesday 14th March, 2006
Hello Alton Williams, I don't have answer to your question but i just want to know why are you doing this through ActiveX control. I mean you can change the background and text color of standard Edit control by Handling WM_CTLCOLOR Message. Is ActiveX your requirement? Muhammad Azam
-
Hello Alton Williams, I don't have answer to your question but i just want to know why are you doing this through ActiveX control. I mean you can change the background and text color of standard Edit control by Handling WM_CTLCOLOR Message. Is ActiveX your requirement? Muhammad Azam
Muhammad Azam wrote:
but i just want to know why are you doing this through ActiveX control
Answer this is a component of my result.
Muhammad Azam wrote:
I mean you can change the background and text color of standard Edit control by Handling WM_CTLCOLOR Message.
I know that I want to able to have the result on VB, Delphi, VC++ ect.
-
I'm Creating an ActiveX subclassing "EDIT". I would like it to be able to change the colour of the background, text or indeed both. I've added the BackColor and ForeColor as Stock implementation. I've changed below:
BEGIN_PROPPAGEIDS(CEditTestCtrl, 1) PROPPAGEID(CEditTestPropPage::guid) END_PROPPAGEIDS(CEditTestCtrl)
to
BEGIN_PROPPAGEIDS(CEditTestCtrl, 2) PROPPAGEID(CEditTestPropPage::guid) PROPPAGEID(CLSID_CColorPropPage) END_PROPPAGEIDS(CEditTestCtrl)
I've also modified the OnDraw method to;
void CEditTestCtrl::OnDraw( CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid) { DoSuperclassPaint(pdc, rcBounds); //added pdc->FillRect(&rcBounds, &CBrush(TranslateColor(GetBackColor()))); }
The Bakground colour changes. The problem lies when enter text in the control, the control reverts back to the orignal colour. The question is what is the correct way in achieving this?:confused::confused: -- modified at 16:03 Tuesday 14th March, 2006
Alton Williams wrote:
void CEditTestCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& cInvalid) { DoSuperclassPaint(pdc, rcBounds); //added pdc->FillRect(&rcBounds, &CBrush(TranslateColor(GetBackColor()))); }
Use
pdc->SetBkMode(TRANSPARENT)
to make text background transparent.
Nibu thomas Software Developer