|
-
June 18th, 1999, 05:16 AM
#1
Drawing in a dialog box
Hi everybody,
New problem today for me. I've created a dialog box and I would like to create a true or virtual area in
which one I want to draw (lines, texts and so on).
Is there any control (standard in VC or extended by another firm) which can make this ?
If not, how can I draw in a dialog box ? I have tried to put my own draw code before and after the CDialog:OnPaint() function, but in all cases, my own drawn objects appear and disappear.
Thanks.
-
June 18th, 1999, 05:29 AM
#2
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) ;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|