Re: Drawing in a dialog box
- First Create a Class CMyCtrl which inherates from CWnd, and draw whatever you want in the OnPaint Method
the Create method should be like this :
BOOL CGraphCtrl::Create(DWORD dwStyle, const RECT& rect,
CWnd* pParentWnd, UINT nID)
{
BOOL result;
static CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW);
result = CWnd::CreateEx(WS_EX_CLIENTEDGE | WS_EX_STATICEDGE,
className, NULL, dwStyle,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
pParentWnd->GetSafeHwnd(), (HMENU)nID);
return result;
}
[/ccode ]
Then in your ressource dialog box add a Picture control (IDC_MY_CONTROL)
Add CMyCtrl m_MyCtrl in the .h of your dialog box class
then on your InitDialog method do something like :
[ccode]
CRect rect;
GetDlgItem((IDC_MY_CONTROL))->GetWindowRect(rect) ;
ScreenToClient(rect) ;
// create the control
m_MyCtrl.Create(WS_VISIBLE | WS_CHILD, rect, this) ;