*.h里面:
HWND hrcWnd;
::OnRButtonUp( .. CPoint point )
{
::GetCursorPos(&point); //获取当前鼠标位置
CWnd *srcWnd=WindowFromPoint(point ); //返回鼠标所在窗口的指针
hrcWnd=srcWnd->m_hWnd;
}
::OnFoo()
{CRect range;
CWnd srcWnd;
srcWnd.Attach(hrcWnd);//截取图像的窗口句柄hrcWnd 转换成CWnd对象
//Attach这里出错。
srcWnd.GetWindowRect(&range);
...
}
奇怪的是:执行CWnd *srcWnd=WindowFromPoint(point ); 之后,
srcWnd->m_hWnd 0x00a50276
unused CXX0030: Error: expression cannot be evaluated
执行完hrcWnd=srcWnd->m_hWnd; 之后,
hrcWnd 自然也是 0x00a50276,
unused CXX0030: Error: expression cannot be evaluated
(unused是在Debug中看到的)