창 기능에는 메시지를 수신하는 기능과 그리기 위한 디바이스 컨텍스트의 소유권이 포함됩니다. 창 없는 서식 있는 편집 컨트롤은 두 개의 인터페이스로 이루어진 ITextServices와 ITextHost을 통해 이 기능을 받습니다.
알아야 할 사항
기술
필수 구성 요소
- C/C++
- Windows 사용자 인터페이스 프로그래밍
지시
창 기능 설정
다음 예제 코드에서는 텍스트 호스트 및 텍스트 서비스를 만드는 방법을 보여 줍니다.
HRESULT hr;
IUnknown* pUnk = NULL;
ITextServices* pTextServices = NULL;
// Create an instance of the application-defined object that implements the ITextHost interface.
TextHost* pTextHost = new TextHost();
if (pTextHost == NULL)
goto errorHandler;
// Create an instance of the text services object.
hr = CreateTextServices(NULL, pTextHost, &pUnk);
if (FAILED(hr))
goto errorHandler;
// Retrieve the IID_ITextServices interface identifier from Msftedit.dll.
IID* pIID_ITS = (IID*) (VOID*) GetProcAddress(hmodRichEdit, "IID_ITextServices");
// Retrieve the ITextServices interface.
hr = pUnk->QueryInterface(*pIID_ITS, (void **)&pTextServices);
if (FAILED(hr))
goto errorHandler;
발언
코드 예제의 hmodRichEdit 매개 변수는 Msftedit.dll 모듈에 대한 핸들이며 GetModuleHandle 함수를 호출하여 이 핸들을 이미 검색한 것으로 가정합니다.
전체 예제
관련 항목