diff options
author | George Hazan <george.hazan@gmail.com> | 2023-11-03 13:28:25 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-11-03 13:28:25 +0300 |
commit | 50691aaecfc2e3206271825403d1a0d3338c6b4d (patch) | |
tree | f998515a4f35551def9584e6f09ed5402984247b /libs | |
parent | fa0e1943d5a6eeb5502b0c68f0170f05d76d6a95 (diff) |
fixes #3778 (NewStory: в предпросмотре шаблонов заработал цвет текста, но не фона)
Diffstat (limited to 'libs')
-rw-r--r-- | libs/mTextControl/src/textcontrol.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/libs/mTextControl/src/textcontrol.cpp b/libs/mTextControl/src/textcontrol.cpp index 5a871d42e5..2391ecc1ac 100644 --- a/libs/mTextControl/src/textcontrol.cpp +++ b/libs/mTextControl/src/textcontrol.cpp @@ -24,6 +24,7 @@ struct TextControlData HANDLE htu; wchar_t *text; struct TextObject *mtext; + COLORREF clBack = -1; }; /// Paint //////////////////////////////////// @@ -32,17 +33,25 @@ static LRESULT MTextControl_OnPaint(HWND hwnd) { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); + + // Find the text to draw + TextControlData *data = (TextControlData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + + SetTextColor(hdc, RGB(0, 0, 0)); + SetBkMode(hdc, TRANSPARENT); { RECT rc; GetClientRect(hwnd, &rc); + + if (data->clBack != -1) { + HBRUSH hbr = CreateSolidBrush(data->clBack); + FillRect(hdc, &rc, hbr); + DeleteObject(hbr); + } + FrameRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); } - SetTextColor(hdc, RGB(0, 0, 0)); - SetBkMode(hdc, TRANSPARENT); - - // Find the text to draw - TextControlData *data = (TextControlData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (data->mtext) { HFONT hfntSave = nullptr; HFONT hfnt = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0); @@ -109,6 +118,11 @@ static LRESULT CALLBACK MTextControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, InvalidateRect(hwnd, nullptr, TRUE); return TRUE; + case MTM_SETBKCOLOR: + data->clBack = wParam; + InvalidateRect(hwnd, nullptr, TRUE); + return TRUE; + case MTM_UPDATEEX: if (data->text) { delete[] data->text; |