這是1樓所示MFC程序的部分代碼: void CMFCApplication2View::OnDraw(CDC* pDC) { CMFCApplication2Doc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return;
// TODO: 在此處為本機數據添加繪製代碼 pDC->TextOut(0, 0, TEXT("在此處為本機數據添加繪製代碼"));
TCHAR text[100]; RECT rect; ::GetClientRect(::GetParent(m_hWnd), &rect); _stprintf_s(text, TEXT("父窗口客戶區大小: %d x %d"), rect.right - rect.left, rect.bottom - rect.top); pDC->TextOut(0, 16, text);
GetClientRect(&rect); _stprintf_s(text, TEXT("子窗口客戶區大小: %d x %d"), rect.right - rect.left, rect.bottom - rect.top); pDC->TextOut(0, 32, text);
RECT rcParentWnd; ::GetWindowRect(::GetParent(m_hWnd), &rcParentWnd); GetWindowRect(&rect); _stprintf_s(text, TEXT("子窗口相對於父窗口的位置: (%d, %d)"), rect.left - rcParentWnd.left, rect.top - rcParentWnd.top); pDC->TextOut(0, 48, text); }
void CMFCApplication2View::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: 在此添加消息處理程序代碼和/或調用默認值 ::SetWindowText(::GetParent(m_hWnd), TEXT("yes")); ::SetWindowText(m_hWnd, TEXT("no")); // 子窗口根本就沒有標題欄,所以這句毫無作用
CView::OnLButtonDown(nFlags, point); }
|