Answers

Question and Answer:

  Home  MFC

⟩ How to give color for dialog button or static buuto?

Brush *brush;

Initialize the brush pointer in the constructor of your Dialog

Code:

brush = new CBrush(RGB(49,49,49));

Add the WM_CTLCOLR Message handler for the dialog and add the following code

Code:

switch (nCtlColor) {

case CTLCOLOR_BTN:

pDC->SetTextColor(RGB(0, 255, 0));

pDC->SetBkColor(RGB(0, 0, 0));

return (HBRUSH)(brush->GetSafeHandle());

default:

return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

}

 161 views

More Questions for you: