Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1 | /* |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 2 | * Combo controls |
| 3 | * |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 4 | * Copyright 1997 Alex Korobka |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 5 | * |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 6 | * FIXME: roll up in Netscape 3.01. |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 7 | */ |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 8 | |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 9 | #include <string.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 10 | |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 11 | #include "winbase.h" |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 12 | #include "windef.h" |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 13 | #include "wingdi.h" |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 14 | #include "winuser.h" |
Alex Korobka | 311d329 | 1999-01-01 18:40:02 +0000 | [diff] [blame] | 15 | #include "wine/winuser16.h" |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 16 | #include "win.h" |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 17 | #include "spy.h" |
Alexandre Julliard | 3a405ba | 1994-10-30 16:25:19 +0000 | [diff] [blame] | 18 | #include "user.h" |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 19 | #include "heap.h" |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 20 | #include "combo.h" |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 21 | #include "drive.h" |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 22 | #include "debugtools.h" |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 23 | #include "tweak.h" |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 24 | |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 25 | DEFAULT_DEBUG_CHANNEL(combo) |
| 26 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 27 | /* bits in the dwKeyData */ |
| 28 | #define KEYDATA_ALT 0x2000 |
| 29 | #define KEYDATA_PREVSTATE 0x4000 |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 30 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 31 | /* |
| 32 | * Additional combo box definitions |
| 33 | */ |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 34 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 35 | #define CB_GETPTR( wnd ) (*(LPHEADCOMBO*)((wnd)->wExtra)) |
| 36 | #define CB_NOTIFY( lphc, code ) \ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 37 | (SendMessageA( (lphc)->owner, WM_COMMAND, \ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 38 | MAKEWPARAM((lphc)->self->wIDmenu, (code)), (lphc)->self->hwndSelf)) |
| 39 | #define CB_GETEDITTEXTLENGTH( lphc ) \ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 40 | (SendMessageA( (lphc)->hWndEdit, WM_GETTEXTLENGTH, 0, 0 )) |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 41 | |
Gerard Patel | 8c36254 | 1999-10-13 13:50:17 +0000 | [diff] [blame] | 42 | #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03) |
| 43 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 44 | /* |
| 45 | * Drawing globals |
| 46 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 47 | static HBITMAP hComboBmp = 0; |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 48 | static UINT CBitHeight, CBitWidth; |
| 49 | |
| 50 | /* |
| 51 | * Look and feel dependant "constants" |
| 52 | */ |
Abey George | 318832e | 1999-07-10 11:34:01 +0000 | [diff] [blame] | 53 | |
| 54 | #define COMBO_YBORDERGAP 5 |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 55 | #define COMBO_XBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 ) |
| 56 | #define COMBO_YBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 ) |
| 57 | #define COMBO_EDITBUTTONSPACE() ( (TWEAK_WineLook == WIN31_LOOK) ? 8 : 0 ) |
| 58 | #define EDIT_CONTROL_PADDING() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 1 ) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 59 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 60 | /*********************************************************************** |
| 61 | * COMBO_Init |
| 62 | * |
| 63 | * Load combo button bitmap. |
| 64 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 65 | static BOOL COMBO_Init() |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 66 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 67 | HDC hDC; |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 68 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 69 | if( hComboBmp ) return TRUE; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 70 | if( (hDC = CreateCompatibleDC(0)) ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 71 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 72 | BOOL bRet = FALSE; |
| 73 | if( (hComboBmp = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_COMBO))) ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 74 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 75 | BITMAP bm; |
| 76 | HBITMAP hPrevB; |
| 77 | RECT r; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 78 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 79 | GetObjectA( hComboBmp, sizeof(bm), &bm ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 80 | CBitHeight = bm.bmHeight; |
| 81 | CBitWidth = bm.bmWidth; |
| 82 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 83 | TRACE("combo bitmap [%i,%i]\n", CBitWidth, CBitHeight ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 84 | |
| 85 | hPrevB = SelectObject16( hDC, hComboBmp); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 86 | SetRect( &r, 0, 0, CBitWidth, CBitHeight ); |
| 87 | InvertRect( hDC, &r ); |
| 88 | SelectObject( hDC, hPrevB ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 89 | bRet = TRUE; |
| 90 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 91 | DeleteDC( hDC ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 92 | return bRet; |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 93 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 94 | return FALSE; |
| 95 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 96 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 97 | /*********************************************************************** |
| 98 | * COMBO_NCCreate |
| 99 | */ |
| 100 | static LRESULT COMBO_NCCreate(WND* wnd, LPARAM lParam) |
| 101 | { |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 102 | LPHEADCOMBO lphc; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 103 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 104 | if ( wnd && COMBO_Init() && |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 105 | (lphc = HeapAlloc(GetProcessHeap(), 0, sizeof(HEADCOMBO))) ) |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 106 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 107 | LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 108 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 109 | memset( lphc, 0, sizeof(HEADCOMBO) ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 110 | *(LPHEADCOMBO*)wnd->wExtra = lphc; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 111 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 112 | /* some braindead apps do try to use scrollbar/border flags */ |
| 113 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 114 | lphc->dwStyle = (lpcs->style & ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL)); |
| 115 | wnd->dwStyle &= ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 116 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 117 | /* |
| 118 | * We also have to remove the client edge style to make sure |
| 119 | * we don't end-up with a non client area. |
| 120 | */ |
| 121 | wnd->dwExStyle &= ~(WS_EX_CLIENTEDGE); |
| 122 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 123 | if( !(lpcs->style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) ) |
| 124 | lphc->dwStyle |= CBS_HASSTRINGS; |
| 125 | if( !(wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) ) |
| 126 | lphc->wState |= CBF_NOTIFY; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 127 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 128 | TRACE("[0x%08x], style = %08x\n", |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 129 | (UINT)lphc, lphc->dwStyle ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 130 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 131 | return (LRESULT)(UINT)wnd->hwndSelf; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 132 | } |
| 133 | return (LRESULT)FALSE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /*********************************************************************** |
| 137 | * COMBO_NCDestroy |
| 138 | */ |
| 139 | static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc ) |
| 140 | { |
| 141 | |
| 142 | if( lphc ) |
| 143 | { |
| 144 | WND* wnd = lphc->self; |
| 145 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 146 | TRACE("[%04x]: freeing storage\n", CB_HWND(lphc)); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 147 | |
| 148 | if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 149 | DestroyWindow( lphc->hWndLBox ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 150 | |
| 151 | HeapFree( GetProcessHeap(), 0, lphc ); |
| 152 | wnd->wExtra[0] = 0; |
| 153 | } |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 154 | return 0; |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 157 | /*********************************************************************** |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 158 | * CBGetTextAreaHeight |
| 159 | * |
| 160 | * This method will calculate the height of the text area of the |
| 161 | * combobox. |
| 162 | * The height of the text area is set in two ways. |
| 163 | * It can be set explicitely through a combobox message of through a |
| 164 | * WM_MEASUREITEM callback. |
| 165 | * If this is not the case, the height is set to 13 dialog units. |
| 166 | * This height was determined through experimentation. |
| 167 | */ |
| 168 | static INT CBGetTextAreaHeight( |
| 169 | HWND hwnd, |
| 170 | LPHEADCOMBO lphc) |
| 171 | { |
| 172 | INT iTextItemHeight; |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 173 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 174 | if( lphc->editHeight ) /* explicitly set height */ |
| 175 | { |
| 176 | iTextItemHeight = lphc->editHeight; |
| 177 | } |
| 178 | else |
| 179 | { |
| 180 | TEXTMETRICA tm; |
| 181 | HDC hDC = GetDC(hwnd); |
| 182 | HFONT hPrevFont = 0; |
| 183 | INT baseUnitY; |
| 184 | |
| 185 | if (lphc->hFont) |
| 186 | hPrevFont = SelectObject( hDC, lphc->hFont ); |
| 187 | |
| 188 | GetTextMetricsA(hDC, &tm); |
| 189 | |
| 190 | baseUnitY = tm.tmHeight; |
| 191 | |
| 192 | if( hPrevFont ) |
| 193 | SelectObject( hDC, hPrevFont ); |
| 194 | |
| 195 | ReleaseDC(hwnd, hDC); |
| 196 | |
| 197 | iTextItemHeight = ((13 * baseUnitY) / 8); |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 198 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 199 | /* |
| 200 | * This "formula" calculates the height of the complete control. |
| 201 | * To calculate the height of the text area, we have to remove the |
| 202 | * borders. |
| 203 | */ |
| 204 | iTextItemHeight -= 2*COMBO_YBORDERSIZE(); |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | * Check the ownerdraw case if we haven't asked the parent the size |
| 209 | * of the item yet. |
| 210 | */ |
| 211 | if ( CB_OWNERDRAWN(lphc) && |
| 212 | (lphc->wState & CBF_MEASUREITEM) ) |
| 213 | { |
| 214 | MEASUREITEMSTRUCT measureItem; |
| 215 | RECT clientRect; |
| 216 | INT originalItemHeight = iTextItemHeight; |
| 217 | |
| 218 | /* |
| 219 | * We use the client rect for the width of the item. |
| 220 | */ |
| 221 | GetClientRect(hwnd, &clientRect); |
| 222 | |
| 223 | lphc->wState &= ~CBF_MEASUREITEM; |
| 224 | |
| 225 | /* |
| 226 | * Send a first one to measure the size of the text area |
| 227 | */ |
| 228 | measureItem.CtlType = ODT_COMBOBOX; |
| 229 | measureItem.CtlID = lphc->self->wIDmenu; |
| 230 | measureItem.itemID = -1; |
| 231 | measureItem.itemWidth = clientRect.right; |
| 232 | measureItem.itemHeight = iTextItemHeight - 6; /* ownerdrawn cb is taller */ |
| 233 | measureItem.itemData = 0; |
| 234 | SendMessageA(lphc->owner, WM_MEASUREITEM, |
| 235 | (WPARAM)measureItem.CtlID, (LPARAM)&measureItem); |
| 236 | iTextItemHeight = 6 + measureItem.itemHeight; |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 237 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 238 | /* |
| 239 | * Send a second one in the case of a fixed ownerdraw list to calculate the |
| 240 | * size of the list items. (we basically do this on behalf of the listbox) |
| 241 | */ |
| 242 | if (lphc->dwStyle & CBS_OWNERDRAWFIXED) |
| 243 | { |
| 244 | measureItem.CtlType = ODT_COMBOBOX; |
| 245 | measureItem.CtlID = lphc->self->wIDmenu; |
| 246 | measureItem.itemID = 0; |
| 247 | measureItem.itemWidth = clientRect.right; |
| 248 | measureItem.itemHeight = originalItemHeight; |
| 249 | measureItem.itemData = 0; |
| 250 | SendMessageA(lphc->owner, WM_MEASUREITEM, |
| 251 | (WPARAM)measureItem.CtlID, (LPARAM)&measureItem); |
| 252 | lphc->fixedOwnerDrawHeight = measureItem.itemHeight; |
| 253 | } |
| 254 | |
| 255 | /* |
| 256 | * Keep the size for the next time |
| 257 | */ |
| 258 | lphc->editHeight = iTextItemHeight; |
| 259 | } |
| 260 | |
| 261 | return iTextItemHeight; |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Jim Aston | aebda22 | 1999-11-07 21:04:57 +0000 | [diff] [blame] | 264 | /*********************************************************************** |
| 265 | * CBForceDummyResize |
| 266 | * |
| 267 | * The dummy resize is used for listboxes that have a popup to trigger |
| 268 | * a re-arranging of the contents of the combobox and the recalculation |
| 269 | * of the size of the "real" control window. |
| 270 | */ |
| 271 | static void CBForceDummyResize( |
| 272 | LPHEADCOMBO lphc) |
| 273 | { |
| 274 | RECT windowRect; |
| 275 | int newComboHeight; |
| 276 | |
| 277 | newComboHeight = CBGetTextAreaHeight(CB_HWND(lphc),lphc) + 2*COMBO_YBORDERSIZE(); |
| 278 | |
| 279 | GetWindowRect(CB_HWND(lphc), &windowRect); |
| 280 | |
| 281 | /* |
| 282 | * We have to be careful, resizing a combobox also has the meaning that the |
| 283 | * dropped rect will be resized. In this case, we want to trigger a resize |
| 284 | * to recalculate layout but we don't want to change the dropped rectangle |
| 285 | * So, we pass the height of text area of control as the height. |
| 286 | * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING |
| 287 | * message. |
| 288 | */ |
| 289 | SetWindowPos( CB_HWND(lphc), |
| 290 | (HWND)NULL, |
| 291 | 0, 0, |
| 292 | windowRect.right - windowRect.left, |
| 293 | newComboHeight, |
| 294 | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE ); |
| 295 | } |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 296 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 297 | /*********************************************************************** |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 298 | * CBCalcPlacement |
| 299 | * |
| 300 | * Set up component coordinates given valid lphc->RectCombo. |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 301 | */ |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 302 | static void CBCalcPlacement( |
| 303 | HWND hwnd, |
| 304 | LPHEADCOMBO lphc, |
| 305 | LPRECT lprEdit, |
| 306 | LPRECT lprButton, |
| 307 | LPRECT lprLB) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 308 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 309 | /* |
| 310 | * Again, start with the client rectangle. |
| 311 | */ |
| 312 | GetClientRect(hwnd, lprEdit); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 313 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 314 | /* |
| 315 | * Remove the borders |
| 316 | */ |
| 317 | InflateRect(lprEdit, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE()); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 318 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 319 | /* |
| 320 | * Chop off the bottom part to fit with the height of the text area. |
| 321 | */ |
| 322 | lprEdit->bottom = lprEdit->top + CBGetTextAreaHeight(hwnd, lphc); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 323 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 324 | /* |
| 325 | * The button starts the same vertical position as the text area. |
| 326 | */ |
| 327 | CopyRect(lprButton, lprEdit); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 328 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 329 | /* |
| 330 | * If the combobox is "simple" there is no button. |
| 331 | */ |
| 332 | if( CB_GETTYPE(lphc) == CBS_SIMPLE ) |
| 333 | lprButton->left = lprButton->right = lprButton->bottom = 0; |
| 334 | else |
| 335 | { |
| 336 | /* |
| 337 | * Let's assume the combobox button is the same width as the |
| 338 | * scrollbar button. |
| 339 | * size the button horizontally and cut-off the text area. |
| 340 | */ |
| 341 | lprButton->left = lprButton->right - GetSystemMetrics(SM_CXVSCROLL); |
| 342 | lprEdit->right = lprButton->left; |
| 343 | } |
| 344 | |
| 345 | /* |
| 346 | * In the case of a dropdown, there is an additional spacing between the |
| 347 | * text area and the button. |
| 348 | */ |
| 349 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) |
| 350 | { |
| 351 | lprEdit->right -= COMBO_EDITBUTTONSPACE(); |
| 352 | } |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 353 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 354 | /* |
| 355 | * If we have an edit control, we space it away from the borders slightly. |
| 356 | */ |
| 357 | if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST) |
| 358 | { |
| 359 | InflateRect(lprEdit, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING()); |
| 360 | } |
| 361 | |
| 362 | /* |
| 363 | * Adjust the size of the listbox popup. |
| 364 | */ |
| 365 | if( CB_GETTYPE(lphc) == CBS_SIMPLE ) |
| 366 | { |
| 367 | /* |
| 368 | * Use the client rectangle to initialize the listbox rectangle |
| 369 | */ |
| 370 | GetClientRect(hwnd, lprLB); |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 371 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 372 | /* |
| 373 | * Then, chop-off the top part. |
| 374 | */ |
| 375 | lprLB->top = lprEdit->bottom + COMBO_YBORDERSIZE(); |
| 376 | } |
| 377 | else |
| 378 | { |
| 379 | /* |
| 380 | * Make sure the dropped width is as large as the combobox itself. |
| 381 | */ |
| 382 | if (lphc->droppedWidth < (lprButton->right + COMBO_XBORDERSIZE())) |
| 383 | { |
| 384 | lprLB->right = lprLB->left + (lprButton->right + COMBO_XBORDERSIZE()); |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 385 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 386 | /* |
| 387 | * In the case of a dropdown, the popup listbox is offset to the right. |
| 388 | * so, we want to make sure it's flush with the right side of the |
| 389 | * combobox |
| 390 | */ |
| 391 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) |
| 392 | lprLB->right -= COMBO_EDITBUTTONSPACE(); |
| 393 | } |
| 394 | else |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 395 | lprLB->right = lprLB->left + lphc->droppedWidth; |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 396 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 397 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 398 | TRACE("\ttext\t= (%i,%i-%i,%i)\n", |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 399 | lprEdit->left, lprEdit->top, lprEdit->right, lprEdit->bottom); |
| 400 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 401 | TRACE("\tbutton\t= (%i,%i-%i,%i)\n", |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 402 | lprButton->left, lprButton->top, lprButton->right, lprButton->bottom); |
| 403 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 404 | TRACE("\tlbox\t= (%i,%i-%i,%i)\n", |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 405 | lprLB->left, lprLB->top, lprLB->right, lprLB->bottom ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | /*********************************************************************** |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 409 | * CBGetDroppedControlRect |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 410 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 411 | static void CBGetDroppedControlRect( LPHEADCOMBO lphc, LPRECT lpRect) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 412 | { |
Francois Boisvert | 3b876e4 | 1999-05-14 18:37:28 +0000 | [diff] [blame] | 413 | /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner |
| 414 | of the combo box and the lower right corner of the listbox */ |
| 415 | |
| 416 | GetWindowRect(lphc->self->hwndSelf, lpRect); |
| 417 | |
| 418 | lpRect->right = lpRect->left + lphc->droppedRect.right - lphc->droppedRect.left; |
| 419 | lpRect->bottom = lpRect->top + lphc->droppedRect.bottom - lphc->droppedRect.top; |
| 420 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | /*********************************************************************** |
| 424 | * COMBO_WindowPosChanging |
| 425 | */ |
| 426 | static LRESULT COMBO_WindowPosChanging( |
| 427 | HWND hwnd, |
| 428 | LPHEADCOMBO lphc, |
| 429 | WINDOWPOS* posChanging) |
| 430 | { |
| 431 | /* |
| 432 | * We need to override the WM_WINDOWPOSCHANGING method to handle all |
| 433 | * the non-simple comboboxes. The problem is that those controls are |
| 434 | * always the same height. We have to make sure they are not resized |
| 435 | * to another value. |
| 436 | */ |
Francis Beaudet | ab6f861 | 1999-04-22 09:08:09 +0000 | [diff] [blame] | 437 | if ( ( CB_GETTYPE(lphc) != CBS_SIMPLE ) && |
| 438 | ((posChanging->flags & SWP_NOSIZE) == 0) ) |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 439 | { |
Francis Beaudet | ab6f861 | 1999-04-22 09:08:09 +0000 | [diff] [blame] | 440 | int newComboHeight; |
| 441 | |
| 442 | newComboHeight = CBGetTextAreaHeight(hwnd,lphc) + |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 443 | 2*COMBO_YBORDERSIZE(); |
Francis Beaudet | ab6f861 | 1999-04-22 09:08:09 +0000 | [diff] [blame] | 444 | |
| 445 | /* |
| 446 | * Resizing a combobox has another side effect, it resizes the dropped |
| 447 | * rectangle as well. However, it does it only if the new height for the |
| 448 | * combobox is different than the height it should have. In other words, |
| 449 | * if the application resizing the combobox only had the intention to resize |
| 450 | * the actual control, for example, to do the layout of a dialog that is |
| 451 | * resized, the height of the dropdown is not changed. |
| 452 | */ |
| 453 | if (posChanging->cy != newComboHeight) |
| 454 | { |
| 455 | lphc->droppedRect.bottom = lphc->droppedRect.top + posChanging->cy - newComboHeight; |
| 456 | |
| 457 | posChanging->cy = newComboHeight; |
| 458 | } |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | return 0; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | /*********************************************************************** |
| 465 | * COMBO_Create |
| 466 | */ |
| 467 | static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, LPARAM lParam) |
| 468 | { |
| 469 | static char clbName[] = "ComboLBox"; |
| 470 | static char editName[] = "Edit"; |
| 471 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 472 | LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 473 | |
| 474 | if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE; |
David Grant | 8a92213 | 2000-05-30 17:48:33 +0000 | [diff] [blame] | 475 | if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT; |
| 476 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 477 | lphc->self = wnd; |
| 478 | lphc->owner = lpcs->hwndParent; |
| 479 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 480 | /* |
| 481 | * The item height and dropped width are not set when the control |
| 482 | * is created. |
| 483 | */ |
| 484 | lphc->droppedWidth = lphc->editHeight = 0; |
| 485 | |
| 486 | /* |
| 487 | * The first time we go through, we want to measure the ownerdraw item |
| 488 | */ |
| 489 | lphc->wState |= CBF_MEASUREITEM; |
| 490 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 491 | /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */ |
| 492 | |
| 493 | if( lphc->owner || !(lpcs->style & WS_VISIBLE) ) |
| 494 | { |
Francis Beaudet | bc0b020 | 1999-07-30 17:57:45 +0000 | [diff] [blame] | 495 | UINT lbeStyle = 0; |
| 496 | UINT lbeExStyle = 0; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 497 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 498 | /* |
| 499 | * Initialize the dropped rect to the size of the client area of the |
| 500 | * control and then, force all the areas of the combobox to be |
| 501 | * recalculated. |
| 502 | */ |
| 503 | GetClientRect( wnd->hwndSelf, &lphc->droppedRect ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 504 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 505 | CBCalcPlacement(wnd->hwndSelf, |
| 506 | lphc, |
| 507 | &lphc->textRect, |
| 508 | &lphc->buttonRect, |
| 509 | &lphc->droppedRect ); |
| 510 | |
| 511 | /* |
| 512 | * Adjust the position of the popup listbox if it's necessary |
| 513 | */ |
| 514 | if ( CB_GETTYPE(lphc) != CBS_SIMPLE ) |
| 515 | { |
| 516 | lphc->droppedRect.top = lphc->textRect.bottom + COMBO_YBORDERSIZE(); |
| 517 | |
| 518 | /* |
| 519 | * If it's a dropdown, the listbox is offset |
| 520 | */ |
| 521 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) |
| 522 | lphc->droppedRect.left += COMBO_EDITBUTTONSPACE(); |
| 523 | |
| 524 | ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect); |
| 525 | ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect.right); |
| 526 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 527 | |
| 528 | /* create listbox popup */ |
| 529 | |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 530 | lbeStyle = (LBS_NOTIFY | WS_BORDER | WS_CLIPSIBLINGS | WS_CHILD) | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 531 | (lpcs->style & (WS_VSCROLL | CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)); |
| 532 | |
| 533 | if( lphc->dwStyle & CBS_SORT ) |
| 534 | lbeStyle |= LBS_SORT; |
| 535 | if( lphc->dwStyle & CBS_HASSTRINGS ) |
| 536 | lbeStyle |= LBS_HASSTRINGS; |
| 537 | if( lphc->dwStyle & CBS_NOINTEGRALHEIGHT ) |
| 538 | lbeStyle |= LBS_NOINTEGRALHEIGHT; |
| 539 | if( lphc->dwStyle & CBS_DISABLENOSCROLL ) |
| 540 | lbeStyle |= LBS_DISABLENOSCROLL; |
| 541 | |
| 542 | if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* child listbox */ |
Francis Beaudet | bc0b020 | 1999-07-30 17:57:45 +0000 | [diff] [blame] | 543 | { |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 544 | lbeStyle |= WS_VISIBLE; |
Francis Beaudet | bc0b020 | 1999-07-30 17:57:45 +0000 | [diff] [blame] | 545 | |
| 546 | /* |
| 547 | * In win 95 look n feel, the listbox in the simple combobox has |
| 548 | * the WS_EXCLIENTEDGE style instead of the WS_BORDER style. |
| 549 | */ |
| 550 | if (TWEAK_WineLook > WIN31_LOOK) |
| 551 | { |
| 552 | lbeStyle &= ~WS_BORDER; |
| 553 | lbeExStyle |= WS_EX_CLIENTEDGE; |
| 554 | } |
| 555 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 556 | |
Francis Beaudet | bc0b020 | 1999-07-30 17:57:45 +0000 | [diff] [blame] | 557 | lphc->hWndLBox = CreateWindowExA(lbeExStyle, |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 558 | clbName, |
| 559 | NULL, |
| 560 | lbeStyle, |
| 561 | lphc->droppedRect.left, |
| 562 | lphc->droppedRect.top, |
| 563 | lphc->droppedRect.right - lphc->droppedRect.left, |
| 564 | lphc->droppedRect.bottom - lphc->droppedRect.top, |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 565 | lphc->self->hwndSelf, |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 566 | (HMENU)ID_CB_LISTBOX, |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 567 | lphc->self->hInstance, |
| 568 | (LPVOID)lphc ); |
| 569 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 570 | if( lphc->hWndLBox ) |
| 571 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 572 | BOOL bEdit = TRUE; |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 573 | lbeStyle = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_LEFT | ES_COMBO; |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 574 | |
| 575 | /* |
| 576 | * In Win95 look, the border fo the edit control is |
| 577 | * provided by the combobox |
| 578 | */ |
| 579 | if (TWEAK_WineLook == WIN31_LOOK) |
| 580 | lbeStyle |= WS_BORDER; |
| 581 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 582 | if( lphc->wState & CBF_EDIT ) |
| 583 | { |
| 584 | if( lphc->dwStyle & CBS_OEMCONVERT ) |
| 585 | lbeStyle |= ES_OEMCONVERT; |
| 586 | if( lphc->dwStyle & CBS_AUTOHSCROLL ) |
| 587 | lbeStyle |= ES_AUTOHSCROLL; |
| 588 | if( lphc->dwStyle & CBS_LOWERCASE ) |
| 589 | lbeStyle |= ES_LOWERCASE; |
| 590 | else if( lphc->dwStyle & CBS_UPPERCASE ) |
| 591 | lbeStyle |= ES_UPPERCASE; |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 592 | |
| 593 | lphc->hWndEdit = CreateWindowExA(0, |
| 594 | editName, |
| 595 | NULL, |
| 596 | lbeStyle, |
| 597 | lphc->textRect.left, lphc->textRect.top, |
| 598 | lphc->textRect.right - lphc->textRect.left, |
| 599 | lphc->textRect.bottom - lphc->textRect.top, |
| 600 | lphc->self->hwndSelf, |
| 601 | (HMENU)ID_CB_EDIT, |
| 602 | lphc->self->hInstance, |
| 603 | NULL ); |
| 604 | |
| 605 | if( !lphc->hWndEdit ) |
| 606 | bEdit = FALSE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | if( bEdit ) |
| 610 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 611 | if( CB_GETTYPE(lphc) != CBS_SIMPLE ) |
| 612 | { |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 613 | /* Now do the trick with parent */ |
| 614 | SetParent(lphc->hWndLBox, HWND_DESKTOP); |
| 615 | /* |
| 616 | * If the combo is a dropdown, we must resize the control to fit only |
| 617 | * the text area and button. To do this, we send a dummy resize and the |
| 618 | * WM_WINDOWPOSCHANGING message will take care of setting the height for |
| 619 | * us. |
| 620 | */ |
Francis Beaudet | ab6f861 | 1999-04-22 09:08:09 +0000 | [diff] [blame] | 621 | CBForceDummyResize(lphc); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 622 | } |
| 623 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 624 | TRACE("init done\n"); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 625 | return wnd->hwndSelf; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 626 | } |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 627 | ERR("edit control failure.\n"); |
| 628 | } else ERR("listbox failure.\n"); |
| 629 | } else ERR("no owner for visible combo.\n"); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 630 | |
| 631 | /* CreateWindow() will send WM_NCDESTROY to cleanup */ |
| 632 | |
| 633 | return -1; |
| 634 | } |
| 635 | |
| 636 | /*********************************************************************** |
| 637 | * CBPaintButton |
| 638 | * |
| 639 | * Paint combo button (normal, pressed, and disabled states). |
| 640 | */ |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 641 | static void CBPaintButton( |
| 642 | LPHEADCOMBO lphc, |
| 643 | HDC hdc, |
| 644 | RECT rectButton) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 645 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 646 | if( lphc->wState & CBF_NOREDRAW ) |
| 647 | return; |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 648 | |
Francis Beaudet | 28d2ccb | 1999-08-14 15:51:49 +0000 | [diff] [blame] | 649 | if (TWEAK_WineLook == WIN31_LOOK) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 650 | { |
Francis Beaudet | 28d2ccb | 1999-08-14 15:51:49 +0000 | [diff] [blame] | 651 | UINT x, y; |
| 652 | BOOL bBool; |
| 653 | HDC hMemDC; |
| 654 | HBRUSH hPrevBrush; |
| 655 | COLORREF oldTextColor, oldBkColor; |
| 656 | |
| 657 | |
| 658 | hPrevBrush = SelectObject(hdc, GetSysColorBrush(COLOR_BTNFACE)); |
| 659 | |
| 660 | /* |
| 661 | * Draw the button background |
| 662 | */ |
| 663 | PatBlt( hdc, |
| 664 | rectButton.left, |
| 665 | rectButton.top, |
| 666 | rectButton.right-rectButton.left, |
| 667 | rectButton.bottom-rectButton.top, |
| 668 | PATCOPY ); |
| 669 | |
| 670 | if( (bBool = lphc->wState & CBF_BUTTONDOWN) ) |
| 671 | { |
| 672 | DrawEdge( hdc, &rectButton, EDGE_SUNKEN, BF_RECT ); |
| 673 | } |
| 674 | else |
| 675 | { |
| 676 | DrawEdge( hdc, &rectButton, EDGE_RAISED, BF_RECT ); |
| 677 | } |
| 678 | |
| 679 | /* |
| 680 | * Remove the edge of the button from the rectangle |
| 681 | * and calculate the position of the bitmap. |
| 682 | */ |
| 683 | InflateRect( &rectButton, -2, -2); |
| 684 | |
| 685 | x = (rectButton.left + rectButton.right - CBitWidth) >> 1; |
| 686 | y = (rectButton.top + rectButton.bottom - CBitHeight) >> 1; |
| 687 | |
| 688 | |
| 689 | hMemDC = CreateCompatibleDC( hdc ); |
| 690 | SelectObject( hMemDC, hComboBmp ); |
| 691 | oldTextColor = SetTextColor( hdc, GetSysColor(COLOR_BTNFACE) ); |
| 692 | oldBkColor = SetBkColor( hdc, CB_DISABLED(lphc) ? RGB(128,128,128) : |
| 693 | RGB(0,0,0) ); |
| 694 | BitBlt( hdc, x, y, CBitWidth, CBitHeight, hMemDC, 0, 0, SRCCOPY ); |
| 695 | SetBkColor( hdc, oldBkColor ); |
| 696 | SetTextColor( hdc, oldTextColor ); |
| 697 | DeleteDC( hMemDC ); |
| 698 | SelectObject( hdc, hPrevBrush ); |
Huw D M Davies | 2d617be | 1998-12-08 09:14:09 +0000 | [diff] [blame] | 699 | } |
Francis Beaudet | 28d2ccb | 1999-08-14 15:51:49 +0000 | [diff] [blame] | 700 | else |
| 701 | { |
| 702 | UINT buttonState = DFCS_SCROLLCOMBOBOX; |
Huw D M Davies | 2d617be | 1998-12-08 09:14:09 +0000 | [diff] [blame] | 703 | |
Francis Beaudet | 28d2ccb | 1999-08-14 15:51:49 +0000 | [diff] [blame] | 704 | if (lphc->wState & CBF_BUTTONDOWN) |
| 705 | { |
| 706 | buttonState |= DFCS_PUSHED; |
| 707 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 708 | |
Francis Beaudet | f132872 | 1999-09-19 14:09:52 +0000 | [diff] [blame] | 709 | if (CB_DISABLED(lphc)) |
| 710 | { |
| 711 | buttonState |= DFCS_INACTIVE; |
| 712 | } |
| 713 | |
| 714 | DrawFrameControl(hdc, |
Francis Beaudet | 28d2ccb | 1999-08-14 15:51:49 +0000 | [diff] [blame] | 715 | &rectButton, |
| 716 | DFC_SCROLL, |
| 717 | buttonState); |
| 718 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | /*********************************************************************** |
| 722 | * CBPaintText |
| 723 | * |
| 724 | * Paint CBS_DROPDOWNLIST text field / update edit control contents. |
| 725 | */ |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 726 | static void CBPaintText( |
| 727 | LPHEADCOMBO lphc, |
| 728 | HDC hdc, |
| 729 | RECT rectEdit) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 730 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 731 | INT id, size = 0; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 732 | LPSTR pText = NULL; |
| 733 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 734 | if( lphc->wState & CBF_NOREDRAW ) return; |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 735 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 736 | /* follow Windows combobox that sends a bunch of text |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 737 | * inquiries to its listbox while processing WM_PAINT. */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 738 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 739 | if( (id = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0) ) != LB_ERR ) |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 740 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 741 | size = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, id, 0); |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 742 | if( (pText = HeapAlloc( GetProcessHeap(), 0, size + 1)) ) |
| 743 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 744 | SendMessageA( lphc->hWndLBox, LB_GETTEXT, (WPARAM)id, (LPARAM)pText ); |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 745 | pText[size] = '\0'; /* just in case */ |
| 746 | } else return; |
| 747 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 748 | |
| 749 | if( lphc->wState & CBF_EDIT ) |
| 750 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 751 | if( CB_HASSTRINGS(lphc) ) SetWindowTextA( lphc->hWndEdit, pText ? pText : "" ); |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 752 | if( lphc->wState & CBF_FOCUSED ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 753 | SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1)); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 754 | } |
| 755 | else /* paint text field ourselves */ |
| 756 | { |
Francis Beaudet | f132872 | 1999-09-19 14:09:52 +0000 | [diff] [blame] | 757 | UINT itemState; |
| 758 | HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 759 | |
Francis Beaudet | f132872 | 1999-09-19 14:09:52 +0000 | [diff] [blame] | 760 | /* |
| 761 | * Give ourselves some space. |
| 762 | */ |
| 763 | InflateRect( &rectEdit, -1, -1 ); |
| 764 | |
| 765 | if ( (lphc->wState & CBF_FOCUSED) && |
| 766 | !(lphc->wState & CBF_DROPPED) ) |
| 767 | { |
| 768 | /* highlight */ |
| 769 | |
| 770 | FillRect( hdc, &rectEdit, GetSysColorBrush(COLOR_HIGHLIGHT) ); |
| 771 | SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) ); |
| 772 | SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) ); |
| 773 | itemState = ODS_SELECTED | ODS_FOCUS; |
| 774 | } |
| 775 | else |
| 776 | itemState = 0; |
| 777 | |
| 778 | if( CB_OWNERDRAWN(lphc) ) |
| 779 | { |
| 780 | DRAWITEMSTRUCT dis; |
| 781 | HRGN clipRegion; |
| 782 | |
| 783 | /* |
| 784 | * Save the current clip region. |
| 785 | * To retrieve the clip region, we need to create one "dummy" |
| 786 | * clip region. |
| 787 | */ |
| 788 | clipRegion = CreateRectRgnIndirect(&rectEdit); |
| 789 | |
| 790 | if (GetClipRgn(hdc, clipRegion)!=1) |
| 791 | { |
| 792 | DeleteObject(clipRegion); |
| 793 | clipRegion=(HRGN)NULL; |
| 794 | } |
| 795 | |
| 796 | if ( lphc->self->dwStyle & WS_DISABLED ) |
| 797 | itemState |= ODS_DISABLED; |
| 798 | |
| 799 | dis.CtlType = ODT_COMBOBOX; |
| 800 | dis.CtlID = lphc->self->wIDmenu; |
| 801 | dis.hwndItem = lphc->self->hwndSelf; |
| 802 | dis.itemAction = ODA_DRAWENTIRE; |
| 803 | dis.itemID = id; |
| 804 | dis.itemState = itemState; |
| 805 | dis.hDC = hdc; |
| 806 | dis.rcItem = rectEdit; |
| 807 | dis.itemData = SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, |
| 808 | (WPARAM)id, 0 ); |
| 809 | |
| 810 | /* |
| 811 | * Clip the DC and have the parent draw the item. |
| 812 | */ |
| 813 | IntersectClipRect(hdc, |
| 814 | rectEdit.left, rectEdit.top, |
| 815 | rectEdit.right, rectEdit.bottom); |
| 816 | |
| 817 | SendMessageA(lphc->owner, WM_DRAWITEM, |
| 818 | lphc->self->wIDmenu, (LPARAM)&dis ); |
| 819 | |
| 820 | /* |
| 821 | * Reset the clipping region. |
| 822 | */ |
| 823 | SelectClipRgn(hdc, clipRegion); |
| 824 | } |
| 825 | else |
| 826 | { |
| 827 | ExtTextOutA( hdc, |
| 828 | rectEdit.left + 1, |
| 829 | rectEdit.top + 1, |
| 830 | ETO_OPAQUE | ETO_CLIPPED, |
| 831 | &rectEdit, |
| 832 | pText ? pText : "" , size, NULL ); |
| 833 | |
| 834 | if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED)) |
| 835 | DrawFocusRect( hdc, &rectEdit ); |
| 836 | } |
| 837 | |
| 838 | if( hPrevFont ) |
| 839 | SelectObject(hdc, hPrevFont ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 840 | } |
David Luyer | 39413f8 | 1998-10-11 14:36:56 +0000 | [diff] [blame] | 841 | if (pText) |
| 842 | HeapFree( GetProcessHeap(), 0, pText ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | /*********************************************************************** |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 846 | * CBPaintBorder |
| 847 | */ |
| 848 | static void CBPaintBorder( |
| 849 | HWND hwnd, |
| 850 | LPHEADCOMBO lphc, |
| 851 | HDC hdc) |
| 852 | { |
| 853 | RECT clientRect; |
| 854 | |
| 855 | if (CB_GETTYPE(lphc) != CBS_SIMPLE) |
| 856 | { |
| 857 | GetClientRect(hwnd, &clientRect); |
| 858 | } |
| 859 | else |
| 860 | { |
| 861 | CopyRect(&clientRect, &lphc->textRect); |
| 862 | |
| 863 | InflateRect(&clientRect, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING()); |
| 864 | InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE()); |
| 865 | } |
| 866 | |
| 867 | DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT); |
| 868 | } |
| 869 | |
| 870 | /*********************************************************************** |
Francis Beaudet | f132872 | 1999-09-19 14:09:52 +0000 | [diff] [blame] | 871 | * COMBO_PrepareColors |
| 872 | * |
| 873 | * This method will sent the appropriate WM_CTLCOLOR message to |
| 874 | * prepare and setup the colors for the combo's DC. |
| 875 | * |
| 876 | * It also returns the brush to use for the background. |
| 877 | */ |
| 878 | static HBRUSH COMBO_PrepareColors( |
| 879 | HWND hwnd, |
| 880 | LPHEADCOMBO lphc, |
| 881 | HDC hDC) |
| 882 | { |
| 883 | HBRUSH hBkgBrush; |
| 884 | |
| 885 | /* |
| 886 | * Get the background brush for this control. |
| 887 | */ |
| 888 | if (CB_DISABLED(lphc)) |
| 889 | { |
| 890 | hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORSTATIC, |
| 891 | hDC, lphc->self->hwndSelf ); |
| 892 | |
| 893 | /* |
| 894 | * We have to change the text color since WM_CTLCOLORSTATIC will |
| 895 | * set it to the "enabled" color. This is the same behavior as the |
| 896 | * edit control |
| 897 | */ |
| 898 | SetTextColor(hDC, GetSysColor(COLOR_GRAYTEXT)); |
| 899 | } |
| 900 | else |
| 901 | { |
| 902 | if (lphc->wState & CBF_EDIT) |
| 903 | { |
| 904 | hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLOREDIT, |
| 905 | hDC, lphc->self->hwndSelf ); |
| 906 | } |
| 907 | else |
| 908 | { |
| 909 | hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX, |
| 910 | hDC, lphc->self->hwndSelf ); |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | /* |
| 915 | * Catch errors. |
| 916 | */ |
| 917 | if( !hBkgBrush ) |
| 918 | hBkgBrush = GetSysColorBrush(COLOR_WINDOW); |
| 919 | |
| 920 | return hBkgBrush; |
| 921 | } |
| 922 | |
| 923 | /*********************************************************************** |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 924 | * COMBO_EraseBackground |
| 925 | */ |
| 926 | static LRESULT COMBO_EraseBackground( |
| 927 | HWND hwnd, |
| 928 | LPHEADCOMBO lphc, |
| 929 | HDC hParamDC) |
| 930 | { |
| 931 | HBRUSH hBkgBrush; |
| 932 | RECT clientRect; |
| 933 | HDC hDC; |
| 934 | |
| 935 | hDC = (hParamDC) ? hParamDC |
| 936 | : GetDC(hwnd); |
| 937 | |
| 938 | /* |
| 939 | * Calculate the area that we want to erase. |
| 940 | */ |
| 941 | if (CB_GETTYPE(lphc) != CBS_SIMPLE) |
| 942 | { |
| 943 | GetClientRect(hwnd, &clientRect); |
| 944 | } |
| 945 | else |
| 946 | { |
| 947 | CopyRect(&clientRect, &lphc->textRect); |
| 948 | |
| 949 | InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE()); |
| 950 | } |
| 951 | |
Francis Beaudet | f132872 | 1999-09-19 14:09:52 +0000 | [diff] [blame] | 952 | /* |
| 953 | * Retrieve the background brush |
| 954 | */ |
| 955 | hBkgBrush = COMBO_PrepareColors(hwnd, lphc, hDC); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 956 | |
| 957 | FillRect(hDC, &clientRect, hBkgBrush); |
| 958 | |
| 959 | if (!hParamDC) |
| 960 | ReleaseDC(hwnd, hDC); |
| 961 | |
| 962 | return TRUE; |
| 963 | } |
| 964 | |
| 965 | /*********************************************************************** |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 966 | * COMBO_Paint |
| 967 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 968 | static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 969 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 970 | PAINTSTRUCT ps; |
| 971 | HDC hDC; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 972 | |
| 973 | hDC = (hParamDC) ? hParamDC |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 974 | : BeginPaint( lphc->self->hwndSelf, &ps); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 975 | |
| 976 | |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 977 | if( hDC && !(lphc->wState & CBF_NOREDRAW) ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 978 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 979 | HBRUSH hPrevBrush, hBkgBrush; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 980 | |
Francis Beaudet | f132872 | 1999-09-19 14:09:52 +0000 | [diff] [blame] | 981 | /* |
| 982 | * Retrieve the background brush and select it in the |
| 983 | * DC. |
| 984 | */ |
| 985 | hBkgBrush = COMBO_PrepareColors(lphc->self->hwndSelf, lphc, hDC); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 986 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 987 | hPrevBrush = SelectObject( hDC, hBkgBrush ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 988 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 989 | /* |
| 990 | * In non 3.1 look, there is a sunken border on the combobox |
| 991 | */ |
| 992 | if (TWEAK_WineLook != WIN31_LOOK) |
| 993 | { |
| 994 | CBPaintBorder(CB_HWND(lphc), lphc, hDC); |
| 995 | } |
| 996 | |
| 997 | if( !IsRectEmpty(&lphc->buttonRect) ) |
| 998 | { |
| 999 | CBPaintButton(lphc, hDC, lphc->buttonRect); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | if( !(lphc->wState & CBF_EDIT) ) |
| 1003 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1004 | /* |
| 1005 | * The text area has a border only in Win 3.1 look. |
| 1006 | */ |
| 1007 | if (TWEAK_WineLook == WIN31_LOOK) |
| 1008 | { |
| 1009 | HPEN hPrevPen = SelectObject( hDC, GetSysColorPen(COLOR_WINDOWFRAME) ); |
Huw D M Davies | 2d617be | 1998-12-08 09:14:09 +0000 | [diff] [blame] | 1010 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1011 | Rectangle( hDC, |
| 1012 | lphc->textRect.left, lphc->textRect.top, |
| 1013 | lphc->textRect.right - 1, lphc->textRect.bottom - 1); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1014 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1015 | SelectObject( hDC, hPrevPen ); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1016 | } |
| 1017 | |
| 1018 | CBPaintText( lphc, hDC, lphc->textRect); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1019 | } |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1020 | |
| 1021 | if( hPrevBrush ) |
| 1022 | SelectObject( hDC, hPrevBrush ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1023 | } |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1024 | |
| 1025 | if( !hParamDC ) |
| 1026 | EndPaint(lphc->self->hwndSelf, &ps); |
| 1027 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1028 | return 0; |
| 1029 | } |
| 1030 | |
| 1031 | /*********************************************************************** |
| 1032 | * CBUpdateLBox |
| 1033 | * |
| 1034 | * Select listbox entry according to the contents of the edit control. |
| 1035 | */ |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1036 | static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1037 | { |
Dmitry Timoshkov | 38d04b8 | 1999-12-06 00:57:20 +0000 | [diff] [blame] | 1038 | INT length, idx; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1039 | LPSTR pText = NULL; |
| 1040 | |
Dmitry Timoshkov | 38d04b8 | 1999-12-06 00:57:20 +0000 | [diff] [blame] | 1041 | idx = LB_ERR; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1042 | length = CB_GETEDITTEXTLENGTH( lphc ); |
| 1043 | |
| 1044 | if( length > 0 ) |
| 1045 | pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1); |
| 1046 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 1047 | TRACE("\t edit text length %i\n", length ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1048 | |
| 1049 | if( pText ) |
| 1050 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1051 | if( length ) GetWindowTextA( lphc->hWndEdit, pText, length + 1); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1052 | else pText[0] = '\0'; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1053 | idx = SendMessageA( lphc->hWndLBox, LB_FINDSTRING, |
| 1054 | (WPARAM)(-1), (LPARAM)pText ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1055 | HeapFree( GetProcessHeap(), 0, pText ); |
| 1056 | } |
| 1057 | |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1058 | SendMessageA( lphc->hWndLBox, LB_SETCURSEL, (WPARAM)(bSelect ? idx : -1), 0 ); |
| 1059 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1060 | /* probably superfluous but Windows sends this too */ |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1061 | SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)(idx < 0 ? 0 : idx), 0 ); |
| 1062 | SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)(idx < 0 ? 0 : idx), 0 ); |
Dmitry Timoshkov | 38d04b8 | 1999-12-06 00:57:20 +0000 | [diff] [blame] | 1063 | return idx; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1064 | } |
| 1065 | |
| 1066 | /*********************************************************************** |
| 1067 | * CBUpdateEdit |
| 1068 | * |
| 1069 | * Copy a listbox entry to the edit control. |
| 1070 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1071 | static void CBUpdateEdit( LPHEADCOMBO lphc , INT index ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1072 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1073 | INT length; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1074 | LPSTR pText = NULL; |
| 1075 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 1076 | TRACE("\t %i\n", index ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1077 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1078 | if( index >= 0 ) /* got an entry */ |
| 1079 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1080 | length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, (WPARAM)index, 0); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1081 | if( length ) |
| 1082 | { |
| 1083 | if( (pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1)) ) |
| 1084 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1085 | SendMessageA( lphc->hWndLBox, LB_GETTEXT, |
| 1086 | (WPARAM)index, (LPARAM)pText ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1087 | } |
| 1088 | } |
| 1089 | } |
Dmitry Timoshkov | 38d04b8 | 1999-12-06 00:57:20 +0000 | [diff] [blame] | 1090 | |
Gerard Patel | c9e6031 | 2000-06-18 17:20:37 +0000 | [diff] [blame] | 1091 | lphc->wState |= (CBF_NOEDITNOTIFY | CBF_NOLBSELECT); |
Dmitry Timoshkov | 38d04b8 | 1999-12-06 00:57:20 +0000 | [diff] [blame] | 1092 | SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, pText ? (LPARAM)pText : (LPARAM)"" ); |
Gerard Patel | c9e6031 | 2000-06-18 17:20:37 +0000 | [diff] [blame] | 1093 | lphc->wState &= ~(CBF_NOEDITNOTIFY | CBF_NOLBSELECT); |
Dmitry Timoshkov | 38d04b8 | 1999-12-06 00:57:20 +0000 | [diff] [blame] | 1094 | |
David Grant | 8a92213 | 2000-05-30 17:48:33 +0000 | [diff] [blame] | 1095 | if( lphc->wState & CBF_FOCUSED ) |
| 1096 | SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) ); |
| 1097 | |
Dmitry Timoshkov | 38d04b8 | 1999-12-06 00:57:20 +0000 | [diff] [blame] | 1098 | if( pText ) |
| 1099 | HeapFree( GetProcessHeap(), 0, pText ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | /*********************************************************************** |
| 1103 | * CBDropDown |
| 1104 | * |
| 1105 | * Show listbox popup. |
| 1106 | */ |
| 1107 | static void CBDropDown( LPHEADCOMBO lphc ) |
| 1108 | { |
Gerard Patel | d292234 | 2000-06-25 12:47:59 +0000 | [diff] [blame] | 1109 | RECT rect,r; |
Abey George | 318832e | 1999-07-10 11:34:01 +0000 | [diff] [blame] | 1110 | int nItems = 0; |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1111 | int nDroppedHeight; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1112 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 1113 | TRACE("[%04x]: drop down\n", CB_HWND(lphc)); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1114 | |
| 1115 | CB_NOTIFY( lphc, CBN_DROPDOWN ); |
| 1116 | |
| 1117 | /* set selection */ |
| 1118 | |
| 1119 | lphc->wState |= CBF_DROPPED; |
| 1120 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) |
| 1121 | { |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1122 | lphc->droppedIndex = CBUpdateLBox( lphc, TRUE ); |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 1123 | |
| 1124 | if( !(lphc->wState & CBF_CAPTURE) ) |
| 1125 | CBUpdateEdit( lphc, lphc->droppedIndex ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1126 | } |
| 1127 | else |
| 1128 | { |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 1129 | lphc->droppedIndex = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 ); |
| 1130 | |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1131 | SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, |
| 1132 | (WPARAM)(lphc->droppedIndex == LB_ERR ? 0 : lphc->droppedIndex), 0 ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1133 | SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | /* now set popup position */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1137 | GetWindowRect( lphc->self->hwndSelf, &rect ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1138 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1139 | /* |
| 1140 | * If it's a dropdown, the listbox is offset |
| 1141 | */ |
| 1142 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) |
| 1143 | rect.left += COMBO_EDITBUTTONSPACE(); |
| 1144 | |
Abey George | 318832e | 1999-07-10 11:34:01 +0000 | [diff] [blame] | 1145 | /* if the dropped height is greater than the total height of the dropped |
| 1146 | items list, then force the drop down list height to be the total height |
| 1147 | of the items in the dropped list */ |
| 1148 | |
Pierre Mageau | a433582 | 1999-09-05 12:12:30 +0000 | [diff] [blame] | 1149 | /* And Remove any extra space (Best Fit) */ |
Abey George | 318832e | 1999-07-10 11:34:01 +0000 | [diff] [blame] | 1150 | nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top; |
Gerard Patel | d292234 | 2000-06-25 12:47:59 +0000 | [diff] [blame] | 1151 | /* if listbox length has been set directly by its handle */ |
| 1152 | GetWindowRect(lphc->hWndLBox, &r); |
| 1153 | if (nDroppedHeight < r.bottom - r.top) |
| 1154 | nDroppedHeight = r.bottom - r.top; |
Abey George | 318832e | 1999-07-10 11:34:01 +0000 | [diff] [blame] | 1155 | nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0); |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1156 | |
| 1157 | if (nItems > 0) |
Abey George | 318832e | 1999-07-10 11:34:01 +0000 | [diff] [blame] | 1158 | { |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1159 | int nHeight; |
Abey George | 318832e | 1999-07-10 11:34:01 +0000 | [diff] [blame] | 1160 | |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1161 | nHeight = (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, 0, 0); |
| 1162 | nHeight *= nItems; |
| 1163 | |
| 1164 | if (nHeight < nDroppedHeight - COMBO_YBORDERSIZE()) |
| 1165 | nDroppedHeight = nHeight + COMBO_YBORDERSIZE(); |
Pierre Mageau | a433582 | 1999-09-05 12:12:30 +0000 | [diff] [blame] | 1166 | } |
Abey George | 318832e | 1999-07-10 11:34:01 +0000 | [diff] [blame] | 1167 | |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1168 | /*If height of dropped rectangle gets beyond a screen size it should go up, otherwise down.*/ |
| 1169 | if( (rect.bottom + nDroppedHeight) >= GetSystemMetrics( SM_CYSCREEN ) ) |
| 1170 | rect.bottom = rect.top - nDroppedHeight; |
Abey George | 318832e | 1999-07-10 11:34:01 +0000 | [diff] [blame] | 1171 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1172 | SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom, |
Francis Beaudet | ab6f861 | 1999-04-22 09:08:09 +0000 | [diff] [blame] | 1173 | lphc->droppedRect.right - lphc->droppedRect.left, |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1174 | nDroppedHeight, |
| 1175 | SWP_NOACTIVATE | SWP_SHOWWINDOW); |
| 1176 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1177 | |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 1178 | if( !(lphc->wState & CBF_NOREDRAW) ) |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1179 | RedrawWindow( lphc->self->hwndSelf, NULL, 0, RDW_INVALIDATE | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1180 | RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN ); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1181 | |
Alexandre Julliard | dcc175d | 2000-05-30 15:28:06 +0000 | [diff] [blame] | 1182 | EnableWindow( lphc->hWndLBox, TRUE ); |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1183 | if (GetCapture() != lphc->self->hwndSelf) |
| 1184 | SetCapture(lphc->hWndLBox); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | /*********************************************************************** |
| 1188 | * CBRollUp |
| 1189 | * |
| 1190 | * Hide listbox popup. |
| 1191 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1192 | static void CBRollUp( LPHEADCOMBO lphc, BOOL ok, BOOL bButton ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1193 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1194 | HWND hWnd = lphc->self->hwndSelf; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1195 | |
| 1196 | CB_NOTIFY( lphc, (ok) ? CBN_SELENDOK : CBN_SELENDCANCEL ); |
| 1197 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1198 | if( IsWindow( hWnd ) && CB_GETTYPE(lphc) != CBS_SIMPLE ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1199 | { |
| 1200 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 1201 | TRACE("[%04x]: roll up [%i]\n", CB_HWND(lphc), (INT)ok ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1202 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1203 | if( lphc->wState & CBF_DROPPED ) |
| 1204 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1205 | RECT rect; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1206 | |
| 1207 | lphc->wState &= ~CBF_DROPPED; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1208 | ShowWindow( lphc->hWndLBox, SW_HIDE ); |
Pierre Mageau | 25c62cc | 1999-09-11 16:26:03 +0000 | [diff] [blame] | 1209 | if(GetCapture() == lphc->hWndLBox) |
| 1210 | { |
| 1211 | ReleaseCapture(); |
| 1212 | } |
| 1213 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1214 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) |
| 1215 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1216 | rect = lphc->buttonRect; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1217 | } |
| 1218 | else |
| 1219 | { |
| 1220 | if( bButton ) |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1221 | { |
| 1222 | UnionRect( &rect, |
| 1223 | &lphc->buttonRect, |
| 1224 | &lphc->textRect); |
| 1225 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1226 | else |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1227 | rect = lphc->textRect; |
| 1228 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1229 | bButton = TRUE; |
| 1230 | } |
| 1231 | |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 1232 | if( bButton && !(lphc->wState & CBF_NOREDRAW) ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1233 | RedrawWindow( hWnd, &rect, 0, RDW_INVALIDATE | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1234 | RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN ); |
| 1235 | CB_NOTIFY( lphc, CBN_CLOSEUP ); |
| 1236 | } |
| 1237 | } |
| 1238 | } |
| 1239 | |
| 1240 | /*********************************************************************** |
| 1241 | * COMBO_FlipListbox |
| 1242 | * |
| 1243 | * Used by the ComboLBox to show/hide itself in response to VK_F4, etc... |
| 1244 | */ |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1245 | BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL ok, BOOL bRedrawButton ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1246 | { |
| 1247 | if( lphc->wState & CBF_DROPPED ) |
| 1248 | { |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1249 | CBRollUp( lphc, ok, bRedrawButton ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1250 | return FALSE; |
| 1251 | } |
| 1252 | |
| 1253 | CBDropDown( lphc ); |
| 1254 | return TRUE; |
| 1255 | } |
| 1256 | |
| 1257 | /*********************************************************************** |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1258 | * CBRepaintButton |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 1259 | */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1260 | static void CBRepaintButton( LPHEADCOMBO lphc ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1261 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1262 | InvalidateRect(CB_HWND(lphc), &lphc->buttonRect, TRUE); |
| 1263 | UpdateWindow(CB_HWND(lphc)); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1264 | } |
| 1265 | |
| 1266 | /*********************************************************************** |
| 1267 | * COMBO_SetFocus |
| 1268 | */ |
| 1269 | static void COMBO_SetFocus( LPHEADCOMBO lphc ) |
| 1270 | { |
| 1271 | if( !(lphc->wState & CBF_FOCUSED) ) |
| 1272 | { |
| 1273 | if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1274 | SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1275 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1276 | lphc->wState |= CBF_FOCUSED; |
Dmitry Timoshkov | cd20758 | 1999-12-12 20:47:45 +0000 | [diff] [blame] | 1277 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1278 | if( !(lphc->wState & CBF_EDIT) ) |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1279 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1280 | |
| 1281 | CB_NOTIFY( lphc, CBN_SETFOCUS ); |
| 1282 | } |
| 1283 | } |
| 1284 | |
| 1285 | /*********************************************************************** |
| 1286 | * COMBO_KillFocus |
| 1287 | */ |
| 1288 | static void COMBO_KillFocus( LPHEADCOMBO lphc ) |
| 1289 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1290 | HWND hWnd = lphc->self->hwndSelf; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1291 | |
| 1292 | if( lphc->wState & CBF_FOCUSED ) |
| 1293 | { |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1294 | CBRollUp( lphc, FALSE, TRUE ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1295 | if( IsWindow( hWnd ) ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1296 | { |
| 1297 | if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1298 | SendMessageA( lphc->hWndLBox, LB_CARETOFF, 0, 0 ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1299 | |
| 1300 | lphc->wState &= ~CBF_FOCUSED; |
| 1301 | |
| 1302 | /* redraw text */ |
Dmitry Timoshkov | cd20758 | 1999-12-12 20:47:45 +0000 | [diff] [blame] | 1303 | if( !(lphc->wState & CBF_EDIT) ) |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1304 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1305 | |
| 1306 | CB_NOTIFY( lphc, CBN_KILLFOCUS ); |
| 1307 | } |
| 1308 | } |
| 1309 | } |
| 1310 | |
| 1311 | /*********************************************************************** |
| 1312 | * COMBO_Command |
| 1313 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1314 | static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1315 | { |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 1316 | if ( lphc->wState & CBF_EDIT && lphc->hWndEdit == hWnd ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1317 | { |
| 1318 | /* ">> 8" makes gcc generate jump-table instead of cmp ladder */ |
| 1319 | |
| 1320 | switch( HIWORD(wParam) >> 8 ) |
| 1321 | { |
| 1322 | case (EN_SETFOCUS >> 8): |
| 1323 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 1324 | TRACE("[%04x]: edit [%04x] got focus\n", |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1325 | CB_HWND(lphc), lphc->hWndEdit ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1326 | |
Dmitry Timoshkov | cd20758 | 1999-12-12 20:47:45 +0000 | [diff] [blame] | 1327 | COMBO_SetFocus( lphc ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1328 | break; |
| 1329 | |
| 1330 | case (EN_KILLFOCUS >> 8): |
| 1331 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 1332 | TRACE("[%04x]: edit [%04x] lost focus\n", |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1333 | CB_HWND(lphc), lphc->hWndEdit ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1334 | |
| 1335 | /* NOTE: it seems that Windows' edit control sends an |
| 1336 | * undocumented message WM_USER + 0x1B instead of this |
| 1337 | * notification (only when it happens to be a part of |
| 1338 | * the combo). ?? - AK. |
| 1339 | */ |
| 1340 | |
| 1341 | COMBO_KillFocus( lphc ); |
| 1342 | break; |
| 1343 | |
| 1344 | |
| 1345 | case (EN_CHANGE >> 8): |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 1346 | /* |
| 1347 | * In some circumstances (when the selection of the combobox |
| 1348 | * is changed for example) we don't wans the EN_CHANGE notification |
| 1349 | * to be forwarded to the parent of the combobox. This code |
| 1350 | * checks a flag that is set in these occasions and ignores the |
| 1351 | * notification. |
| 1352 | */ |
Huw D M Davies | 2e34030 | 2000-03-24 19:44:39 +0000 | [diff] [blame] | 1353 | if (!(lphc->wState & CBF_NOEDITNOTIFY)) |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 1354 | CB_NOTIFY( lphc, CBN_EDITCHANGE ); |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 1355 | |
David Grant | 8a92213 | 2000-05-30 17:48:33 +0000 | [diff] [blame] | 1356 | if (lphc->wState & CBF_NOLBSELECT) |
| 1357 | { |
| 1358 | lphc->wState &= ~CBF_NOLBSELECT; |
| 1359 | } |
| 1360 | else |
| 1361 | { |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1362 | CBUpdateLBox( lphc, lphc->wState & CBF_DROPPED ); |
David Grant | 8a92213 | 2000-05-30 17:48:33 +0000 | [diff] [blame] | 1363 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1364 | break; |
| 1365 | |
| 1366 | case (EN_UPDATE >> 8): |
Huw D M Davies | 2e34030 | 2000-03-24 19:44:39 +0000 | [diff] [blame] | 1367 | if (!(lphc->wState & CBF_NOEDITNOTIFY)) |
| 1368 | CB_NOTIFY( lphc, CBN_EDITUPDATE ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1369 | break; |
| 1370 | |
| 1371 | case (EN_ERRSPACE >> 8): |
| 1372 | CB_NOTIFY( lphc, CBN_ERRSPACE ); |
| 1373 | } |
| 1374 | } |
| 1375 | else if( lphc->hWndLBox == hWnd ) |
| 1376 | { |
| 1377 | switch( HIWORD(wParam) ) |
| 1378 | { |
| 1379 | case LBN_ERRSPACE: |
| 1380 | CB_NOTIFY( lphc, CBN_ERRSPACE ); |
| 1381 | break; |
| 1382 | |
| 1383 | case LBN_DBLCLK: |
| 1384 | CB_NOTIFY( lphc, CBN_DBLCLK ); |
| 1385 | break; |
| 1386 | |
| 1387 | case LBN_SELCHANGE: |
| 1388 | case LBN_SELCANCEL: |
| 1389 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 1390 | TRACE("[%04x]: lbox selection change [%04x]\n", |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1391 | CB_HWND(lphc), lphc->wState ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1392 | |
| 1393 | /* do not roll up if selection is being tracked |
| 1394 | * by arrowkeys in the dropdown listbox */ |
| 1395 | |
David Grant | 8a92213 | 2000-05-30 17:48:33 +0000 | [diff] [blame] | 1396 | if( (lphc->dwStyle & CBS_SIMPLE) || |
| 1397 | ((lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP)) ) |
| 1398 | { |
| 1399 | CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE ); |
| 1400 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1401 | else lphc->wState &= ~CBF_NOROLLUP; |
| 1402 | |
| 1403 | CB_NOTIFY( lphc, CBN_SELCHANGE ); |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1404 | |
| 1405 | if( HIWORD(wParam) == LBN_SELCHANGE) |
| 1406 | { |
| 1407 | if( lphc->wState & CBF_EDIT ) |
| 1408 | { |
| 1409 | INT index = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0); |
| 1410 | lphc->wState |= CBF_NOLBSELECT; |
| 1411 | CBUpdateEdit( lphc, index ); |
| 1412 | /* select text in edit, as Windows does */ |
| 1413 | SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) ); |
| 1414 | } |
| 1415 | else |
| 1416 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); |
| 1417 | } |
| 1418 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1419 | /* fall through */ |
| 1420 | |
| 1421 | case LBN_SETFOCUS: |
| 1422 | case LBN_KILLFOCUS: |
| 1423 | /* nothing to do here since ComboLBox always resets the focus to its |
| 1424 | * combo/edit counterpart */ |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 1425 | break; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1426 | } |
| 1427 | } |
| 1428 | return 0; |
| 1429 | } |
| 1430 | |
| 1431 | /*********************************************************************** |
| 1432 | * COMBO_ItemOp |
| 1433 | * |
| 1434 | * Fixup an ownerdrawn item operation and pass it up to the combobox owner. |
| 1435 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1436 | static LRESULT COMBO_ItemOp( LPHEADCOMBO lphc, UINT msg, |
| 1437 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1438 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1439 | HWND hWnd = lphc->self->hwndSelf; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1440 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 1441 | TRACE("[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1442 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1443 | #define lpIS ((LPDELETEITEMSTRUCT)lParam) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1444 | |
| 1445 | /* two first items are the same in all 4 structs */ |
| 1446 | lpIS->CtlType = ODT_COMBOBOX; |
| 1447 | lpIS->CtlID = lphc->self->wIDmenu; |
| 1448 | |
| 1449 | switch( msg ) /* patch window handle */ |
| 1450 | { |
| 1451 | case WM_DELETEITEM: |
| 1452 | lpIS->hwndItem = hWnd; |
| 1453 | #undef lpIS |
| 1454 | break; |
| 1455 | case WM_DRAWITEM: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1456 | #define lpIS ((LPDRAWITEMSTRUCT)lParam) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1457 | lpIS->hwndItem = hWnd; |
| 1458 | #undef lpIS |
| 1459 | break; |
| 1460 | case WM_COMPAREITEM: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1461 | #define lpIS ((LPCOMPAREITEMSTRUCT)lParam) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1462 | lpIS->hwndItem = hWnd; |
| 1463 | #undef lpIS |
| 1464 | break; |
| 1465 | } |
| 1466 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1467 | return SendMessageA( lphc->owner, msg, lphc->self->wIDmenu, lParam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1468 | } |
| 1469 | |
| 1470 | /*********************************************************************** |
| 1471 | * COMBO_GetText |
| 1472 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1473 | static LRESULT COMBO_GetText( LPHEADCOMBO lphc, UINT N, LPSTR lpText) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1474 | { |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1475 | if( lphc->wState & CBF_EDIT ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1476 | return SendMessageA( lphc->hWndEdit, WM_GETTEXT, |
| 1477 | (WPARAM)N, (LPARAM)lpText ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1478 | |
| 1479 | /* get it from the listbox */ |
| 1480 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1481 | if( lphc->hWndLBox ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1482 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1483 | INT idx = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 ); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1484 | if( idx != LB_ERR ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1485 | { |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1486 | LPSTR lpBuffer; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1487 | INT length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, |
| 1488 | (WPARAM)idx, 0 ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1489 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1490 | /* 'length' is without the terminating character */ |
| 1491 | if( length >= N ) |
| 1492 | lpBuffer = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1 ); |
| 1493 | else |
| 1494 | lpBuffer = lpText; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1495 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1496 | if( lpBuffer ) |
| 1497 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1498 | INT n = SendMessageA( lphc->hWndLBox, LB_GETTEXT, |
| 1499 | (WPARAM)idx, (LPARAM)lpBuffer ); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1500 | |
| 1501 | /* truncate if buffer is too short */ |
| 1502 | |
| 1503 | if( length >= N ) |
| 1504 | { |
Marcus Meissner | 21777c5 | 1998-11-22 15:41:00 +0000 | [diff] [blame] | 1505 | if (N && lpText) { |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1506 | if( n != LB_ERR ) memcpy( lpText, lpBuffer, (N>n) ? n+1 : N-1 ); |
| 1507 | lpText[N - 1] = '\0'; |
Marcus Meissner | 21777c5 | 1998-11-22 15:41:00 +0000 | [diff] [blame] | 1508 | } |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 1509 | HeapFree( GetProcessHeap(), 0, lpBuffer ); |
| 1510 | } |
| 1511 | return (LRESULT)n; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1512 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1513 | } |
| 1514 | } |
| 1515 | return 0; |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 1516 | } |
| 1517 | |
| 1518 | |
| 1519 | /*********************************************************************** |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1520 | * CBResetPos |
| 1521 | * |
| 1522 | * This function sets window positions according to the updated |
| 1523 | * component placement struct. |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 1524 | */ |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1525 | static void CBResetPos( |
| 1526 | LPHEADCOMBO lphc, |
| 1527 | LPRECT rectEdit, |
| 1528 | LPRECT rectLB, |
| 1529 | BOOL bRedraw) |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 1530 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1531 | BOOL bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE); |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 1532 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1533 | /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of |
| 1534 | * sizing messages */ |
| 1535 | |
| 1536 | if( lphc->wState & CBF_EDIT ) |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1537 | SetWindowPos( lphc->hWndEdit, 0, |
| 1538 | rectEdit->left, rectEdit->top, |
| 1539 | rectEdit->right - rectEdit->left, |
| 1540 | rectEdit->bottom - rectEdit->top, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1541 | SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) ); |
| 1542 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1543 | SetWindowPos( lphc->hWndLBox, 0, |
| 1544 | rectLB->left, rectLB->top, |
| 1545 | rectLB->right - rectLB->left, |
| 1546 | rectLB->bottom - rectLB->top, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1547 | SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) ); |
| 1548 | |
| 1549 | if( bDrop ) |
| 1550 | { |
| 1551 | if( lphc->wState & CBF_DROPPED ) |
| 1552 | { |
| 1553 | lphc->wState &= ~CBF_DROPPED; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1554 | ShowWindow( lphc->hWndLBox, SW_HIDE ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1555 | } |
| 1556 | |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 1557 | if( bRedraw && !(lphc->wState & CBF_NOREDRAW) ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1558 | RedrawWindow( lphc->self->hwndSelf, NULL, 0, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1559 | RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW ); |
| 1560 | } |
| 1561 | } |
| 1562 | |
| 1563 | |
| 1564 | /*********************************************************************** |
| 1565 | * COMBO_Size |
| 1566 | */ |
| 1567 | static void COMBO_Size( LPHEADCOMBO lphc ) |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 1568 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1569 | CBCalcPlacement(lphc->self->hwndSelf, |
| 1570 | lphc, |
| 1571 | &lphc->textRect, |
| 1572 | &lphc->buttonRect, |
| 1573 | &lphc->droppedRect); |
Pascal Lessard | e69fcc0 | 1999-03-24 14:59:37 +0000 | [diff] [blame] | 1574 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1575 | CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1576 | } |
| 1577 | |
| 1578 | |
| 1579 | /*********************************************************************** |
| 1580 | * COMBO_Font |
| 1581 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1582 | static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1583 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1584 | /* |
| 1585 | * Set the font |
| 1586 | */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1587 | lphc->hFont = hFont; |
| 1588 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1589 | /* |
| 1590 | * Propagate to owned windows. |
| 1591 | */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1592 | if( lphc->wState & CBF_EDIT ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1593 | SendMessageA( lphc->hWndEdit, WM_SETFONT, (WPARAM)hFont, bRedraw ); |
| 1594 | SendMessageA( lphc->hWndLBox, WM_SETFONT, (WPARAM)hFont, bRedraw ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1595 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1596 | /* |
| 1597 | * Redo the layout of the control. |
| 1598 | */ |
| 1599 | if ( CB_GETTYPE(lphc) == CBS_SIMPLE) |
| 1600 | { |
| 1601 | CBCalcPlacement(lphc->self->hwndSelf, |
| 1602 | lphc, |
| 1603 | &lphc->textRect, |
| 1604 | &lphc->buttonRect, |
| 1605 | &lphc->droppedRect); |
| 1606 | |
| 1607 | CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE ); |
| 1608 | } |
| 1609 | else |
| 1610 | { |
Francis Beaudet | ab6f861 | 1999-04-22 09:08:09 +0000 | [diff] [blame] | 1611 | CBForceDummyResize(lphc); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1612 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1613 | } |
| 1614 | |
| 1615 | |
| 1616 | /*********************************************************************** |
| 1617 | * COMBO_SetItemHeight |
| 1618 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1619 | static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT index, INT height ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1620 | { |
| 1621 | LRESULT lRet = CB_ERR; |
| 1622 | |
| 1623 | if( index == -1 ) /* set text field height */ |
| 1624 | { |
| 1625 | if( height < 32768 ) |
| 1626 | { |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1627 | lphc->editHeight = height; |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1628 | |
| 1629 | /* |
| 1630 | * Redo the layout of the control. |
| 1631 | */ |
| 1632 | if ( CB_GETTYPE(lphc) == CBS_SIMPLE) |
| 1633 | { |
| 1634 | CBCalcPlacement(lphc->self->hwndSelf, |
| 1635 | lphc, |
| 1636 | &lphc->textRect, |
| 1637 | &lphc->buttonRect, |
| 1638 | &lphc->droppedRect); |
| 1639 | |
| 1640 | CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE ); |
| 1641 | } |
| 1642 | else |
| 1643 | { |
Francis Beaudet | ab6f861 | 1999-04-22 09:08:09 +0000 | [diff] [blame] | 1644 | CBForceDummyResize(lphc); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1645 | } |
| 1646 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1647 | lRet = height; |
| 1648 | } |
| 1649 | } |
| 1650 | else if ( CB_OWNERDRAWN(lphc) ) /* set listbox item height */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1651 | lRet = SendMessageA( lphc->hWndLBox, LB_SETITEMHEIGHT, |
| 1652 | (WPARAM)index, (LPARAM)height ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1653 | return lRet; |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 1654 | } |
| 1655 | |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1656 | /*********************************************************************** |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1657 | * COMBO_SelectString |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1658 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1659 | static LRESULT COMBO_SelectString( LPHEADCOMBO lphc, INT start, LPCSTR pText ) |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1660 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1661 | INT index = SendMessageA( lphc->hWndLBox, LB_SELECTSTRING, |
| 1662 | (WPARAM)start, (LPARAM)pText ); |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 1663 | if( index >= 0 ) |
| 1664 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1665 | if( lphc->wState & CBF_EDIT ) |
| 1666 | CBUpdateEdit( lphc, index ); |
| 1667 | else |
| 1668 | { |
| 1669 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); |
| 1670 | } |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1671 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1672 | return (LRESULT)index; |
Alexandre Julliard | 75d86e1 | 1996-11-17 18:59:11 +0000 | [diff] [blame] | 1673 | } |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 1674 | |
| 1675 | /*********************************************************************** |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1676 | * COMBO_LButtonDown |
| 1677 | */ |
| 1678 | static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam ) |
| 1679 | { |
Patrik Stridvall | 0f8bc5b | 1999-04-22 16:27:50 +0000 | [diff] [blame] | 1680 | POINT pt; |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1681 | BOOL bButton; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1682 | HWND hWnd = lphc->self->hwndSelf; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1683 | |
Patrik Stridvall | 0f8bc5b | 1999-04-22 16:27:50 +0000 | [diff] [blame] | 1684 | pt.x = LOWORD(lParam); |
| 1685 | pt.y = HIWORD(lParam); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1686 | bButton = PtInRect(&lphc->buttonRect, pt); |
| 1687 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1688 | if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) || |
| 1689 | (bButton && (CB_GETTYPE(lphc) == CBS_DROPDOWN)) ) |
| 1690 | { |
| 1691 | lphc->wState |= CBF_BUTTONDOWN; |
| 1692 | if( lphc->wState & CBF_DROPPED ) |
| 1693 | { |
| 1694 | /* got a click to cancel selection */ |
| 1695 | |
Pavel Roskin | 6d40d1b | 1999-03-12 17:00:13 +0000 | [diff] [blame] | 1696 | lphc->wState &= ~CBF_BUTTONDOWN; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1697 | CBRollUp( lphc, TRUE, FALSE ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1698 | if( !IsWindow( hWnd ) ) return; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1699 | |
| 1700 | if( lphc->wState & CBF_CAPTURE ) |
| 1701 | { |
| 1702 | lphc->wState &= ~CBF_CAPTURE; |
| 1703 | ReleaseCapture(); |
| 1704 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1705 | } |
| 1706 | else |
| 1707 | { |
| 1708 | /* drop down the listbox and start tracking */ |
| 1709 | |
| 1710 | lphc->wState |= CBF_CAPTURE; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1711 | SetCapture( hWnd ); |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1712 | CBDropDown( lphc ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1713 | } |
| 1714 | if( bButton ) CBRepaintButton( lphc ); |
| 1715 | } |
| 1716 | } |
| 1717 | |
| 1718 | /*********************************************************************** |
| 1719 | * COMBO_LButtonUp |
| 1720 | * |
| 1721 | * Release capture and stop tracking if needed. |
| 1722 | */ |
| 1723 | static void COMBO_LButtonUp( LPHEADCOMBO lphc, LPARAM lParam ) |
| 1724 | { |
| 1725 | if( lphc->wState & CBF_CAPTURE ) |
| 1726 | { |
| 1727 | lphc->wState &= ~CBF_CAPTURE; |
| 1728 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) |
| 1729 | { |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1730 | INT index = CBUpdateLBox( lphc, TRUE ); |
| 1731 | lphc->wState |= CBF_NOLBSELECT; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1732 | CBUpdateEdit( lphc, index ); |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1733 | lphc->wState &= ~CBF_NOLBSELECT; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1734 | } |
| 1735 | ReleaseCapture(); |
Pierre Mageau | 25c62cc | 1999-09-11 16:26:03 +0000 | [diff] [blame] | 1736 | SetCapture(lphc->hWndLBox); |
| 1737 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1738 | } |
| 1739 | |
| 1740 | if( lphc->wState & CBF_BUTTONDOWN ) |
| 1741 | { |
| 1742 | lphc->wState &= ~CBF_BUTTONDOWN; |
| 1743 | CBRepaintButton( lphc ); |
| 1744 | } |
| 1745 | } |
| 1746 | |
| 1747 | /*********************************************************************** |
| 1748 | * COMBO_MouseMove |
| 1749 | * |
| 1750 | * Two things to do - track combo button and release capture when |
| 1751 | * pointer goes into the listbox. |
| 1752 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1753 | static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1754 | { |
Patrik Stridvall | 0f8bc5b | 1999-04-22 16:27:50 +0000 | [diff] [blame] | 1755 | POINT pt; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1756 | RECT lbRect; |
Patrik Stridvall | 0f8bc5b | 1999-04-22 16:27:50 +0000 | [diff] [blame] | 1757 | |
| 1758 | pt.x = LOWORD(lParam); |
| 1759 | pt.y = HIWORD(lParam); |
| 1760 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1761 | if( lphc->wState & CBF_BUTTONDOWN ) |
| 1762 | { |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1763 | BOOL bButton; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1764 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1765 | bButton = PtInRect(&lphc->buttonRect, pt); |
| 1766 | |
| 1767 | if( !bButton ) |
| 1768 | { |
| 1769 | lphc->wState &= ~CBF_BUTTONDOWN; |
| 1770 | CBRepaintButton( lphc ); |
| 1771 | } |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1772 | } |
| 1773 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1774 | GetClientRect( lphc->hWndLBox, &lbRect ); |
| 1775 | MapWindowPoints( lphc->self->hwndSelf, lphc->hWndLBox, &pt, 1 ); |
| 1776 | if( PtInRect(&lbRect, pt) ) |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1777 | { |
| 1778 | lphc->wState &= ~CBF_CAPTURE; |
| 1779 | ReleaseCapture(); |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1780 | if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc, TRUE ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1781 | |
| 1782 | /* hand over pointer tracking */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1783 | SendMessageA( lphc->hWndLBox, WM_LBUTTONDOWN, wParam, lParam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1784 | } |
| 1785 | } |
| 1786 | |
| 1787 | |
| 1788 | /*********************************************************************** |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1789 | * ComboWndProc_locked |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1790 | * |
| 1791 | * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 1792 | */ |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1793 | static inline LRESULT WINAPI ComboWndProc_locked( WND* pWnd, UINT message, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1794 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 1795 | { |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1796 | if( pWnd ) { |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1797 | LPHEADCOMBO lphc = CB_GETPTR(pWnd); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1798 | HWND hwnd = pWnd->hwndSelf; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1799 | |
Alexandre Julliard | 9fe7a25 | 1999-05-14 08:17:14 +0000 | [diff] [blame] | 1800 | TRACE("[%04x]: msg %s wp %08x lp %08lx\n", |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1801 | pWnd->hwndSelf, SPY_GetMsgName(message), wParam, lParam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1802 | |
| 1803 | if( lphc || message == WM_NCCREATE ) |
| 1804 | switch(message) |
| 1805 | { |
| 1806 | |
| 1807 | /* System messages */ |
| 1808 | |
| 1809 | case WM_NCCREATE: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1810 | return COMBO_NCCreate(pWnd, lParam); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1811 | case WM_NCDESTROY: |
| 1812 | COMBO_NCDestroy(lphc); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1813 | break;/* -> DefWindowProc */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1814 | |
| 1815 | case WM_CREATE: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1816 | return COMBO_Create(lphc, pWnd, lParam); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1817 | |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1818 | case WM_PRINTCLIENT: |
| 1819 | if (lParam & PRF_ERASEBKGND) |
| 1820 | COMBO_EraseBackground(hwnd, lphc, wParam); |
| 1821 | |
| 1822 | /* Fallthrough */ |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1823 | case WM_PAINT: |
| 1824 | /* wParam may contain a valid HDC! */ |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1825 | return COMBO_Paint(lphc, wParam); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1826 | case WM_ERASEBKGND: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1827 | return COMBO_EraseBackground(hwnd, lphc, wParam); |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1828 | case WM_GETDLGCODE: |
| 1829 | { |
| 1830 | LRESULT result = DLGC_WANTARROWS | DLGC_WANTCHARS; |
| 1831 | if (lParam && (((LPMSG)lParam)->message == WM_KEYDOWN)) |
| 1832 | { |
| 1833 | int vk = (int)((LPMSG)lParam)->wParam; |
| 1834 | |
| 1835 | if ((vk == VK_RETURN || vk == VK_ESCAPE) && (lphc->wState & CBF_DROPPED)) |
| 1836 | result |= DLGC_WANTMESSAGE; |
| 1837 | } |
| 1838 | return result; |
| 1839 | } |
| 1840 | case WM_WINDOWPOSCHANGING: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1841 | return COMBO_WindowPosChanging(hwnd, lphc, (LPWINDOWPOS)lParam); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1842 | case WM_SIZE: |
| 1843 | if( lphc->hWndLBox && |
| 1844 | !(lphc->wState & CBF_NORESIZE) ) COMBO_Size( lphc ); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1845 | return TRUE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1846 | case WM_SETFONT: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1847 | COMBO_Font( lphc, (HFONT16)wParam, (BOOL)lParam ); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1848 | return TRUE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1849 | case WM_GETFONT: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1850 | return (LRESULT)lphc->hFont; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1851 | case WM_SETFOCUS: |
| 1852 | if( lphc->wState & CBF_EDIT ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1853 | SetFocus( lphc->hWndEdit ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1854 | else |
| 1855 | COMBO_SetFocus( lphc ); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1856 | return TRUE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1857 | case WM_KILLFOCUS: |
| 1858 | #define hwndFocus ((HWND16)wParam) |
| 1859 | if( !hwndFocus || |
| 1860 | (hwndFocus != lphc->hWndEdit && hwndFocus != lphc->hWndLBox )) |
| 1861 | COMBO_KillFocus( lphc ); |
| 1862 | #undef hwndFocus |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1863 | return TRUE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1864 | case WM_COMMAND: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1865 | return COMBO_Command( lphc, wParam, (HWND)lParam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1866 | case WM_GETTEXT: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1867 | return COMBO_GetText( lphc, (UINT)wParam, (LPSTR)lParam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1868 | case WM_SETTEXT: |
| 1869 | case WM_GETTEXTLENGTH: |
| 1870 | case WM_CLEAR: |
| 1871 | case WM_CUT: |
| 1872 | case WM_PASTE: |
| 1873 | case WM_COPY: |
Gerard Patel | 8c36254 | 1999-10-13 13:50:17 +0000 | [diff] [blame] | 1874 | if ((message == WM_GETTEXTLENGTH) && !ISWIN31 && !(lphc->wState & CBF_EDIT)) |
| 1875 | { |
| 1876 | int j = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 ); |
| 1877 | if (j == -1) return 0; |
| 1878 | return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, j, 0); |
| 1879 | } |
| 1880 | else if( lphc->wState & CBF_EDIT ) |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 1881 | { |
Huw D M Davies | 2e34030 | 2000-03-24 19:44:39 +0000 | [diff] [blame] | 1882 | LRESULT ret; |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 1883 | lphc->wState |= CBF_NOEDITNOTIFY; |
Huw D M Davies | 2e34030 | 2000-03-24 19:44:39 +0000 | [diff] [blame] | 1884 | ret = SendMessageA( lphc->hWndEdit, message, wParam, lParam ); |
| 1885 | lphc->wState &= ~CBF_NOEDITNOTIFY; |
| 1886 | return ret; |
Francis Beaudet | 6ec3eaf | 1999-06-12 10:51:19 +0000 | [diff] [blame] | 1887 | } |
Gerard Patel | 8c36254 | 1999-10-13 13:50:17 +0000 | [diff] [blame] | 1888 | else return CB_ERR; |
| 1889 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1890 | case WM_DRAWITEM: |
| 1891 | case WM_DELETEITEM: |
| 1892 | case WM_COMPAREITEM: |
| 1893 | case WM_MEASUREITEM: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1894 | return COMBO_ItemOp( lphc, message, wParam, lParam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1895 | case WM_ENABLE: |
| 1896 | if( lphc->wState & CBF_EDIT ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1897 | EnableWindow( lphc->hWndEdit, (BOOL)wParam ); |
| 1898 | EnableWindow( lphc->hWndLBox, (BOOL)wParam ); |
Francis Beaudet | f132872 | 1999-09-19 14:09:52 +0000 | [diff] [blame] | 1899 | |
| 1900 | /* Force the control to repaint when the enabled state changes. */ |
| 1901 | InvalidateRect(CB_HWND(lphc), NULL, TRUE); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1902 | return TRUE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1903 | case WM_SETREDRAW: |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 1904 | if( wParam ) |
| 1905 | lphc->wState &= ~CBF_NOREDRAW; |
| 1906 | else |
| 1907 | lphc->wState |= CBF_NOREDRAW; |
| 1908 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1909 | if( lphc->wState & CBF_EDIT ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1910 | SendMessageA( lphc->hWndEdit, message, wParam, lParam ); |
| 1911 | SendMessageA( lphc->hWndLBox, message, wParam, lParam ); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1912 | return 0; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1913 | case WM_SYSKEYDOWN: |
| 1914 | if( KEYDATA_ALT & HIWORD(lParam) ) |
| 1915 | if( wParam == VK_UP || wParam == VK_DOWN ) |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1916 | COMBO_FlipListbox( lphc, FALSE, FALSE ); |
| 1917 | return 0; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1918 | |
| 1919 | case WM_CHAR: |
| 1920 | case WM_KEYDOWN: |
Serge Ivanov | 9926d33 | 2000-06-07 03:48:02 +0000 | [diff] [blame] | 1921 | if (((CHAR)wParam == VK_RETURN || (CHAR)wParam == VK_ESCAPE) && |
| 1922 | (lphc->wState & CBF_DROPPED)) |
| 1923 | { |
| 1924 | CBRollUp( lphc, (CHAR)wParam == VK_RETURN, FALSE ); |
| 1925 | return TRUE; |
| 1926 | } |
| 1927 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1928 | if( lphc->wState & CBF_EDIT ) |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1929 | return SendMessageA( lphc->hWndEdit, message, wParam, lParam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1930 | else |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1931 | return SendMessageA( lphc->hWndLBox, message, wParam, lParam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1932 | case WM_LBUTTONDOWN: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1933 | if( !(lphc->wState & CBF_FOCUSED) ) SetFocus( lphc->self->hwndSelf ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1934 | if( lphc->wState & CBF_FOCUSED ) COMBO_LButtonDown( lphc, lParam ); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1935 | return TRUE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1936 | case WM_LBUTTONUP: |
| 1937 | COMBO_LButtonUp( lphc, lParam ); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1938 | return TRUE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1939 | case WM_MOUSEMOVE: |
| 1940 | if( lphc->wState & CBF_CAPTURE ) |
| 1941 | COMBO_MouseMove( lphc, wParam, lParam ); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1942 | return TRUE; |
Stephane Lussier | 4bdf4af | 2000-04-18 11:56:33 +0000 | [diff] [blame] | 1943 | |
| 1944 | case WM_MOUSEWHEEL: |
| 1945 | if (wParam & (MK_SHIFT | MK_CONTROL)) |
| 1946 | return DefWindowProcA( hwnd, message, wParam, lParam ); |
| 1947 | if ((short) HIWORD(wParam) > 0) return SendMessageA(hwnd,WM_KEYDOWN,VK_UP,0); |
| 1948 | if ((short) HIWORD(wParam) < 0) return SendMessageA(hwnd,WM_KEYDOWN,VK_DOWN,0); |
| 1949 | return TRUE; |
| 1950 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1951 | /* Combo messages */ |
| 1952 | |
| 1953 | case CB_ADDSTRING16: |
| 1954 | if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1955 | case CB_ADDSTRING: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1956 | return SendMessageA( lphc->hWndLBox, LB_ADDSTRING, 0, lParam); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1957 | case CB_INSERTSTRING16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1958 | wParam = (INT)(INT16)wParam; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1959 | if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1960 | case CB_INSERTSTRING: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1961 | return SendMessageA( lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1962 | case CB_DELETESTRING16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1963 | case CB_DELETESTRING: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1964 | return SendMessageA( lphc->hWndLBox, LB_DELETESTRING, wParam, 0); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1965 | case CB_SELECTSTRING16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1966 | wParam = (INT)(INT16)wParam; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1967 | if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1968 | case CB_SELECTSTRING: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1969 | return COMBO_SelectString( lphc, (INT)wParam, (LPSTR)lParam ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1970 | case CB_FINDSTRING16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1971 | wParam = (INT)(INT16)wParam; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1972 | if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1973 | case CB_FINDSTRING: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1974 | return SendMessageA( lphc->hWndLBox, LB_FINDSTRING, wParam, lParam); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1975 | case CB_FINDSTRINGEXACT16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1976 | wParam = (INT)(INT16)wParam; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1977 | if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1978 | case CB_FINDSTRINGEXACT: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1979 | return SendMessageA( lphc->hWndLBox, LB_FINDSTRINGEXACT, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1980 | wParam, lParam ); |
| 1981 | case CB_SETITEMHEIGHT16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1982 | wParam = (INT)(INT16)wParam; /* signed integer */ |
| 1983 | case CB_SETITEMHEIGHT: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1984 | return COMBO_SetItemHeight( lphc, (INT)wParam, (INT)lParam); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1985 | case CB_GETITEMHEIGHT16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1986 | wParam = (INT)(INT16)wParam; |
| 1987 | case CB_GETITEMHEIGHT: |
| 1988 | if( (INT)wParam >= 0 ) /* listbox item */ |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1989 | return SendMessageA( lphc->hWndLBox, LB_GETITEMHEIGHT, wParam, 0); |
| 1990 | return CBGetTextAreaHeight(hwnd, lphc); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1991 | case CB_RESETCONTENT16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1992 | case CB_RESETCONTENT: |
| 1993 | SendMessageA( lphc->hWndLBox, LB_RESETCONTENT, 0, 0 ); |
Francis Beaudet | f585c61 | 1999-04-02 10:37:42 +0000 | [diff] [blame] | 1994 | InvalidateRect(CB_HWND(lphc), NULL, TRUE); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1995 | return TRUE; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1996 | case CB_INITSTORAGE: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1997 | return SendMessageA( lphc->hWndLBox, LB_INITSTORAGE, wParam, lParam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1998 | case CB_GETHORIZONTALEXTENT: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 1999 | return SendMessageA( lphc->hWndLBox, LB_GETHORIZONTALEXTENT, 0, 0); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2000 | case CB_SETHORIZONTALEXTENT: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2001 | return SendMessageA( lphc->hWndLBox, LB_SETHORIZONTALEXTENT, wParam, 0); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2002 | case CB_GETTOPINDEX: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2003 | return SendMessageA( lphc->hWndLBox, LB_GETTOPINDEX, 0, 0); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2004 | case CB_GETLOCALE: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2005 | return SendMessageA( lphc->hWndLBox, LB_GETLOCALE, 0, 0); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2006 | case CB_SETLOCALE: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2007 | return SendMessageA( lphc->hWndLBox, LB_SETLOCALE, wParam, 0); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2008 | case CB_GETDROPPEDWIDTH: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2009 | if( lphc->droppedWidth ) |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2010 | return lphc->droppedWidth; |
| 2011 | return lphc->droppedRect.right - lphc->droppedRect.left; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2012 | case CB_SETDROPPEDWIDTH: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2013 | if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2014 | (INT)wParam < 32768 ) lphc->droppedWidth = (INT)wParam; |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2015 | return CB_ERR; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2016 | case CB_GETDROPPEDCONTROLRECT16: |
| 2017 | lParam = (LPARAM)PTR_SEG_TO_LIN(lParam); |
| 2018 | if( lParam ) |
| 2019 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2020 | RECT r; |
| 2021 | CBGetDroppedControlRect( lphc, &r ); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2022 | CONV_RECT32TO16( &r, (LPRECT16)lParam ); |
| 2023 | } |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2024 | return CB_OKAY; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2025 | case CB_GETDROPPEDCONTROLRECT: |
| 2026 | if( lParam ) CBGetDroppedControlRect(lphc, (LPRECT)lParam ); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2027 | return CB_OKAY; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2028 | case CB_GETDROPPEDSTATE16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2029 | case CB_GETDROPPEDSTATE: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2030 | return (lphc->wState & CBF_DROPPED) ? TRUE : FALSE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2031 | case CB_DIR16: |
| 2032 | lParam = (LPARAM)PTR_SEG_TO_LIN(lParam); |
| 2033 | /* fall through */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2034 | case CB_DIR: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2035 | return COMBO_Directory( lphc, (UINT)wParam, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2036 | (LPSTR)lParam, (message == CB_DIR)); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2037 | case CB_SHOWDROPDOWN16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2038 | case CB_SHOWDROPDOWN: |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 2039 | if( CB_GETTYPE(lphc) != CBS_SIMPLE ) |
| 2040 | { |
| 2041 | if( wParam ) |
| 2042 | { |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2043 | if( !(lphc->wState & CBF_DROPPED) ) |
| 2044 | CBDropDown( lphc ); |
Alex Korobka | f172d64 | 1998-10-14 18:40:35 +0000 | [diff] [blame] | 2045 | } |
| 2046 | else |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2047 | if( lphc->wState & CBF_DROPPED ) |
| 2048 | CBRollUp( lphc, FALSE, TRUE ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2049 | } |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2050 | return TRUE; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2051 | case CB_GETCOUNT16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2052 | case CB_GETCOUNT: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2053 | return SendMessageA( lphc->hWndLBox, LB_GETCOUNT, 0, 0); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2054 | case CB_GETCURSEL16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2055 | case CB_GETCURSEL: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2056 | return SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2057 | case CB_SETCURSEL16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2058 | wParam = (INT)(INT16)wParam; |
| 2059 | case CB_SETCURSEL: |
| 2060 | lParam = SendMessageA( lphc->hWndLBox, LB_SETCURSEL, wParam, 0); |
David Grant | 8a92213 | 2000-05-30 17:48:33 +0000 | [diff] [blame] | 2061 | if( lParam >= 0 ) |
| 2062 | SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, wParam, 0); |
| 2063 | if( lphc->wState & CBF_SELCHANGE ) |
Alex Korobka | 311d329 | 1999-01-01 18:40:02 +0000 | [diff] [blame] | 2064 | { |
| 2065 | /* no LBN_SELCHANGE in this case, update manually */ |
Dmitry Timoshkov | f4a27b8 | 1999-11-28 19:45:58 +0000 | [diff] [blame] | 2066 | if( lphc->wState & CBF_EDIT ) |
| 2067 | CBUpdateEdit( lphc, (INT)wParam ); |
| 2068 | else |
| 2069 | InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); |
Alex Korobka | 311d329 | 1999-01-01 18:40:02 +0000 | [diff] [blame] | 2070 | lphc->wState &= ~CBF_SELCHANGE; |
| 2071 | } |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2072 | return lParam; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2073 | case CB_GETLBTEXT16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2074 | wParam = (INT)(INT16)wParam; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2075 | lParam = (LPARAM)PTR_SEG_TO_LIN(lParam); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2076 | case CB_GETLBTEXT: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2077 | return SendMessageA( lphc->hWndLBox, LB_GETTEXT, wParam, lParam); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2078 | case CB_GETLBTEXTLEN16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2079 | wParam = (INT)(INT16)wParam; |
| 2080 | case CB_GETLBTEXTLEN: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2081 | return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2082 | case CB_GETITEMDATA16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2083 | wParam = (INT)(INT16)wParam; |
| 2084 | case CB_GETITEMDATA: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2085 | return SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, wParam, 0); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2086 | case CB_SETITEMDATA16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2087 | wParam = (INT)(INT16)wParam; |
| 2088 | case CB_SETITEMDATA: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2089 | return SendMessageA( lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam); |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2090 | case CB_GETEDITSEL16: |
| 2091 | wParam = lParam = 0; /* just in case */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2092 | case CB_GETEDITSEL: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2093 | if( lphc->wState & CBF_EDIT ) |
| 2094 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2095 | INT a, b; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2096 | |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2097 | return SendMessageA( lphc->hWndEdit, EM_GETSEL, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2098 | (wParam) ? wParam : (WPARAM)&a, |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2099 | (lParam) ? lParam : (LPARAM)&b ); |
| 2100 | } |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2101 | return CB_ERR; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2102 | case CB_SETEDITSEL16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2103 | case CB_SETEDITSEL: |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2104 | if( lphc->wState & CBF_EDIT ) |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2105 | return SendMessageA( lphc->hWndEdit, EM_SETSEL, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2106 | (INT)(INT16)LOWORD(lParam), (INT)(INT16)HIWORD(lParam) ); |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2107 | return CB_ERR; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2108 | case CB_SETEXTENDEDUI16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2109 | case CB_SETEXTENDEDUI: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2110 | if( CB_GETTYPE(lphc) == CBS_SIMPLE ) |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2111 | return CB_ERR; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2112 | if( wParam ) |
| 2113 | lphc->wState |= CBF_EUI; |
| 2114 | else lphc->wState &= ~CBF_EUI; |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2115 | return CB_OKAY; |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 2116 | case CB_GETEXTENDEDUI16: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2117 | case CB_GETEXTENDEDUI: |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2118 | return (lphc->wState & CBF_EUI) ? TRUE : FALSE; |
Dmitry Timoshkov | 92f376f | 1999-12-05 02:45:10 +0000 | [diff] [blame] | 2119 | |
| 2120 | default: |
| 2121 | if (message >= WM_USER) |
| 2122 | WARN("unknown msg WM_USER+%04x wp=%04x lp=%08lx\n", |
| 2123 | message - WM_USER, wParam, lParam ); |
| 2124 | break; |
Alexandre Julliard | 0e60778 | 1993-11-03 19:23:37 +0000 | [diff] [blame] | 2125 | } |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2126 | return DefWindowProcA(hwnd, message, wParam, lParam); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 2127 | } |
Marcus Meissner | 9aded51 | 1999-05-01 10:23:45 +0000 | [diff] [blame] | 2128 | return CB_ERR; |
| 2129 | } |
| 2130 | |
| 2131 | /*********************************************************************** |
| 2132 | * ComboWndProc |
| 2133 | * |
| 2134 | * This is just a wrapper for the real ComboWndProc which locks/unlocks |
| 2135 | * window structs. |
| 2136 | */ |
| 2137 | LRESULT WINAPI ComboWndProc( HWND hwnd, UINT message, |
| 2138 | WPARAM wParam, LPARAM lParam ) |
| 2139 | { |
| 2140 | WND* pWnd = WIN_FindWndPtr(hwnd); |
| 2141 | LRESULT retvalue = ComboWndProc_locked(pWnd,message,wParam,lParam); |
| 2142 | |
| 2143 | |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2144 | WIN_ReleaseWndPtr(pWnd); |
| 2145 | return retvalue; |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 2146 | } |
| 2147 | |