void COpenGlDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
m_ocdn.SpecialKeys(nChar, m_mouse.x, m_mouse.y);//图像旋转
CWnd* hwnd = GetDlgItem(IDC_STA_OPENGL);
RECT rect;
//GetClientRect(&rect);
//hwnd->GetClientRect(&rect);
hwnd->GetWindowRect(&rect); hwnd->ScreenToClient(&rect); InvalidateRect(&rect,true);
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
这是我的代码
出现的问题是我刷新的区域和我获得的控件区域不一致!
谁能帮帮忙!
{
// TODO: Add your message handler code here and/or call default
m_ocdn.SpecialKeys(nChar, m_mouse.x, m_mouse.y);//图像旋转
CWnd* hwnd = GetDlgItem(IDC_STA_OPENGL);
RECT rect;
//GetClientRect(&rect);
//hwnd->GetClientRect(&rect);
hwnd->GetWindowRect(&rect); hwnd->ScreenToClient(&rect); InvalidateRect(&rect,true);
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
这是我的代码
出现的问题是我刷新的区域和我获得的控件区域不一致!
谁能帮帮忙!
hwnd->GetClientRect(&rect); // hwnd 的 client 坐标
hwnd->ClientToScreen(&rect); // hwnd 的 client 坐标 -》 屏幕坐标
this->ScreenToClient(&rect); // 屏幕坐标 => this的client坐标
InvalidateRect(&rect,true); // this的client坐标上Invalidate
如果是让 IDC_STA_OPENGL 重画:
GetDlgItem(IDC_STA_OPENGL)->Invalidate();
可以考虑1楼的,简单易懂。