From bde5cf0bc23acaa06831e8100ff104ccd608bdef Mon Sep 17 00:00:00 2001 From: Guy Albertelli Date: Thu, 31 Jan 2002 21:02:17 +0000 Subject: [PATCH] Paint control immediately on WM_SETTEXT. --- controls/static.c | 79 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 12 deletions(-) diff --git a/controls/static.c b/controls/static.c index 8724a8449d..28857386a4 100644 --- a/controls/static.c +++ b/controls/static.c @@ -176,6 +176,26 @@ static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name ) return hbitmap; } +/*********************************************************************** + * STATIC_TryPaintFcn + * + * Try to immediately paint the control. + */ +static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style) +{ + LONG style = full_style & SS_TYPEMASK; + RECT rc; + + GetClientRect( hwnd, &rc ); + if (!IsRectEmpty(&rc) && IsWindowVisible(hwnd) && staticPaintFunc[style]) + { + HDC hdc; + hdc = GetDC( hwnd ); + (staticPaintFunc[style])( hwnd, hdc, full_style ); + ReleaseDC( hwnd, hdc ); + } +} + /*********************************************************************** * StaticWndProc_common */ @@ -247,7 +267,8 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, lParam = (LPARAM)(((LPCREATESTRUCTA)lParam)->lpszName); /* fall through */ case WM_SETTEXT: - if (style == SS_ICON) + switch (style) { + case SS_ICON: { HICON hIcon; if(unicode) @@ -256,8 +277,9 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam); /* FIXME : should we also return the previous hIcon here ??? */ STATIC_SetIcon(hwnd, hIcon, style); + break; } - else if (style == SS_BITMAP) + case SS_BITMAP: { HBITMAP hBitmap; if(unicode) @@ -265,23 +287,56 @@ static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, else hBitmap = STATIC_LoadBitmapA(hwnd, (LPCSTR)lParam); STATIC_SetBitmap(hwnd, hBitmap, style); + break; } - else if (HIWORD(lParam)) - { - if(unicode) - lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam ); - else - lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam ); + case SS_LEFT: + case SS_CENTER: + case SS_RIGHT: + case SS_SIMPLE: + case SS_LEFTNOWORDWRAP: + { + if (HIWORD(lParam)) + { + if(unicode) + lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam ); + else + lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam ); + } + if (uMsg == WM_SETTEXT) + STATIC_TryPaintFcn( hwnd, full_style ); + break; + } + default: + if (HIWORD(lParam)) + { + if(unicode) + lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam ); + else + lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam ); + } + if(uMsg == WM_SETTEXT) + InvalidateRect(hwnd, NULL, FALSE); } - if(uMsg == WM_SETTEXT) - InvalidateRect(hwnd, NULL, FALSE); return 1; /* success. FIXME: check text length */ case WM_SETFONT: if ((style == SS_ICON) || (style == SS_BITMAP)) return 0; SetWindowLongA( hwnd, HFONT_GWL_OFFSET, wParam ); - if (LOWORD(lParam)) - InvalidateRect( hwnd, NULL, FALSE ); + switch (style) { + case SS_LEFT: + case SS_CENTER: + case SS_RIGHT: + case SS_SIMPLE: + case SS_LEFTNOWORDWRAP: + { + if (uMsg == WM_SETTEXT) + STATIC_TryPaintFcn( hwnd, full_style ); + break; + } + default: + if (LOWORD(lParam)) + InvalidateRect( hwnd, NULL, FALSE ); + } break; case WM_GETFONT: -- 2.32.0.93.g670b81a890