Changing the look and feel of a MFC dialog box
-
Hi, I want to change the shape and color of a MFC dialog box? Any feedback on this would be appreciated. I know this is probably a very common question, just dont know how to do this. Much appreciated, garyc
-
Hi, I want to change the shape and color of a MFC dialog box? Any feedback on this would be appreciated. I know this is probably a very common question, just dont know how to do this. Much appreciated, garyc
A window is always rectangular. Any other shape can be created using a region. There are several functions in GDI that help you create regions - Region Functions[^] Here is a simple example with source code to create a region from a bitmap and apply to a window. Fish Region[^] Background color can be set by handling the WM_CTLCOLORDLG[^] message.
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
A window is always rectangular. Any other shape can be created using a region. There are several functions in GDI that help you create regions - Region Functions[^] Here is a simple example with source code to create a region from a bitmap and apply to a window. Fish Region[^] Background color can be set by handling the WM_CTLCOLORDLG[^] message.
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)Much appreciated. I never knew how they did this and now I know. Thanks, Garyc
-
Much appreciated. I never knew how they did this and now I know. Thanks, Garyc
you can add this with ClassWizard,or in the sources code to add it by yourself. just like this: C***Dlg.h
afx\_msg HBRUSH OnCtlColor(CDC\* pDC, CWnd\* pWnd, UINT nCtlColor);
C***Dlg.cpp
BEGIN_MESSAGE_MAP
......
ON_WM_CTLCOLOR()
......
END_MESSAGE_MAP()HBRUSH C***Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);// TODO: Change any attributes of the DC here switch (pWnd->GetDlgCtrlID()) { case IDC\_STATIC1: case IDC\_STATIC2: pDC->SetTextColor(RGB(255,0,0)); break; case IDC\_STATIC3: case IDC\_STATIC4: pDC->SetTextColor(RGB(0,0,255)); break; } // TODO: Return a different brush if the default is not desired return hbr;
}
Best Reguards ! by Koma http://blog.csdn.net/wangningyu
-
you can add this with ClassWizard,or in the sources code to add it by yourself. just like this: C***Dlg.h
afx\_msg HBRUSH OnCtlColor(CDC\* pDC, CWnd\* pWnd, UINT nCtlColor);
C***Dlg.cpp
BEGIN_MESSAGE_MAP
......
ON_WM_CTLCOLOR()
......
END_MESSAGE_MAP()HBRUSH C***Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);// TODO: Change any attributes of the DC here switch (pWnd->GetDlgCtrlID()) { case IDC\_STATIC1: case IDC\_STATIC2: pDC->SetTextColor(RGB(255,0,0)); break; case IDC\_STATIC3: case IDC\_STATIC4: pDC->SetTextColor(RGB(0,0,255)); break; } // TODO: Return a different brush if the default is not desired return hbr;
}
Best Reguards ! by Koma http://blog.csdn.net/wangningyu
Much apreciated guys for your contributions. Thanks, Garyc