Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Static control |
| 3 | * |
| 4 | * Copyright David W. Metcalfe, 1993 |
| 5 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 8664b89 | 1996-04-05 14:58:24 +0000 | [diff] [blame] | 19 | */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 20 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 21 | #include "windef.h" |
| 22 | #include "wingdi.h" |
Michael Veksler | ca1bc86 | 1999-01-01 18:57:33 +0000 | [diff] [blame] | 23 | #include "wine/winuser16.h" |
Alexandre Julliard | 0ca051e | 2002-10-17 16:43:42 +0000 | [diff] [blame] | 24 | #include "wownt32.h" |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 25 | #include "cursoricon.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 26 | #include "controls.h" |
Alexandre Julliard | a41b2cf | 2001-01-15 20:12:55 +0000 | [diff] [blame] | 27 | #include "user.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 28 | #include "wine/debug.h" |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 29 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 30 | WINE_DEFAULT_DEBUG_CHANNEL(static); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 31 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 32 | static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style ); |
| 33 | static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style ); |
| 34 | static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style ); |
| 35 | static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style ); |
| 36 | static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, DWORD style ); |
| 37 | static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style ); |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 38 | static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 39 | static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 40 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 41 | static COLORREF color_windowframe, color_background, color_window; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 42 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 43 | /* offsets for GetWindowLong for static private information */ |
| 44 | #define HFONT_GWL_OFFSET 0 |
| 45 | #define HICON_GWL_OFFSET (sizeof(HFONT)) |
| 46 | #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON)) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 47 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 48 | typedef void (*pfPaint)( HWND hwnd, HDC hdc, DWORD style ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 49 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 50 | static pfPaint staticPaintFunc[SS_TYPEMASK+1] = |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 51 | { |
Alexandre Julliard | 8664b89 | 1996-04-05 14:58:24 +0000 | [diff] [blame] | 52 | STATIC_PaintTextfn, /* SS_LEFT */ |
| 53 | STATIC_PaintTextfn, /* SS_CENTER */ |
| 54 | STATIC_PaintTextfn, /* SS_RIGHT */ |
| 55 | STATIC_PaintIconfn, /* SS_ICON */ |
| 56 | STATIC_PaintRectfn, /* SS_BLACKRECT */ |
| 57 | STATIC_PaintRectfn, /* SS_GRAYRECT */ |
| 58 | STATIC_PaintRectfn, /* SS_WHITERECT */ |
| 59 | STATIC_PaintRectfn, /* SS_BLACKFRAME */ |
| 60 | STATIC_PaintRectfn, /* SS_GRAYFRAME */ |
| 61 | STATIC_PaintRectfn, /* SS_WHITEFRAME */ |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 62 | NULL, /* Not defined */ |
Alexandre Julliard | 8664b89 | 1996-04-05 14:58:24 +0000 | [diff] [blame] | 63 | STATIC_PaintTextfn, /* SS_SIMPLE */ |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 64 | STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */ |
Luc Tourangeau | e84b678 | 2000-02-07 16:01:04 +0000 | [diff] [blame] | 65 | STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */ |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 66 | STATIC_PaintBitmapfn, /* SS_BITMAP */ |
| 67 | NULL, /* SS_ENHMETAFILE */ |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 68 | STATIC_PaintEtchedfn, /* SS_ETCHEDHORIZ */ |
| 69 | STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */ |
| 70 | STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 74 | /********************************************************************* |
| 75 | * static class descriptor |
| 76 | */ |
| 77 | const struct builtin_class_descr STATIC_builtin_class = |
| 78 | { |
| 79 | "Static", /* name */ |
| 80 | CS_GLOBALCLASS | CS_DBLCLKS | CS_PARENTDC, /* style */ |
| 81 | StaticWndProcA, /* procA */ |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 82 | StaticWndProcW, /* procW */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 83 | STATIC_EXTRA_BYTES, /* extra */ |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 84 | IDC_ARROWA, /* cursor */ |
| 85 | 0 /* brush */ |
| 86 | }; |
| 87 | |
| 88 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 89 | /*********************************************************************** |
| 90 | * STATIC_SetIcon |
| 91 | * |
| 92 | * Set the icon for an SS_ICON control. |
| 93 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 94 | static HICON STATIC_SetIcon( HWND hwnd, HICON hicon, DWORD style ) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 95 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 96 | HICON prevIcon; |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 97 | CURSORICONINFO *info = hicon?(CURSORICONINFO *) GlobalLock16(HICON_16(hicon)):NULL; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 98 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 99 | if ((style & SS_TYPEMASK) != SS_ICON) return 0; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 100 | if (hicon && !info) { |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 101 | ERR("huh? hicon!=0, but info=0???\n"); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 102 | return 0; |
| 103 | } |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 104 | prevIcon = (HICON)SetWindowLongA( hwnd, HICON_GWL_OFFSET, (LONG)hicon ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 105 | if (hicon) |
| 106 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 107 | SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight, |
Alexandre Julliard | 01d6346 | 1997-01-20 19:43:45 +0000 | [diff] [blame] | 108 | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER ); |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 109 | GlobalUnlock16(HICON_16(hicon)); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 110 | } |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 111 | return prevIcon; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 112 | } |
| 113 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 114 | /*********************************************************************** |
| 115 | * STATIC_SetBitmap |
| 116 | * |
| 117 | * Set the bitmap for an SS_BITMAP control. |
| 118 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 119 | static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style ) |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 120 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 121 | HBITMAP hOldBitmap; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 122 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 123 | if ((style & SS_TYPEMASK) != SS_BITMAP) return 0; |
Huw D M Davies | df78d68 | 1999-07-25 11:15:54 +0000 | [diff] [blame] | 124 | if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) { |
| 125 | ERR("huh? hBitmap!=0, but not bitmap\n"); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 126 | return 0; |
| 127 | } |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 128 | hOldBitmap = (HBITMAP)SetWindowLongA( hwnd, HICON_GWL_OFFSET, (LONG)hBitmap ); |
Huw D M Davies | df78d68 | 1999-07-25 11:15:54 +0000 | [diff] [blame] | 129 | if (hBitmap) |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 130 | { |
Huw D M Davies | df78d68 | 1999-07-25 11:15:54 +0000 | [diff] [blame] | 131 | BITMAP bm; |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 132 | GetObjectW(hBitmap, sizeof(bm), &bm); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 133 | SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight, |
Huw D M Davies | df78d68 | 1999-07-25 11:15:54 +0000 | [diff] [blame] | 134 | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 135 | } |
Huw D M Davies | df78d68 | 1999-07-25 11:15:54 +0000 | [diff] [blame] | 136 | return hOldBitmap; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 139 | /*********************************************************************** |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 140 | * STATIC_LoadIconA |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 141 | * |
| 142 | * Load the icon for an SS_ICON control. |
| 143 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 144 | static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name ) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 145 | { |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 146 | HINSTANCE hInstance = (HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 147 | HICON hicon = LoadIconA( hInstance, name ); |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 148 | if (!hicon) hicon = LoadIconA( 0, name ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 149 | return hicon; |
| 150 | } |
| 151 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 152 | /*********************************************************************** |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 153 | * STATIC_LoadIconW |
| 154 | * |
| 155 | * Load the icon for an SS_ICON control. |
| 156 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 157 | static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name ) |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 158 | { |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 159 | HINSTANCE hInstance = (HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 160 | HICON hicon = LoadIconW( hInstance, name ); |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 161 | if (!hicon) hicon = LoadIconW( 0, name ); |
| 162 | return hicon; |
| 163 | } |
| 164 | |
| 165 | /*********************************************************************** |
| 166 | * STATIC_LoadBitmapA |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 167 | * |
| 168 | * Load the bitmap for an SS_BITMAP control. |
| 169 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 170 | static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name ) |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 171 | { |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 172 | HINSTANCE hInstance = (HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 173 | HBITMAP hbitmap = LoadBitmapA( hInstance, name ); |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 174 | if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */ |
| 175 | hbitmap = LoadBitmapA( 0, name ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 176 | return hbitmap; |
| 177 | } |
| 178 | |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 179 | /*********************************************************************** |
| 180 | * STATIC_LoadBitmapW |
| 181 | * |
| 182 | * Load the bitmap for an SS_BITMAP control. |
| 183 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 184 | static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name ) |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 185 | { |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 186 | HINSTANCE hInstance = (HINSTANCE)GetWindowLongA( hwnd, GWL_HINSTANCE ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 187 | HBITMAP hbitmap = LoadBitmapW( hInstance, name ); |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 188 | if (!hbitmap) /* Try OEM icon (FIXME: is this right?) */ |
| 189 | hbitmap = LoadBitmapW( 0, name ); |
| 190 | return hbitmap; |
| 191 | } |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 192 | |
| 193 | /*********************************************************************** |
Guy Albertelli | bde5cf0 | 2002-01-31 21:02:17 +0000 | [diff] [blame] | 194 | * STATIC_TryPaintFcn |
| 195 | * |
| 196 | * Try to immediately paint the control. |
| 197 | */ |
| 198 | static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style) |
| 199 | { |
| 200 | LONG style = full_style & SS_TYPEMASK; |
| 201 | RECT rc; |
| 202 | |
| 203 | GetClientRect( hwnd, &rc ); |
| 204 | if (!IsRectEmpty(&rc) && IsWindowVisible(hwnd) && staticPaintFunc[style]) |
| 205 | { |
| 206 | HDC hdc; |
| 207 | hdc = GetDC( hwnd ); |
| 208 | (staticPaintFunc[style])( hwnd, hdc, full_style ); |
| 209 | ReleaseDC( hwnd, hdc ); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | /*********************************************************************** |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 214 | * StaticWndProc_common |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 215 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 216 | static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam, |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 217 | LPARAM lParam, BOOL unicode ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 218 | { |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 219 | LRESULT lResult = 0; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 220 | LONG full_style = GetWindowLongA( hwnd, GWL_STYLE ); |
| 221 | LONG style = full_style & SS_TYPEMASK; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 222 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 223 | switch (uMsg) |
| 224 | { |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 225 | case WM_CREATE: |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 226 | if (style < 0L || style > SS_TYPEMASK) |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 227 | { |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 228 | ERR("Unknown style 0x%02lx\n", style ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 229 | return -1; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 230 | } |
| 231 | /* initialise colours */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 232 | color_windowframe = GetSysColor(COLOR_WINDOWFRAME); |
| 233 | color_background = GetSysColor(COLOR_BACKGROUND); |
| 234 | color_window = GetSysColor(COLOR_WINDOW); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 235 | break; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 236 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 237 | case WM_NCDESTROY: |
Huw D M Davies | 1fea6b9 | 1998-12-07 12:50:14 +0000 | [diff] [blame] | 238 | if (style == SS_ICON) { |
| 239 | /* |
| 240 | * FIXME |
| 241 | * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 242 | * |
Huw D M Davies | 1fea6b9 | 1998-12-07 12:50:14 +0000 | [diff] [blame] | 243 | * We don't want to do this yet because DestroyIcon32 is broken. If the icon |
| 244 | * had already been loaded by the application the last thing we want to do is |
| 245 | * GlobalFree16 the handle. |
| 246 | */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 247 | break; |
| 248 | } |
| 249 | else return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) : |
| 250 | DefWindowProcA(hwnd, uMsg, wParam, lParam); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 251 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 252 | case WM_PAINT: |
| 253 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 254 | PAINTSTRUCT ps; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 255 | BeginPaint(hwnd, &ps); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 256 | if (staticPaintFunc[style]) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 257 | (staticPaintFunc[style])( hwnd, ps.hdc, full_style ); |
| 258 | EndPaint(hwnd, &ps); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 259 | } |
| 260 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 261 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 262 | case WM_ENABLE: |
Dmitry Timoshkov | aba60df | 2002-04-09 01:34:48 +0000 | [diff] [blame] | 263 | InvalidateRect(hwnd, NULL, TRUE); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 264 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 265 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 266 | case WM_SYSCOLORCHANGE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 267 | color_windowframe = GetSysColor(COLOR_WINDOWFRAME); |
| 268 | color_background = GetSysColor(COLOR_BACKGROUND); |
| 269 | color_window = GetSysColor(COLOR_WINDOW); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 270 | InvalidateRect(hwnd, NULL, TRUE); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 271 | break; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 272 | |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 273 | case WM_NCCREATE: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 274 | if ((TWEAK_WineLook > WIN31_LOOK) && (full_style & SS_SUNKEN)) |
| 275 | SetWindowLongA( hwnd, GWL_EXSTYLE, |
| 276 | GetWindowLongA( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE ); |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 277 | |
| 278 | if(unicode) |
| 279 | lParam = (LPARAM)(((LPCREATESTRUCTW)lParam)->lpszName); |
| 280 | else |
| 281 | lParam = (LPARAM)(((LPCREATESTRUCTA)lParam)->lpszName); |
| 282 | /* fall through */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 283 | case WM_SETTEXT: |
Guy Albertelli | bde5cf0 | 2002-01-31 21:02:17 +0000 | [diff] [blame] | 284 | switch (style) { |
| 285 | case SS_ICON: |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 286 | { |
| 287 | HICON hIcon; |
| 288 | if(unicode) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 289 | hIcon = STATIC_LoadIconW(hwnd, (LPCWSTR)lParam); |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 290 | else |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 291 | hIcon = STATIC_LoadIconA(hwnd, (LPCSTR)lParam); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 292 | /* FIXME : should we also return the previous hIcon here ??? */ |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 293 | STATIC_SetIcon(hwnd, hIcon, style); |
Guy Albertelli | bde5cf0 | 2002-01-31 21:02:17 +0000 | [diff] [blame] | 294 | break; |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 295 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 296 | case SS_BITMAP: |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 297 | { |
| 298 | HBITMAP hBitmap; |
| 299 | if(unicode) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 300 | hBitmap = STATIC_LoadBitmapW(hwnd, (LPCWSTR)lParam); |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 301 | else |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 302 | hBitmap = STATIC_LoadBitmapA(hwnd, (LPCSTR)lParam); |
| 303 | STATIC_SetBitmap(hwnd, hBitmap, style); |
Guy Albertelli | bde5cf0 | 2002-01-31 21:02:17 +0000 | [diff] [blame] | 304 | break; |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 305 | } |
Guy Albertelli | bde5cf0 | 2002-01-31 21:02:17 +0000 | [diff] [blame] | 306 | case SS_LEFT: |
| 307 | case SS_CENTER: |
| 308 | case SS_RIGHT: |
| 309 | case SS_SIMPLE: |
| 310 | case SS_LEFTNOWORDWRAP: |
| 311 | { |
| 312 | if (HIWORD(lParam)) |
| 313 | { |
| 314 | if(unicode) |
| 315 | lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam ); |
| 316 | else |
| 317 | lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam ); |
| 318 | } |
| 319 | if (uMsg == WM_SETTEXT) |
| 320 | STATIC_TryPaintFcn( hwnd, full_style ); |
| 321 | break; |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 322 | } |
Guy Albertelli | bde5cf0 | 2002-01-31 21:02:17 +0000 | [diff] [blame] | 323 | default: |
| 324 | if (HIWORD(lParam)) |
| 325 | { |
| 326 | if(unicode) |
| 327 | lResult = DefWindowProcW( hwnd, WM_SETTEXT, wParam, lParam ); |
| 328 | else |
| 329 | lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam ); |
| 330 | } |
| 331 | if(uMsg == WM_SETTEXT) |
Dmitry Timoshkov | aba60df | 2002-04-09 01:34:48 +0000 | [diff] [blame] | 332 | InvalidateRect(hwnd, NULL, TRUE); |
Guy Albertelli | bde5cf0 | 2002-01-31 21:02:17 +0000 | [diff] [blame] | 333 | } |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 334 | return 1; /* success. FIXME: check text length */ |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 335 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 336 | case WM_SETFONT: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 337 | if ((style == SS_ICON) || (style == SS_BITMAP)) return 0; |
| 338 | SetWindowLongA( hwnd, HFONT_GWL_OFFSET, wParam ); |
Dmitry Timoshkov | aba60df | 2002-04-09 01:34:48 +0000 | [diff] [blame] | 339 | if (LOWORD(lParam)) |
| 340 | InvalidateRect( hwnd, NULL, TRUE ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 341 | break; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 342 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 343 | case WM_GETFONT: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 344 | return GetWindowLongA( hwnd, HFONT_GWL_OFFSET ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 345 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 346 | case WM_NCHITTEST: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 347 | if (full_style & SS_NOTIFY) |
| 348 | return HTCLIENT; |
Serge Ivanov | bfe15b1 | 2000-06-01 22:46:51 +0000 | [diff] [blame] | 349 | else |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 350 | return HTTRANSPARENT; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 351 | |
| 352 | case WM_GETDLGCODE: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 353 | return DLGC_STATIC; |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 354 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 355 | case STM_GETIMAGE: |
| 356 | case STM_GETICON16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 357 | case STM_GETICON: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 358 | return GetWindowLongA( hwnd, HICON_GWL_OFFSET ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 359 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 360 | case STM_SETIMAGE: |
Huw D M Davies | d552d98 | 2000-06-11 20:00:33 +0000 | [diff] [blame] | 361 | switch(wParam) { |
| 362 | case IMAGE_BITMAP: |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 363 | lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, style ); |
Huw D M Davies | d552d98 | 2000-06-11 20:00:33 +0000 | [diff] [blame] | 364 | break; |
| 365 | case IMAGE_ICON: |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 366 | lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, style ); |
Huw D M Davies | d552d98 | 2000-06-11 20:00:33 +0000 | [diff] [blame] | 367 | break; |
| 368 | default: |
| 369 | FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam); |
| 370 | break; |
| 371 | } |
Dmitry Timoshkov | aba60df | 2002-04-09 01:34:48 +0000 | [diff] [blame] | 372 | InvalidateRect( hwnd, NULL, TRUE ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 373 | break; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 374 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 375 | case STM_SETICON16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 376 | case STM_SETICON: |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 377 | lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, style ); |
Dmitry Timoshkov | aba60df | 2002-04-09 01:34:48 +0000 | [diff] [blame] | 378 | InvalidateRect( hwnd, NULL, TRUE ); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 379 | break; |
| 380 | |
| 381 | default: |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 382 | return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) : |
| 383 | DefWindowProcA(hwnd, uMsg, wParam, lParam); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 384 | } |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 385 | return lResult; |
| 386 | } |
| 387 | |
| 388 | /*********************************************************************** |
| 389 | * StaticWndProcA |
| 390 | */ |
| 391 | static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) |
| 392 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 393 | if (!IsWindow( hWnd )) return 0; |
| 394 | return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE); |
Dmitry Timoshkov | 009c1f8 | 2001-01-05 22:20:57 +0000 | [diff] [blame] | 395 | } |
| 396 | |
| 397 | /*********************************************************************** |
| 398 | * StaticWndProcW |
| 399 | */ |
| 400 | static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) |
| 401 | { |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 402 | if (!IsWindow( hWnd )) return 0; |
| 403 | return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 404 | } |
| 405 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 406 | static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style ) |
Luc Tourangeau | e84b678 | 2000-02-07 16:01:04 +0000 | [diff] [blame] | 407 | { |
| 408 | DRAWITEMSTRUCT dis; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 409 | LONG id = GetWindowLongA( hwnd, GWL_ID ); |
Luc Tourangeau | e84b678 | 2000-02-07 16:01:04 +0000 | [diff] [blame] | 410 | |
| 411 | dis.CtlType = ODT_STATIC; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 412 | dis.CtlID = id; |
Luc Tourangeau | e84b678 | 2000-02-07 16:01:04 +0000 | [diff] [blame] | 413 | dis.itemID = 0; |
| 414 | dis.itemAction = ODA_DRAWENTIRE; |
| 415 | dis.itemState = 0; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 416 | dis.hwndItem = hwnd; |
Luc Tourangeau | e84b678 | 2000-02-07 16:01:04 +0000 | [diff] [blame] | 417 | dis.hDC = hdc; |
| 418 | dis.itemData = 0; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 419 | GetClientRect( hwnd, &dis.rcItem ); |
Luc Tourangeau | e84b678 | 2000-02-07 16:01:04 +0000 | [diff] [blame] | 420 | |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 421 | SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd ); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 422 | SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis ); |
Luc Tourangeau | e84b678 | 2000-02-07 16:01:04 +0000 | [diff] [blame] | 423 | } |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 424 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 425 | static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 426 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 427 | RECT rc; |
| 428 | HBRUSH hBrush; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 429 | HFONT hFont; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 430 | WORD wFormat; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 431 | INT len; |
| 432 | WCHAR *text; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 433 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 434 | GetClientRect( hwnd, &rc); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 435 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 436 | switch (style & SS_TYPEMASK) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 437 | { |
| 438 | case SS_LEFT: |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 439 | wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 440 | break; |
| 441 | |
| 442 | case SS_CENTER: |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 443 | wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 444 | break; |
| 445 | |
| 446 | case SS_RIGHT: |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 447 | wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK | DT_NOCLIP; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 448 | break; |
| 449 | |
| 450 | case SS_SIMPLE: |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 451 | wFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOCLIP; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 452 | break; |
| 453 | |
| 454 | case SS_LEFTNOWORDWRAP: |
Niclas Karlsson | a0dc4e4 | 1999-01-23 12:22:20 +0000 | [diff] [blame] | 455 | wFormat = DT_LEFT | DT_EXPANDTABS | DT_VCENTER; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 456 | break; |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 457 | |
| 458 | default: |
| 459 | return; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | if (style & SS_NOPREFIX) |
| 463 | wFormat |= DT_NOPREFIX; |
| 464 | |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 465 | if ((hFont = (HFONT)GetWindowLongA( hwnd, HFONT_GWL_OFFSET ))) SelectObject( hdc, hFont ); |
Francis Beaudet | 2862362 | 1999-09-20 18:28:08 +0000 | [diff] [blame] | 466 | |
Gerard Patel | 0e805aa | 2000-07-16 14:39:21 +0000 | [diff] [blame] | 467 | if ((style & SS_NOPREFIX) || ((style & SS_TYPEMASK) != SS_SIMPLE)) |
| 468 | { |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 469 | hBrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, |
| 470 | (WPARAM)hdc, (LPARAM)hwnd ); |
Gerard Patel | d36a3ef | 2001-03-10 19:16:26 +0000 | [diff] [blame] | 471 | if (!hBrush) /* did the app forget to call defwindowproc ? */ |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 472 | hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC, |
| 473 | (WPARAM)hdc, (LPARAM)hwnd); |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 474 | FillRect( hdc, &rc, hBrush ); |
Gerard Patel | 0e805aa | 2000-07-16 14:39:21 +0000 | [diff] [blame] | 475 | } |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 476 | if (!IsWindowEnabled(hwnd)) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); |
Francis Beaudet | 2862362 | 1999-09-20 18:28:08 +0000 | [diff] [blame] | 477 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 478 | if (!(len = SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ))) return; |
| 479 | if (!(text = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return; |
| 480 | SendMessageW( hwnd, WM_GETTEXT, len + 1, (LPARAM)text ); |
| 481 | DrawTextW( hdc, text, -1, &rc, wFormat ); |
| 482 | HeapFree( GetProcessHeap(), 0, text ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 483 | } |
| 484 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 485 | static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style ) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 486 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 487 | RECT rc; |
| 488 | HBRUSH hBrush; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 489 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 490 | GetClientRect( hwnd, &rc); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 491 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 492 | switch (style & SS_TYPEMASK) |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 493 | { |
| 494 | case SS_BLACKRECT: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 495 | hBrush = CreateSolidBrush(color_windowframe); |
| 496 | FillRect( hdc, &rc, hBrush ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 497 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 498 | case SS_GRAYRECT: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 499 | hBrush = CreateSolidBrush(color_background); |
| 500 | FillRect( hdc, &rc, hBrush ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 501 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 502 | case SS_WHITERECT: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 503 | hBrush = CreateSolidBrush(color_window); |
| 504 | FillRect( hdc, &rc, hBrush ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 505 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 506 | case SS_BLACKFRAME: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 507 | hBrush = CreateSolidBrush(color_windowframe); |
| 508 | FrameRect( hdc, &rc, hBrush ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 509 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 510 | case SS_GRAYFRAME: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 511 | hBrush = CreateSolidBrush(color_background); |
| 512 | FrameRect( hdc, &rc, hBrush ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 513 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 514 | case SS_WHITEFRAME: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 515 | hBrush = CreateSolidBrush(color_window); |
| 516 | FrameRect( hdc, &rc, hBrush ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 517 | break; |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 518 | default: |
| 519 | return; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 520 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 521 | DeleteObject( hBrush ); |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 525 | static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style ) |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 526 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 527 | RECT rc; |
| 528 | HBRUSH hbrush; |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 529 | HICON hIcon; |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 530 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 531 | GetClientRect( hwnd, &rc ); |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 532 | hbrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, |
| 533 | (WPARAM)hdc, (LPARAM)hwnd ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 534 | FillRect( hdc, &rc, hbrush ); |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 535 | if ((hIcon = (HICON)GetWindowLongA( hwnd, HICON_GWL_OFFSET ))) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 536 | DrawIcon( hdc, rc.left, rc.top, hIcon ); |
Alexandre Julliard | e399fc3 | 1993-11-24 17:08:56 +0000 | [diff] [blame] | 537 | } |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 538 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 539 | static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style ) |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 540 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 541 | RECT rc; |
| 542 | HBRUSH hbrush; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 543 | HDC hMemDC; |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 544 | HBITMAP hBitmap, oldbitmap; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 545 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 546 | GetClientRect( hwnd, &rc ); |
Michael Stefaniuc | ec5612e | 2002-10-30 23:45:38 +0000 | [diff] [blame] | 547 | hbrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, |
| 548 | (WPARAM)hdc, (LPARAM)hwnd ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 549 | FillRect( hdc, &rc, hbrush ); |
Huw D M Davies | df78d68 | 1999-07-25 11:15:54 +0000 | [diff] [blame] | 550 | |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 551 | if ((hBitmap = (HBITMAP)GetWindowLongA( hwnd, HICON_GWL_OFFSET ))) |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 552 | { |
Huw D M Davies | df78d68 | 1999-07-25 11:15:54 +0000 | [diff] [blame] | 553 | BITMAP bm; |
| 554 | SIZE sz; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 555 | |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 556 | if(GetObjectType(hBitmap) != OBJ_BITMAP) return; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 557 | if (!(hMemDC = CreateCompatibleDC( hdc ))) return; |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 558 | GetObjectW(hBitmap, sizeof(bm), &bm); |
| 559 | GetBitmapDimensionEx(hBitmap, &sz); |
| 560 | oldbitmap = SelectObject(hMemDC, hBitmap); |
Huw D M Davies | df78d68 | 1999-07-25 11:15:54 +0000 | [diff] [blame] | 561 | BitBlt(hdc, sz.cx, sz.cy, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, |
| 562 | SRCCOPY); |
| 563 | SelectObject(hMemDC, oldbitmap); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 564 | DeleteDC(hMemDC); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 565 | } |
| 566 | } |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 567 | |
| 568 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 569 | static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style ) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 570 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 571 | RECT rc; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 572 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 573 | if (TWEAK_WineLook == WIN31_LOOK) |
| 574 | return; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 575 | |
Alexandre Julliard | de42428 | 2001-08-10 22:51:42 +0000 | [diff] [blame] | 576 | GetClientRect( hwnd, &rc ); |
| 577 | switch (style & SS_TYPEMASK) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 578 | { |
| 579 | case SS_ETCHEDHORZ: |
Marcus Meissner | 2e48a2c | 1999-10-31 17:36:26 +0000 | [diff] [blame] | 580 | DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 581 | break; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 582 | case SS_ETCHEDVERT: |
Marcus Meissner | 2e48a2c | 1999-10-31 17:36:26 +0000 | [diff] [blame] | 583 | DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 584 | break; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 585 | case SS_ETCHEDFRAME: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 586 | DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 587 | break; |
| 588 | } |
| 589 | } |