这个只是在创建的默认的public COleControl 控件上画 如果你要画出你自己的子控件 可以在OnCreate()中画出来这个是OnDraw()参数的意义: virtual void OnDraw( CDC* pDC, const CRect& rcBounds, const CRect& rcInvalid ); Parameters pDC The device context in which the drawing occurs. rcBounds The rectangular area of the control, including the border. rcInvalid The rectangular area of the control that is invalid.
use BeginPaint or do anything in OnPaint with ATL_DRAWINFO
我的ATL工程怎么没有默认的控件啊?要自己加入public COleControl
Search atlfire.sln in MSDN, The sample uses BeginPaint function
hWndParent
[in] The handle to the owner window.是父窗口的handle
CPaintDC dc();
CFont newFont;
CPen NewPen;
dc.MoveTo(20,20);//从这行开始出同一个错误
dc.LineTo(20,240);
dc.LineTo(240,240);
dc.Rectangle(40,mem1,60,240);
dc.Rectangle(80,mem2,100,240);
dc.Rectangle(120,mem3,140,240);
dc.Rectangle(160,mem4,180,240);
dc.TextOut(19,19,"%");
dc.TextOut(241,241,"num");
这是我的画图程序,编译报错:left of '.MoveTo' must have class/struct/union type
是指什么?没有初始化吗?请问应该怎样改?
error C2664: 'CPaintDC::CPaintDC' : cannot convert parameter 1 from 'class Cinface *const ' to 'class CWnd *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)楼主就用CDC* pdc来画图试试我测试过这样没问题:void CTestCtrl::OnDraw(
CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
// TODO: Replace the following code with your own drawing code.
HBRUSH hBakBrush=CreateSolidBrush(RGB(0x00,0x66,0xcc));
pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)hBakBrush));
// pdc->Ellipse(rcBounds);
pdc->SetBkColor(RGB(0x00,0x66,0xcc));
pdc->SetTextColor(RGB(255,255,255));
pdc->TextOut(20,20,"Test ActiveX");
DeleteObject(hBakBrush);
}
virtual void OnDraw(
CDC* pDC,
const CRect& rcBounds,
const CRect& rcInvalid
);
Parameters
pDC
The device context in which the drawing occurs.
rcBounds
The rectangular area of the control, including the border.
rcInvalid
The rectangular area of the control that is invalid.
The sample uses BeginPaint function