在vc++技术内幕IV中第4章讲到:
在View.h中声明:
//{{AFX_MSG(CCex03View)
afx_msg void OnLButtonDown(UINT nFlags,CPoint point);
//}}AFX_MSG
private:
int m_nColor;
CRect m_rectEllipse;
在.cpp文件中这样写:
CCex04View::CCex04View():m_rectEllipse(0,0,200,200)
{
// TODO: add construction code here
m_nColor=GRAY_BRUSH;
}
void CCex03View::OnDraw(CDC* pDC)
{
pDC->SelectStockObject(m_nColor);
pDC->Ellipse(m_rectEllipse);
}
void CCex03View::OnLButtonDown(UINT nFlags,CPoint point)
{
if(m_rectEllipse.PtInRect(point))
{
if (m_nColor=GRAY_BRUSH)
{
m_nColor=WHITE_BRUSH;
}
else
{
m_nColor=GRAY_BRUSH;
}
InvalidateRect(m_rectEllipse);
}
}
为什么我左键按下的时候,没有变色
在View.h中声明:
//{{AFX_MSG(CCex03View)
afx_msg void OnLButtonDown(UINT nFlags,CPoint point);
//}}AFX_MSG
private:
int m_nColor;
CRect m_rectEllipse;
在.cpp文件中这样写:
CCex04View::CCex04View():m_rectEllipse(0,0,200,200)
{
// TODO: add construction code here
m_nColor=GRAY_BRUSH;
}
void CCex03View::OnDraw(CDC* pDC)
{
pDC->SelectStockObject(m_nColor);
pDC->Ellipse(m_rectEllipse);
}
void CCex03View::OnLButtonDown(UINT nFlags,CPoint point)
{
if(m_rectEllipse.PtInRect(point))
{
if (m_nColor=GRAY_BRUSH)
{
m_nColor=WHITE_BRUSH;
}
else
{
m_nColor=GRAY_BRUSH;
}
InvalidateRect(m_rectEllipse);
}
}
为什么我左键按下的时候,没有变色
解决方案 »
- 输出使用CreatePolygonRgn创建的一个区域
- 难!!!期待高手!!!
- 求一个 程序员联合开发网 的源码下载 有账户的帮忙下~
- 想向大家问问一些VC++方面的事
- SQL Server数据库程序的问题
- !!!一个应届毕业生的困惑,望指点
- 希望各位高手帮小弟一把!请问如何统计上网流量?如何区别局域网和internet上的流量?
- 请问让CListCtrl一整行都高亮该如何做?
- WSARecv 线程退出后错误995
- 一个MFC显示BMP图片的问题
- 如何知道移动驱动器有没有插入软盘(譬如那种插入SD卡的)?
- 各位好,下面是我在用MFC开发COM中遇到的一些问题,希望大家能过来看看,发表一些您的看法。谢谢!
必须在
(0,0,200,200)
之内或者把
if(m_rectEllipse.PtInRect(point))
注释掉
在cpp文件中要加
//{{AFX_MSG_MAP(CCex03View)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
BEGIN_MESSAGE_MAP(...)
END_MESSAGE_MAP()
之间是否有ON_WM_LBUTTONDOWN()?若没有则加上