Changeset 8382 for trunk/src/comctl32/comboex.c
- Timestamp:
- May 8, 2002, 1:26:30 PM (24 years ago)
- File:
-
- 1 edited
-
trunk/src/comctl32/comboex.c (modified) (91 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/comboex.c
r7815 r8382 1 1 /* 2 * TODO <------------- 3 * 1. The following extended styles need to be implemented, use will 4 * result in a FIXME: 5 * CBES_EX_NOEDITIMAGEINDENT 2 * ComboBoxEx control 3 * 4 * Copyright 1998, 1999 Eric Kohl 5 * Copyright 2000, 2001, 2002 Guy Albertelli <galberte@neo.lrun.com> 6 * Copyright 2002 Dimitrie O. Paun 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 22 * FIXME: 23 * 1. Implement following extended styles: 6 24 * CBES_EX_PATHWORDBREAKPROC 7 25 * CBES_EX_NOSIZELIMIT 8 26 * CBES_EX_CASESENSITIVE 9 * 2. None of the following callback items are implemented. Therefor 10 * no CBEN_GETDISPINFO notifies are issued. Use in either CBEM_INSERTITEM 11 * or CBEM_SETITEM will result in a FIXME: 12 * LPSTR_TEXTCALLBACK 13 * I_IMAGECALLBACK 14 * I_INDENTCALLBACK 15 * 3. No use is made of the iOverlay image. 16 * 4. Notify CBEN_DRAGBEGIN is not implemented. 17 */ 18 19 20 /* 21 * ComboBoxEx control v2 (mod6) 22 * 23 * Copyright 1998, 1999 Eric Kohl 24 * 25 * NOTES 26 * This is just a dummy control. An author is needed! Any volunteers? 27 * I will only improve this control once in a while. 28 * Eric <ekohl@abo.rhein-zeitung.de> 29 * 30 31 * Changes Guy Albertelli <galberte@neo.lrun.com> 32 * v1 Implemented messages: CB_SETITEMHEIGHT, WM_WINDOWPOSCHANGING, 33 * WM_DRAWITEM, and WM_MEASUREITEM. Fixed WM_CREATE. Fixed height 34 * of window rect reported fixing rebar control. 35 * v2 36 * 1. Rewrite of WM_Create for own created EDIT control. Also try to 37 * generate message sequence similar to native DLL. 38 * 2. Handle case where CBEM_SETITEM is called to display data in EDIT 39 * Control. 40 * 3. Add override for WNDPROC for the EDIT control (reqed for VK_RETURN). 41 * 4. Dump input data for things using COMBOBOXEXITEM{A|W}. 42 * 5. Handle positioning EDIT control based on whether icon present. 43 * 6. Make InsertItemA use InsertItemW, and store all data in ..W form. 44 * 7. Implement CBEM_DELETEITEM, CBEM_GETITEM{A|W}, CB_SETCURSEL, 45 * CBEM_{GET|SET}UNICODEFORMAT. 46 * 8. Add override for WNDPROC for the COMBO control. 47 * 9. Support extended style CBES_EX_NOEDITIMAGE and warn others are not 48 * supported. 49 * 10. Implement CB_FINDSTRINGEXACT in both the Combo and ComboEx window 50 * procs to match the items. This eliminates dup entries in the listbox. 51 * 52 * mod 4 53 * 1. Implemented CBN_SELCHANGE, CBN_KILLFOCUS, and CBN_SELENDOK. 54 * 2. Fix putting text in CBEN_ENDEDIT notifies for CBN_DROPDOWN case. 55 * 3. Lock image selected status to focus state of edit control if 56 * edit control exists. Mimics native actions. 57 * 4. Implemented WM_SETFOCUS in EditWndProc to track status of 58 * focus for 3 above. 59 * 5. The LBN_SELCHANGE is just for documentation purposes. 60 * 61 * mod 5 62 * 1. Add support for CB_GETITEMDATA to a Comboex. Returns the LPARAM 63 * passed during insert of item. 64 * 2. Remember selected item and don't issue CB_SETCURSEL unless needed. 65 * 3. Add initial support for WM_NCCREATE to remove unwanted window styles 66 * (Currently just WS_VSCROLL and WS_HSCROLL, but probably should be 67 * more.) 68 * 4. Improve some traces. 69 * 5. Add support for CB_SETITEMDATA sets LPARAM value from item. 70 * 71 * mod 6 72 * 1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do 73 * WM_NOTIFY correctly based on results. 74 * 2. Fix memory leaks of text strings in COMBOEX_WM_DELETEITEM. 75 * 3. Add routines to handle special cases of NMCBEENDEDIT and NMCOMBOXEX 76 * so translation to ANSI is done correctly. 77 * 4. Fix some issues with COMBOEX_DrawItem. 78 * 79 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe), 80 * WinRAR, and IE 4.0. 27 * 2. Notify CBEN_DRAGBEGIN is not implemented. 81 28 * 82 29 */ … … 85 32 #include "winbase.h" 86 33 #include "commctrl.h" 87 #include " debugtools.h"34 #include "wine/debug.h" 88 35 #include "wine/unicode.h" 89 36 90 DEFAULT_DEBUG_CHANNEL(comboex); 91 /* 92 * The following is necessary for the test done in COMBOEX_DrawItem 93 * to determine whether to dump out the DRAWITEM structure or not. 94 */ 95 DECLARE_DEBUG_CHANNEL(message); 37 WINE_DEFAULT_DEBUG_CHANNEL(comboex); 96 38 97 39 /* Item structure */ … … 101 43 UINT mask; 102 44 LPWSTR pszText; 45 LPWSTR pszTemp; 103 46 int cchTextMax; 104 47 int iImage; … … 117 60 HWND hwndEdit; 118 61 WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */ 119 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */62 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */ 120 63 DWORD dwExtStyle; 121 64 INT selected; /* index of selected item */ 122 65 DWORD flags; /* WINE internal flags */ 123 HFONT hDefaultFont;66 HFONT defaultFont; 124 67 HFONT font; 125 68 INT nb_items; /* Number of items */ 126 BOOL bUnicode;/* TRUE if this window is Unicode */127 BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */69 BOOL unicode; /* TRUE if this window is Unicode */ 70 BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */ 128 71 CBE_ITEMDATA *edit; /* item data for edit item */ 129 72 CBE_ITEMDATA *items; /* Array of items */ … … 131 74 132 75 /* internal flags in the COMBOEX_INFO structure */ 133 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e.76 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e. 134 77 * CBEN_BEGINEDIT issued 135 78 * but CBEN_ENDEDIT{A|W} 136 79 * not yet issued. */ 137 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */ 138 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */ 139 140 141 #define ID_CB_EDIT 1001 80 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */ 81 #define WCBE_EDITHASCHANGED (WCBE_ACTEDIT | WCBE_EDITCHG) 82 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */ 83 84 85 #define ID_CB_EDIT 1001 142 86 143 87 … … 152 96 * only version 4.0 applications will have ODS_COMBOBOXEDIT set. 153 97 */ 154 #define ODS_COMBOEXLBOX 0x400098 #define ODS_COMBOEXLBOX 0x4000 155 99 156 100 157 101 158 102 /* Height in pixels of control over the amount of the selected font */ 159 #define CBE_EXTRA 3103 #define CBE_EXTRA 3 160 104 161 105 /* Indent amount per MS documentation */ 162 #define CBE_INDENT 10106 #define CBE_INDENT 10 163 107 164 108 /* Offset in pixels from left side for start of image or text */ 165 #define CBE_STARTOFFSET 6109 #define CBE_STARTOFFSET 6 166 110 167 111 /* Offset between image and text */ 168 #define CBE_SEP 4 169 170 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0)) 112 #define CBE_SEP 4 113 114 #define COMBOEX_SUBCLASS_PROP "CCComboEx32SubclassInfo" 115 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongW (hwnd, 0)) 171 116 172 117 173 118 /* Things common to the entire DLL */ 174 static ATOM ComboExInfo;175 119 static LRESULT WINAPI 176 120 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 177 121 static LRESULT WINAPI 178 122 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 179 180 static void 181 COMBOEX_DumpItem (CBE_ITEMDATA *item) 182 { 183 if (TRACE_ON(comboex)){ 184 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n", 185 item, item->mask, item->pszText, item->cchTextMax, 186 item->iImage); 187 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 188 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam); 189 if ((item->mask & CBEIF_TEXT) && item->pszText) 190 TRACE("item %p - pszText=%s\n", 191 item, debugstr_w((const WCHAR *)item->pszText)); 192 } 193 } 194 195 196 static void 197 COMBOEX_DumpInput (COMBOBOXEXITEMA *input, BOOL true_for_w) 198 { 199 if (TRACE_ON(comboex)){ 200 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n", 201 input->mask, input->iItem, input->pszText, input->cchTextMax, 202 input->iImage); 203 if ((input->mask & CBEIF_TEXT) && input->pszText) { 204 if (true_for_w) 205 TRACE("input - pszText=<%s>\n", 206 debugstr_w((const WCHAR *)input->pszText)); 207 else 208 TRACE("input - pszText=<%s>\n", 209 debugstr_a((const char *)input->pszText)); 210 } 211 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 212 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam); 213 } 214 } 215 216 217 inline static LRESULT 218 COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 219 { 220 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 221 222 if (infoPtr->hwndCombo) 223 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam); 224 225 return 0; 226 } 227 228 229 static INT 230 COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr) 231 { 232 123 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr); 124 125 inline static BOOL is_textW(LPCWSTR str) 126 { 127 return str && str != LPSTR_TEXTCALLBACKW; 128 } 129 130 inline static BOOL is_textA(LPCSTR str) 131 { 132 return str && str != LPSTR_TEXTCALLBACKA; 133 } 134 135 inline static LPCSTR debugstr_txt(LPCWSTR str) 136 { 137 if (str == LPSTR_TEXTCALLBACKW) return "(callback)"; 138 return debugstr_w(str); 139 } 140 141 static void COMBOEX_DumpItem (CBE_ITEMDATA *item) 142 { 143 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n", 144 item, item->mask, item->pszText, item->cchTextMax, item->iImage); 145 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 146 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam); 147 if (item->mask & CBEIF_TEXT) 148 TRACE("item %p - pszText=%s\n", item, debugstr_txt(item->pszText)); 149 } 150 151 152 static void COMBOEX_DumpInput (COMBOBOXEXITEMW *input) 153 { 154 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n", 155 input->mask, input->iItem, input->pszText, input->cchTextMax, 156 input->iImage); 157 if (input->mask & CBEIF_TEXT) 158 TRACE("input - pszText=<%s>\n", debugstr_txt(input->pszText)); 159 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 160 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam); 161 } 162 163 164 inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index) 165 { 166 return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA, 167 (WPARAM)index, 0); 168 } 169 170 171 static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr) 172 { 233 173 hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf); 234 174 hdr->hwndFrom = infoPtr->hwndSelf; … … 246 186 COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT code, NMCOMBOBOXEXW *hdr) 247 187 { 248 249 188 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ 250 251 hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf);252 hdr->hdr.hwndFrom = infoPtr->hwndSelf;253 hdr->hdr.code = code;254 189 if (infoPtr->NtfUnicode) 255 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 256 (LPARAM)hdr); 190 return COMBOEX_Notify (infoPtr, code, &hdr->hdr); 257 191 else { 258 LPWSTR str, ostr = NULL; 192 LPWSTR wstr = hdr->ceItem.pszText; 193 LPSTR astr = 0; 259 194 INT ret, len = 0; 260 195 261 if (hdr->ceItem.mask & CBEIF_TEXT) { 262 ostr = hdr->ceItem.pszText; 263 str = ostr; 264 if (!str) str = (LPWSTR)L""; 265 len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL); 196 if ((hdr->ceItem.mask & CBEIF_TEXT) && is_textW(wstr)) { 197 len = WideCharToMultiByte (CP_ACP, 0, wstr, -1, 0, 0, NULL, NULL); 266 198 if (len > 0) { 267 hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR)); 268 WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText, 269 len, NULL, NULL); 199 astr = (LPSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR)); 200 if (!astr) return 0; 201 WideCharToMultiByte (CP_ACP, 0, wstr, -1, astr, len, 0, 0); 202 hdr->ceItem.pszText = (LPWSTR)astr; 270 203 } 271 204 } 272 205 273 ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 274 (LPARAM)hdr); 275 if (hdr->ceItem.mask & CBEIF_TEXT) { 276 if (len > 0) 277 COMCTL32_Free (hdr->ceItem.pszText); 278 hdr->ceItem.pszText = ostr; 279 } 206 if (code == CBEN_ENDEDITW) code = CBEN_ENDEDITA; 207 else if (code == CBEN_GETDISPINFOW) code = CBEN_GETDISPINFOA; 208 else if (code == CBEN_DRAGBEGINW) code = CBEN_DRAGBEGINA; 209 210 ret = COMBOEX_Notify (infoPtr, code, (NMHDR *)hdr); 211 212 if (astr && hdr->ceItem.pszText == (LPWSTR)astr) 213 hdr->ceItem.pszText = wstr; 214 215 if (astr) COMCTL32_Free(astr); 216 280 217 return ret; 281 218 } … … 283 220 284 221 285 static INT 286 COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *hdr, LPWSTR itemText) 287 { 288 222 static INT COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *neew, LPCWSTR wstr) 223 { 289 224 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ 290 291 hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf); 292 hdr->hdr.hwndFrom = infoPtr->hwndSelf; 293 hdr->hdr.code = (infoPtr->NtfUnicode) ? CBEN_ENDEDITW : CBEN_ENDEDITA; 294 if (infoPtr->NtfUnicode) 295 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 296 (LPARAM)hdr); 297 else { 298 NMCBEENDEDITA ansi; 299 300 memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR)); 301 ansi.fChanged = hdr->fChanged; 302 ansi.iNewSelection = hdr->iNewSelection; 303 WideCharToMultiByte (CP_ACP, 0, itemText, -1, 304 (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL); 305 ansi.iWhy = hdr->iWhy; 306 return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 307 (LPARAM)&ansi); 308 } 309 } 310 311 312 static void 313 COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size) 225 if (infoPtr->NtfUnicode) { 226 lstrcpynW(neew->szText, wstr, CBEMAXSTRLEN); 227 return COMBOEX_Notify (infoPtr, CBEN_ENDEDITW, &neew->hdr); 228 } else { 229 NMCBEENDEDITA neea; 230 231 memcpy (&neea.hdr, &neew->hdr, sizeof(NMHDR)); 232 neea.fChanged = neew->fChanged; 233 neea.iNewSelection = neew->iNewSelection; 234 WideCharToMultiByte (CP_ACP, 0, wstr, -1, neea.szText, CBEMAXSTRLEN, 0, 0); 235 neea.iWhy = neew->iWhy; 236 237 return COMBOEX_Notify (infoPtr, CBEN_ENDEDITA, &neea.hdr); 238 } 239 } 240 241 242 static void COMBOEX_FreeText (CBE_ITEMDATA *item) 243 { 244 if (is_textW(item->pszText)) COMCTL32_Free(item->pszText); 245 item->pszText = 0; 246 if (item->pszTemp) COMCTL32_Free(item->pszTemp); 247 item->pszTemp = 0; 248 } 249 250 251 static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) 252 { 253 NMCOMBOBOXEXW nmce; 254 LPWSTR text, buf; 255 INT len; 256 257 if (item->pszText != LPSTR_TEXTCALLBACKW) 258 return item->pszText; 259 260 ZeroMemory(&nmce, sizeof(nmce)); 261 nmce.ceItem.mask = CBEIF_TEXT; 262 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); 263 264 if (is_textW(nmce.ceItem.pszText)) { 265 len = MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, NULL, 0); 266 buf = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 267 if (buf) 268 MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, buf, len); 269 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) { 270 COMBOEX_FreeText(item); 271 item->pszText = buf; 272 } else { 273 if (item->pszTemp) COMCTL32_Free(item->pszTemp); 274 item->pszTemp = buf; 275 } 276 text = buf; 277 } else 278 text = nmce.ceItem.pszText; 279 280 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) 281 item->pszText = text; 282 return text; 283 } 284 285 286 static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size) 314 287 { 315 288 HFONT nfont, ofont; … … 326 299 327 300 328 static void 329 COMBOEX_CopyItem (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit) 301 static void COMBOEX_CopyItem (CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit) 330 302 { 331 303 if (cit->mask & CBEIF_TEXT) { 332 cit->pszText = item->pszText; 333 cit->cchTextMax = item->cchTextMax; 304 /* 305 * when given a text buffer actually use that buffer 306 */ 307 if (cit->pszText) { 308 if (is_textW(item->pszText)) 309 lstrcpynW(cit->pszText, item->pszText, cit->cchTextMax); 310 else 311 cit->pszText[0] = 0; 312 } else { 313 cit->pszText = item->pszText; 314 cit->cchTextMax = item->cchTextMax; 315 } 334 316 } 335 317 if (cit->mask & CBEIF_IMAGE) … … 343 325 if (cit->mask & CBEIF_LPARAM) 344 326 cit->lParam = item->lParam; 345 346 } 347 348 349 static void 350 COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr) 327 } 328 329 330 static void COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr) 351 331 { 352 332 SIZE mysize; 353 IMAGEINFO iinfo; 354 INT x, y, w, h, xoff = 0; 333 INT x, y, w, h, xioff; 355 334 RECT rect; 356 335 357 336 if (!infoPtr->hwndEdit) return; 358 iinfo.rcImage.left = iinfo.rcImage.right = 0; 359 if (infoPtr->himl) { 337 338 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) { 339 IMAGEINFO iinfo; 340 iinfo.rcImage.left = iinfo.rcImage.right = 0; 360 341 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); 361 xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; 362 } 342 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; 343 } else xioff = 0; 344 363 345 GetClientRect (infoPtr->hwndCombo, &rect); 364 346 InflateRect (&rect, -2, -2); … … 368 350 COMBOEX_GetComboFontSize (infoPtr, &mysize); 369 351 TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy); 370 x = xoff + CBE_STARTOFFSET + 1; 371 y = CBE_EXTRA + 1; 352 x = xioff + CBE_STARTOFFSET + 1; 372 353 w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1; 373 354 h = mysize.cy + 1; 355 y = rect.bottom - h - 1; 374 356 375 357 TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n", 376 rect.left, rect.top, rect.right, rect.bottom, 377 x, y, x + w, y + h); 378 SetWindowPos(infoPtr->hwndEdit, HWND_TOP, 379 x, y, 380 w, h, 358 rect.left, rect.top, rect.right, rect.bottom, x, y, x + w, y + h); 359 SetWindowPos(infoPtr->hwndEdit, HWND_TOP, x, y, w, h, 381 360 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); 382 361 } 383 362 384 363 385 static void 386 COMBOEX_ReSize (HWND hwnd, COMBOEX_INFO *infoPtr) 364 static void COMBOEX_ReSize (COMBOEX_INFO *infoPtr) 387 365 { 388 366 SIZE mysize; … … 397 375 TRACE("upgraded height due to image: height=%d\n", cy); 398 376 } 399 SendMessageW ( hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM)cy);377 SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy); 400 378 if (infoPtr->hwndCombo) 401 379 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, … … 404 382 405 383 406 static void 407 COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) 384 static void COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) 408 385 { 409 386 if (!infoPtr->hwndEdit) return; … … 413 390 /* EM_SETSEL32 (0,-1) */ 414 391 if (item->mask & CBEIF_TEXT) { 415 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM) item->pszText);392 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)COMBOEX_GetText(infoPtr, item)); 416 393 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0); 417 394 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1); … … 420 397 421 398 422 static CBE_ITEMDATA * 423 COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index) 399 static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index) 424 400 { 425 401 CBE_ITEMDATA *item; … … 439 415 } 440 416 if (!item || (i != index)) { 441 FIXME("COMBOBOXEX item structures broken. Please report!\n");417 ERR("COMBOBOXEX item structures broken. Please report!\n"); 442 418 return 0; 443 419 } … … 446 422 447 423 448 static void 449 COMBOEX_WarnCallBack (CBE_ITEMDATA *item) 450 { 451 if (item->pszText == LPSTR_TEXTCALLBACKW) 452 FIXME("Callback not implemented yet for pszText\n"); 453 if (item->iImage == I_IMAGECALLBACK) 454 FIXME("Callback not implemented yet for iImage\n"); 455 if (item->iSelectedImage == I_IMAGECALLBACK) 456 FIXME("Callback not implemented yet for iSelectedImage\n"); 457 if (item->iOverlay == I_IMAGECALLBACK) 458 FIXME("Callback not implemented yet for iOverlay\n"); 459 if (item->iIndent == I_INDENTCALLBACK) 460 FIXME("Callback not implemented yet for iIndent\n"); 461 } 462 424 static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr) 425 { 426 return infoPtr->hwndEdit; 427 } 428 463 429 464 430 /* *** CBEM_xxx message support *** */ 465 431 466 432 467 static LRESULT 468 COMBOEX_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 469 { 470 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 471 INT index = (INT) wParam; 433 static INT COMBOEX_DeleteItem (COMBOEX_INFO *infoPtr, INT index) 434 { 472 435 CBE_ITEMDATA *item; 473 436 474 TRACE("( 0x%08x 0x%08lx)\n", wParam, lParam);437 TRACE("(index=%d)\n", index); 475 438 476 439 /* if item number requested does not exist then return failure */ 477 if ((index > infoPtr->nb_items) || (index < 0)) { 478 ERR("attempt to delete item that does not exist\n"); 479 return CB_ERR; 480 } 481 482 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 483 ERR("attempt to delete item that was not found!\n"); 484 return CB_ERR; 485 } 440 if ((index > infoPtr->nb_items) || (index < 0)) return CB_ERR; 441 if (!(item = COMBOEX_FindItem(infoPtr, index))) return CB_ERR; 486 442 487 443 /* doing this will result in WM_DELETEITEM being issued */ … … 492 448 493 449 494 inline static LRESULT 495 COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam) 496 { 497 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 498 499 TRACE("\n"); 500 501 return (LRESULT)infoPtr->hwndCombo; 502 } 503 504 505 inline static LRESULT 506 COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam) 507 { 508 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 509 510 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN) 511 return 0; 512 513 TRACE("-- 0x%x\n", infoPtr->hwndEdit); 514 515 return (LRESULT)infoPtr->hwndEdit; 516 } 517 518 519 inline static LRESULT 520 COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam) 521 { 522 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 523 524 TRACE("-- 0x%08lx\n", infoPtr->dwExtStyle); 525 526 return (LRESULT)infoPtr->dwExtStyle; 527 } 528 529 530 inline static LRESULT 531 COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) 532 { 533 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 534 535 TRACE("-- %p\n", infoPtr->himl); 536 537 return (LRESULT)infoPtr->himl; 538 } 539 540 541 static LRESULT 542 COMBOEX_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) 543 { 544 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 545 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam; 546 INT index; 450 static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) 451 { 452 INT index = cit->iItem; 547 453 CBE_ITEMDATA *item; 548 454 549 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam); 550 551 /* get real index of item to insert */ 552 index = cit->iItem; 455 TRACE("(...)\n"); 553 456 554 457 /* if item number requested does not exist then return failure */ 555 if ((index > infoPtr->nb_items) || (index < -1)) { 556 ERR("attempt to get item that does not exist\n"); 557 return 0; 558 } 458 if ((index > infoPtr->nb_items) || (index < -1)) return FALSE; 559 459 560 460 /* if the item is the edit control and there is no edit control, skip */ 561 if ((index == -1) && 562 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)) 563 return 0; 564 565 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 566 ERR("attempt to get item that was not found!\n"); 567 return 0; 568 } 569 570 COMBOEX_CopyItem (infoPtr, item, cit); 461 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE; 462 463 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE; 464 465 COMBOEX_CopyItem (item, cit); 571 466 572 467 return TRUE; … … 574 469 575 470 576 inline static LRESULT 577 COMBOEX_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 578 { 579 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam; 471 static BOOL COMBOEX_GetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) 472 { 580 473 COMBOBOXEXITEMW tmpcit; 581 INT len; 582 583 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam); 474 475 TRACE("(...)\n"); 584 476 585 477 tmpcit.mask = cit->mask; 586 478 tmpcit.iItem = cit->iItem; 587 COMBOEX_GetItemW (hwnd, wParam, (LPARAM) &tmpcit);588 589 len = WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 0, 0, NULL, NULL); 590 if ( len > 0)591 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,479 tmpcit.pszText = 0; 480 if(!COMBOEX_GetItemW (infoPtr, &tmpcit)) return FALSE; 481 482 if (is_textW(tmpcit.pszText) && cit->pszText) 483 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 592 484 cit->pszText, cit->cchTextMax, NULL, NULL); 485 else if (cit->pszText) cit->pszText[0] = 0; 486 else cit->pszText = (LPSTR)tmpcit.pszText; 593 487 594 488 cit->iImage = tmpcit.iImage; … … 602 496 603 497 604 inline static LRESULT 605 COMBOEX_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) 606 { 607 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 608 609 TRACE("%s hwnd=0x%x\n", 610 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd); 611 612 return infoPtr->bUnicode; 613 } 614 615 616 inline static LRESULT 617 COMBOEX_HasEditChanged (HWND hwnd, WPARAM wParam, LPARAM lParam) 618 { 619 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 620 621 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN) 622 return FALSE; 623 if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) == 624 (WCBE_ACTEDIT | WCBE_EDITCHG)) 625 return TRUE; 626 return FALSE; 627 } 628 629 630 static LRESULT 631 COMBOEX_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) 632 { 633 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 634 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam; 498 inline static BOOL COMBOEX_HasEditChanged (COMBOEX_INFO *infoPtr) 499 { 500 return COMBOEX_HasEdit(infoPtr) && 501 (infoPtr->flags & WCBE_EDITHASCHANGED) == WCBE_EDITHASCHANGED; 502 } 503 504 505 static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) 506 { 635 507 INT index; 636 508 CBE_ITEMDATA *item; … … 639 511 TRACE("\n"); 640 512 641 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);513 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit); 642 514 643 515 /* get real index of item to insert */ … … 646 518 if (index > infoPtr->nb_items) index = infoPtr->nb_items; 647 519 648 /* get space and chain it in */ 649 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA)); 650 item->next = NULL; 651 item->pszText = NULL; 652 520 /* get zero-filled space and chain it in */ 521 if(!(item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof(*item)))) return -1; 522 653 523 /* locate position to insert new item in */ 654 524 if (index == infoPtr->nb_items) { … … 666 536 } 667 537 if (!moving) { 668 FIXME("COMBOBOXEX item structures broken. Please report!\n");538 ERR("COMBOBOXEX item structures broken. Please report!\n"); 669 539 COMCTL32_Free(item); 670 540 return -1; … … 675 545 676 546 /* fill in our hidden item structure */ 677 item->mask = cit->mask;547 item->mask = cit->mask; 678 548 if (item->mask & CBEIF_TEXT) { 679 LPWSTR str; 680 INT len; 681 682 str = cit->pszText; 683 if (!str) str = (LPWSTR) L""; 684 len = strlenW (str); 549 INT len = 0; 550 551 if (is_textW(cit->pszText)) len = strlenW (cit->pszText); 685 552 if (len > 0) { 686 553 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 687 strcpyW (item->pszText, str); 688 } 689 else 690 item->pszText = NULL; 691 item->cchTextMax = cit->cchTextMax; 554 if (!item->pszText) { 555 COMCTL32_Free(item); 556 return -1; 557 } 558 strcpyW (item->pszText, cit->pszText); 559 } 560 else if (cit->pszText == LPSTR_TEXTCALLBACKW) 561 item->pszText = LPSTR_TEXTCALLBACKW; 562 item->cchTextMax = cit->cchTextMax; 692 563 } 693 564 if (item->mask & CBEIF_IMAGE) 694 item->iImage= cit->iImage;565 item->iImage = cit->iImage; 695 566 if (item->mask & CBEIF_SELECTEDIMAGE) 696 item->iSelectedImage = cit->iSelectedImage;567 item->iSelectedImage = cit->iSelectedImage; 697 568 if (item->mask & CBEIF_OVERLAY) 698 item->iOverlay= cit->iOverlay;569 item->iOverlay = cit->iOverlay; 699 570 if (item->mask & CBEIF_INDENT) 700 item->iIndent= cit->iIndent;571 item->iIndent = cit->iIndent; 701 572 if (item->mask & CBEIF_LPARAM) 702 item->lParam= cit->lParam;573 item->lParam = cit->lParam; 703 574 infoPtr->nb_items++; 704 575 705 COMBOEX_WarnCallBack (item); 706 707 COMBOEX_DumpItem (item); 576 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); 708 577 709 578 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, 710 579 (WPARAM)cit->iItem, (LPARAM)item); 711 580 712 COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem); 581 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem)); 582 COMBOEX_CopyItem (item, &nmcit.ceItem); 713 583 COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit); 714 584 … … 718 588 719 589 720 static LRESULT 721 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 722 { 723 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam; 724 COMBOBOXEXITEMW citW; 725 LRESULT ret; 590 static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) 591 { 592 COMBOBOXEXITEMW citW; 593 LPWSTR wstr = NULL; 594 INT ret; 726 595 727 596 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA)); 728 if (cit->mask & CBEIF_TEXT) { 729 LPSTR str; 730 INT len; 731 732 str = cit->pszText; 733 if (!str) str=""; 734 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0); 735 if (len > 0) { 736 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 737 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len); 738 } 739 } 740 ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);; 741 742 if (cit->mask & CBEIF_TEXT) 743 COMCTL32_Free(citW.pszText); 597 if (cit->mask & CBEIF_TEXT && is_textA(cit->pszText)) { 598 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0); 599 wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 600 if (!wstr) return -1; 601 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len); 602 citW.pszText = wstr; 603 } 604 ret = COMBOEX_InsertItemW(infoPtr, &citW);; 605 606 if (wstr) COMCTL32_Free(wstr); 607 744 608 return ret; 745 609 } 746 610 747 611 748 static LRESULT 749 COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam) 750 { 751 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 612 static DWORD 613 COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style) 614 { 752 615 DWORD dwTemp; 753 616 754 TRACE("( 0x%08x 0x%08lx)\n", wParam, lParam);617 TRACE("(mask=x%08lx, style=0x%08lx)\n", mask, style); 755 618 756 619 dwTemp = infoPtr->dwExtStyle; 757 620 758 if (lParam & (CBES_EX_NOEDITIMAGEINDENT | 759 CBES_EX_PATHWORDBREAKPROC | 621 if (style & (CBES_EX_PATHWORDBREAKPROC | 760 622 CBES_EX_NOSIZELIMIT | 761 623 CBES_EX_CASESENSITIVE)) 762 FIXME("Extended style not implemented %08lx\n", lParam); 763 764 if ((DWORD)wParam) { 765 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam; 766 } 624 FIXME("Extended style not implemented %08lx\n", style); 625 626 if (mask) 627 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~mask) | style; 767 628 else 768 infoPtr->dwExtStyle = (DWORD)lParam; 769 770 /* 771 * native does this for CBES_EX_NOEDITIMAGE state change 772 */ 773 if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^ 774 (dwTemp & CBES_EX_NOEDITIMAGE)) { 629 infoPtr->dwExtStyle = style; 630 631 /* test if the control's appearance has changed */ 632 mask = CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT; 633 if ((infoPtr->dwExtStyle & mask) != (dwTemp & mask)) { 775 634 /* if state of EX_NOEDITIMAGE changes, invalidate all */ 776 635 TRACE("EX_NOEDITIMAGE state changed to %ld\n", 777 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);778 InvalidateRect ( hwnd, NULL, TRUE);636 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE); 637 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE); 779 638 COMBOEX_AdjustEditPos (infoPtr); 780 639 if (infoPtr->hwndEdit) … … 782 641 } 783 642 784 return (LRESULT)dwTemp; 785 } 786 787 788 inline static LRESULT 789 COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) 790 { 791 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 792 HIMAGELIST himlTemp; 793 794 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam); 795 796 himlTemp = infoPtr->himl; 797 infoPtr->himl = (HIMAGELIST)lParam; 798 799 COMBOEX_ReSize (hwnd, infoPtr); 643 return dwTemp; 644 } 645 646 647 static HIMAGELIST COMBOEX_SetImageList (COMBOEX_INFO *infoPtr, HIMAGELIST himl) 648 { 649 HIMAGELIST himlTemp = infoPtr->himl; 650 651 TRACE("(...)\n"); 652 653 infoPtr->himl = himl; 654 655 COMBOEX_ReSize (infoPtr); 800 656 InvalidateRect (infoPtr->hwndCombo, NULL, TRUE); 801 657 802 658 /* reposition the Edit control based on whether icon exists */ 803 659 COMBOEX_AdjustEditPos (infoPtr); 804 return (LRESULT)himlTemp; 805 } 806 807 static LRESULT 808 COMBOEX_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) 809 { 810 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 811 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam; 812 INT index; 660 return himlTemp; 661 } 662 663 static BOOL COMBOEX_SetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) 664 { 665 INT index = cit->iItem; 813 666 CBE_ITEMDATA *item; 814 667 815 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE); 816 817 /* get real index of item to insert */ 818 index = cit->iItem; 668 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit); 819 669 820 670 /* if item number requested does not exist then return failure */ 821 if ((index > infoPtr->nb_items) || (index < -1)) { 822 ERR("attempt to set item that does not exist yet!\n"); 823 return 0; 824 } 671 if ((index > infoPtr->nb_items) || (index < -1)) return FALSE; 825 672 826 673 /* if the item is the edit control and there is no edit control, skip */ 827 if ((index == -1) && 828 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)) 829 return 0; 830 831 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 832 ERR("attempt to set item that was not found!\n"); 833 return 0; 834 } 674 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE; 675 676 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE; 835 677 836 678 /* add/change stuff to the internal item structure */ 837 679 item->mask |= cit->mask; 838 680 if (cit->mask & CBEIF_TEXT) { 839 LPWSTR str; 840 INT len; 841 WCHAR emptystr[1] = {0}; 842 843 str = cit->pszText; 844 if (!str) str=emptystr; 845 len = strlenW(str); 681 INT len = 0; 682 683 COMBOEX_FreeText(item); 684 if (is_textW(cit->pszText)) len = strlenW(cit->pszText); 846 685 if (len > 0) { 847 686 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 848 strcpyW(item->pszText,str); 849 } 850 item->cchTextMax = cit->cchTextMax; 687 if (!item->pszText) return FALSE; 688 strcpyW(item->pszText, cit->pszText); 689 } else if (cit->pszText == LPSTR_TEXTCALLBACKW) 690 item->pszText = LPSTR_TEXTCALLBACKW; 691 item->cchTextMax = cit->cchTextMax; 851 692 } 852 693 if (cit->mask & CBEIF_IMAGE) 853 item->iImage= cit->iImage;694 item->iImage = cit->iImage; 854 695 if (cit->mask & CBEIF_SELECTEDIMAGE) 855 item->iSelectedImage = cit->iSelectedImage;696 item->iSelectedImage = cit->iSelectedImage; 856 697 if (cit->mask & CBEIF_OVERLAY) 857 item->iOverlay= cit->iOverlay;698 item->iOverlay = cit->iOverlay; 858 699 if (cit->mask & CBEIF_INDENT) 859 item->iIndent= cit->iIndent;700 item->iIndent = cit->iIndent; 860 701 if (cit->mask & CBEIF_LPARAM) 861 cit->lParam = cit->lParam; 862 863 COMBOEX_WarnCallBack (item); 864 865 COMBOEX_DumpItem (item); 702 cit->lParam = cit->lParam; 703 704 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); 866 705 867 706 /* if original request was to update edit control, do some fast foot work */ … … 873 712 } 874 713 875 static LRESULT 876 COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 877 { 878 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam; 879 COMBOBOXEXITEMW citW; 880 LRESULT ret; 881 882 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA)); 883 if (cit->mask & CBEIF_TEXT) { 884 LPSTR str; 885 INT len; 886 887 str = cit->pszText; 888 if (!str) str=""; 889 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0); 890 if (len > 0) { 891 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 892 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len); 893 } 894 } 895 ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);; 896 897 if (cit->mask & CBEIF_TEXT) 898 COMCTL32_Free(citW.pszText); 714 static BOOL COMBOEX_SetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) 715 { 716 COMBOBOXEXITEMW citW; 717 LPWSTR wstr = NULL; 718 BOOL ret; 719 720 memcpy(&citW, cit, sizeof(COMBOBOXEXITEMA)); 721 if ((cit->mask & CBEIF_TEXT) && is_textA(cit->pszText)) { 722 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0); 723 wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 724 if (!wstr) return FALSE; 725 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len); 726 citW.pszText = wstr; 727 } 728 ret = COMBOEX_SetItemW(infoPtr, &citW);; 729 730 if (wstr) COMCTL32_Free(wstr); 731 899 732 return ret; 900 733 } 901 734 902 735 903 inline static LRESULT 904 COMBOEX_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) 905 { 906 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 907 BOOL bTemp = infoPtr->bUnicode; 908 909 TRACE("to %s hwnd=0x%04x, was %s\n", 910 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd, 911 (bTemp) ? "TRUE" : "FALSE"); 912 913 infoPtr->bUnicode = (BOOL)wParam; 736 static BOOL COMBOEX_SetUnicodeFormat (COMBOEX_INFO *infoPtr, BOOL value) 737 { 738 BOOL bTemp = infoPtr->unicode; 739 740 TRACE("to %s, was %s\n", value ? "TRUE":"FALSE", bTemp ? "TRUE":"FALSE"); 741 742 infoPtr->unicode = value; 914 743 915 744 return bTemp; … … 917 746 918 747 919 920 748 /* *** CB_xxx message support *** */ 921 749 922 923 static LRESULT 924 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 750 static INT 751 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCSTR str) 925 752 { 926 753 INT i, count; 927 754 CBE_ITEMDATA *item; 928 755 LPWSTR desired = NULL; 929 INT start = (INT) wParam; 930 931 i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0); 756 757 i = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0); 932 758 if (i > 0) { 933 759 desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR)); 934 MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i); 935 } 936 937 count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0 , 0); 760 if (!desired) return CB_ERR; 761 MultiByteToWideChar (CP_ACP, 0, str, -1, desired, i); 762 } 763 764 count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0); 938 765 939 766 /* now search from after starting loc and wrapping back to start */ 940 767 for(i=start+1; i<count; i++) { 941 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 942 CB_GETITEMDATA, (WPARAM)i, 0); 943 TRACE("desired=%s, item=%s\n", 944 debugstr_w(desired), debugstr_w(item->pszText)); 945 if (lstrcmpiW(item->pszText, desired) == 0) { 768 item = get_item_data(infoPtr, i); 769 if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) { 946 770 COMCTL32_Free (desired); 947 771 return i; … … 949 773 } 950 774 for(i=0; i<=start; i++) { 951 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 952 CB_GETITEMDATA, (WPARAM)i, 0); 953 TRACE("desired=%s, item=%s\n", 954 debugstr_w(desired), debugstr_w(item->pszText)); 955 if (lstrcmpiW(item->pszText, desired) == 0) { 775 item = get_item_data(infoPtr, i); 776 if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) { 956 777 COMCTL32_Free (desired); 957 778 return i; … … 963 784 964 785 965 static LRESULT 966 COMBOEX_GetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam) 967 { 968 INT index = wParam; 969 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 786 static DWORD COMBOEX_GetItemData (COMBOEX_INFO *infoPtr, INT index) 787 { 970 788 CBE_ITEMDATA *item1, *item2; 971 LRESULT lret = 0; 972 973 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 974 wParam, lParam); 789 DWORD ret = 0; 790 791 item1 = get_item_data(infoPtr, index); 975 792 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { 976 793 item2 = COMBOEX_FindItem (infoPtr, index); … … 979 796 return CB_ERR; 980 797 } 981 if (item1->mask & CBEIF_LPARAM) 982 lret = (LRESULT) item1->lParam; 983 TRACE("returning 0x%08lx\n", lret); 984 return lret; 985 } 986 lret = (LRESULT)item1; 987 TRACE("non-valid result from combo, returning 0x%08lx\n", lret); 988 return lret; 989 } 990 991 992 static LRESULT 993 COMBOEX_SetCursel (HWND hwnd, WPARAM wParam, LPARAM lParam) 994 { 995 INT index = wParam; 996 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 798 if (item1->mask & CBEIF_LPARAM) ret = item1->lParam; 799 TRACE("returning 0x%08lx\n", ret); 800 } else { 801 ret = (DWORD)item1; 802 TRACE("non-valid result from combo, returning 0x%08lx\n", ret); 803 } 804 return ret; 805 } 806 807 808 static INT COMBOEX_SetCursel (COMBOEX_INFO *infoPtr, INT index) 809 { 997 810 CBE_ITEMDATA *item; 998 LRESULT lret; 999 1000 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 1001 /* FIXME: need to clear selection */ 1002 return CB_ERR; 1003 } 1004 1005 TRACE("selecting item %d text=%s\n", index, (item->pszText) ? 1006 debugstr_w(item->pszText) : "<null>"); 811 INT sel; 812 813 if (!(item = COMBOEX_FindItem(infoPtr, index))) 814 return SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0); 815 816 TRACE("selecting item %d text=%s\n", index, debugstr_txt(item->pszText)); 1007 817 infoPtr->selected = index; 1008 818 1009 lret = SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, wParam, lParam);819 sel = (INT)SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0); 1010 820 COMBOEX_SetEditText (infoPtr, item); 1011 return lret; 1012 } 1013 1014 1015 static LRESULT 1016 COMBOEX_SetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam) 1017 { 1018 INT index = wParam; 1019 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 821 return sel; 822 } 823 824 825 static DWORD COMBOEX_SetItemData (COMBOEX_INFO *infoPtr, INT index, DWORD data) 826 { 1020 827 CBE_ITEMDATA *item1, *item2; 1021 828 1022 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 1023 wParam, lParam); 829 item1 = get_item_data(infoPtr, index); 1024 830 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { 1025 831 item2 = COMBOEX_FindItem (infoPtr, index); … … 1029 835 } 1030 836 item1->mask |= CBEIF_LPARAM; 1031 item1->lParam = lParam;1032 TRACE("setting lparam to 0x%08lx\n", lParam);837 item1->lParam = data; 838 TRACE("setting lparam to 0x%08lx\n", data); 1033 839 return 0; 1034 840 } … … 1038 844 1039 845 1040 static LRESULT 1041 COMBOEX_SetItemHeight (HWND hwnd, WPARAM wParam, LPARAM lParam) 1042 { 1043 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 846 static INT COMBOEX_SetItemHeight (COMBOEX_INFO *infoPtr, INT index, UINT height) 847 { 1044 848 RECT cb_wrect, cbx_wrect, cbx_crect; 1045 LRESULT ret = 0;1046 UINT height;1047 849 1048 850 /* First, lets forward the message to the normal combo control 1049 851 just like Windows. */ 1050 if (infoPtr->hwndCombo) 1051 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam); 852 if (infoPtr->hwndCombo) 853 if (SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, 854 index, height) == CB_ERR) return CB_ERR; 1052 855 1053 856 GetWindowRect (infoPtr->hwndCombo, &cb_wrect); 1054 GetWindowRect ( hwnd, &cbx_wrect);1055 GetClientRect ( hwnd, &cbx_crect);857 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect); 858 GetClientRect (infoPtr->hwndSelf, &cbx_crect); 1056 859 /* the height of comboex as height of the combo + comboex border */ 1057 860 height = cb_wrect.bottom-cb_wrect.top … … 1064 867 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom, 1065 868 cbx_wrect.right-cbx_wrect.left, height); 1066 SetWindowPos (hwnd, HWND_TOP, 0, 0, 1067 cbx_wrect.right-cbx_wrect.left, 1068 height, 869 SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0, 870 cbx_wrect.right-cbx_wrect.left, height, 1069 871 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); 1070 872 1071 return ret;873 return 0; 1072 874 } 1073 875 … … 1076 878 1077 879 1078 static LRESULT 1079 COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) 1080 { 1081 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam; 880 static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs) 881 { 882 WCHAR COMBOBOX[] = { 'C', 'o', 'm', 'b', 'o', 'B', 'o', 'x', 0 }; 883 WCHAR EDIT[] = { 'E', 'D', 'I', 'T', 0 }; 884 WCHAR NIL[] = { 0 }; 1082 885 COMBOEX_INFO *infoPtr; 1083 886 DWORD dwComboStyle; 1084 LOGFONTA mylogfont; 1085 CBE_ITEMDATA *item; 887 LOGFONTW mylogfont; 1086 888 RECT wnrc1, clrc1, cmbwrc; 1087 LONG test;1088 889 INT i; 1089 890 1090 891 /* allocate memory for info structure */ 1091 892 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO)); 1092 if (infoPtr == NULL) { 1093 ERR("could not allocate info memory!\n"); 1094 return 0; 1095 } 893 if (!infoPtr) return -1; 1096 894 1097 895 /* initialize info structure */ 1098 1099 infoPtr->items = NULL; 1100 infoPtr->nb_items = 0; 896 /* note that infoPtr is allocated zero-filled */ 897 1101 898 infoPtr->hwndSelf = hwnd; 1102 899 infoPtr->selected = -1; 1103 900 1104 infoPtr->bUnicode = IsWindowUnicode (hwnd); 1105 1106 i = SendMessageA(GetParent (hwnd), 1107 WM_NOTIFYFORMAT, hwnd, NF_QUERY); 1108 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { 1109 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", 1110 i); 901 infoPtr->unicode = IsWindowUnicode (hwnd); 902 903 i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, hwnd, NF_QUERY); 904 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) { 905 WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i); 1111 906 i = NFR_ANSI; 1112 907 } 1113 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;1114 1115 SetWindowLong A(hwnd, 0, (DWORD)infoPtr);908 infoPtr->NtfUnicode = (i == NFR_UNICODE); 909 910 SetWindowLongW (hwnd, 0, (DWORD)infoPtr); 1116 911 1117 912 /* create combo box */ 1118 dwComboStyle = GetWindowLong A(hwnd, GWL_STYLE) &913 dwComboStyle = GetWindowLongW (hwnd, GWL_STYLE) & 1119 914 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD); 1120 915 … … 1136 931 /* (allow space for the icons). */ 1137 932 1138 infoPtr->hwndCombo = CreateWindow A ("ComboBox", "",933 infoPtr->hwndCombo = CreateWindowW (COMBOBOX, NIL, 1139 934 /* following line added to match native */ 1140 935 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | … … 1143 938 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle, 1144 939 cs->y, cs->x, cs->cx, cs->cy, hwnd, 1145 (HMENU) GetWindowLong A(hwnd, GWL_ID),1146 GetWindowLong A(hwnd, GWL_HINSTANCE), NULL);940 (HMENU) GetWindowLongW (hwnd, GWL_ID), 941 GetWindowLongW (hwnd, GWL_HINSTANCE), NULL); 1147 942 1148 943 /* … … 1158 953 * data structure. 1159 954 */ 1160 test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo); 1161 if (!test || ((COMBOEX_INFO *)test != infoPtr)) { 1162 SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr); 1163 } 1164 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo, 955 SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd); 956 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo, 1165 957 GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc); 1166 958 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); … … 1172 964 */ 1173 965 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) { 1174 infoPtr->hwndEdit = CreateWindowEx A (0, "EDIT", "",966 infoPtr->hwndEdit = CreateWindowExW (0, EDIT, NIL, 1175 967 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL, 1176 968 0, 0, 0, 0, /* will set later */ 1177 969 infoPtr->hwndCombo, 1178 (HMENU) GetWindowLong A(hwnd, GWL_ID),1179 GetWindowLong A(hwnd, GWL_HINSTANCE),970 (HMENU) GetWindowLongW (hwnd, GWL_ID), 971 GetWindowLongW (hwnd, GWL_HINSTANCE), 1180 972 NULL); 1181 973 … … 1191 983 * data structure. 1192 984 */ 1193 test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo); 1194 if (!test || ((COMBOEX_INFO *)test != infoPtr)) { 1195 SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr); 1196 } 1197 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit, 985 SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd); 986 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit, 1198 987 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc); 1199 988 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); 1200 }1201 else {1202 infoPtr->hwndEdit = 0;1203 infoPtr->font = 0;1204 989 } 1205 990 … … 1209 994 */ 1210 995 if (!infoPtr->font) { 1211 SystemParametersInfo A(SPI_GETICONTITLELOGFONT, sizeof(mylogfont),996 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), 1212 997 &mylogfont, 0); 1213 infoPtr->font = infoPtr-> hDefaultFont = CreateFontIndirectA(&mylogfont);998 infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont); 1214 999 } 1215 1000 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0); … … 1219 1004 } 1220 1005 1221 COMBOEX_ReSize ( hwnd,infoPtr);1006 COMBOEX_ReSize (infoPtr); 1222 1007 1223 1008 /* Above is fairly certain, below is much less certain. */ … … 1245 1030 /* 1246 1031 * Create an item structure to represent the data in the 1247 * EDIT control. 1032 * EDIT control. It is allocated zero-filled. 1248 1033 */ 1249 i tem= (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));1250 i tem->next = NULL;1251 item->pszText = NULL;1252 item->mask = 0;1253 infoPtr->edit = item;1034 infoPtr->edit = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA)); 1035 if (!infoPtr->edit) { 1036 COMBOEX_Destroy(infoPtr); 1037 return -1; 1038 } 1254 1039 1255 1040 return 0; … … 1257 1042 1258 1043 1259 inline static LRESULT 1260 COMBOEX_Command (HWND hwnd, WPARAM wParam, LPARAM lParam) 1044 static LRESULT COMBOEX_Command (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 1261 1045 { 1262 1046 LRESULT lret; 1263 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);1264 1047 INT command = HIWORD(wParam); 1265 1048 CBE_ITEMDATA *item = 0; … … 1268 1051 NMCBEENDEDITW cbeend; 1269 1052 DWORD oldflags; 1053 HWND parent = GetParent (infoPtr->hwndSelf); 1270 1054 1271 1055 TRACE("for command %d\n", command); … … 1274 1058 { 1275 1059 case CBN_DROPDOWN: 1276 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1277 (LPARAM)hwnd); 1060 SetFocus (infoPtr->hwndCombo); 1061 ShowWindow (infoPtr->hwndEdit, SW_HIDE); 1062 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1063 1064 case CBN_CLOSEUP: 1065 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1278 1066 /* 1279 1067 * from native trace of first dropdown after typing in URL in IE4 … … 1289 1077 * the rest is supposition 1290 1078 */ 1079 ShowWindow (infoPtr->hwndEdit, SW_SHOW); 1080 InvalidateRect (infoPtr->hwndCombo, 0, TRUE); 1081 InvalidateRect (infoPtr->hwndEdit, 0, TRUE); 1291 1082 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); 1292 1083 if (cursel == -1) { … … 1295 1086 n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0); 1296 1087 for (cursel = 0; cursel < n; cursel++){ 1297 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 1298 CB_GETITEMDATA, 1299 cursel, 0); 1088 item = get_item_data(infoPtr, cursel); 1300 1089 if ((INT)item == CB_ERR) break; 1301 if ( lstrcmpiW(item->pszText, wintext) == 0) break;1090 if (!lstrcmpiW(COMBOEX_GetText(infoPtr, item), wintext)) break; 1302 1091 } 1303 1092 if ((cursel == n) || ((INT)item == CB_ERR)) { … … 1310 1099 } 1311 1100 else { 1312 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 1313 CB_GETITEMDATA, 1314 cursel, 0); 1101 item = get_item_data(infoPtr, cursel); 1315 1102 if ((INT)item == CB_ERR) { 1316 1103 TRACE("failed to find match??? item=%p cursel=%d\n", … … 1332 1119 cbeend.iWhy = CBENF_DROPDOWN; 1333 1120 1334 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) { 1335 /* abort the change */ 1336 TRACE("Notify requested abort of change\n"); 1337 return 0; 1338 } 1121 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, COMBOEX_GetText(infoPtr, item))) return 0; 1339 1122 } 1340 1123 … … 1343 1126 if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) { 1344 1127 infoPtr->selected = cursel; 1345 SendMessageW ( hwnd, CB_SETCURSEL, cursel, 0);1128 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, cursel, 0); 1346 1129 SetFocus(infoPtr->hwndCombo); 1347 1130 } … … 1369 1152 infoPtr->selected = oldItem; 1370 1153 COMBOEX_SetEditText (infoPtr, item); 1371 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1372 (LPARAM)hwnd); 1154 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1373 1155 1374 1156 case CBN_SELENDOK: … … 1377 1159 * issuing the message. IE4 depends on this. 1378 1160 */ 1379 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1380 (LPARAM)hwnd); 1161 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1381 1162 1382 1163 case CBN_KILLFOCUS: … … 1392 1173 * return 0 1393 1174 */ 1394 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1395 (LPARAM)hwnd); 1175 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1396 1176 if (infoPtr->flags & WCBE_ACTEDIT) { 1397 1177 GetWindowTextW (infoPtr->hwndEdit, wintext, 260); … … 1402 1182 1403 1183 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); 1404 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) { 1405 /* abort the change */ 1406 TRACE("Notify requested abort of change\n"); 1407 return 0; 1408 } 1184 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) return 0; 1409 1185 } 1410 1186 /* possible CB_GETCURSEL */ … … 1412 1188 return 0; 1413 1189 1414 case CBN_CLOSEUP:1415 1190 default: 1416 1191 /* … … 1420 1195 * after passing the command to the parent of the ComboEx. 1421 1196 */ 1422 lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1423 (LPARAM)hwnd); 1197 lret = SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1424 1198 if (infoPtr->hwndEdit) 1425 1199 SetFocus(infoPtr->hwndEdit); … … 1430 1204 1431 1205 1432 inline static LRESULT 1433 COMBOEX_WM_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 1434 { 1435 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1436 DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)lParam; 1206 static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis) 1207 { 1437 1208 CBE_ITEMDATA *item, *olditem; 1209 NMCOMBOBOXEXW nmcit; 1438 1210 INT i; 1439 NMCOMBOBOXEXW nmcit;1440 1211 1441 1212 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n", … … 1460 1231 } 1461 1232 if (!item->next || (i != dis->itemID)) { 1462 FIXME("COMBOBOXEX item structures broken. Please report!\n");1233 ERR("COMBOBOXEX item structures broken. Please report!\n"); 1463 1234 return FALSE; 1464 1235 } … … 1468 1239 infoPtr->nb_items--; 1469 1240 1470 COMBOEX_CopyItem (infoPtr, olditem, &nmcit.ceItem); 1241 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem)); 1242 COMBOEX_CopyItem (olditem, &nmcit.ceItem); 1471 1243 COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit); 1472 1244 1473 if (olditem->pszText) 1474 COMCTL32_Free(olditem->pszText); 1245 COMBOEX_FreeText(olditem); 1475 1246 COMCTL32_Free(olditem); 1476 1247 1477 1248 return TRUE; 1478 1479 } 1480 1481 1482 inline static LRESULT 1483 COMBOEX_DrawItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 1484 { 1485 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1486 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam; 1249 } 1250 1251 1252 static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT *dis) 1253 { 1254 WCHAR nil[] = { 0 }; 1487 1255 CBE_ITEMDATA *item = 0; 1488 1256 SIZE txtsize; 1489 1257 RECT rect; 1490 LPWSTR str; 1491 int drawimage, drawstate; 1258 LPCWSTR str = nil; 1492 1259 UINT xbase, x, y; 1493 UINT xioff = 0; /* size and spacer of image if any */1494 IMAGEINFO iinfo;1495 1260 INT len; 1496 COLORREF nbkc, ntxc; 1261 COLORREF nbkc, ntxc, bkc, txc; 1262 int drawimage, drawstate, xioff; 1497 1263 1498 1264 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0; 1499 1265 1500 /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */ 1501 if (!TRACE_ON(message)) { 1502 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n", 1503 dis->CtlType, dis->CtlID); 1504 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n", 1505 dis->itemID, dis->itemAction, dis->itemState); 1506 TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n", 1507 dis->hwndItem, dis->hDC, dis->rcItem.left, 1508 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom, 1509 dis->itemData); 1510 } 1266 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n", 1267 dis->CtlType, dis->CtlID); 1268 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n", 1269 dis->itemID, dis->itemAction, dis->itemState); 1270 TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n", 1271 dis->hwndItem, dis->hDC, dis->rcItem.left, 1272 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom, 1273 dis->itemData); 1511 1274 1512 1275 /* MSDN says: */ … … 1536 1299 { 1537 1300 RECT exrc, cbrc, edrc; 1538 GetWindowRect ( hwnd, &exrc);1301 GetWindowRect (infoPtr->hwndSelf, &exrc); 1539 1302 GetWindowRect (infoPtr->hwndCombo, &cbrc); 1540 1303 edrc.left=edrc.top=edrc.right=edrc.bottom=-1; … … 1558 1321 /* If draw item is -1 (edit control) setup the item pointer */ 1559 1322 if (dis->itemID == 0xffffffff) { 1560 CHAR str[260];1561 INT wlen, alen;1562 1563 1323 item = infoPtr->edit; 1564 1324 1565 1325 if (infoPtr->hwndEdit) { 1326 INT len; 1566 1327 1567 1328 /* free previous text of edit item */ 1568 if (item->pszText) { 1569 COMCTL32_Free(item->pszText); 1570 item->pszText = 0; 1571 item->mask &= ~CBEIF_TEXT; 1329 COMBOEX_FreeText(item); 1330 item->mask &= ~CBEIF_TEXT; 1331 if( (len = GetWindowTextLengthW(infoPtr->hwndEdit)) ) { 1332 item->mask |= CBEIF_TEXT; 1333 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 1334 if (item->pszText) 1335 GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1); 1336 1337 TRACE("edit control hwndEdit=%0x, text len=%d str=%s\n", 1338 infoPtr->hwndEdit, len, debugstr_txt(item->pszText)); 1572 1339 } 1573 alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str); 1574 TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n", 1575 infoPtr->hwndEdit, alen, str); 1576 if (alen > 0) { 1577 item->mask |= CBEIF_TEXT; 1578 wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0); 1579 if (wlen > 0) { 1580 item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR)); 1581 MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen); 1582 } 1583 } 1584 } 1585 } 1340 } 1341 } 1342 1586 1343 1587 1344 /* if the item pointer is not set, then get the data and locate it */ 1588 1345 if (!item) { 1589 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 1590 CB_GETITEMDATA, (WPARAM)dis->itemID, 0); 1591 if (item == (CBE_ITEMDATA *)CB_ERR) 1592 { 1593 FIXME("invalid item for id %d \n",dis->itemID); 1594 return 0; 1346 item = get_item_data(infoPtr, dis->itemID); 1347 if (item == (CBE_ITEMDATA *)CB_ERR) { 1348 ERR("invalid item for id %d \n", dis->itemID); 1349 return 0; 1350 } 1351 } 1352 1353 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); 1354 1355 xbase = CBE_STARTOFFSET; 1356 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) { 1357 INT indent = item->iIndent; 1358 if (indent == I_INDENTCALLBACK) { 1359 NMCOMBOBOXEXW nmce; 1360 ZeroMemory(&nmce, sizeof(nmce)); 1361 nmce.ceItem.mask = CBEIF_INDENT; 1362 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); 1363 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) 1364 item->iIndent = nmce.ceItem.iIndent; 1365 indent = nmce.ceItem.iIndent; 1366 } 1367 xbase += (indent * CBE_INDENT); 1368 } 1369 1370 drawimage = -2; 1371 drawstate = ILD_NORMAL; 1372 if (item->mask & CBEIF_IMAGE) 1373 drawimage = item->iImage; 1374 if (dis->itemState & ODS_COMBOEXLBOX) { 1375 /* drawing listbox entry */ 1376 if (dis->itemState & ODS_SELECTED) { 1377 if (item->mask & CBEIF_SELECTEDIMAGE) 1378 drawimage = item->iSelectedImage; 1379 drawstate = ILD_SELECTED; 1380 } 1381 } else { 1382 /* drawing combo/edit entry */ 1383 if (IsWindowVisible(infoPtr->hwndEdit)) { 1384 /* if we have an edit control, the slave the 1385 * selection state to the Edit focus state 1386 */ 1387 if (infoPtr->flags & WCBE_EDITFOCUSED) { 1388 if (item->mask & CBEIF_SELECTEDIMAGE) 1389 drawimage = item->iSelectedImage; 1390 drawstate = ILD_SELECTED; 1595 1391 } 1596 } 1597 1598 COMBOEX_DumpItem (item); 1599 1600 xbase = CBE_STARTOFFSET; 1601 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) 1602 xbase += (item->iIndent * CBE_INDENT); 1603 if (item->mask & CBEIF_IMAGE) { 1604 ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo); 1605 xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP); 1606 } 1607 1608 switch (dis->itemAction) { 1609 case ODA_FOCUS: 1610 if (dis->itemState & ODS_SELECTED /*1*/) { 1611 if ((item->mask & CBEIF_TEXT) && item->pszText) { 1612 RECT rect2; 1613 1614 len = strlenW (item->pszText); 1615 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize); 1616 rect.left = xbase + xioff - 1; 1617 rect.right = rect.left + txtsize.cx + 2; 1618 rect.top = dis->rcItem.top; 1619 rect.bottom = dis->rcItem.bottom; 1620 GetClipBox (dis->hDC, &rect2); 1621 TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n", 1622 dis->itemID, rect.left, rect.top, 1623 rect.right, rect.bottom); 1624 TRACE(" clip=(%d,%d)-(%d,%d)\n", 1625 rect2.left, rect2.top, 1626 rect2.right, rect2.bottom); 1627 1628 DrawFocusRect(dis->hDC, &rect); 1392 } else { 1393 /* if we don't have an edit control, use 1394 * the requested state. 1395 */ 1396 if (dis->itemState & ODS_SELECTED) { 1397 if (item->mask & CBEIF_SELECTEDIMAGE) 1398 drawimage = item->iSelectedImage; 1399 drawstate = ILD_SELECTED; 1629 1400 } 1630 else { 1631 FIXME("ODA_FOCUS and ODS_SELECTED but no text\n"); 1632 } 1633 } 1634 else { 1635 FIXME("ODA_FOCUS but not ODS_SELECTED\n"); 1636 } 1637 break; 1638 case ODA_SELECT: 1639 case ODA_DRAWENTIRE: 1640 drawimage = -1; 1641 drawstate = ILD_NORMAL; 1642 if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) { 1643 if (item->mask & CBEIF_IMAGE) 1644 drawimage = item->iImage; 1645 if (dis->itemState & ODS_COMBOEXLBOX) { 1646 /* drawing listbox entry */ 1647 if (dis->itemState & ODS_SELECTED) { 1648 if (item->mask & CBEIF_SELECTEDIMAGE) 1649 drawimage = item->iSelectedImage; 1650 drawstate = ILD_SELECTED; 1651 } 1652 } 1653 else { 1654 /* drawing combo/edit entry */ 1655 if (infoPtr->hwndEdit) { 1656 /* if we have an edit control, the slave the 1657 * selection state to the Edit focus state 1658 */ 1659 if (infoPtr->flags & WCBE_EDITFOCUSED) { 1660 if (item->mask & CBEIF_SELECTEDIMAGE) 1661 drawimage = item->iSelectedImage; 1662 drawstate = ILD_SELECTED; 1663 } 1664 } 1665 else { 1666 /* if we don't have an edit control, use 1667 * the requested state. 1668 */ 1669 if (dis->itemState & ODS_SELECTED) { 1670 if (item->mask & CBEIF_SELECTEDIMAGE) 1671 drawimage = item->iSelectedImage; 1672 drawstate = ILD_SELECTED; 1673 } 1674 } 1675 } 1676 } 1677 if (drawimage != -1) { 1678 TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED); 1679 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, 1680 xbase, dis->rcItem.top, drawstate); 1681 } 1682 1683 /* setup pointer to text to be drawn */ 1684 if ((item->mask & CBEIF_TEXT) && item->pszText) 1685 str = item->pszText; 1686 else 1687 str = (LPWSTR) L""; 1401 } 1402 } 1403 1404 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) { 1405 IMAGEINFO iinfo; 1406 iinfo.rcImage.left = iinfo.rcImage.right = 0; 1407 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); 1408 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; 1409 } else xioff = 0; 1410 1411 /* setup pointer to text to be drawn */ 1412 str = COMBOEX_GetText(infoPtr, item); 1413 if (!str) str = nil; 1414 1415 len = strlenW (str); 1416 GetTextExtentPoint32W (dis->hDC, str, len, &txtsize); 1417 1418 if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) { 1419 int overlay = item->iOverlay; 1420 1421 if (drawimage == I_IMAGECALLBACK) { 1422 NMCOMBOBOXEXW nmce; 1423 ZeroMemory(&nmce, sizeof(nmce)); 1424 nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE; 1425 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); 1426 if (drawstate == ILD_NORMAL) { 1427 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage; 1428 drawimage = nmce.ceItem.iImage; 1429 } else if (drawstate == ILD_SELECTED) { 1430 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iSelectedImage = nmce.ceItem.iSelectedImage; 1431 drawimage = nmce.ceItem.iSelectedImage; 1432 } else ERR("Bad draw state = %d\n", drawstate); 1433 } 1434 1435 if (overlay == I_IMAGECALLBACK) { 1436 NMCOMBOBOXEXW nmce; 1437 ZeroMemory(&nmce, sizeof(nmce)); 1438 nmce.ceItem.mask = CBEIF_OVERLAY; 1439 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); 1440 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) 1441 item->iOverlay = nmce.ceItem.iOverlay; 1442 overlay = nmce.ceItem.iOverlay; 1443 } 1444 1445 if (drawimage >= 0 && 1446 !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) { 1447 if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1); 1448 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top, 1449 drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0)); 1450 } 1688 1451 1689 1452 /* now draw the text */ 1690 len = lstrlenW (str); 1691 GetTextExtentPointW (dis->hDC, str, len, &txtsize); 1692 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ? 1693 COLOR_HIGHLIGHT : COLOR_WINDOW); 1694 SetBkColor (dis->hDC, nbkc); 1695 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ? 1696 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT); 1697 SetTextColor (dis->hDC, ntxc); 1698 x = xbase + xioff; 1699 y = dis->rcItem.top + 1700 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2; 1701 rect.left = x; 1702 rect.right = x + txtsize.cx; 1703 rect.top = dis->rcItem.top + 1; 1704 rect.bottom = dis->rcItem.bottom - 1; 1705 TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n", 1706 dis->itemID, rect.left, rect.top, rect.right, rect.bottom); 1707 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED, 1708 &rect, str, len, 0); 1709 if (dis->itemState & ODS_FOCUS) { 1710 rect.top -= 1; 1711 rect.bottom += 1; 1712 rect.left -= 1; 1713 rect.right += 1; 1714 TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n", 1715 dis->itemID, rect.left, rect.top, rect.right, rect.bottom); 1716 DrawFocusRect (dis->hDC, &rect); 1717 } 1718 break; 1719 default: 1720 FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n", 1721 hwnd, wParam, lParam, dis->itemAction); 1453 if (!IsWindowVisible (infoPtr->hwndEdit)) { 1454 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ? 1455 COLOR_HIGHLIGHT : COLOR_WINDOW); 1456 bkc = SetBkColor (dis->hDC, nbkc); 1457 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ? 1458 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT); 1459 txc = SetTextColor (dis->hDC, ntxc); 1460 x = xbase + xioff; 1461 y = dis->rcItem.top + 1462 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2; 1463 rect.left = x; 1464 rect.right = x + txtsize.cx; 1465 rect.top = dis->rcItem.top + 1; 1466 rect.bottom = dis->rcItem.bottom - 1; 1467 TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n", 1468 dis->itemID, rect.left, rect.top, rect.right, rect.bottom); 1469 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED, 1470 &rect, str, len, 0); 1471 SetBkColor (dis->hDC, bkc); 1472 SetTextColor (dis->hDC, txc); 1473 } 1474 } 1475 1476 if (dis->itemAction & ODA_FOCUS) { 1477 rect.left = xbase + xioff - 1; 1478 rect.right = rect.left + txtsize.cx + 2; 1479 rect.top = dis->rcItem.top; 1480 rect.bottom = dis->rcItem.bottom; 1481 DrawFocusRect(dis->hDC, &rect); 1722 1482 } 1723 1483 … … 1726 1486 1727 1487 1728 static LRESULT 1729 COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) 1730 { 1731 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1732 1488 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr) 1489 { 1733 1490 if (infoPtr->hwndCombo) 1734 1491 DestroyWindow (infoPtr->hwndCombo); … … 1740 1497 1741 1498 if (infoPtr->items) { 1742 CBE_ITEMDATA *this, *next; 1743 1744 this = infoPtr->items; 1745 while (this) { 1746 next = (CBE_ITEMDATA *)this->next; 1747 if ((this->mask & CBEIF_TEXT) && this->pszText) 1748 COMCTL32_Free (this->pszText); 1749 COMCTL32_Free (this); 1750 this = next; 1751 } 1752 } 1753 1754 if (infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont); 1499 CBE_ITEMDATA *item, *next; 1500 1501 item = infoPtr->items; 1502 while (item) { 1503 next = (CBE_ITEMDATA *)item->next; 1504 COMBOEX_FreeText (item); 1505 COMCTL32_Free (item); 1506 item = next; 1507 } 1508 infoPtr->items = 0; 1509 } 1510 1511 if (infoPtr->defaultFont) 1512 DeleteObject (infoPtr->defaultFont); 1755 1513 1756 1514 /* free comboex info data */ 1757 1515 COMCTL32_Free (infoPtr); 1758 SetWindowLong A (hwnd, 0, 0);1516 SetWindowLongW (infoPtr->hwndSelf, 0, 0); 1759 1517 return 0; 1760 1518 } 1761 1519 1762 1520 1763 static LRESULT 1764 COMBOEX_MeasureItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 1765 { 1766 /*COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);*/ 1767 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam; 1521 static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO *infoPtr, MEASUREITEMSTRUCT *mis) 1522 { 1523 SIZE mysize; 1768 1524 HDC hdc; 1769 SIZE mysize;1770 1525 1771 1526 hdc = GetDC (0); … … 1775 1530 1776 1531 TRACE("adjusted height hwnd=%08x, height=%d\n", 1777 hwnd, mis->itemHeight);1532 infoPtr->hwndSelf, mis->itemHeight); 1778 1533 1779 1534 return 0; … … 1781 1536 1782 1537 1783 static LRESULT 1784 COMBOEX_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) 1538 static LRESULT COMBOEX_NCCreate (HWND hwnd) 1785 1539 { 1786 1540 /* WARNING: The COMBOEX_INFO structure is not yet created */ 1787 1541 DWORD oldstyle, newstyle; 1788 1542 1789 oldstyle = (DWORD)GetWindowLong A(hwnd, GWL_STYLE);1543 oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE); 1790 1544 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL); 1791 1545 if (newstyle != oldstyle) { 1792 1546 TRACE("req style %08lx, reseting style %08lx\n", 1793 1547 oldstyle, newstyle); 1794 SetWindowLong A(hwnd, GWL_STYLE, newstyle);1548 SetWindowLongW (hwnd, GWL_STYLE, newstyle); 1795 1549 } 1796 1550 return 1; … … 1798 1552 1799 1553 1800 static LRESULT 1801 COMBOEX_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) 1802 { 1803 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1804 INT i; 1805 1554 static LRESULT COMBOEX_NotifyFormat (COMBOEX_INFO *infoPtr, LPARAM lParam) 1555 { 1806 1556 if (lParam == NF_REQUERY) { 1807 i = SendMessageA(GetParent (hwnd),1557 INT i = SendMessageW(GetParent (infoPtr->hwndSelf), 1808 1558 WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY); 1809 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {1810 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",1811 i);1812 i = NFR_ANSI;1813 }1814 1559 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; 1815 return (LRESULT)i; 1816 } 1817 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI); 1818 } 1819 1820 1821 static LRESULT 1822 COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) 1823 { 1824 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1825 RECT rect; 1826 1827 GetWindowRect (hwnd, &rect); 1828 TRACE("my rect (%d,%d)-(%d,%d)\n", 1829 rect.left, rect.top, rect.right, rect.bottom); 1830 1831 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left, 1832 rect.bottom - rect.top, TRUE); 1560 } 1561 return infoPtr->NtfUnicode ? NFR_UNICODE : NFR_ANSI; 1562 } 1563 1564 1565 static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height) 1566 { 1567 TRACE("(width=%d, height=%d)\n", width, height); 1568 1569 MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE); 1833 1570 1834 1571 COMBOEX_AdjustEditPos (infoPtr); … … 1838 1575 1839 1576 1840 static LRESULT 1841 COMBOEX_WindowPosChanging (HWND hwnd, WPARAM wParam, LPARAM lParam) 1842 { 1843 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1577 static LRESULT COMBOEX_WindowPosChanging (COMBOEX_INFO *infoPtr, WINDOWPOS *wp) 1578 { 1844 1579 RECT cbx_wrect, cbx_crect, cb_wrect; 1845 1580 UINT width, height; 1846 WINDOWPOS *wp = (WINDOWPOS *)lParam; 1847 1848 GetWindowRect (hwnd, &cbx_wrect); 1849 GetClientRect (hwnd, &cbx_crect); 1581 1582 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect); 1583 GetClientRect (infoPtr->hwndSelf, &cbx_crect); 1850 1584 GetWindowRect (infoPtr->hwndCombo, &cb_wrect); 1851 1585 … … 1888 1622 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 1889 1623 { 1890 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo); 1624 HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); 1625 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); 1891 1626 NMCBEENDEDITW cbeend; 1892 1627 WCHAR edit_text[260]; 1893 COLORREF nbkc,obkc;1628 COLORREF obkc; 1894 1629 HDC hDC; 1895 1630 RECT rect; … … 1904 1639 { 1905 1640 1906 case WM_CHAR:1641 case WM_CHAR: 1907 1642 /* handle (ignore) the return character */ 1908 1643 if (wParam == VK_RETURN) return 0; 1909 1644 /* all other characters pass into the real Edit */ 1910 return CallWindowProc A(infoPtr->prevEditWndProc,1645 return CallWindowProcW (infoPtr->prevEditWndProc, 1911 1646 hwnd, uMsg, wParam, lParam); 1912 1647 1913 case WM_ERASEBKGND:1648 case WM_ERASEBKGND: 1914 1649 /* 1915 1650 * The following was determined by traces of the native 1916 1651 */ 1917 1652 hDC = (HDC) wParam; 1918 nbkc = GetSysColor (COLOR_WINDOW); 1919 obkc = SetBkColor (hDC, nbkc); 1653 obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW)); 1920 1654 GetClientRect (hwnd, &rect); 1921 1655 TRACE("erasing (%d,%d)-(%d,%d)\n", … … 1923 1657 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); 1924 1658 SetBkColor (hDC, obkc); 1925 return CallWindowProc A(infoPtr->prevEditWndProc,1659 return CallWindowProcW (infoPtr->prevEditWndProc, 1926 1660 hwnd, uMsg, wParam, lParam); 1927 1661 1928 case WM_KEYDOWN: {1929 INT oldItem, selected ;1662 case WM_KEYDOWN: { 1663 INT oldItem, selected, step = 1; 1930 1664 CBE_ITEMDATA *item; 1931 1665 … … 1960 1694 cbeend.iWhy = CBENF_ESCAPE; 1961 1695 1962 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) { 1963 /* abort the change */ 1964 TRACE("Notify requested abort of change\n"); 1965 return 0; 1966 } 1967 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0); 1696 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0; 1697 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); 1968 1698 InvalidateRect (infoPtr->hwndCombo, 0, 0); 1969 1699 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) { … … 2010 1740 item = COMBOEX_FindItem (infoPtr, selected); 2011 1741 TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n", 2012 selected, debugstr_ w(item->pszText));1742 selected, debugstr_txt(item->pszText)); 2013 1743 TRACE("handling VK_RETURN, edittext=%s\n", 2014 1744 debugstr_w(edit_text)); 2015 if (lstrcmpiW ( item->pszText, edit_text)) {1745 if (lstrcmpiW (COMBOEX_GetText(infoPtr, item), edit_text)) { 2016 1746 /* strings not equal -- indicate edit has changed */ 2017 1747 selected = -1; … … 2040 1770 break; 2041 1771 1772 case VK_UP: 1773 step = -1; 1774 case VK_DOWN: 1775 /* by default, step is 1 */ 1776 oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0); 1777 if (oldItem >= 0 && oldItem + step >= 0) 1778 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0); 1779 return 0; 2042 1780 default: 2043 return CallWindowProc A(infoPtr->prevEditWndProc,1781 return CallWindowProcW (infoPtr->prevEditWndProc, 2044 1782 hwnd, uMsg, wParam, lParam); 2045 1783 } … … 2047 1785 } 2048 1786 2049 case WM_SETFOCUS:1787 case WM_SETFOCUS: 2050 1788 /* remember the focus to set state of icon */ 2051 lret = CallWindowProc A(infoPtr->prevEditWndProc,1789 lret = CallWindowProcW (infoPtr->prevEditWndProc, 2052 1790 hwnd, uMsg, wParam, lParam); 2053 1791 infoPtr->flags |= WCBE_EDITFOCUSED; 2054 1792 return lret; 2055 1793 2056 case WM_KILLFOCUS:1794 case WM_KILLFOCUS: 2057 1795 /* 2058 1796 * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS … … 2072 1810 /* fall through */ 2073 1811 2074 default:2075 return CallWindowProc A(infoPtr->prevEditWndProc,1812 default: 1813 return CallWindowProcW (infoPtr->prevEditWndProc, 2076 1814 hwnd, uMsg, wParam, lParam); 2077 1815 } … … 2083 1821 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 2084 1822 { 2085 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo); 1823 HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); 1824 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); 2086 1825 NMCBEENDEDITW cbeend; 2087 1826 NMMOUSE nmmse; 2088 COLORREF nbkc,obkc;1827 COLORREF obkc; 2089 1828 HDC hDC; 2090 1829 HWND focusedhwnd; … … 2101 1840 2102 1841 case CB_FINDSTRINGEXACT: 2103 return COMBOEX_FindStringExact (infoPtr, wParam,lParam);1842 return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam); 2104 1843 2105 1844 case WM_DRAWITEM: … … 2110 1849 */ 2111 1850 ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX; 2112 return CallWindowProc A(infoPtr->prevComboWndProc,1851 return CallWindowProcW (infoPtr->prevComboWndProc, 2113 1852 hwnd, uMsg, wParam, lParam); 2114 1853 … … 2118 1857 */ 2119 1858 hDC = (HDC) wParam; 2120 nbkc = GetSysColor (COLOR_WINDOW); 2121 obkc = SetBkColor (hDC, nbkc); 1859 obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW)); 2122 1860 GetClientRect (hwnd, &rect); 2123 1861 TRACE("erasing (%d,%d)-(%d,%d)\n", … … 2125 1863 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); 2126 1864 SetBkColor (hDC, obkc); 2127 return CallWindowProc A(infoPtr->prevComboWndProc,1865 return CallWindowProcW (infoPtr->prevComboWndProc, 2128 1866 hwnd, uMsg, wParam, lParam); 2129 1867 … … 2140 1878 nmmse.dwHitInfo = lParam; 2141 1879 COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse); 2142 return CallWindowProc A(infoPtr->prevComboWndProc,1880 return CallWindowProcW (infoPtr->prevComboWndProc, 2143 1881 hwnd, uMsg, wParam, lParam); 2144 1882 … … 2174 1912 2175 1913 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); 2176 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) { 2177 /* abort the change */ 2178 TRACE("Notify requested abort of change\n"); 2179 return 0; 2180 } 1914 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0; 2181 1915 } 2182 1916 /* possible CB_GETCURSEL */ … … 2219 1953 */ 2220 1954 WCHAR edit_text[260]; 2221 WCHAR *lastwrk;2222 INT selected , cnt;1955 LPCWSTR lastwrk; 1956 INT selected; 2223 1957 CBE_ITEMDATA *item; 2224 1958 … … 2231 1965 if (selected == -1) { 2232 1966 lastwrk = infoPtr->edit->pszText; 2233 cnt = lstrlenW (lastwrk);2234 if (cnt >= 259) cnt = 259;2235 1967 } 2236 1968 else { 2237 1969 item = COMBOEX_FindItem (infoPtr, selected); 2238 cnt = lstrlenW (item->pszText); 2239 lastwrk = item->pszText; 2240 if (cnt >= 259) cnt = 259; 1970 lastwrk = COMBOEX_GetText(infoPtr, item); 2241 1971 } 2242 1972 2243 1973 TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n", 2244 selected, debugstr_w(lastwrk));1974 selected, debugstr_w(lastwrk)); 2245 1975 TRACE("handling EN_CHANGE, edittext=%s\n", 2246 1976 debugstr_w(edit_text)); 2247 1977 2248 1978 /* lstrcmpiW is between lastworkingURL and GetWindowText */ 2249 2250 1979 if (lstrcmpiW (lastwrk, edit_text)) { 2251 1980 /* strings not equal -- indicate edit has changed */ … … 2295 2024 }/* fall through */ 2296 2025 default: 2297 return CallWindowProc A(infoPtr->prevComboWndProc,2026 return CallWindowProcW (infoPtr->prevComboWndProc, 2298 2027 hwnd, uMsg, wParam, lParam); 2299 2028 } … … 2309 2038 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam); 2310 2039 2311 if (! COMBOEX_GetInfoPtr (hwnd)) {2040 if (!infoPtr) { 2312 2041 if (uMsg == WM_CREATE) 2313 return COMBOEX_Create (hwnd, wParam,lParam);2042 return COMBOEX_Create (hwnd, (LPCREATESTRUCTA)lParam); 2314 2043 if (uMsg == WM_NCCREATE) 2315 COMBOEX_NCCreate (hwnd , wParam, lParam);2316 return DefWindowProc A(hwnd, uMsg, wParam, lParam);2044 COMBOEX_NCCreate (hwnd); 2045 return DefWindowProcW (hwnd, uMsg, wParam, lParam); 2317 2046 } 2318 2047 2319 2048 switch (uMsg) 2320 2049 { 2321 case CBEM_DELETEITEM: /* maps to CB_DELETESTRING */2322 return COMBOEX_DeleteItem ( hwnd, wParam, lParam);2050 case CBEM_DELETEITEM: 2051 return COMBOEX_DeleteItem (infoPtr, wParam); 2323 2052 2324 2053 case CBEM_GETCOMBOCONTROL: 2325 return COMBOEX_GetComboControl (hwnd, wParam, lParam);2054 return infoPtr->hwndCombo; 2326 2055 2327 2056 case CBEM_GETEDITCONTROL: 2328 return COMBOEX_GetEditControl (hwnd, wParam, lParam);2057 return infoPtr->hwndEdit; 2329 2058 2330 2059 case CBEM_GETEXTENDEDSTYLE: 2331 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);2060 return infoPtr->dwExtStyle; 2332 2061 2333 2062 case CBEM_GETIMAGELIST: 2334 return COMBOEX_GetImageList (hwnd, wParam, lParam);2063 return (LRESULT)infoPtr->himl; 2335 2064 2336 2065 case CBEM_GETITEMA: 2337 return COMBOEX_GetItemA (hwnd, wParam,lParam);2066 return (LRESULT)COMBOEX_GetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); 2338 2067 2339 2068 case CBEM_GETITEMW: 2340 return COMBOEX_GetItemW (hwnd, wParam,lParam);2069 return (LRESULT)COMBOEX_GetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); 2341 2070 2342 2071 case CBEM_GETUNICODEFORMAT: 2343 return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);2072 return infoPtr->unicode; 2344 2073 2345 2074 case CBEM_HASEDITCHANGED: 2346 return COMBOEX_HasEditChanged ( hwnd, wParam, lParam);2075 return COMBOEX_HasEditChanged (infoPtr); 2347 2076 2348 2077 case CBEM_INSERTITEMA: 2349 return COMBOEX_InsertItemA ( hwnd, wParam,lParam);2078 return COMBOEX_InsertItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); 2350 2079 2351 2080 case CBEM_INSERTITEMW: 2352 return COMBOEX_InsertItemW ( hwnd, wParam,lParam);2353 2354 case CBEM_SETEXSTYLE: /* FIXME: obsoleted, should be the same as: */2081 return COMBOEX_InsertItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); 2082 2083 case CBEM_SETEXSTYLE: 2355 2084 case CBEM_SETEXTENDEDSTYLE: 2356 return COMBOEX_SetExtendedStyle ( hwnd, wParam,lParam);2085 return COMBOEX_SetExtendedStyle (infoPtr, (DWORD)wParam, (DWORD)lParam); 2357 2086 2358 2087 case CBEM_SETIMAGELIST: 2359 return COMBOEX_SetImageList (hwnd, wParam,lParam);2088 return (LRESULT)COMBOEX_SetImageList (infoPtr, (HIMAGELIST)lParam); 2360 2089 2361 2090 case CBEM_SETITEMA: 2362 return COMBOEX_SetItemA ( hwnd, wParam,lParam);2091 return COMBOEX_SetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); 2363 2092 2364 2093 case CBEM_SETITEMW: 2365 return COMBOEX_SetItemW ( hwnd, wParam,lParam);2094 return COMBOEX_SetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); 2366 2095 2367 2096 case CBEM_SETUNICODEFORMAT: 2368 return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam); 2369 2097 return COMBOEX_SetUnicodeFormat (infoPtr, wParam); 2098 2099 /*case CBEM_SETWINDOWTHEME: 2100 FIXME("CBEM_SETWINDOWTHEME: stub\n");*/ 2370 2101 2371 2102 /* Combo messages we are not sure if we need to process or just forward */ … … 2382 2113 FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n", 2383 2114 uMsg, wParam, lParam); 2384 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);2385 2115 2386 2116 /* Combo messages OK to just forward to the regular COMBO */ … … 2391 2121 case CB_SETEXTENDEDUI: 2392 2122 case CB_SHOWDROPDOWN: 2393 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);2123 return SendMessageW (infoPtr->hwndCombo, uMsg, wParam, lParam); 2394 2124 2395 2125 /* Combo messages we need to process specially */ 2396 2126 case CB_FINDSTRINGEXACT: 2397 return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd), 2398 wParam, lParam); 2127 return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam); 2399 2128 2400 2129 case CB_GETITEMDATA: 2401 return COMBOEX_GetItemData ( hwnd, wParam, lParam);2130 return COMBOEX_GetItemData (infoPtr, (INT)wParam); 2402 2131 2403 2132 case CB_SETCURSEL: 2404 return COMBOEX_SetCursel ( hwnd, wParam, lParam);2133 return COMBOEX_SetCursel (infoPtr, (INT)wParam); 2405 2134 2406 2135 case CB_SETITEMDATA: 2407 return COMBOEX_SetItemData ( hwnd, wParam,lParam);2136 return COMBOEX_SetItemData (infoPtr, (INT)wParam, (DWORD)lParam); 2408 2137 2409 2138 case CB_SETITEMHEIGHT: 2410 return COMBOEX_SetItemHeight ( hwnd, wParam,lParam);2139 return COMBOEX_SetItemHeight (infoPtr, (INT)wParam, (UINT)lParam); 2411 2140 2412 2141 … … 2414 2143 /* Window messages passed to parent */ 2415 2144 case WM_COMMAND: 2416 return COMBOEX_Command ( hwnd, wParam, lParam);2145 return COMBOEX_Command (infoPtr, wParam, lParam); 2417 2146 2418 2147 case WM_NOTIFY: 2419 2148 if (infoPtr->NtfUnicode) 2420 return SendMessageW (GetParent (hwnd), 2421 uMsg, wParam, lParam); 2149 return SendMessageW (GetParent (hwnd), uMsg, wParam, lParam); 2422 2150 else 2423 return SendMessageA (GetParent (hwnd), 2424 uMsg, wParam, lParam); 2151 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); 2425 2152 2426 2153 2427 2154 /* Window messages we need to process */ 2428 2155 case WM_DELETEITEM: 2429 return COMBOEX_WM_DeleteItem ( hwnd, wParam,lParam);2156 return COMBOEX_WM_DeleteItem (infoPtr, (DELETEITEMSTRUCT *)lParam); 2430 2157 2431 2158 case WM_DRAWITEM: 2432 return COMBOEX_DrawItem ( hwnd, wParam,lParam);2159 return COMBOEX_DrawItem (infoPtr, (DRAWITEMSTRUCT *)lParam); 2433 2160 2434 2161 case WM_DESTROY: 2435 return COMBOEX_Destroy ( hwnd, wParam, lParam);2162 return COMBOEX_Destroy (infoPtr); 2436 2163 2437 2164 case WM_MEASUREITEM: 2438 return COMBOEX_MeasureItem ( hwnd, wParam,lParam);2165 return COMBOEX_MeasureItem (infoPtr, (MEASUREITEMSTRUCT *)lParam); 2439 2166 2440 2167 case WM_NOTIFYFORMAT: 2441 return COMBOEX_NotifyFormat ( hwnd, wParam, lParam);2168 return COMBOEX_NotifyFormat (infoPtr, lParam); 2442 2169 2443 2170 case WM_SIZE: 2444 return COMBOEX_Size ( hwnd, wParam, lParam);2171 return COMBOEX_Size (infoPtr, LOWORD(lParam), HIWORD(lParam)); 2445 2172 2446 2173 case WM_WINDOWPOSCHANGING: 2447 return COMBOEX_WindowPosChanging ( hwnd, wParam,lParam);2174 return COMBOEX_WindowPosChanging (infoPtr, (WINDOWPOS *)lParam); 2448 2175 2449 2176 default: 2450 2177 if (uMsg >= WM_USER) 2451 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 2452 uMsg, wParam, lParam); 2453 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 2178 ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam); 2179 return DefWindowProcW (hwnd, uMsg, wParam, lParam); 2454 2180 } 2455 2181 return 0; … … 2457 2183 2458 2184 2459 VOID 2460 COMBOEX_Register (void) 2461 { 2462 WNDCLASSA wndClass; 2463 2464 ZeroMemory (&wndClass, sizeof(WNDCLASSA)); 2185 void COMBOEX_Register (void) 2186 { 2187 WNDCLASSW wndClass; 2188 2189 ZeroMemory (&wndClass, sizeof(WNDCLASSW)); 2465 2190 wndClass.style = CS_GLOBALCLASS; 2466 2191 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc; 2467 2192 wndClass.cbClsExtra = 0; 2468 2193 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *); 2469 wndClass.hCursor = LoadCursor A (0, IDC_ARROWA);2194 wndClass.hCursor = LoadCursorW (0, IDC_ARROWW); 2470 2195 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 2471 wndClass.lpszClassName = WC_COMBOBOXEX A;2196 wndClass.lpszClassName = WC_COMBOBOXEXW; 2472 2197 2473 RegisterClassA (&wndClass); 2474 2475 ComboExInfo = GlobalAddAtomA("CC32SubclassInfo"); 2476 } 2477 2478 2479 VOID 2480 COMBOEX_Unregister (void) 2481 { 2482 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL); 2483 } 2484 2198 RegisterClassW (&wndClass); 2199 } 2200 2201 2202 void COMBOEX_Unregister (void) 2203 { 2204 UnregisterClassW (WC_COMBOBOXEXW, (HINSTANCE)NULL); 2205 } 2206
Note:
See TracChangeset
for help on using the changeset viewer.
