Background of the control is becoming dark on minimising and maximizing the window

169 Views Asked by At

Control background is getting changed after minimizing and maximizing the window. I want the background to be same and transparent.

Before minimizing the window

After maximizing the window

This is an ActiveX control. which can be used in multiple projects. CEdit is the base class for this control on which I have added some extra feature. I tried setting Bkmode in OnCtlColor and OnCtlColor but it is not working out.

1

There are 1 best solutions below

1
On

I resolved this by fetching the background color and filling the rec of the control

BOOL CComboBoxCtrl::OnEraseBkgnd(CDC* pDC) 
{
COleControl::OnEraseBkgnd(pDC);
RECT rc,rc1;
GetClientRect(&rc);
// Get the color from the parent window
COLORREF crBkgnd = COleControl::AmbientBackColor();

//Fill the rect to overcome the black background issue
pDC->FillSolidRect(&rc,crBkgnd);

if(inputbox != NULL)
    inputbox->Invalidate(TRUE);
return S_OK;

}