这是基类:
void CMyStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
CNetWatcherViewerDoc* pDoc = (CNetWatcherViewerDoc*)((CView*)GetParent())->GetDocument(); // TODO: Add your message handler code here
int tmpx,tmpy,tmp1,tmp2;
double tmpfft;
UINT i;
CString ctrText;
int ptr1=0,ptr2=0,ptr3=0,ptr4=0,ptr5=0,ptr6=0,ptr7=0,ptr8=0;
CDC MemDC;
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(&dc);
//建立一个与屏幕显示兼容的位图
----------------绘图部分--------------------
dc.BitBlt(0 ,0 ,rect.Width() ,rect.Height() ,&MemDC,0,0,SRCCOPY);
MemDC.SelectObject(pOldPen);
MemBitmap.DeleteObject();
MemDC.DeleteDC();
}
这是派生出来的类的:
void CMyStaticChannel1::OnPaint()
{
CPaintDC dc(this); // device context for painting
CNetWatcherViewerDoc* pDoc = (CNetWatcherViewerDoc*)((CView*)GetParent())->GetDocument(); dc.MoveTo(0,0);
dc.LineTo(100,100);
}
为什么派生出来的类绘制的那条线没有绘制出来?
void CMyStatic::OnPaint()
{
CPaintDC dc(this); // device context for painting
CNetWatcherViewerDoc* pDoc = (CNetWatcherViewerDoc*)((CView*)GetParent())->GetDocument(); // TODO: Add your message handler code here
int tmpx,tmpy,tmp1,tmp2;
double tmpfft;
UINT i;
CString ctrText;
int ptr1=0,ptr2=0,ptr3=0,ptr4=0,ptr5=0,ptr6=0,ptr7=0,ptr8=0;
CDC MemDC;
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(&dc);
//建立一个与屏幕显示兼容的位图
----------------绘图部分--------------------
dc.BitBlt(0 ,0 ,rect.Width() ,rect.Height() ,&MemDC,0,0,SRCCOPY);
MemDC.SelectObject(pOldPen);
MemBitmap.DeleteObject();
MemDC.DeleteDC();
}
这是派生出来的类的:
void CMyStaticChannel1::OnPaint()
{
CPaintDC dc(this); // device context for painting
CNetWatcherViewerDoc* pDoc = (CNetWatcherViewerDoc*)((CView*)GetParent())->GetDocument(); dc.MoveTo(0,0);
dc.LineTo(100,100);
}
为什么派生出来的类绘制的那条线没有绘制出来?
解决方案 »
- 请问Winsock如何实现一对多发送功能?
- 拜求:在钩子程序中取窗体中信息记录的方法(就这么点儿家底了,望见谅)
- 发现CTreeControl的一个问题?
- 还是richedit的问题:在richedit中加入了activex进度条后,进度条的实现是不断的刷新自己来绘制进度条的效果.....
- 我这样结束一个进程为什么错误,请有心人多多指教,非常感谢(因刚注册分少,请包含)
- 3000分学习windows系列(2)
- ADO中,如何将指针移动到末记录?
- 为什么有时候能跟进DLL中,而有时候不能
- -=寻找有关内存的技术资料=-
- 在DELPHI调用vc的dll 动态连接库的问题,急救
- ACE/TAO问题
- 请问我将一个dll工程中的对话框中添加控件,然后为控件关联变量,但是为什么编译的时候,会出现error C2065: 'IDC_ZHLX_COMBO' : undeclared identifier
在OnDraw函数里绘图
ON_WM_PAINT()
现在按大家说的加上
CMyStaticChannel1::~CMyStaticChannel1()
{ BEGIN_MESSAGE_MAP(CMyStaticChannel1, CMyStatic)
//{{AFX_MSG_MAP(CMyStaticChannel1)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()}
蹦出来好多错误:
error C2601: 'GetMessageMap' : local function definitions are illegal
error C2655: 'messageMap' : definition or redeclaration illegal in current scope
error C2655: '_messageEntries' : definition or redeclaration illegal in current scope
error C2276: '&' : illegal operation on bound member function expression
{
}
BEGIN_MESSAGE_MAP(CMyStaticChannel1, CMyStatic)
//{{AFX_MSG_MAP(CMyStaticChannel1)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
error C2509: 'GetMessageMap' : member function not declared in 'CMyStaticChannel1'
2, BEGIN_MESSAGE_MAP:标记源文件消息映射的开始
3,END_MESSAGE_MA:标记源文件消息映射的结束
//{{AFX_MSG_MAP(CMyStaticChannel1)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
这些怎么能放到函数里面!
在类定义中加上DECLARE_MESSAGE_MAP(),不要分号。