为何在图片控件框上不能显示文字?
//图片控件的设置是默认的
void XDlg::OnBnClickedOk()
{
const CWnd *pWnd = GetDlgItem(IDC_PLAY_AREA); //IDC_PLAY_AREA为图片控件ID
const HWND hWnd = pWnd->m_hWnd;
PAINTSTRUCT ps;
const HDC hdc = ::BeginPaint(hWnd, &ps);
TCHAR strText[64]=_T("XXXYYYZZZ");
SetTextColor(hdc, 0xFF00FF);
TextOut(hdc,10, 10, strText, 12);
::EndPaint(hWnd, &ps);
UpdateData(false);
}
[解决办法]
PAINTSTRUCT ps的更新区可能=0。查查。(应该先Invalidate)
[解决办法]
const CWnd *pWnd = GetDlgItem(IDC_PLAY_AREA); //IDC_PLAY_AREA为图片控件IDconst HWND hWnd = pWnd->m_hWnd;PAINTSTRUCT ps; const HDC hdc = ::BeginPaint(hWnd, &ps);TCHAR strText[64]=_T("XXXYYYZZZ"); SetTextColor(hdc, 0xFF00FF);TextOut(hdc,10, 10, strText, 12); ::EndPaint(hWnd, &ps);
[解决办法]
c初试为false
void CXXXDlg::OnPaint() {............................ if(c==true) { const CWnd *pWnd = GetDlgItem(IDC_PLAY_AREA); //IDC_PLAY_AREA为图片控件ID const HWND hWnd = pWnd->m_hWnd; PAINTSTRUCT ps; const HDC hdc = ::BeginPaint(hWnd, &ps); TCHAR strText[64]=_T("XXXYYYZZZ"); SetTextColor(hdc, 0xFF00FF); TextOut(hdc,10, 10, strText, 12); ::EndPaint(hWnd, &ps); }}void CXXXDlg::OnButton1() { // TODO: Add your control notification handler code here c=true; Invalidate(true);// UpdateData(false);}