CWnd::SetWindowText

지정한 텍스트 창의 제목을 설정합니다.

void SetWindowText(
   LPCTSTR lpszString 
);

매개 변수

  • lpszString
    가리키는 있는 CString 개체 또는 새 컨트롤 또는 제목 텍스트로 사용 되는 null로 끝나는 문자열입니다.

설명

창의 컨트롤인 경우 컨트롤 내의 텍스트 설정 됩니다.

이 함수는 WM_SETTEXT 이 창에 보낼 메시지입니다.

예제

// set the text in IDC_EDITNAME
CWnd* pWnd = GetDlgItem(IDC_EDITNAME);
pWnd->SetWindowText(_T("Gerald Samper"));

// Get the text back. CString is convenient, because MFC
// will automatically allocate enough memory to hold the
// text--no matter how large it is.

CString str;
pWnd->GetWindowText(str);
ASSERT(str == _T("Gerald Samper"));

// The LPTSTR override works, too, but it might be too short.
// If we supply a buffer that's too small, we'll only get those
// characters that fit.

TCHAR sz[10];
int nRet = pWnd->GetWindowText(sz, 10);

// Nine characters, plus terminating null
ASSERT(_tcscmp(sz, _T("Gerald Sa")) == 0);
ASSERT(nRet == 9);

// You can query the length of the text without the length of
// the string using CWnd::GetWindowTextLength()
nRet = pWnd->GetWindowTextLength();
ASSERT(nRet == 13);

요구 사항

헤더: afxwin.h

참고 항목

참조

CWnd 클래스

계층 구조 차트

CWnd::GetWindowText

SetWindowText