エディット コントロールのフォントの設定に問題があります。使っSendMessage(hwnd, WM_FONT, args)
ていますが、効果はないようです。メッセージを追加しましEM_SETMODIFY
たが、それも効果がありませんでした。これが私が使用しているコードです:
class EditBox : public Wide::OS::EditBox {
HWND box;
std::unique_ptr<std::decay<decltype(*HFONT())>::type, decltype(&DeleteObject)> font;
Math::AbsolutePoint curr_pos;
Math::AbsolutePoint curr_dim;
public:
void SetFont(std::shared_ptr<Render::Font> f) {
font = decltype(this->font)(CreateFontIndirect(&dynamic_cast<Wide::Direct3D9::Font*>(f.get())->GetLogFont()), &DeleteObject);
SendMessage(box, WM_SETFONT, reinterpret_cast<WPARAM>(font.get()), true);
SendMessage(box, EM_SETMODIFY, true, 0);
}
EditBox(std::shared_ptr<Render::Font> font, HWND owner, Math::AbsolutePoint position, Math::AbsolutePoint dimensions, HINSTANCE hinst)
: curr_pos(position), curr_dim(dimensions), font(CreateFontIndirect(&dynamic_cast<Wide::Direct3D9::Font*>(font.get())->GetLogFont()), &DeleteObject){
box = CreateWindowEx(
0,
L"EDIT",
L"Type here",
WS_VISIBLE | WS_CHILD | WS_TABSTOP | ES_LEFT,
position.x,
position.y,
dimensions.x,
dimensions.y,
owner,
0,
hinst,
0);
/*SetWindowSubclass(box, [](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, UINT_PTR, DWORD_PTR) -> LRESULT {
if (msg != WM_PAINT)
return DefSubclassProc(hwnd, msg, wparam, lparam);
PAINTSTRUCT paint;
BeginPaint(hwnd, &paint);
EndPaint(hwnd, &paint);
return 0;
}, 0, 0);*/
SendMessage(box, WM_SETFONT, reinterpret_cast<WPARAM>(font.get()), true);
SendMessage(box, EM_SETMODIFY, true, 0);
}
~EditBox() { DestroyWindow(box); }
};
返ってきた LOGFONT の値を確認したところ、妥当な値でしたが、リクエストに応じて表示できました。
フォントが変更されていない理由について何か提案はありますか?