在窗口视图中的位图点击鼠标左键,使之响应消息。实现方法是在位图所在的矩形区域响应鼠标消息。但是窗口大小变化之后,区域和位图就错位了,该怎么改。求大神帮忙。。下面是代码
void CLianxiView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default CRect rect1(435,35,490,75);//该区域是位图所在区域
if(PtInRect(&rect1,point))
MessageBox("hello");
CView::OnLButtonDown(nFlags, point);
}
void CLianxiView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default CRect rect1(435,35,490,75);//该区域是位图所在区域
if(PtInRect(&rect1,point))
MessageBox("hello");
CView::OnLButtonDown(nFlags, point);
}
void CLianxiView::OnLButtonDown(UINT nFlags, CPoint point)
{
//获取控件的客户区坐标
GetDlgItem(STATIC_SHOWICON)->GetWindowRect(&m_rcRect);
ScreenToClient(m_rcRect);
if(PtInRect(&m_rcRect,point))
MessageBox("hello"); CView::OnLButtonDown(nFlags, point);}
还有个问题,绘图时,位图可以随着窗口大小而变化大小和位置,以致于不产生错位。Static控件怎么实现?