HBRUSH CffffDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{....
if(pWnd->GetDlgCtrlID()==IDC_EDIT1);
//pDC->SetTextCharacterExtra(20);//正确
(edit.GetDC())->SetTextCharacterExtra(20);//不正确(edit为控件变量)
...
}
pDC和(edit.GetDC())为什么不同.应该相同啊!
{....
if(pWnd->GetDlgCtrlID()==IDC_EDIT1);
//pDC->SetTextCharacterExtra(20);//正确
(edit.GetDC())->SetTextCharacterExtra(20);//不正确(edit为控件变量)
...
}
pDC和(edit.GetDC())为什么不同.应该相同啊!
The GetDC function retrieves a handle to a display device context (DC) for the client area of a specified window or for the entire screen
OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
CDC* pDC Contains a pointer to the display context for the child window
HWND hWnd // handle to window
);
返回的值为HANDLE,不是DC,因此不能那么用。