Home > Software engineering >  Unable to set the background transparent after setting the Text Control controls content in the cont
Unable to set the background transparent after setting the Text Control controls content in the cont

Time:10-09

Text Control controls by timer Settings, controls the content of the inside, every seconds but after I set the background transparent effect, Control can not be refreshed, set fixed color background can refresh content
Effect:



The Text Control display code
 bool CIDCardCountDown: : ShowMessage () 
{
Unsigned int delaySeconds=m_countDownSeconds - m_consumeSeconds;


CRect rc;
: : GetWindowRect (m_hWnd, rc);
M_pParent - & gt; The InvalidateRect (rc);
Cstrings strFormat;
If (delaySeconds>=10)
{
StrFormat. LoadString (IDS_IDCARD_COUNT_DOWN_MSG);//show message
}
The else
{
StrFormat. LoadString (IDS_IDCARD_COUNT_DOWN_MSG_LESSTHAN10);
}

Cstrings strMsg;
StrMsg. The Format (strFormat delaySeconds);

: : SetWindowText (m_hWnd, strMsg);
//: : InvalidateRect (m_hWnd, & amp; Rc, TRUE);
If (delaySeconds==0)
{
EndCountDown ();
FireCountDownComplete ();
Return false;
}

M_consumeSeconds + +;

return true;
}


The Text Control Control code

 HBRUSH CLoginDlg: : OnCtlColor (CDC * pDC, CWnd * pWnd, UINT nCtlColor) 
{


HBRUSH gets=__super: : OnCtlColor (pDC, pWnd, nCtlColor);

Int nControlID=pWnd - & gt; GetDlgCtrlID ();

The switch (nControlID)
{


Case IDC_COUNT_DOWN_MSG:
PDC - & gt; SetTextColor (RGB (100100100));
//pDC - & gt; SetBkColor (RGB (255255255));
PDC - & gt; SetBkMode (TRANSPARENT);
PDC - & gt; SelectObject (& amp; M_countDownFont);
Gets=(HBRUSH) GetStockObject (NULL_BRUSH);

break;

}
Return gets;
}


CodePudding user response:

OnEraseBkgnd?

CodePudding user response:

reference 1st floor zhao4zhong1 response:
OnEraseBkgnd?


Could you explain in detail the teacher, the Text controls need to be redrawn?


Ps: I don't have redrawn the Text control, transparent background is the control of
 pDC - & gt; SetBkMode (TRANSPARENT); 


CodePudding user response:

Gets=(HBRUSH) GetStockObject ( NULL_BRUSH ).
Said don't erase the background, of course, the overlap (30 to 2 x)
  • Related