我写了个类(CLed),在别的类中不能访问我写的类的成员函数?
基于对话框的
估计出错在CClientDC dcl(this);?
为什么不能这样用呢?
小弟谢过!
class CLed : public CWnd
void CLed::draw_LedA(int add)
{
CClientDC dcl(this);
// CPen penBlue(PS_SOLID, 5, RGB(255, 255, 255));
// CPen* pOldPen =dcl.SelectObject(&penBlue); // and a solid red brush
// CBrush brushRed(RGB(m_clorled[0], 0, 0));
// CBrush* pOldBrush = dcl.SelectObject(&brushRed);
// dc.Rectangle(20,20,100,100);
CPoint pts[6];
pts[0].x = 54+add;
pts[0].y = 21; pts[1].x = 66+add;
pts[1].y = 14; pts[2].x = 165+add;
pts[2].y = 14; pts[3].x = 174+add;
pts[3].y = 21; pts[4].x = 159+add;
pts[4].y = 38; pts[5].x = 69+add;
pts[5].y = 38;
dcl.Polygon(pts, 6);
}
void CCledDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CLed led;
led.draw_LedA(0);
}
基于对话框的
估计出错在CClientDC dcl(this);?
为什么不能这样用呢?
小弟谢过!
class CLed : public CWnd
void CLed::draw_LedA(int add)
{
CClientDC dcl(this);
// CPen penBlue(PS_SOLID, 5, RGB(255, 255, 255));
// CPen* pOldPen =dcl.SelectObject(&penBlue); // and a solid red brush
// CBrush brushRed(RGB(m_clorled[0], 0, 0));
// CBrush* pOldBrush = dcl.SelectObject(&brushRed);
// dc.Rectangle(20,20,100,100);
CPoint pts[6];
pts[0].x = 54+add;
pts[0].y = 21; pts[1].x = 66+add;
pts[1].y = 14; pts[2].x = 165+add;
pts[2].y = 14; pts[3].x = 174+add;
pts[3].y = 21; pts[4].x = 159+add;
pts[4].y = 38; pts[5].x = 69+add;
pts[5].y = 38;
dcl.Polygon(pts, 6);
}
void CCledDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CLed led;
led.draw_LedA(0);
}
解决方案 »
- 异步事件模型必须用TCP来写吗?
- 关于GetObject获取位图信息的问题
- list control ,如何实现文本框(edit control)将数据提交到list control中的item 高亮显示,
- 怎么样快速检索文件夹中的文件?
- MFC中调用含WCHAR字符串出错的问题.mbstowcs 和MultiByteWideChar转换时都是只转了第一个字符的问题.
- 请问如何在MFC中用Serialize读取一个其他程序生成的文本格式的文件?
- 如何在窗体的制定区域创建一个Button?
- vc 对硬件的操作应学哪部分,找了很多没发现
- 这个错误是什么原因~~~~~
- 一张游戏光盘,第一次插入光驱时自动自行SETUP程序,安装完后,第二次插入光盘自动开始游戏,怎么实现的
- 如何判断是内网用户还是外网用户
- 异步发送 10035
----------------
至少需要Create窗口
通常需要显示出来才有绘制的必要:)
{
CClientDC dcl(AfxGetApp()->m_pMainWnd);
// CPen penBlue(PS_SOLID, 5, RGB(255, 255, 255));
// CPen* pOldPen =dcl.SelectObject(&penBlue); // and a solid red brush
CBrush brushRed(RGB(m_clorled[0], 0, 0));
CBrush* pOldBrush = dcl.SelectObject(&brushRed);
// dc.Rectangle(20,20,100,100);
CPoint pts[6];
pts[0].x = 54+add;
pts[0].y = 21; pts[1].x = 66+add;
pts[1].y = 14; pts[2].x = 165+add;
pts[2].y = 14; pts[3].x = 174+add;
pts[3].y = 21; pts[4].x = 159+add;
pts[4].y = 38; pts[5].x = 69+add;
pts[5].y = 38;
dcl.Polygon(pts, 6);
}
{
}