-1

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.

Anoop Kumar
  • 137
  • 10

1 Answers1

0

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;

}

Anoop Kumar
  • 137
  • 10
  • `S_OK` is a COM `HRESULT` (that evaluates to 0). Since you did erase the background, [OnEraseBkgnd](https://msdn.microsoft.com/en-us/library/a0a52fkz.aspx) should return a non-zero value. Besides, you aren't using `rc1`. Why is it there? And why do you ignore compiler warnings? – IInspectable Dec 22 '16 at 18:58