ウィンドウ機能には、メッセージを受信する機能と、描画先のデバイス コンテキストの所有権が含まれます。 ウィンドウレス リッチ エディット コントロールは、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 関数の呼び出しによってこのハンドルが既に取得されていることを前提としています。
コード例全体
関連トピック