From c2dda4c1d27f5d033cdb02ea55b03e9798a2d57f Mon Sep 17 00:00:00 2001 From: trustable-code Date: Sat, 31 Aug 2019 13:16:22 +0200 Subject: Fix #50 Label color doesn't change using textColor (Windows) --- src/nigui/private/windows/platform_impl.nim | 11 +++++++---- src/nigui/private/windows/windows.nim | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nigui/private/windows/platform_impl.nim b/src/nigui/private/windows/platform_impl.nim index dce331c..b171ff8 100755 --- a/src/nigui/private/windows/platform_impl.nim +++ b/src/nigui/private/windows/platform_impl.nim @@ -191,12 +191,11 @@ proc pCommonWndProc(hWnd: pointer, uMsg: int32, wParam, lParam: pointer): pointe let control = cast[Control](pGetWindowLongPtr(lParam, GWLP_USERDATA)) var evt = new TextChangeEvent control.handleTextChangeEvent(evt) - of WM_CTLCOLOREDIT: + of WM_CTLCOLORSTATIC, WM_CTLCOLOREDIT: let control = cast[Control](pGetWindowLongPtr(lParam, GWLP_USERDATA)) discard SetTextColor(wParam, control.textColor.pColorToRGB32()) - # discard SetBkColor(wParam, control.backgroundColor.pColorToRGB32()) - # does not cover complete background - return GetCurrentObject(wParam, OBJ_BRUSH) + discard SetBkColor(wParam, control.backgroundColor.pColorToRGB32()) + return CreateSolidBrush(control.backgroundColor.pColorToRGB32) else: discard result = DefWindowProcA(hWnd, uMsg, wParam, lParam) @@ -1472,6 +1471,10 @@ method `selectionStart=`(textBox: NativeTextBox, selectionStart: int) = method `selectionEnd=`(textBox: NativeTextBox, selectionEnd: int) = discard SendMessageA(textBox.fHandle, EM_SETSEL, cast[pointer](textBox.selectionStart), cast[pointer](selectionEnd)) +method resetBackgroundColor(textBox: NativeTextBox) = + # textBox.setBackgroundColor(rgb(255, 255, 0)) + textBox.setBackgroundColor(GetSysColor(COLOR_WINDOW).pRgb32ToColor()) + textBox.fUseDefaultBackgroundColor = true # ---------------------------------------------------------------------------------------- # TextArea diff --git a/src/nigui/private/windows/windows.nim b/src/nigui/private/windows/windows.nim index f359358..709bdc3 100755 --- a/src/nigui/private/windows/windows.nim +++ b/src/nigui/private/windows/windows.nim @@ -41,6 +41,7 @@ const BS_GROUPBOX* = 0x00000007 CF_TEXT* = 1 COLOR_BTNFACE* = 15 + COLOR_WINDOW* = 5 COLOR_WINDOWTEXT* = 8 CP_UTF8* = 65001 CS_HREDRAW* = 2 @@ -141,6 +142,7 @@ const WM_SYSKEYDOWN* = 260 WM_SYSCOMMAND* = 274 WM_CTLCOLOREDIT* = 307 + WM_CTLCOLORSTATIC* = 312 WM_CUT* = 0x0300 WM_COPY* = 0x0301 WM_PASTE* = 0x0302 -- cgit v1.2.3