I try to owner draw radio button appearance. But I cann't get it.
I tested in DialogResizing demo:
1. Modify mydialog:: OnInitDialog to add
m_radioA.SetButtonStyle(BS_AUTORADIOBUTTON | BS_OWNERDRAW, TRUE);
2. Override OnMessageReflect to handle DrawItem message
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lparam;
CRect rc = pDIS->rcItem;
CDC dc = pDIS->hDC;
dc.SolidFill(RGB(32, 32, 32), rc);
}
return TRUE;
Yes we can handle the WM_DRAWITEM in our customized classes. The DDXDemo sample provides a practical demonstration of how to handle the WM_DRAWITEM in CView::DialogProc. This sample uses owner draw to render the status button and push button.
Best regards,
David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I try to owner draw radio button appearance. But I cann't get it.
I tested in DialogResizing demo:
1. Modify mydialog:: OnInitDialog to add
m_radioA.SetButtonStyle(BS_AUTORADIOBUTTON | BS_OWNERDRAW, TRUE);
2. Override OnMessageReflect to handle DrawItem message
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lparam;
CRect rc = pDIS->rcItem;
CDC dc = pDIS->hDC;
dc.SolidFill(RGB(32, 32, 32), rc);
}
return TRUE;
Solved.
Hi Kite,
I'm pleased to see you were able to resolve this one.
As you've noticed, the WM_DRAWITEM message needs to be handled in the dialog's DialogProc.
Best regards,
David
Hi. David How can we make all owner draw code in our inhired control class that we can re-use in different project?
Hi, David,
Can we handle the WM_DRAWITEM in our customized control class, and how?
Thank you!
Hi Erik,
Yes we can handle the WM_DRAWITEM in our customized classes. The DDXDemo sample provides a practical demonstration of how to handle the WM_DRAWITEM in CView::DialogProc. This sample uses owner draw to render the status button and push button.
Best regards,
David
Great,I will learn it , Thank you!