Home > Software engineering >  MFC problem, consult everybody
MFC problem, consult everybody

Time:09-23

With a brush to modify the static text font color inside, the read only the edit control inside the
Font is modified, would like to ask how can only modify the static text control content, without affecting the read only
The edit control?

 HBRUSH sellout: : OnCtlColor (CDC * pDC, CWnd * pWnd, UINT nCtlColor) 
{
HBRUSH HBRUSH=CDialog: : OnCtlColor (pDC, pWnd, nCtlColor);

If (nCtlColor==CTLCOLOR_STATIC)//the static will be selected to read only edit
{
PDC - & gt; SetBkMode (TRANSPARENT);
PDC - & gt; SetTextColor (RGB (255, 255, 255));//set the font to white
Return (HBRUSH) : : GetStockObject (NULL_BRUSH);
}

Return hBrush;
}

CodePudding user response:

 HBRUSH HBRUSH=CDialog: : OnCtlColor (pDC, pWnd, nCtlColor); 

If (nCtlColor==CTLCOLOR_STATIC)//the static will be selected to read only edit
{
If (pWnd - & gt; GetDlgCtrlID ()==IDC_STATIC_1)//IDC_STATIC_1 to need to change the color of the control ID
{
PDC - & gt; SetBkMode (TRANSPARENT);
PDC - & gt; SetTextColor (RGB (255, 255, 255));//set the font to white
Return (HBRUSH) : : GetStockObject (NULL_BRUSH);
}
}

Return hBrush;

CodePudding user response:

If (pWnd==GetDlgItem (IDC_EDIT))

CodePudding user response:

You don't use the static text, text drawing
  • Related