Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1 | /* |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2 | * ComboBoxEx control |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright 1998, 1999 Eric Kohl |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 5 | * Copyright 2000, 2001, 2002 Guy Albertelli <galberte@neo.lrun.com> |
| 6 | * Copyright 2002 Dimitrie O. Paun |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 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 | * |
Dimitrie O. Paun | da9bac4 | 2002-10-16 18:57:14 +0000 | [diff] [blame] | 22 | * NOTE |
| 23 | * |
| 24 | * This code was audited for completeness against the documented features |
| 25 | * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun. |
| 26 | * |
Robert Shearman | 3c6956d | 2004-03-11 00:39:53 +0000 | [diff] [blame] | 27 | * Unless otherwise noted, we believe this code to be complete, as per |
Dimitrie O. Paun | da9bac4 | 2002-10-16 18:57:14 +0000 | [diff] [blame] | 28 | * the specification mentioned above. |
| 29 | * If you discover missing features, or bugs, please note them below. |
| 30 | * |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 31 | */ |
| 32 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 33 | #include <stdarg.h> |
Jeff Garzik | 9fd15a9 | 2001-03-22 19:33:57 +0000 | [diff] [blame] | 34 | #include <string.h> |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 35 | #include "windef.h" |
Marcus Meissner | 3480e4a | 1999-03-16 10:53:11 +0000 | [diff] [blame] | 36 | #include "winbase.h" |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 37 | #include "wingdi.h" |
| 38 | #include "winuser.h" |
| 39 | #include "winnls.h" |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 40 | #include "commctrl.h" |
Alexandre Julliard | f5cb3dd | 2003-09-17 20:15:21 +0000 | [diff] [blame] | 41 | #include "comctl32.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 42 | #include "wine/debug.h" |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 43 | #include "wine/unicode.h" |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 44 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 45 | WINE_DEFAULT_DEBUG_CHANNEL(comboex); |
Alexandre Julliard | 70c9e09 | 2000-08-09 00:41:17 +0000 | [diff] [blame] | 46 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 47 | /* Item structure */ |
Alexandre Julliard | 70c9e09 | 2000-08-09 00:41:17 +0000 | [diff] [blame] | 48 | typedef struct |
| 49 | { |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 50 | VOID *next; |
| 51 | UINT mask; |
| 52 | LPWSTR pszText; |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 53 | LPWSTR pszTemp; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 54 | int cchTextMax; |
| 55 | int iImage; |
| 56 | int iSelectedImage; |
| 57 | int iOverlay; |
| 58 | int iIndent; |
| 59 | LPARAM lParam; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 60 | } CBE_ITEMDATA; |
| 61 | |
| 62 | /* ComboBoxEx structure */ |
| 63 | typedef struct |
| 64 | { |
| 65 | HIMAGELIST himl; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 66 | HWND hwndSelf; /* my own hwnd */ |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 67 | HWND hwndNotify; /* my parent hwnd */ |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 68 | HWND hwndCombo; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 69 | HWND hwndEdit; |
| 70 | WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 71 | WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */ |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 72 | DWORD dwExtStyle; |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 73 | INT selected; /* index of selected item */ |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 74 | DWORD flags; /* WINE internal flags */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 75 | HFONT defaultFont; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 76 | HFONT font; |
| 77 | INT nb_items; /* Number of items */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 78 | BOOL unicode; /* TRUE if this window is Unicode */ |
| 79 | BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */ |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 80 | CBE_ITEMDATA *edit; /* item data for edit item */ |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 81 | CBE_ITEMDATA *items; /* Array of items */ |
Alexandre Julliard | 70c9e09 | 2000-08-09 00:41:17 +0000 | [diff] [blame] | 82 | } COMBOEX_INFO; |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 83 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 84 | /* internal flags in the COMBOEX_INFO structure */ |
Dimitrie O. Paun | 69c9c43 | 2002-08-28 22:21:46 +0000 | [diff] [blame] | 85 | #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e. |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 86 | * CBEN_BEGINEDIT issued |
| 87 | * but CBEN_ENDEDIT{A|W} |
| 88 | * not yet issued. */ |
Dimitrie O. Paun | 69c9c43 | 2002-08-28 22:21:46 +0000 | [diff] [blame] | 89 | #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */ |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 90 | #define WCBE_EDITHASCHANGED (WCBE_ACTEDIT | WCBE_EDITCHG) |
Dimitrie O. Paun | 69c9c43 | 2002-08-28 22:21:46 +0000 | [diff] [blame] | 91 | #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */ |
| 92 | #define WCBE_MOUSECAPTURED 0x00000008 /* Combo has captured mouse */ |
| 93 | #define WCBE_MOUSEDRAGGED 0x00000010 /* User has dragged in combo */ |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 94 | |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 95 | #define ID_CB_EDIT 1001 |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 96 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 97 | |
| 98 | /* |
| 99 | * Special flag set in DRAWITEMSTRUCT itemState field. It is set by |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 100 | * the ComboEx version of the Combo Window Proc so that when the |
| 101 | * WM_DRAWITEM message is then passed to ComboEx, we know that this |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 102 | * particular WM_DRAWITEM message is for listbox only items. Any messasges |
| 103 | * without this flag is then for the Edit control field. |
| 104 | * |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 105 | * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 106 | * only version 4.0 applications will have ODS_COMBOBOXEDIT set. |
| 107 | */ |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 108 | #define ODS_COMBOEXLBOX 0x4000 |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 109 | |
| 110 | |
| 111 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 112 | /* Height in pixels of control over the amount of the selected font */ |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 113 | #define CBE_EXTRA 3 |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 114 | |
| 115 | /* Indent amount per MS documentation */ |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 116 | #define CBE_INDENT 10 |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 117 | |
| 118 | /* Offset in pixels from left side for start of image or text */ |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 119 | #define CBE_STARTOFFSET 6 |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 120 | |
| 121 | /* Offset between image and text */ |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 122 | #define CBE_SEP 4 |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 123 | |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 124 | #define COMBOEX_SUBCLASS_PROP "CCComboEx32SubclassInfo" |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 125 | #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongW (hwnd, 0)) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 126 | |
| 127 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 128 | /* Things common to the entire DLL */ |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 129 | static LRESULT WINAPI |
| 130 | COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 131 | static LRESULT WINAPI |
| 132 | COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
Dimitrie O. Paun | f14b527 | 2002-08-27 18:16:48 +0000 | [diff] [blame] | 133 | static int CALLBACK |
| 134 | COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code); |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 135 | static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr); |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 136 | typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 137 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 138 | inline static BOOL is_textW(LPCWSTR str) |
| 139 | { |
| 140 | return str && str != LPSTR_TEXTCALLBACKW; |
| 141 | } |
| 142 | |
| 143 | inline static BOOL is_textA(LPCSTR str) |
| 144 | { |
| 145 | return str && str != LPSTR_TEXTCALLBACKA; |
| 146 | } |
| 147 | |
| 148 | inline static LPCSTR debugstr_txt(LPCWSTR str) |
| 149 | { |
| 150 | if (str == LPSTR_TEXTCALLBACKW) return "(callback)"; |
| 151 | return debugstr_w(str); |
| 152 | } |
| 153 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 154 | static void COMBOEX_DumpItem (CBE_ITEMDATA *item) |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 155 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 156 | TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n", |
| 157 | item, item->mask, item->pszText, item->cchTextMax, item->iImage); |
| 158 | TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", |
| 159 | item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 160 | if (item->mask & CBEIF_TEXT) |
| 161 | TRACE("item %p - pszText=%s\n", item, debugstr_txt(item->pszText)); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 165 | static void COMBOEX_DumpInput (COMBOBOXEXITEMW *input) |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 166 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 167 | TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n", |
| 168 | input->mask, input->iItem, input->pszText, input->cchTextMax, |
| 169 | input->iImage); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 170 | if (input->mask & CBEIF_TEXT) |
| 171 | TRACE("input - pszText=<%s>\n", debugstr_txt(input->pszText)); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 172 | TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", |
| 173 | input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 177 | inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index) |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 178 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 179 | return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA, |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 180 | (WPARAM)index, 0); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 181 | } |
| 182 | |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 183 | inline static cmp_func_t get_cmp_func(COMBOEX_INFO *infoPtr) |
| 184 | { |
| 185 | return infoPtr->dwExtStyle & CBES_EX_CASESENSITIVE ? lstrcmpW : lstrcmpiW; |
| 186 | } |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 187 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 188 | static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr) |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 189 | { |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 190 | hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf); |
| 191 | hdr->hwndFrom = infoPtr->hwndSelf; |
| 192 | hdr->code = code; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 193 | if (infoPtr->NtfUnicode) |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 194 | return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, 0, (LPARAM)hdr); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 195 | else |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 196 | return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 0, (LPARAM)hdr); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 200 | static INT |
| 201 | COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT code, NMCOMBOBOXEXW *hdr) |
| 202 | { |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 203 | /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 204 | if (infoPtr->NtfUnicode) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 205 | return COMBOEX_Notify (infoPtr, code, &hdr->hdr); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 206 | else { |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 207 | LPWSTR wstr = hdr->ceItem.pszText; |
| 208 | LPSTR astr = 0; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 209 | INT ret, len = 0; |
| 210 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 211 | if ((hdr->ceItem.mask & CBEIF_TEXT) && is_textW(wstr)) { |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 212 | len = WideCharToMultiByte (CP_ACP, 0, wstr, -1, 0, 0, NULL, NULL); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 213 | if (len > 0) { |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 214 | astr = (LPSTR)Alloc ((len + 1)*sizeof(CHAR)); |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 215 | if (!astr) return 0; |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 216 | WideCharToMultiByte (CP_ACP, 0, wstr, -1, astr, len, 0, 0); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 217 | hdr->ceItem.pszText = (LPWSTR)astr; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 218 | } |
| 219 | } |
| 220 | |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 221 | if (code == CBEN_ENDEDITW) code = CBEN_ENDEDITA; |
| 222 | else if (code == CBEN_GETDISPINFOW) code = CBEN_GETDISPINFOA; |
| 223 | else if (code == CBEN_DRAGBEGINW) code = CBEN_DRAGBEGINA; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 224 | |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 225 | ret = COMBOEX_Notify (infoPtr, code, (NMHDR *)hdr); |
| 226 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 227 | if (astr && hdr->ceItem.pszText == (LPWSTR)astr) |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 228 | hdr->ceItem.pszText = wstr; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 229 | |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 230 | if (astr) Free(astr); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 231 | |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 232 | return ret; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 237 | static INT COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *neew, LPCWSTR wstr) |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 238 | { |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 239 | /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 240 | if (infoPtr->NtfUnicode) { |
| 241 | lstrcpynW(neew->szText, wstr, CBEMAXSTRLEN); |
| 242 | return COMBOEX_Notify (infoPtr, CBEN_ENDEDITW, &neew->hdr); |
| 243 | } else { |
| 244 | NMCBEENDEDITA neea; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 245 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 246 | memcpy (&neea.hdr, &neew->hdr, sizeof(NMHDR)); |
| 247 | neea.fChanged = neew->fChanged; |
| 248 | neea.iNewSelection = neew->iNewSelection; |
| 249 | WideCharToMultiByte (CP_ACP, 0, wstr, -1, neea.szText, CBEMAXSTRLEN, 0, 0); |
| 250 | neea.iWhy = neew->iWhy; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 251 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 252 | return COMBOEX_Notify (infoPtr, CBEN_ENDEDITA, &neea.hdr); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | |
| 256 | |
Dimitrie O. Paun | 69c9c43 | 2002-08-28 22:21:46 +0000 | [diff] [blame] | 257 | static void COMBOEX_NotifyDragBegin(COMBOEX_INFO *infoPtr, LPCWSTR wstr) |
| 258 | { |
| 259 | /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ |
| 260 | if (infoPtr->NtfUnicode) { |
| 261 | NMCBEDRAGBEGINW ndbw; |
| 262 | |
| 263 | ndbw.iItemid = -1; |
| 264 | lstrcpynW(ndbw.szText, wstr, CBEMAXSTRLEN); |
| 265 | COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINW, &ndbw.hdr); |
| 266 | } else { |
| 267 | NMCBEDRAGBEGINA ndba; |
| 268 | |
| 269 | ndba.iItemid = -1; |
| 270 | WideCharToMultiByte (CP_ACP, 0, wstr, -1, ndba.szText, CBEMAXSTRLEN, 0, 0); |
| 271 | |
| 272 | COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINA, &ndba.hdr); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 277 | static void COMBOEX_FreeText (CBE_ITEMDATA *item) |
| 278 | { |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 279 | if (is_textW(item->pszText)) Free(item->pszText); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 280 | item->pszText = 0; |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 281 | if (item->pszTemp) Free(item->pszTemp); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 282 | item->pszTemp = 0; |
| 283 | } |
| 284 | |
| 285 | |
| 286 | static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) |
| 287 | { |
| 288 | NMCOMBOBOXEXW nmce; |
| 289 | LPWSTR text, buf; |
| 290 | INT len; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 291 | |
| 292 | if (item->pszText != LPSTR_TEXTCALLBACKW) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 293 | return item->pszText; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 294 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 295 | ZeroMemory(&nmce, sizeof(nmce)); |
| 296 | nmce.ceItem.mask = CBEIF_TEXT; |
Carlos | 392defd | 2002-10-28 18:50:14 +0000 | [diff] [blame] | 297 | nmce.ceItem.lParam = item->lParam; |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 298 | COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); |
| 299 | |
| 300 | if (is_textW(nmce.ceItem.pszText)) { |
| 301 | len = MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, NULL, 0); |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 302 | buf = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR)); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 303 | if (buf) |
| 304 | MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, buf, len); |
| 305 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) { |
| 306 | COMBOEX_FreeText(item); |
| 307 | item->pszText = buf; |
| 308 | } else { |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 309 | if (item->pszTemp) Free(item->pszTemp); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 310 | item->pszTemp = buf; |
| 311 | } |
| 312 | text = buf; |
| 313 | } else |
| 314 | text = nmce.ceItem.pszText; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 315 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 316 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) |
| 317 | item->pszText = text; |
| 318 | return text; |
| 319 | } |
| 320 | |
| 321 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 322 | static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size) |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 323 | { |
| 324 | HFONT nfont, ofont; |
| 325 | HDC mydc; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 326 | |
| 327 | mydc = GetDC (0); /* why the entire screen???? */ |
Michael Stefaniuc | f3d1893 | 2002-10-23 20:19:22 +0000 | [diff] [blame] | 328 | nfont = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 329 | ofont = (HFONT) SelectObject (mydc, nfont); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 330 | GetTextExtentPointA (mydc, "A", 1, size); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 331 | SelectObject (mydc, ofont); |
| 332 | ReleaseDC (0, mydc); |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 333 | TRACE("selected font hwnd=%p, height=%ld\n", nfont, size->cy); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 337 | static void COMBOEX_CopyItem (CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit) |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 338 | { |
| 339 | if (cit->mask & CBEIF_TEXT) { |
Aric Stewart | 1282ef9 | 2002-02-08 17:10:49 +0000 | [diff] [blame] | 340 | /* |
| 341 | * when given a text buffer actually use that buffer |
| 342 | */ |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 343 | if (cit->pszText) { |
| 344 | if (is_textW(item->pszText)) |
| 345 | lstrcpynW(cit->pszText, item->pszText, cit->cchTextMax); |
| 346 | else |
| 347 | cit->pszText[0] = 0; |
| 348 | } else { |
Aric Stewart | 1282ef9 | 2002-02-08 17:10:49 +0000 | [diff] [blame] | 349 | cit->pszText = item->pszText; |
| 350 | cit->cchTextMax = item->cchTextMax; |
| 351 | } |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 352 | } |
| 353 | if (cit->mask & CBEIF_IMAGE) |
| 354 | cit->iImage = item->iImage; |
| 355 | if (cit->mask & CBEIF_SELECTEDIMAGE) |
| 356 | cit->iSelectedImage = item->iSelectedImage; |
| 357 | if (cit->mask & CBEIF_OVERLAY) |
| 358 | cit->iOverlay = item->iOverlay; |
| 359 | if (cit->mask & CBEIF_INDENT) |
| 360 | cit->iIndent = item->iIndent; |
| 361 | if (cit->mask & CBEIF_LPARAM) |
| 362 | cit->lParam = item->lParam; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 366 | static void COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr) |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 367 | { |
| 368 | SIZE mysize; |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 369 | INT x, y, w, h, xioff; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 370 | RECT rect; |
| 371 | |
| 372 | if (!infoPtr->hwndEdit) return; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 373 | |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 374 | if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) { |
| 375 | IMAGEINFO iinfo; |
| 376 | iinfo.rcImage.left = iinfo.rcImage.right = 0; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 377 | ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 378 | xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; |
| 379 | } else xioff = 0; |
| 380 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 381 | GetClientRect (infoPtr->hwndCombo, &rect); |
| 382 | InflateRect (&rect, -2, -2); |
| 383 | InvalidateRect (infoPtr->hwndCombo, &rect, TRUE); |
| 384 | |
| 385 | /* reposition the Edit control based on whether icon exists */ |
| 386 | COMBOEX_GetComboFontSize (infoPtr, &mysize); |
| 387 | TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy); |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 388 | x = xioff + CBE_STARTOFFSET + 1; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 389 | w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1; |
| 390 | h = mysize.cy + 1; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 391 | y = rect.bottom - h - 1; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 392 | |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 393 | TRACE("Combo client (%ld,%ld)-(%ld,%ld), setting Edit to (%d,%d)-(%d,%d)\n", |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 394 | rect.left, rect.top, rect.right, rect.bottom, x, y, x + w, y + h); |
| 395 | SetWindowPos(infoPtr->hwndEdit, HWND_TOP, x, y, w, h, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 396 | SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); |
| 397 | } |
| 398 | |
| 399 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 400 | static void COMBOEX_ReSize (COMBOEX_INFO *infoPtr) |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 401 | { |
| 402 | SIZE mysize; |
| 403 | UINT cy; |
| 404 | IMAGEINFO iinfo; |
| 405 | |
| 406 | COMBOEX_GetComboFontSize (infoPtr, &mysize); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 407 | cy = mysize.cy + CBE_EXTRA; |
Huw Davies | 8d74ef1 | 2002-11-13 19:39:09 +0000 | [diff] [blame] | 408 | if (infoPtr->himl && ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo)) { |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 409 | cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 410 | TRACE("upgraded height due to image: height=%d\n", cy); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 411 | } |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 412 | SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy); |
Dimitrie O. Paun | ca13564 | 2002-08-30 00:02:20 +0000 | [diff] [blame] | 413 | if (infoPtr->hwndCombo) { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 414 | SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 415 | (WPARAM) 0, (LPARAM) cy); |
Dimitrie O. Paun | ca13564 | 2002-08-30 00:02:20 +0000 | [diff] [blame] | 416 | if ( !(infoPtr->flags & CBES_EX_NOSIZELIMIT)) { |
| 417 | RECT comboRect; |
| 418 | if (GetWindowRect(infoPtr->hwndCombo, &comboRect)) { |
| 419 | RECT ourRect; |
| 420 | if (GetWindowRect(infoPtr->hwndSelf, &ourRect)) { |
| 421 | if (comboRect.bottom > ourRect.bottom) { |
| 422 | POINT pt = { ourRect.left, ourRect.top }; |
| 423 | if (ScreenToClient(infoPtr->hwndSelf, &pt)) |
| 424 | MoveWindow( infoPtr->hwndSelf, pt.x, pt.y, ourRect.right - ourRect.left, |
| 425 | comboRect.bottom - comboRect.top, FALSE); |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | } |
| 430 | } |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 434 | static void COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 435 | { |
| 436 | if (!infoPtr->hwndEdit) return; |
| 437 | /* native issues the following messages to the {Edit} control */ |
| 438 | /* WM_SETTEXT (0,addr) */ |
| 439 | /* EM_SETSEL32 (0,0) */ |
| 440 | /* EM_SETSEL32 (0,-1) */ |
| 441 | if (item->mask & CBEIF_TEXT) { |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 442 | SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)COMBOEX_GetText(infoPtr, item)); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 443 | SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0); |
| 444 | SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 445 | } |
| 446 | } |
| 447 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 448 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 449 | static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index) |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 450 | { |
| 451 | CBE_ITEMDATA *item; |
| 452 | INT i; |
| 453 | |
| 454 | if ((index > infoPtr->nb_items) || (index < -1)) |
| 455 | return 0; |
| 456 | if (index == -1) |
| 457 | return infoPtr->edit; |
| 458 | item = infoPtr->items; |
| 459 | i = infoPtr->nb_items - 1; |
| 460 | |
| 461 | /* find the item in the list */ |
| 462 | while (item && (i > index)) { |
| 463 | item = (CBE_ITEMDATA *)item->next; |
| 464 | i--; |
| 465 | } |
| 466 | if (!item || (i != index)) { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 467 | ERR("COMBOBOXEX item structures broken. Please report!\n"); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 468 | return 0; |
| 469 | } |
| 470 | return item; |
| 471 | } |
| 472 | |
| 473 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 474 | static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr) |
| 475 | { |
Michael Stefaniuc | 025c0b7 | 2002-09-06 19:41:17 +0000 | [diff] [blame] | 476 | return infoPtr->hwndEdit ? TRUE : FALSE; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 477 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 478 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 479 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 480 | /* *** CBEM_xxx message support *** */ |
| 481 | |
| 482 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 483 | static INT COMBOEX_DeleteItem (COMBOEX_INFO *infoPtr, INT index) |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 484 | { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 485 | CBE_ITEMDATA *item; |
| 486 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 487 | TRACE("(index=%d)\n", index); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 488 | |
| 489 | /* if item number requested does not exist then return failure */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 490 | if ((index > infoPtr->nb_items) || (index < 0)) return CB_ERR; |
| 491 | if (!(item = COMBOEX_FindItem(infoPtr, index))) return CB_ERR; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 492 | |
| 493 | /* doing this will result in WM_DELETEITEM being issued */ |
| 494 | SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0); |
| 495 | |
| 496 | return infoPtr->nb_items; |
| 497 | } |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 498 | |
| 499 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 500 | static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 501 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 502 | INT index = cit->iItem; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 503 | CBE_ITEMDATA *item; |
| 504 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 505 | TRACE("(...)\n"); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 506 | |
| 507 | /* if item number requested does not exist then return failure */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 508 | if ((index > infoPtr->nb_items) || (index < -1)) return FALSE; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 509 | |
| 510 | /* if the item is the edit control and there is no edit control, skip */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 511 | if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 512 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 513 | if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 514 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 515 | COMBOEX_CopyItem (item, cit); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 516 | |
| 517 | return TRUE; |
| 518 | } |
| 519 | |
| 520 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 521 | static BOOL COMBOEX_GetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 522 | { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 523 | COMBOBOXEXITEMW tmpcit; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 524 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 525 | TRACE("(...)\n"); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 526 | |
| 527 | tmpcit.mask = cit->mask; |
| 528 | tmpcit.iItem = cit->iItem; |
Guy L. Albertelli | 683c00a | 2002-02-12 18:41:48 +0000 | [diff] [blame] | 529 | tmpcit.pszText = 0; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 530 | if(!COMBOEX_GetItemW (infoPtr, &tmpcit)) return FALSE; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 531 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 532 | if (is_textW(tmpcit.pszText) && cit->pszText) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 533 | WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 534 | cit->pszText, cit->cchTextMax, NULL, NULL); |
| 535 | else if (cit->pszText) cit->pszText[0] = 0; |
| 536 | else cit->pszText = (LPSTR)tmpcit.pszText; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 537 | |
| 538 | cit->iImage = tmpcit.iImage; |
| 539 | cit->iSelectedImage = tmpcit.iSelectedImage; |
| 540 | cit->iOverlay = tmpcit.iOverlay; |
| 541 | cit->iIndent = tmpcit.iIndent; |
| 542 | cit->lParam = tmpcit.lParam; |
| 543 | |
| 544 | return TRUE; |
| 545 | } |
| 546 | |
| 547 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 548 | inline static BOOL COMBOEX_HasEditChanged (COMBOEX_INFO *infoPtr) |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 549 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 550 | return COMBOEX_HasEdit(infoPtr) && |
| 551 | (infoPtr->flags & WCBE_EDITHASCHANGED) == WCBE_EDITHASCHANGED; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 555 | static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 556 | { |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 557 | INT index; |
| 558 | CBE_ITEMDATA *item; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 559 | NMCOMBOBOXEXW nmcit; |
| 560 | |
| 561 | TRACE("\n"); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 562 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 563 | if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 564 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 565 | /* get real index of item to insert */ |
| 566 | index = cit->iItem; |
| 567 | if (index == -1) index = infoPtr->nb_items; |
| 568 | if (index > infoPtr->nb_items) index = infoPtr->nb_items; |
| 569 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 570 | /* get zero-filled space and chain it in */ |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 571 | if(!(item = (CBE_ITEMDATA *)Alloc (sizeof(*item)))) return -1; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 572 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 573 | /* locate position to insert new item in */ |
| 574 | if (index == infoPtr->nb_items) { |
| 575 | /* fast path for iItem = -1 */ |
| 576 | item->next = infoPtr->items; |
| 577 | infoPtr->items = item; |
| 578 | } |
| 579 | else { |
| 580 | INT i = infoPtr->nb_items-1; |
| 581 | CBE_ITEMDATA *moving = infoPtr->items; |
| 582 | |
| 583 | while ((i > index) && moving) { |
| 584 | moving = (CBE_ITEMDATA *)moving->next; |
| 585 | i--; |
| 586 | } |
| 587 | if (!moving) { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 588 | ERR("COMBOBOXEX item structures broken. Please report!\n"); |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 589 | Free(item); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 590 | return -1; |
| 591 | } |
| 592 | item->next = moving->next; |
| 593 | moving->next = item; |
| 594 | } |
| 595 | |
| 596 | /* fill in our hidden item structure */ |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 597 | item->mask = cit->mask; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 598 | if (item->mask & CBEIF_TEXT) { |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 599 | INT len = 0; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 600 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 601 | if (is_textW(cit->pszText)) len = strlenW (cit->pszText); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 602 | if (len > 0) { |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 603 | item->pszText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR)); |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 604 | if (!item->pszText) { |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 605 | Free(item); |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 606 | return -1; |
| 607 | } |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 608 | strcpyW (item->pszText, cit->pszText); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 609 | } |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 610 | else if (cit->pszText == LPSTR_TEXTCALLBACKW) |
| 611 | item->pszText = LPSTR_TEXTCALLBACKW; |
| 612 | item->cchTextMax = cit->cchTextMax; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 613 | } |
| 614 | if (item->mask & CBEIF_IMAGE) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 615 | item->iImage = cit->iImage; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 616 | if (item->mask & CBEIF_SELECTEDIMAGE) |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 617 | item->iSelectedImage = cit->iSelectedImage; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 618 | if (item->mask & CBEIF_OVERLAY) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 619 | item->iOverlay = cit->iOverlay; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 620 | if (item->mask & CBEIF_INDENT) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 621 | item->iIndent = cit->iIndent; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 622 | if (item->mask & CBEIF_LPARAM) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 623 | item->lParam = cit->lParam; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 624 | infoPtr->nb_items++; |
| 625 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 626 | if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 627 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 628 | SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 629 | (WPARAM)cit->iItem, (LPARAM)item); |
| 630 | |
Guy L. Albertelli | 683c00a | 2002-02-12 18:41:48 +0000 | [diff] [blame] | 631 | memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem)); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 632 | COMBOEX_CopyItem (item, &nmcit.ceItem); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 633 | COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 634 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 635 | return index; |
| 636 | |
| 637 | } |
| 638 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 639 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 640 | static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 641 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 642 | COMBOBOXEXITEMW citW; |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 643 | LPWSTR wstr = NULL; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 644 | INT ret; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 645 | |
| 646 | memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA)); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 647 | if (cit->mask & CBEIF_TEXT && is_textA(cit->pszText)) { |
| 648 | INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0); |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 649 | wstr = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR)); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 650 | if (!wstr) return -1; |
| 651 | MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len); |
| 652 | citW.pszText = wstr; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 653 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 654 | ret = COMBOEX_InsertItemW(infoPtr, &citW); |
| 655 | |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 656 | if (wstr) Free(wstr); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 657 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 658 | return ret; |
| 659 | } |
| 660 | |
| 661 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 662 | static DWORD |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 663 | COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 664 | { |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 665 | DWORD dwTemp; |
| 666 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 667 | TRACE("(mask=x%08lx, style=0x%08lx)\n", mask, style); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 668 | |
| 669 | dwTemp = infoPtr->dwExtStyle; |
| 670 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 671 | if (mask) |
| 672 | infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~mask) | style; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 673 | else |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 674 | infoPtr->dwExtStyle = style; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 675 | |
Dimitrie O. Paun | f14b527 | 2002-08-27 18:16:48 +0000 | [diff] [blame] | 676 | /* see if we need to change the word break proc on the edit */ |
| 677 | if ((infoPtr->dwExtStyle ^ dwTemp) & CBES_EX_PATHWORDBREAKPROC) { |
| 678 | SendMessageW(infoPtr->hwndEdit, EM_SETWORDBREAKPROC, 0, |
| 679 | (infoPtr->dwExtStyle & CBES_EX_PATHWORDBREAKPROC) ? |
| 680 | (LPARAM)COMBOEX_PathWordBreakProc : 0); |
| 681 | } |
| 682 | |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 683 | /* test if the control's appearance has changed */ |
| 684 | mask = CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT; |
| 685 | if ((infoPtr->dwExtStyle & mask) != (dwTemp & mask)) { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 686 | /* if state of EX_NOEDITIMAGE changes, invalidate all */ |
| 687 | TRACE("EX_NOEDITIMAGE state changed to %ld\n", |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 688 | infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE); |
| 689 | InvalidateRect (infoPtr->hwndSelf, NULL, TRUE); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 690 | COMBOEX_AdjustEditPos (infoPtr); |
| 691 | if (infoPtr->hwndEdit) |
| 692 | InvalidateRect (infoPtr->hwndEdit, NULL, TRUE); |
| 693 | } |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 694 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 695 | return dwTemp; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 699 | static HIMAGELIST COMBOEX_SetImageList (COMBOEX_INFO *infoPtr, HIMAGELIST himl) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 700 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 701 | HIMAGELIST himlTemp = infoPtr->himl; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 702 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 703 | TRACE("(...)\n"); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 704 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 705 | infoPtr->himl = himl; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 706 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 707 | COMBOEX_ReSize (infoPtr); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 708 | InvalidateRect (infoPtr->hwndCombo, NULL, TRUE); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 709 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 710 | /* reposition the Edit control based on whether icon exists */ |
| 711 | COMBOEX_AdjustEditPos (infoPtr); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 712 | return himlTemp; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 713 | } |
| 714 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 715 | static BOOL COMBOEX_SetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 716 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 717 | INT index = cit->iItem; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 718 | CBE_ITEMDATA *item; |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 719 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 720 | if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 721 | |
| 722 | /* if item number requested does not exist then return failure */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 723 | if ((index > infoPtr->nb_items) || (index < -1)) return FALSE; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 724 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 725 | /* if the item is the edit control and there is no edit control, skip */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 726 | if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 727 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 728 | if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 729 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 730 | /* add/change stuff to the internal item structure */ |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 731 | item->mask |= cit->mask; |
| 732 | if (cit->mask & CBEIF_TEXT) { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 733 | INT len = 0; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 734 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 735 | COMBOEX_FreeText(item); |
| 736 | if (is_textW(cit->pszText)) len = strlenW(cit->pszText); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 737 | if (len > 0) { |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 738 | item->pszText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR)); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 739 | if (!item->pszText) return FALSE; |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 740 | strcpyW(item->pszText, cit->pszText); |
| 741 | } else if (cit->pszText == LPSTR_TEXTCALLBACKW) |
| 742 | item->pszText = LPSTR_TEXTCALLBACKW; |
| 743 | item->cchTextMax = cit->cchTextMax; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 744 | } |
| 745 | if (cit->mask & CBEIF_IMAGE) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 746 | item->iImage = cit->iImage; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 747 | if (cit->mask & CBEIF_SELECTEDIMAGE) |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 748 | item->iSelectedImage = cit->iSelectedImage; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 749 | if (cit->mask & CBEIF_OVERLAY) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 750 | item->iOverlay = cit->iOverlay; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 751 | if (cit->mask & CBEIF_INDENT) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 752 | item->iIndent = cit->iIndent; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 753 | if (cit->mask & CBEIF_LPARAM) |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 754 | cit->lParam = cit->lParam; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 755 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 756 | if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 757 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 758 | /* if original request was to update edit control, do some fast foot work */ |
| 759 | if (cit->iItem == -1) { |
| 760 | COMBOEX_SetEditText (infoPtr, item); |
| 761 | RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE); |
| 762 | } |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 763 | return TRUE; |
| 764 | } |
| 765 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 766 | static BOOL COMBOEX_SetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) |
Marcus Meissner | 643fcff | 2000-11-06 20:22:06 +0000 | [diff] [blame] | 767 | { |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 768 | COMBOBOXEXITEMW citW; |
| 769 | LPWSTR wstr = NULL; |
| 770 | BOOL ret; |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 771 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 772 | memcpy(&citW, cit, sizeof(COMBOBOXEXITEMA)); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 773 | if ((cit->mask & CBEIF_TEXT) && is_textA(cit->pszText)) { |
| 774 | INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0); |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 775 | wstr = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR)); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 776 | if (!wstr) return FALSE; |
| 777 | MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len); |
| 778 | citW.pszText = wstr; |
Marcus Meissner | 643fcff | 2000-11-06 20:22:06 +0000 | [diff] [blame] | 779 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 780 | ret = COMBOEX_SetItemW(infoPtr, &citW); |
Marcus Meissner | 643fcff | 2000-11-06 20:22:06 +0000 | [diff] [blame] | 781 | |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 782 | if (wstr) Free(wstr); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 783 | |
Marcus Meissner | 643fcff | 2000-11-06 20:22:06 +0000 | [diff] [blame] | 784 | return ret; |
| 785 | } |
| 786 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 787 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 788 | static BOOL COMBOEX_SetUnicodeFormat (COMBOEX_INFO *infoPtr, BOOL value) |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 789 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 790 | BOOL bTemp = infoPtr->unicode; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 791 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 792 | TRACE("to %s, was %s\n", value ? "TRUE":"FALSE", bTemp ? "TRUE":"FALSE"); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 793 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 794 | infoPtr->unicode = value; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 795 | |
| 796 | return bTemp; |
| 797 | } |
| 798 | |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 799 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 800 | /* *** CB_xxx message support *** */ |
| 801 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 802 | static INT |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 803 | COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCWSTR str) |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 804 | { |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 805 | INT i; |
| 806 | cmp_func_t cmptext = get_cmp_func(infoPtr); |
| 807 | INT count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 808 | |
| 809 | /* now search from after starting loc and wrapping back to start */ |
| 810 | for(i=start+1; i<count; i++) { |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 811 | CBE_ITEMDATA *item = get_item_data(infoPtr, i); |
| 812 | if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 813 | } |
| 814 | for(i=0; i<=start; i++) { |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 815 | CBE_ITEMDATA *item = get_item_data(infoPtr, i); |
| 816 | if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 817 | } |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 818 | return CB_ERR; |
| 819 | } |
| 820 | |
| 821 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 822 | static DWORD COMBOEX_GetItemData (COMBOEX_INFO *infoPtr, INT index) |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 823 | { |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 824 | CBE_ITEMDATA *item1, *item2; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 825 | DWORD ret = 0; |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 826 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 827 | item1 = get_item_data(infoPtr, index); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 828 | if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { |
| 829 | item2 = COMBOEX_FindItem (infoPtr, index); |
| 830 | if (item2 != item1) { |
| 831 | ERR("data structures damaged!\n"); |
| 832 | return CB_ERR; |
| 833 | } |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 834 | if (item1->mask & CBEIF_LPARAM) ret = item1->lParam; |
| 835 | TRACE("returning 0x%08lx\n", ret); |
| 836 | } else { |
| 837 | ret = (DWORD)item1; |
| 838 | TRACE("non-valid result from combo, returning 0x%08lx\n", ret); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 839 | } |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 840 | return ret; |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 844 | static INT COMBOEX_SetCursel (COMBOEX_INFO *infoPtr, INT index) |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 845 | { |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 846 | CBE_ITEMDATA *item; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 847 | INT sel; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 848 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 849 | if (!(item = COMBOEX_FindItem(infoPtr, index))) |
| 850 | return SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 851 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 852 | TRACE("selecting item %d text=%s\n", index, debugstr_txt(item->pszText)); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 853 | infoPtr->selected = index; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 854 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 855 | sel = (INT)SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 856 | COMBOEX_SetEditText (infoPtr, item); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 857 | return sel; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 861 | static DWORD COMBOEX_SetItemData (COMBOEX_INFO *infoPtr, INT index, DWORD data) |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 862 | { |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 863 | CBE_ITEMDATA *item1, *item2; |
| 864 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 865 | item1 = get_item_data(infoPtr, index); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 866 | if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { |
| 867 | item2 = COMBOEX_FindItem (infoPtr, index); |
| 868 | if (item2 != item1) { |
| 869 | ERR("data structures damaged!\n"); |
| 870 | return CB_ERR; |
| 871 | } |
| 872 | item1->mask |= CBEIF_LPARAM; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 873 | item1->lParam = data; |
| 874 | TRACE("setting lparam to 0x%08lx\n", data); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 875 | return 0; |
| 876 | } |
| 877 | TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1); |
| 878 | return (LRESULT)item1; |
| 879 | } |
| 880 | |
| 881 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 882 | static INT COMBOEX_SetItemHeight (COMBOEX_INFO *infoPtr, INT index, UINT height) |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 883 | { |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 884 | RECT cb_wrect, cbx_wrect, cbx_crect; |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 885 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 886 | /* First, lets forward the message to the normal combo control |
| 887 | just like Windows. */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 888 | if (infoPtr->hwndCombo) |
| 889 | if (SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, |
| 890 | index, height) == CB_ERR) return CB_ERR; |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 891 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 892 | GetWindowRect (infoPtr->hwndCombo, &cb_wrect); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 893 | GetWindowRect (infoPtr->hwndSelf, &cbx_wrect); |
| 894 | GetClientRect (infoPtr->hwndSelf, &cbx_crect); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 895 | /* the height of comboex as height of the combo + comboex border */ |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 896 | height = cb_wrect.bottom-cb_wrect.top |
| 897 | + cbx_wrect.bottom-cbx_wrect.top |
| 898 | - (cbx_crect.bottom-cbx_crect.top); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 899 | TRACE("EX window=(%ld,%ld)-(%ld,%ld), client=(%ld,%ld)-(%ld,%ld)\n", |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 900 | cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom, |
| 901 | cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 902 | TRACE("CB window=(%ld,%ld)-(%ld,%ld), EX setting=(0,0)-(%ld,%d)\n", |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 903 | cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom, |
| 904 | cbx_wrect.right-cbx_wrect.left, height); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 905 | SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0, |
| 906 | cbx_wrect.right-cbx_wrect.left, height, |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 907 | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 908 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 909 | return 0; |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 910 | } |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 911 | |
| 912 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 913 | /* *** WM_xxx message support *** */ |
| 914 | |
| 915 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 916 | static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 917 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 918 | WCHAR COMBOBOX[] = { 'C', 'o', 'm', 'b', 'o', 'B', 'o', 'x', 0 }; |
| 919 | WCHAR EDIT[] = { 'E', 'D', 'I', 'T', 0 }; |
| 920 | WCHAR NIL[] = { 0 }; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 921 | COMBOEX_INFO *infoPtr; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 922 | LOGFONTW mylogfont; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 923 | RECT wnrc1, clrc1, cmbwrc; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 924 | INT i; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 925 | |
| 926 | /* allocate memory for info structure */ |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 927 | infoPtr = (COMBOEX_INFO *)Alloc (sizeof(COMBOEX_INFO)); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 928 | if (!infoPtr) return -1; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 929 | |
| 930 | /* initialize info structure */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 931 | /* note that infoPtr is allocated zero-filled */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 932 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 933 | infoPtr->hwndSelf = hwnd; |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 934 | infoPtr->selected = -1; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 935 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 936 | infoPtr->unicode = IsWindowUnicode (hwnd); |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 937 | infoPtr->hwndNotify = cs->hwndParent; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 938 | |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 939 | i = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 940 | if ((i != NFR_ANSI) && (i != NFR_UNICODE)) { |
| 941 | WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 942 | i = NFR_ANSI; |
| 943 | } |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 944 | infoPtr->NtfUnicode = (i == NFR_UNICODE); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 945 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 946 | SetWindowLongW (hwnd, 0, (DWORD)infoPtr); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 947 | |
| 948 | /* create combo box */ |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 949 | GetWindowRect(hwnd, &wnrc1); |
| 950 | GetClientRect(hwnd, &clrc1); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 951 | TRACE("EX window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld)\n", |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 952 | wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom, |
| 953 | clrc1.left, clrc1.top, clrc1.right, clrc1.bottom); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 954 | |
| 955 | /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */ |
| 956 | /* specified. It then creates it's own version of the EDIT control */ |
| 957 | /* and makes the ComboBox the parent. This is because a normal */ |
| 958 | /* DROPDOWNLIST does not have a EDIT control, but we need one. */ |
| 959 | /* We also need to place the edit control at the proper location */ |
| 960 | /* (allow space for the icons). */ |
| 961 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 962 | infoPtr->hwndCombo = CreateWindowW (COMBOBOX, NIL, |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 963 | /* following line added to match native */ |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 964 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 965 | CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 966 | /* was base and is necessary */ |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 967 | WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | |
| 968 | GetWindowLongW (hwnd, GWL_STYLE), |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 969 | cs->y, cs->x, cs->cx, cs->cy, hwnd, |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 970 | (HMENU) GetWindowLongW (hwnd, GWL_ID), |
Michael Stefaniuc | f3d1893 | 2002-10-23 20:19:22 +0000 | [diff] [blame] | 971 | (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 972 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 973 | /* |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 974 | * native does the following at this point according to trace: |
| 975 | * GetWindowThreadProcessId(hwndCombo,0) |
| 976 | * GetCurrentThreadId() |
| 977 | * GetWindowThreadProcessId(hwndCombo, &???) |
| 978 | * GetCurrentProcessId() |
| 979 | */ |
| 980 | |
| 981 | /* |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 982 | * Setup a property to hold the pointer to the COMBOBOXEX |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 983 | * data structure. |
| 984 | */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 985 | SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 986 | infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 987 | GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc); |
Michael Stefaniuc | f3d1893 | 2002-10-23 20:19:22 +0000 | [diff] [blame] | 988 | infoPtr->font = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 989 | |
| 990 | |
| 991 | /* |
| 992 | * Now create our own EDIT control so we can position it. |
| 993 | * It is created only for CBS_DROPDOWN style |
| 994 | */ |
| 995 | if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 996 | infoPtr->hwndEdit = CreateWindowExW (0, EDIT, NIL, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 997 | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL, |
| 998 | 0, 0, 0, 0, /* will set later */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 999 | infoPtr->hwndCombo, |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1000 | (HMENU) GetWindowLongW (hwnd, GWL_ID), |
Michael Stefaniuc | f3d1893 | 2002-10-23 20:19:22 +0000 | [diff] [blame] | 1001 | (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1002 | |
| 1003 | /* native does the following at this point according to trace: |
| 1004 | * GetWindowThreadProcessId(hwndEdit,0) |
| 1005 | * GetCurrentThreadId() |
| 1006 | * GetWindowThreadProcessId(hwndEdit, &???) |
| 1007 | * GetCurrentProcessId() |
| 1008 | */ |
| 1009 | |
| 1010 | /* |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1011 | * Setup a property to hold the pointer to the COMBOBOXEX |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1012 | * data structure. |
| 1013 | */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1014 | SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1015 | infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1016 | GWL_WNDPROC, (LONG)COMBOEX_EditWndProc); |
Michael Stefaniuc | f3d1893 | 2002-10-23 20:19:22 +0000 | [diff] [blame] | 1017 | infoPtr->font = (HFONT)SendMessageW(infoPtr->hwndCombo, WM_GETFONT, 0, 0); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1018 | } |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1019 | |
| 1020 | /* |
| 1021 | * Locate the default font if necessary and then set it in |
| 1022 | * all associated controls |
| 1023 | */ |
| 1024 | if (!infoPtr->font) { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1025 | SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1026 | &mylogfont, 0); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1027 | infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1028 | } |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1029 | SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1030 | if (infoPtr->hwndEdit) { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1031 | SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0); |
| 1032 | SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1033 | } |
| 1034 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1035 | COMBOEX_ReSize (infoPtr); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1036 | |
| 1037 | /* Above is fairly certain, below is much less certain. */ |
| 1038 | |
| 1039 | GetWindowRect(hwnd, &wnrc1); |
| 1040 | GetClientRect(hwnd, &clrc1); |
| 1041 | GetWindowRect(infoPtr->hwndCombo, &cmbwrc); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1042 | TRACE("EX window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) CB wnd=(%ld,%ld)-(%ld,%ld)\n", |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1043 | wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom, |
| 1044 | clrc1.left, clrc1.top, clrc1.right, clrc1.bottom, |
| 1045 | cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1046 | SetWindowPos(infoPtr->hwndCombo, HWND_TOP, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1047 | 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top, |
| 1048 | SWP_NOACTIVATE | SWP_NOREDRAW); |
| 1049 | |
| 1050 | GetWindowRect(infoPtr->hwndCombo, &cmbwrc); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1051 | TRACE("CB window=(%ld,%ld)-(%ld,%ld)\n", |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1052 | cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1053 | SetWindowPos(hwnd, HWND_TOP, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1054 | 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top, |
| 1055 | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); |
| 1056 | |
| 1057 | COMBOEX_AdjustEditPos (infoPtr); |
| 1058 | |
| 1059 | /* |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1060 | * Create an item structure to represent the data in the |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1061 | * EDIT control. It is allocated zero-filled. |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1062 | */ |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 1063 | infoPtr->edit = (CBE_ITEMDATA *)Alloc (sizeof (CBE_ITEMDATA)); |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1064 | if (!infoPtr->edit) { |
| 1065 | COMBOEX_Destroy(infoPtr); |
| 1066 | return -1; |
| 1067 | } |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1068 | |
| 1069 | return 0; |
| 1070 | } |
| 1071 | |
| 1072 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1073 | static LRESULT COMBOEX_Command (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam) |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1074 | { |
| 1075 | LRESULT lret; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1076 | INT command = HIWORD(wParam); |
| 1077 | CBE_ITEMDATA *item = 0; |
| 1078 | WCHAR wintext[520]; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1079 | INT cursel, n, oldItem; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1080 | NMCBEENDEDITW cbeend; |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1081 | DWORD oldflags; |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 1082 | HWND parent = infoPtr->hwndNotify; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1083 | |
| 1084 | TRACE("for command %d\n", command); |
| 1085 | |
| 1086 | switch (command) |
| 1087 | { |
| 1088 | case CBN_DROPDOWN: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1089 | SetFocus (infoPtr->hwndCombo); |
| 1090 | ShowWindow (infoPtr->hwndEdit, SW_HIDE); |
| 1091 | return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1092 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1093 | case CBN_CLOSEUP: |
| 1094 | SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1095 | /* |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1096 | * from native trace of first dropdown after typing in URL in IE4 |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1097 | * CB_GETCURSEL(Combo) |
| 1098 | * GetWindowText(Edit) |
| 1099 | * CB_GETCURSEL(Combo) |
| 1100 | * CB_GETCOUNT(Combo) |
| 1101 | * CB_GETITEMDATA(Combo, n) |
| 1102 | * WM_NOTIFY(parent, CBEN_ENDEDITA|W) |
| 1103 | * CB_GETCURSEL(Combo) |
| 1104 | * CB_SETCURSEL(COMBOEX, n) |
| 1105 | * SetFocus(Combo) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1106 | * the rest is supposition |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1107 | */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1108 | ShowWindow (infoPtr->hwndEdit, SW_SHOW); |
| 1109 | InvalidateRect (infoPtr->hwndCombo, 0, TRUE); |
| 1110 | InvalidateRect (infoPtr->hwndEdit, 0, TRUE); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1111 | cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); |
| 1112 | if (cursel == -1) { |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 1113 | cmp_func_t cmptext = get_cmp_func(infoPtr); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1114 | /* find match from edit against those in Combobox */ |
| 1115 | GetWindowTextW (infoPtr->hwndEdit, wintext, 520); |
| 1116 | n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0); |
| 1117 | for (cursel = 0; cursel < n; cursel++){ |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1118 | item = get_item_data(infoPtr, cursel); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1119 | if ((INT)item == CB_ERR) break; |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 1120 | if (!cmptext(COMBOEX_GetText(infoPtr, item), wintext)) break; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1121 | } |
| 1122 | if ((cursel == n) || ((INT)item == CB_ERR)) { |
| 1123 | TRACE("failed to find match??? item=%p cursel=%d\n", |
| 1124 | item, cursel); |
| 1125 | if (infoPtr->hwndEdit) |
| 1126 | SetFocus(infoPtr->hwndEdit); |
| 1127 | return 0; |
| 1128 | } |
| 1129 | } |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1130 | else { |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1131 | item = get_item_data(infoPtr, cursel); |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1132 | if ((INT)item == CB_ERR) { |
| 1133 | TRACE("failed to find match??? item=%p cursel=%d\n", |
| 1134 | item, cursel); |
| 1135 | if (infoPtr->hwndEdit) |
| 1136 | SetFocus(infoPtr->hwndEdit); |
| 1137 | return 0; |
| 1138 | } |
| 1139 | } |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1140 | |
| 1141 | /* Save flags for testing and reset them */ |
| 1142 | oldflags = infoPtr->flags; |
| 1143 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); |
| 1144 | |
| 1145 | if (oldflags & WCBE_ACTEDIT) { |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1146 | cbeend.fChanged = (oldflags & WCBE_EDITCHG); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1147 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, |
| 1148 | CB_GETCURSEL, 0, 0); |
| 1149 | cbeend.iWhy = CBENF_DROPDOWN; |
| 1150 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1151 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, COMBOEX_GetText(infoPtr, item))) return 0; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1152 | } |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1153 | |
| 1154 | /* if selection has changed the set the new current selection */ |
| 1155 | cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); |
| 1156 | if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) { |
| 1157 | infoPtr->selected = cursel; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1158 | SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, cursel, 0); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1159 | SetFocus(infoPtr->hwndCombo); |
| 1160 | } |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1161 | return 0; |
| 1162 | |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1163 | case CBN_SELCHANGE: |
| 1164 | /* |
| 1165 | * CB_GETCURSEL(Combo) |
| 1166 | * CB_GETITEMDATA(Combo) < simulated by COMBOEX_FindItem |
| 1167 | * lstrlenA |
| 1168 | * WM_SETTEXT(Edit) |
| 1169 | * WM_GETTEXTLENGTH(Edit) |
| 1170 | * WM_GETTEXT(Edit) |
| 1171 | * EM_SETSEL(Edit, 0,0) |
| 1172 | * WM_GETTEXTLENGTH(Edit) |
| 1173 | * WM_GETTEXT(Edit) |
| 1174 | * EM_SETSEL(Edit, 0,len) |
| 1175 | * return WM_COMMAND to parent |
| 1176 | */ |
| 1177 | oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); |
| 1178 | if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) { |
| 1179 | ERR("item %d not found. Problem!\n", oldItem); |
| 1180 | break; |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1181 | } |
| 1182 | infoPtr->selected = oldItem; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1183 | COMBOEX_SetEditText (infoPtr, item); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1184 | return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1185 | |
| 1186 | case CBN_SELENDOK: |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1187 | /* |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1188 | * We have to change the handle since we are the control |
| 1189 | * issuing the message. IE4 depends on this. |
| 1190 | */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1191 | return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1192 | |
| 1193 | case CBN_KILLFOCUS: |
| 1194 | /* |
| 1195 | * from native trace: |
| 1196 | * |
| 1197 | * pass to parent |
| 1198 | * WM_GETTEXT(Edit, 104) |
| 1199 | * CB_GETCURSEL(Combo) rets -1 |
| 1200 | * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS |
| 1201 | * CB_GETCURSEL(Combo) |
| 1202 | * InvalidateRect(Combo, 0, 0) |
| 1203 | * return 0 |
| 1204 | */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1205 | SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1206 | if (infoPtr->flags & WCBE_ACTEDIT) { |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1207 | GetWindowTextW (infoPtr->hwndEdit, wintext, 260); |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1208 | cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG); |
| 1209 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, |
| 1210 | CB_GETCURSEL, 0, 0); |
| 1211 | cbeend.iWhy = CBENF_KILLFOCUS; |
| 1212 | |
| 1213 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1214 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) return 0; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1215 | } |
| 1216 | /* possible CB_GETCURSEL */ |
| 1217 | InvalidateRect (infoPtr->hwndCombo, 0, 0); |
| 1218 | return 0; |
| 1219 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1220 | default: |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1221 | /* |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1222 | * We have to change the handle since we are the control |
| 1223 | * issuing the message. IE4 depends on this. |
| 1224 | * We also need to set the focus back to the Edit control |
| 1225 | * after passing the command to the parent of the ComboEx. |
| 1226 | */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1227 | lret = SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1228 | if (infoPtr->hwndEdit) |
| 1229 | SetFocus(infoPtr->hwndEdit); |
| 1230 | return lret; |
| 1231 | } |
| 1232 | return 0; |
| 1233 | } |
| 1234 | |
| 1235 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1236 | static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis) |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1237 | { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1238 | CBE_ITEMDATA *item, *olditem; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1239 | NMCOMBOBOXEXW nmcit; |
Rolf Kalbermatter | 6c79930 | 2002-12-16 22:43:58 +0000 | [diff] [blame] | 1240 | UINT i; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1241 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 1242 | TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%p, data=%08lx\n", |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1243 | dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData); |
| 1244 | |
Jörg Mayer | e5b5af9 | 2001-08-10 22:49:35 +0000 | [diff] [blame] | 1245 | if (dis->itemID >= infoPtr->nb_items) return FALSE; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1246 | |
| 1247 | olditem = infoPtr->items; |
| 1248 | i = infoPtr->nb_items - 1; |
| 1249 | |
| 1250 | if (i == dis->itemID) { |
| 1251 | infoPtr->items = infoPtr->items->next; |
| 1252 | } |
| 1253 | else { |
| 1254 | item = olditem; |
| 1255 | i--; |
| 1256 | |
| 1257 | /* find the prior item in the list */ |
| 1258 | while (item->next && (i > dis->itemID)) { |
| 1259 | item = (CBE_ITEMDATA *)item->next; |
| 1260 | i--; |
| 1261 | } |
| 1262 | if (!item->next || (i != dis->itemID)) { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1263 | ERR("COMBOBOXEX item structures broken. Please report!\n"); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1264 | return FALSE; |
| 1265 | } |
| 1266 | olditem = item->next; |
| 1267 | item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next; |
| 1268 | } |
| 1269 | infoPtr->nb_items--; |
| 1270 | |
Guy L. Albertelli | 683c00a | 2002-02-12 18:41:48 +0000 | [diff] [blame] | 1271 | memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem)); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1272 | COMBOEX_CopyItem (olditem, &nmcit.ceItem); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1273 | COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1274 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1275 | COMBOEX_FreeText(olditem); |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 1276 | Free(olditem); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1277 | |
| 1278 | return TRUE; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1279 | } |
| 1280 | |
| 1281 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1282 | static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT *dis) |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1283 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1284 | WCHAR nil[] = { 0 }; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1285 | CBE_ITEMDATA *item = 0; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1286 | SIZE txtsize; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1287 | RECT rect; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1288 | LPCWSTR str = nil; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1289 | UINT xbase, x, y; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1290 | INT len; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1291 | COLORREF nbkc, ntxc, bkc, txc; |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1292 | int drawimage, drawstate, xioff; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1293 | |
| 1294 | if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0; |
| 1295 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1296 | TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n", |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1297 | dis->CtlType, dis->CtlID); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1298 | TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n", |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1299 | dis->itemID, dis->itemAction, dis->itemState); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1300 | TRACE("hWnd=%p hDC=%p (%ld,%ld)-(%ld,%ld) itemData=0x%08lx\n", |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1301 | dis->hwndItem, dis->hDC, dis->rcItem.left, |
| 1302 | dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom, |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1303 | dis->itemData); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1304 | |
Guy L. Albertelli | 312beec | 2000-10-31 01:00:39 +0000 | [diff] [blame] | 1305 | /* MSDN says: */ |
| 1306 | /* "itemID - Specifies the menu item identifier for a menu */ |
| 1307 | /* item or the index of the item in a list box or combo box. */ |
| 1308 | /* For an empty list box or combo box, this member can be -1. */ |
| 1309 | /* This allows the application to draw only the focus */ |
| 1310 | /* rectangle at the coordinates specified by the rcItem */ |
| 1311 | /* member even though there are no items in the control. */ |
| 1312 | /* This indicates to the user whether the list box or combo */ |
| 1313 | /* box has the focus. How the bits are set in the itemAction */ |
| 1314 | /* member determines whether the rectangle is to be drawn as */ |
| 1315 | /* though the list box or combo box has the focus. */ |
| 1316 | if (dis->itemID == 0xffffffff) { |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1317 | if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) || |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1318 | ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1319 | |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1320 | TRACE("drawing item -1 special focus, rect=(%ld,%ld)-(%ld,%ld)\n", |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1321 | dis->rcItem.left, dis->rcItem.top, |
| 1322 | dis->rcItem.right, dis->rcItem.bottom); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1323 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1324 | else if ((dis->CtlType == ODT_COMBOBOX) && |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1325 | (dis->itemAction == ODA_DRAWENTIRE)) { |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1326 | /* draw of edit control data */ |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1327 | |
| 1328 | /* testing */ |
| 1329 | { |
| 1330 | RECT exrc, cbrc, edrc; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1331 | GetWindowRect (infoPtr->hwndSelf, &exrc); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1332 | GetWindowRect (infoPtr->hwndCombo, &cbrc); |
| 1333 | edrc.left=edrc.top=edrc.right=edrc.bottom=-1; |
| 1334 | if (infoPtr->hwndEdit) |
| 1335 | GetWindowRect (infoPtr->hwndEdit, &edrc); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1336 | TRACE("window rects ex=(%ld,%ld)-(%ld,%ld), cb=(%ld,%ld)-(%ld,%ld), ed=(%ld,%ld)-(%ld,%ld)\n", |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1337 | exrc.left, exrc.top, exrc.right, exrc.bottom, |
| 1338 | cbrc.left, cbrc.top, cbrc.right, cbrc.bottom, |
| 1339 | edrc.left, edrc.top, edrc.right, edrc.bottom); |
| 1340 | } |
| 1341 | } |
| 1342 | else { |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1343 | ERR("NOT drawing item -1 special focus, rect=(%ld,%ld)-(%ld,%ld), action=%08x, state=%08x\n", |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1344 | dis->rcItem.left, dis->rcItem.top, |
| 1345 | dis->rcItem.right, dis->rcItem.bottom, |
| 1346 | dis->itemAction, dis->itemState); |
| 1347 | return 0; |
| 1348 | } |
Guy L. Albertelli | 312beec | 2000-10-31 01:00:39 +0000 | [diff] [blame] | 1349 | } |
| 1350 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1351 | /* If draw item is -1 (edit control) setup the item pointer */ |
| 1352 | if (dis->itemID == 0xffffffff) { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1353 | item = infoPtr->edit; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1354 | |
| 1355 | if (infoPtr->hwndEdit) { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1356 | INT len; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1357 | |
| 1358 | /* free previous text of edit item */ |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1359 | COMBOEX_FreeText(item); |
| 1360 | item->mask &= ~CBEIF_TEXT; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1361 | if( (len = GetWindowTextLengthW(infoPtr->hwndEdit)) ) { |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1362 | item->mask |= CBEIF_TEXT; |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 1363 | item->pszText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR)); |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1364 | if (item->pszText) |
| 1365 | GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1366 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 1367 | TRACE("edit control hwndEdit=%p, text len=%d str=%s\n", |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1368 | infoPtr->hwndEdit, len, debugstr_txt(item->pszText)); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1369 | } |
| 1370 | } |
Uwe Bonnes | a07258d | 2000-10-29 18:04:45 +0000 | [diff] [blame] | 1371 | } |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1372 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1373 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1374 | /* if the item pointer is not set, then get the data and locate it */ |
| 1375 | if (!item) { |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1376 | item = get_item_data(infoPtr, dis->itemID); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1377 | if (item == (CBE_ITEMDATA *)CB_ERR) { |
| 1378 | ERR("invalid item for id %d \n", dis->itemID); |
| 1379 | return 0; |
| 1380 | } |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1381 | } |
| 1382 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1383 | if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1384 | |
| 1385 | xbase = CBE_STARTOFFSET; |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1386 | if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) { |
| 1387 | INT indent = item->iIndent; |
| 1388 | if (indent == I_INDENTCALLBACK) { |
| 1389 | NMCOMBOBOXEXW nmce; |
| 1390 | ZeroMemory(&nmce, sizeof(nmce)); |
| 1391 | nmce.ceItem.mask = CBEIF_INDENT; |
Carlos Lozano | 5347222 | 2002-10-31 22:02:47 +0000 | [diff] [blame] | 1392 | nmce.ceItem.lParam = item->lParam; |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1393 | COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); |
| 1394 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) |
| 1395 | item->iIndent = nmce.ceItem.iIndent; |
| 1396 | indent = nmce.ceItem.iIndent; |
| 1397 | } |
| 1398 | xbase += (indent * CBE_INDENT); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1399 | } |
| 1400 | |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1401 | drawimage = -2; |
| 1402 | drawstate = ILD_NORMAL; |
| 1403 | if (item->mask & CBEIF_IMAGE) |
| 1404 | drawimage = item->iImage; |
| 1405 | if (dis->itemState & ODS_COMBOEXLBOX) { |
| 1406 | /* drawing listbox entry */ |
| 1407 | if (dis->itemState & ODS_SELECTED) { |
| 1408 | if (item->mask & CBEIF_SELECTEDIMAGE) |
| 1409 | drawimage = item->iSelectedImage; |
| 1410 | drawstate = ILD_SELECTED; |
| 1411 | } |
| 1412 | } else { |
| 1413 | /* drawing combo/edit entry */ |
| 1414 | if (IsWindowVisible(infoPtr->hwndEdit)) { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1415 | /* if we have an edit control, the slave the |
| 1416 | * selection state to the Edit focus state |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1417 | */ |
| 1418 | if (infoPtr->flags & WCBE_EDITFOCUSED) { |
| 1419 | if (item->mask & CBEIF_SELECTEDIMAGE) |
| 1420 | drawimage = item->iSelectedImage; |
| 1421 | drawstate = ILD_SELECTED; |
| 1422 | } |
| 1423 | } else { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1424 | /* if we don't have an edit control, use |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1425 | * the requested state. |
| 1426 | */ |
| 1427 | if (dis->itemState & ODS_SELECTED) { |
| 1428 | if (item->mask & CBEIF_SELECTEDIMAGE) |
| 1429 | drawimage = item->iSelectedImage; |
| 1430 | drawstate = ILD_SELECTED; |
| 1431 | } |
| 1432 | } |
| 1433 | } |
| 1434 | |
| 1435 | if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) { |
| 1436 | IMAGEINFO iinfo; |
| 1437 | iinfo.rcImage.left = iinfo.rcImage.right = 0; |
| 1438 | ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); |
| 1439 | xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; |
| 1440 | } else xioff = 0; |
| 1441 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1442 | /* setup pointer to text to be drawn */ |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1443 | str = COMBOEX_GetText(infoPtr, item); |
| 1444 | if (!str) str = nil; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1445 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1446 | len = strlenW (str); |
| 1447 | GetTextExtentPoint32W (dis->hDC, str, len, &txtsize); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1448 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1449 | if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) { |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1450 | int overlay = item->iOverlay; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1451 | |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1452 | if (drawimage == I_IMAGECALLBACK) { |
| 1453 | NMCOMBOBOXEXW nmce; |
| 1454 | ZeroMemory(&nmce, sizeof(nmce)); |
| 1455 | nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE; |
Carlos Lozano | 5347222 | 2002-10-31 22:02:47 +0000 | [diff] [blame] | 1456 | nmce.ceItem.lParam = item->lParam; |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1457 | COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); |
| 1458 | if (drawstate == ILD_NORMAL) { |
| 1459 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage; |
| 1460 | drawimage = nmce.ceItem.iImage; |
| 1461 | } else if (drawstate == ILD_SELECTED) { |
| 1462 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iSelectedImage = nmce.ceItem.iSelectedImage; |
| 1463 | drawimage = nmce.ceItem.iSelectedImage; |
| 1464 | } else ERR("Bad draw state = %d\n", drawstate); |
| 1465 | } |
| 1466 | |
| 1467 | if (overlay == I_IMAGECALLBACK) { |
| 1468 | NMCOMBOBOXEXW nmce; |
| 1469 | ZeroMemory(&nmce, sizeof(nmce)); |
| 1470 | nmce.ceItem.mask = CBEIF_OVERLAY; |
Carlos Lozano | 5347222 | 2002-10-31 22:02:47 +0000 | [diff] [blame] | 1471 | nmce.ceItem.lParam = item->lParam; |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1472 | COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); |
| 1473 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) |
| 1474 | item->iOverlay = nmce.ceItem.iOverlay; |
| 1475 | overlay = nmce.ceItem.iOverlay; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1476 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1477 | |
| 1478 | if (drawimage >= 0 && |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1479 | !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) { |
| 1480 | if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1481 | ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top, |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1482 | drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0)); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1483 | } |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1484 | |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1485 | /* now draw the text */ |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1486 | if (!IsWindowVisible (infoPtr->hwndEdit)) { |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1487 | nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ? |
| 1488 | COLOR_HIGHLIGHT : COLOR_WINDOW); |
| 1489 | bkc = SetBkColor (dis->hDC, nbkc); |
| 1490 | ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ? |
| 1491 | COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT); |
| 1492 | txc = SetTextColor (dis->hDC, ntxc); |
| 1493 | x = xbase + xioff; |
| 1494 | y = dis->rcItem.top + |
| 1495 | (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2; |
| 1496 | rect.left = x; |
| 1497 | rect.right = x + txtsize.cx; |
| 1498 | rect.top = dis->rcItem.top + 1; |
| 1499 | rect.bottom = dis->rcItem.bottom - 1; |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1500 | TRACE("drawing item %d text, rect=(%ld,%ld)-(%ld,%ld)\n", |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 1501 | dis->itemID, rect.left, rect.top, rect.right, rect.bottom); |
| 1502 | ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED, |
| 1503 | &rect, str, len, 0); |
| 1504 | SetBkColor (dis->hDC, bkc); |
| 1505 | SetTextColor (dis->hDC, txc); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1506 | } |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1507 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1508 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1509 | if (dis->itemAction & ODA_FOCUS) { |
| 1510 | rect.left = xbase + xioff - 1; |
| 1511 | rect.right = rect.left + txtsize.cx + 2; |
| 1512 | rect.top = dis->rcItem.top; |
| 1513 | rect.bottom = dis->rcItem.bottom; |
| 1514 | DrawFocusRect(dis->hDC, &rect); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1515 | } |
| 1516 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1517 | return 0; |
| 1518 | } |
| 1519 | |
| 1520 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1521 | static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1522 | { |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1523 | if (infoPtr->hwndCombo) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1524 | DestroyWindow (infoPtr->hwndCombo); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1525 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1526 | if (infoPtr->edit) { |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 1527 | Free (infoPtr->edit); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1528 | infoPtr->edit = 0; |
| 1529 | } |
| 1530 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1531 | if (infoPtr->items) { |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1532 | CBE_ITEMDATA *item, *next; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1533 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1534 | item = infoPtr->items; |
| 1535 | while (item) { |
| 1536 | next = (CBE_ITEMDATA *)item->next; |
| 1537 | COMBOEX_FreeText (item); |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 1538 | Free (item); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1539 | item = next; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1540 | } |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1541 | infoPtr->items = 0; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1542 | } |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1543 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1544 | if (infoPtr->defaultFont) |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1545 | DeleteObject (infoPtr->defaultFont); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1546 | |
| 1547 | /* free comboex info data */ |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 1548 | Free (infoPtr); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1549 | SetWindowLongW (infoPtr->hwndSelf, 0, 0); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1550 | return 0; |
| 1551 | } |
| 1552 | |
| 1553 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1554 | static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO *infoPtr, MEASUREITEMSTRUCT *mis) |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1555 | { |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1556 | SIZE mysize; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1557 | HDC hdc; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1558 | |
| 1559 | hdc = GetDC (0); |
| 1560 | GetTextExtentPointA (hdc, "W", 1, &mysize); |
| 1561 | ReleaseDC (0, hdc); |
| 1562 | mis->itemHeight = mysize.cy + CBE_EXTRA; |
| 1563 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 1564 | TRACE("adjusted height hwnd=%p, height=%d\n", |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1565 | infoPtr->hwndSelf, mis->itemHeight); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1566 | |
| 1567 | return 0; |
| 1568 | } |
| 1569 | |
| 1570 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1571 | static LRESULT COMBOEX_NCCreate (HWND hwnd) |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1572 | { |
| 1573 | /* WARNING: The COMBOEX_INFO structure is not yet created */ |
| 1574 | DWORD oldstyle, newstyle; |
| 1575 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1576 | oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1577 | newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL); |
| 1578 | if (newstyle != oldstyle) { |
| 1579 | TRACE("req style %08lx, reseting style %08lx\n", |
| 1580 | oldstyle, newstyle); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1581 | SetWindowLongW (hwnd, GWL_STYLE, newstyle); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1582 | } |
| 1583 | return 1; |
| 1584 | } |
| 1585 | |
| 1586 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1587 | static LRESULT COMBOEX_NotifyFormat (COMBOEX_INFO *infoPtr, LPARAM lParam) |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1588 | { |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1589 | if (lParam == NF_REQUERY) { |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 1590 | INT i = SendMessageW(infoPtr->hwndNotify, |
Michael Stefaniuc | 025c0b7 | 2002-09-06 19:41:17 +0000 | [diff] [blame] | 1591 | WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1592 | infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1593 | } |
Dimitrie O. Paun | 55f9b75 | 2002-04-23 19:27:10 +0000 | [diff] [blame] | 1594 | return infoPtr->NtfUnicode ? NFR_UNICODE : NFR_ANSI; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1595 | } |
| 1596 | |
| 1597 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1598 | static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1599 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1600 | TRACE("(width=%d, height=%d)\n", width, height); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1601 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1602 | MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1603 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1604 | COMBOEX_AdjustEditPos (infoPtr); |
| 1605 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1606 | return 0; |
| 1607 | } |
| 1608 | |
| 1609 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1610 | static LRESULT COMBOEX_WindowPosChanging (COMBOEX_INFO *infoPtr, WINDOWPOS *wp) |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1611 | { |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1612 | RECT cbx_wrect, cbx_crect, cb_wrect; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1613 | UINT width, height; |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1614 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1615 | GetWindowRect (infoPtr->hwndSelf, &cbx_wrect); |
| 1616 | GetClientRect (infoPtr->hwndSelf, &cbx_crect); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1617 | GetWindowRect (infoPtr->hwndCombo, &cb_wrect); |
| 1618 | |
| 1619 | /* width is winpos value + border width of comboex */ |
| 1620 | width = wp->cx |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1621 | + (cbx_wrect.right-cbx_wrect.left) |
| 1622 | - (cbx_crect.right-cbx_crect.left); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1623 | |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 1624 | TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n", |
| 1625 | wp->x, wp->y, wp->cx, wp->cy, wp->flags); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1626 | TRACE("EX window=(%ld,%ld)-(%ld,%ld), client=(%ld,%ld)-(%ld,%ld)\n", |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1627 | cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom, |
| 1628 | cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1629 | TRACE("CB window=(%ld,%ld)-(%ld,%ld), EX setting=(0,0)-(%d,%ld)\n", |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1630 | cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom, |
| 1631 | width, cb_wrect.bottom-cb_wrect.top); |
| 1632 | |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1633 | if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0, |
| 1634 | width, |
| 1635 | cb_wrect.bottom-cb_wrect.top, |
| 1636 | SWP_NOACTIVATE); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 1637 | |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1638 | GetWindowRect (infoPtr->hwndCombo, &cb_wrect); |
| 1639 | |
| 1640 | /* height is combo window height plus border width of comboex */ |
| 1641 | height = (cb_wrect.bottom-cb_wrect.top) |
| 1642 | + (cbx_wrect.bottom-cbx_wrect.top) |
| 1643 | - (cbx_crect.bottom-cbx_crect.top); |
| 1644 | if (wp->cy < height) wp->cy = height; |
| 1645 | if (infoPtr->hwndEdit) { |
| 1646 | COMBOEX_AdjustEditPos (infoPtr); |
| 1647 | InvalidateRect (infoPtr->hwndCombo, 0, TRUE); |
| 1648 | } |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1649 | |
| 1650 | return 0; |
| 1651 | } |
| 1652 | |
Dimitrie O. Paun | f14b527 | 2002-08-27 18:16:48 +0000 | [diff] [blame] | 1653 | static inline int is_delimiter(WCHAR c) |
| 1654 | { |
| 1655 | switch(c) { |
| 1656 | case '/': |
| 1657 | case '\\': |
| 1658 | case '.': |
| 1659 | return TRUE; |
| 1660 | } |
| 1661 | return FALSE; |
| 1662 | } |
| 1663 | |
| 1664 | static int CALLBACK |
| 1665 | COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code) |
| 1666 | { |
| 1667 | if (code == WB_ISDELIMITER) { |
| 1668 | return is_delimiter(lpch[ichCurrent]); |
| 1669 | } else { |
| 1670 | int dir = (code == WB_LEFT) ? -1 : 1; |
| 1671 | for(; 0 <= ichCurrent && ichCurrent < cch; ichCurrent += dir) |
| 1672 | if (is_delimiter(lpch[ichCurrent])) return ichCurrent; |
| 1673 | } |
| 1674 | return ichCurrent; |
| 1675 | } |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1676 | |
| 1677 | static LRESULT WINAPI |
| 1678 | COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 1679 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1680 | HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); |
| 1681 | COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1682 | NMCBEENDEDITW cbeend; |
| 1683 | WCHAR edit_text[260]; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1684 | COLORREF obkc; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1685 | HDC hDC; |
| 1686 | RECT rect; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1687 | LRESULT lret; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1688 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 1689 | TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1690 | hwnd, uMsg, wParam, lParam, infoPtr); |
| 1691 | |
| 1692 | if (!infoPtr) return 0; |
| 1693 | |
| 1694 | switch (uMsg) |
| 1695 | { |
| 1696 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1697 | case WM_CHAR: |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1698 | /* handle (ignore) the return character */ |
| 1699 | if (wParam == VK_RETURN) return 0; |
| 1700 | /* all other characters pass into the real Edit */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1701 | return CallWindowProcW (infoPtr->prevEditWndProc, |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1702 | hwnd, uMsg, wParam, lParam); |
| 1703 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1704 | case WM_ERASEBKGND: |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1705 | /* |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1706 | * The following was determined by traces of the native |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1707 | */ |
| 1708 | hDC = (HDC) wParam; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1709 | obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW)); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1710 | GetClientRect (hwnd, &rect); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1711 | TRACE("erasing (%ld,%ld)-(%ld,%ld)\n", |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1712 | rect.left, rect.top, rect.right, rect.bottom); |
| 1713 | ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); |
| 1714 | SetBkColor (hDC, obkc); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1715 | return CallWindowProcW (infoPtr->prevEditWndProc, |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1716 | hwnd, uMsg, wParam, lParam); |
| 1717 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1718 | case WM_KEYDOWN: { |
| 1719 | INT oldItem, selected, step = 1; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1720 | CBE_ITEMDATA *item; |
| 1721 | |
| 1722 | switch ((INT)wParam) |
| 1723 | { |
| 1724 | case VK_ESCAPE: |
| 1725 | /* native version seems to do following for COMBOEX */ |
| 1726 | /* |
| 1727 | * GetWindowTextA(Edit,&?, 0x104) x |
| 1728 | * CB_GETCURSEL to Combo rets -1 x |
| 1729 | * WM_NOTIFY to COMBOEX parent (rebar) x |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1730 | * (CBEN_ENDEDIT{A|W} |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1731 | * fChanged = FALSE x |
| 1732 | * inewSelection = -1 x |
| 1733 | * txt="www.hoho" x |
| 1734 | * iWhy = 3 x |
| 1735 | * CB_GETCURSEL to Combo rets -1 x |
| 1736 | * InvalidateRect(Combo, 0) x |
| 1737 | * WM_SETTEXT to Edit x |
| 1738 | * EM_SETSEL to Edit (0,0) x |
| 1739 | * EM_SETSEL to Edit (0,-1) x |
| 1740 | * RedrawWindow(Combo, 0, 0, 5) x |
| 1741 | */ |
| 1742 | TRACE("special code for VK_ESCAPE\n"); |
| 1743 | |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1744 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1745 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1746 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1747 | cbeend.fChanged = FALSE; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1748 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1749 | CB_GETCURSEL, 0, 0); |
| 1750 | cbeend.iWhy = CBENF_ESCAPE; |
| 1751 | |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1752 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1753 | oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1754 | InvalidateRect (infoPtr->hwndCombo, 0, 0); |
| 1755 | if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) { |
| 1756 | ERR("item %d not found. Problem!\n", oldItem); |
| 1757 | break; |
| 1758 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1759 | infoPtr->selected = oldItem; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1760 | COMBOEX_SetEditText (infoPtr, item); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1761 | RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1762 | RDW_INVALIDATE); |
| 1763 | break; |
| 1764 | |
| 1765 | case VK_RETURN: |
| 1766 | /* native version seems to do following for COMBOEX */ |
| 1767 | /* |
| 1768 | * GetWindowTextA(Edit,&?, 0x104) x |
| 1769 | * CB_GETCURSEL to Combo rets -1 x |
| 1770 | * CB_GETCOUNT to Combo rets 0 |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1771 | * if >0 loop |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1772 | * CB_GETITEMDATA to match |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1773 | * *** above 3 lines simulated by FindItem x |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1774 | * WM_NOTIFY to COMBOEX parent (rebar) x |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1775 | * (CBEN_ENDEDIT{A|W} x |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1776 | * fChanged = TRUE (-1) x |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1777 | * iNewSelection = -1 or selected x |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1778 | * txt= x |
| 1779 | * iWhy = 2 (CBENF_RETURN) x |
| 1780 | * CB_GETCURSEL to Combo rets -1 x |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1781 | * if -1 send CB_SETCURSEL to Combo -1 x |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1782 | * InvalidateRect(Combo, 0, 0) x |
| 1783 | * SetFocus(Edit) x |
| 1784 | * CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001) |
| 1785 | */ |
| 1786 | |
| 1787 | TRACE("special code for VK_RETURN\n"); |
| 1788 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1789 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1790 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1791 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); |
| 1792 | selected = SendMessageW (infoPtr->hwndCombo, |
| 1793 | CB_GETCURSEL, 0, 0); |
| 1794 | |
| 1795 | if (selected != -1) { |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 1796 | cmp_func_t cmptext = get_cmp_func(infoPtr); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1797 | item = COMBOEX_FindItem (infoPtr, selected); |
| 1798 | TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n", |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 1799 | selected, debugstr_txt(item->pszText)); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1800 | TRACE("handling VK_RETURN, edittext=%s\n", |
| 1801 | debugstr_w(edit_text)); |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 1802 | if (cmptext (COMBOEX_GetText(infoPtr, item), edit_text)) { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1803 | /* strings not equal -- indicate edit has changed */ |
| 1804 | selected = -1; |
| 1805 | } |
| 1806 | } |
| 1807 | |
| 1808 | cbeend.iNewSelection = selected; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1809 | cbeend.fChanged = TRUE; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1810 | cbeend.iWhy = CBENF_RETURN; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1811 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1812 | /* abort the change, restore previous */ |
| 1813 | TRACE("Notify requested abort of change\n"); |
| 1814 | COMBOEX_SetEditText (infoPtr, infoPtr->edit); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1815 | RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1816 | RDW_INVALIDATE); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1817 | return 0; |
| 1818 | } |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1819 | oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0); |
| 1820 | if (oldItem != -1) { |
| 1821 | /* if something is selected, then deselect it */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1822 | SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1823 | (WPARAM)-1, 0); |
| 1824 | } |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1825 | InvalidateRect (infoPtr->hwndCombo, 0, 0); |
| 1826 | SetFocus(infoPtr->hwndEdit); |
| 1827 | break; |
| 1828 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1829 | case VK_UP: |
| 1830 | step = -1; |
| 1831 | case VK_DOWN: |
| 1832 | /* by default, step is 1 */ |
| 1833 | oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0); |
| 1834 | if (oldItem >= 0 && oldItem + step >= 0) |
| 1835 | SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0); |
| 1836 | return 0; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1837 | default: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1838 | return CallWindowProcW (infoPtr->prevEditWndProc, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1839 | hwnd, uMsg, wParam, lParam); |
| 1840 | } |
| 1841 | return 0; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1842 | } |
| 1843 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1844 | case WM_SETFOCUS: |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1845 | /* remember the focus to set state of icon */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1846 | lret = CallWindowProcW (infoPtr->prevEditWndProc, |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1847 | hwnd, uMsg, wParam, lParam); |
| 1848 | infoPtr->flags |= WCBE_EDITFOCUSED; |
| 1849 | return lret; |
| 1850 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1851 | case WM_KILLFOCUS: |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1852 | /* |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1853 | * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1854 | */ |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1855 | infoPtr->flags &= ~WCBE_EDITFOCUSED; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1856 | if (infoPtr->flags & WCBE_ACTEDIT) { |
| 1857 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1858 | |
| 1859 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1860 | cbeend.fChanged = FALSE; |
| 1861 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, |
| 1862 | CB_GETCURSEL, 0, 0); |
| 1863 | cbeend.iWhy = CBENF_KILLFOCUS; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1864 | |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1865 | COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1866 | } |
| 1867 | /* fall through */ |
| 1868 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1869 | default: |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1870 | return CallWindowProcW (infoPtr->prevEditWndProc, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1871 | hwnd, uMsg, wParam, lParam); |
| 1872 | } |
| 1873 | return 0; |
| 1874 | } |
| 1875 | |
| 1876 | |
| 1877 | static LRESULT WINAPI |
| 1878 | COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 1879 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1880 | HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); |
| 1881 | COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1882 | NMCBEENDEDITW cbeend; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1883 | NMMOUSE nmmse; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1884 | COLORREF obkc; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1885 | HDC hDC; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1886 | HWND focusedhwnd; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1887 | RECT rect; |
Dimitrie O. Paun | 69c9c43 | 2002-08-28 22:21:46 +0000 | [diff] [blame] | 1888 | POINT pt; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1889 | WCHAR edit_text[260]; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1890 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 1891 | TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1892 | hwnd, uMsg, wParam, lParam, infoPtr); |
| 1893 | |
| 1894 | if (!infoPtr) return 0; |
| 1895 | |
| 1896 | switch (uMsg) |
| 1897 | { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1898 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1899 | case WM_DRAWITEM: |
| 1900 | /* |
| 1901 | * The only way this message should come is from the |
| 1902 | * child Listbox issuing the message. Flag this so |
| 1903 | * that ComboEx knows this is listbox. |
| 1904 | */ |
| 1905 | ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1906 | return CallWindowProcW (infoPtr->prevComboWndProc, |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1907 | hwnd, uMsg, wParam, lParam); |
| 1908 | |
| 1909 | case WM_ERASEBKGND: |
| 1910 | /* |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1911 | * The following was determined by traces of the native |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1912 | */ |
| 1913 | hDC = (HDC) wParam; |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 1914 | obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW)); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1915 | GetClientRect (hwnd, &rect); |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 1916 | TRACE("erasing (%ld,%ld)-(%ld,%ld)\n", |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1917 | rect.left, rect.top, rect.right, rect.bottom); |
| 1918 | ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); |
| 1919 | SetBkColor (hDC, obkc); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1920 | return CallWindowProcW (infoPtr->prevComboWndProc, |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1921 | hwnd, uMsg, wParam, lParam); |
| 1922 | |
| 1923 | case WM_SETCURSOR: |
| 1924 | /* |
| 1925 | * WM_NOTIFY to comboex parent (rebar) |
| 1926 | * with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001 |
| 1927 | * CallWindowProc (previous) |
| 1928 | */ |
| 1929 | nmmse.dwItemSpec = 0; |
| 1930 | nmmse.dwItemData = 0; |
| 1931 | nmmse.pt.x = 0; |
| 1932 | nmmse.pt.y = 0; |
| 1933 | nmmse.dwHitInfo = lParam; |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1934 | COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1935 | return CallWindowProcW (infoPtr->prevComboWndProc, |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 1936 | hwnd, uMsg, wParam, lParam); |
| 1937 | |
Dimitrie O. Paun | 69c9c43 | 2002-08-28 22:21:46 +0000 | [diff] [blame] | 1938 | case WM_LBUTTONDOWN: |
| 1939 | GetClientRect (hwnd, &rect); |
| 1940 | rect.bottom = rect.top + SendMessageW(infoPtr->hwndSelf, |
| 1941 | CB_GETITEMHEIGHT, -1, 0); |
| 1942 | rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL); |
Dimitrie O. Paun | 856a91b | 2002-09-09 19:21:30 +0000 | [diff] [blame] | 1943 | POINTSTOPOINT(pt, MAKEPOINTS(lParam)); |
Dimitrie O. Paun | 69c9c43 | 2002-08-28 22:21:46 +0000 | [diff] [blame] | 1944 | if (PtInRect(&rect, pt)) |
| 1945 | return CallWindowProcW (infoPtr->prevComboWndProc, |
| 1946 | hwnd, uMsg, wParam, lParam); |
| 1947 | infoPtr->flags |= WCBE_MOUSECAPTURED; |
| 1948 | SetCapture(hwnd); |
| 1949 | break; |
| 1950 | |
| 1951 | case WM_LBUTTONUP: |
| 1952 | if (!(infoPtr->flags & WCBE_MOUSECAPTURED)) |
| 1953 | return CallWindowProcW (infoPtr->prevComboWndProc, |
| 1954 | hwnd, uMsg, wParam, lParam); |
| 1955 | ReleaseCapture(); |
| 1956 | infoPtr->flags &= ~WCBE_MOUSECAPTURED; |
| 1957 | if (infoPtr->flags & WCBE_MOUSEDRAGGED) { |
| 1958 | infoPtr->flags &= ~WCBE_MOUSEDRAGGED; |
| 1959 | } else { |
| 1960 | SendMessageW(hwnd, CB_SHOWDROPDOWN, TRUE, 0); |
| 1961 | } |
| 1962 | break; |
| 1963 | |
| 1964 | case WM_MOUSEMOVE: |
| 1965 | if ( (infoPtr->flags & WCBE_MOUSECAPTURED) && |
| 1966 | !(infoPtr->flags & WCBE_MOUSEDRAGGED)) { |
| 1967 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); |
| 1968 | COMBOEX_NotifyDragBegin(infoPtr, edit_text); |
| 1969 | infoPtr->flags |= WCBE_MOUSEDRAGGED; |
| 1970 | } |
| 1971 | return CallWindowProcW (infoPtr->prevComboWndProc, |
| 1972 | hwnd, uMsg, wParam, lParam); |
| 1973 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1974 | case WM_COMMAND: |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1975 | switch (HIWORD(wParam)) { |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 1976 | |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1977 | case EN_UPDATE: |
| 1978 | /* traces show that COMBOEX does not issue CBN_EDITUPDATE |
| 1979 | * on the EN_UPDATE |
| 1980 | */ |
| 1981 | return 0; |
| 1982 | |
| 1983 | case EN_KILLFOCUS: |
| 1984 | /* |
| 1985 | * Native does: |
| 1986 | * |
| 1987 | * GetFocus() retns AA |
| 1988 | * GetWindowTextA(Edit) |
| 1989 | * CB_GETCURSEL(Combo) (got -1) |
| 1990 | * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS |
| 1991 | * CB_GETCURSEL(Combo) (got -1) |
| 1992 | * InvalidateRect(Combo, 0, 0) |
| 1993 | * WM_KILLFOCUS(Combo, AA) |
| 1994 | * return 0; |
| 1995 | */ |
| 1996 | focusedhwnd = GetFocus(); |
| 1997 | if (infoPtr->flags & WCBE_ACTEDIT) { |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 1998 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 1999 | cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG); |
| 2000 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, |
| 2001 | CB_GETCURSEL, 0, 0); |
| 2002 | cbeend.iWhy = CBENF_KILLFOCUS; |
| 2003 | |
| 2004 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 2005 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 2006 | } |
| 2007 | /* possible CB_GETCURSEL */ |
| 2008 | InvalidateRect (infoPtr->hwndCombo, 0, 0); |
| 2009 | if (focusedhwnd) |
| 2010 | SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2011 | (WPARAM)focusedhwnd, 0); |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 2012 | return 0; |
| 2013 | |
| 2014 | case EN_SETFOCUS: { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2015 | /* |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2016 | * For EN_SETFOCUS this issues the same calls and messages |
| 2017 | * as the native seems to do. |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2018 | * |
| 2019 | * for some cases however native does the following: |
| 2020 | * (noticed after SetFocus during LBUTTONDOWN on |
| 2021 | * on dropdown arrow) |
| 2022 | * WM_GETTEXTLENGTH (Edit); |
| 2023 | * WM_GETTEXT (Edit, len+1, str); |
| 2024 | * EM_SETSEL (Edit, 0, 0); |
| 2025 | * WM_GETTEXTLENGTH (Edit); |
| 2026 | * WM_GETTEXT (Edit, len+1, str); |
| 2027 | * EM_SETSEL (Edit, 0, len); |
| 2028 | * WM_NOTIFY (parent, CBEN_BEGINEDIT) |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2029 | */ |
| 2030 | NMHDR hdr; |
| 2031 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2032 | SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0); |
| 2033 | SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 2034 | COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2035 | infoPtr->flags |= WCBE_ACTEDIT; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2036 | infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */ |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2037 | return 0; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 2038 | } |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2039 | |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 2040 | case EN_CHANGE: { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2041 | /* |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2042 | * For EN_CHANGE this issues the same calls and messages |
| 2043 | * as the native seems to do. |
| 2044 | */ |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2045 | WCHAR edit_text[260]; |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 2046 | LPCWSTR lastwrk; |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 2047 | cmp_func_t cmptext = get_cmp_func(infoPtr); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2048 | |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 2049 | INT selected = SendMessageW (infoPtr->hwndCombo, |
| 2050 | CB_GETCURSEL, 0, 0); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2051 | |
| 2052 | /* lstrlenA( lastworkingURL ) */ |
| 2053 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2054 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); |
| 2055 | if (selected == -1) { |
| 2056 | lastwrk = infoPtr->edit->pszText; |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2057 | } |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2058 | else { |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 2059 | CBE_ITEMDATA *item = COMBOEX_FindItem (infoPtr, selected); |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 2060 | lastwrk = COMBOEX_GetText(infoPtr, item); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2061 | } |
| 2062 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2063 | TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n", |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2064 | selected, debugstr_w(lastwrk)); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2065 | TRACE("handling EN_CHANGE, edittext=%s\n", |
| 2066 | debugstr_w(edit_text)); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2067 | |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 2068 | /* cmptext is between lastworkingURL and GetWindowText */ |
| 2069 | if (cmptext (lastwrk, edit_text)) { |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2070 | /* strings not equal -- indicate edit has changed */ |
| 2071 | infoPtr->flags |= WCBE_EDITCHG; |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2072 | } |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 2073 | SendMessageW ( infoPtr->hwndNotify, WM_COMMAND, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2074 | MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf), |
| 2075 | CBN_EDITCHANGE), |
Michael Stefaniuc | 025c0b7 | 2002-09-06 19:41:17 +0000 | [diff] [blame] | 2076 | (LPARAM)infoPtr->hwndSelf); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2077 | return 0; |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 2078 | } |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2079 | |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 2080 | case LBN_SELCHANGE: |
| 2081 | /* |
| 2082 | * Therefore from traces there is no additional code here |
| 2083 | */ |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2084 | |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 2085 | /* |
| 2086 | * Using native COMCTL32 gets the following: |
| 2087 | * 1 == SHDOCVW.DLL issues call/message |
| 2088 | * 2 == COMCTL32.DLL issues call/message |
| 2089 | * 3 == WINE issues call/message |
| 2090 | * |
| 2091 | * |
| 2092 | * for LBN_SELCHANGE: |
| 2093 | * 1 CB_GETCURSEL(ComboEx) |
| 2094 | * 1 CB_GETDROPPEDSTATE(ComboEx) |
| 2095 | * 1 CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE) |
| 2096 | * 2 CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE) |
| 2097 | ** call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE) |
| 2098 | * 3 WM_COMMAND(ComboEx, CBN_SELENDOK) |
| 2099 | * WM_USER+49(ComboLB, 1,0) <=============!!!!!!!!!!! |
| 2100 | * 3 ShowWindow(ComboLB, SW_HIDE) |
| 2101 | * 3 RedrawWindow(Combo, RDW_UPDATENOW) |
| 2102 | * 3 WM_COMMAND(ComboEX, CBN_CLOSEUP) |
| 2103 | ** end of CBRollUp |
| 2104 | * 3 WM_COMMAND(ComboEx, CBN_SELCHANGE) (echo to parent) |
| 2105 | * ? LB_GETCURSEL <==| |
| 2106 | * ? LB_GETTEXTLEN | |
| 2107 | * ? LB_GETTEXT | Needs to be added to |
| 2108 | * ? WM_CTLCOLOREDIT(ComboEx) | Combo processing |
| 2109 | * ? LB_GETITEMDATA | |
| 2110 | * ? WM_DRAWITEM(ComboEx) <==| |
| 2111 | */ |
| 2112 | default: |
| 2113 | break; |
| 2114 | }/* fall through */ |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2115 | default: |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2116 | return CallWindowProcW (infoPtr->prevComboWndProc, |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2117 | hwnd, uMsg, wParam, lParam); |
| 2118 | } |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2119 | return 0; |
| 2120 | } |
| 2121 | |
| 2122 | |
Patrik Stridvall | 26ffb3c | 1999-07-31 14:41:43 +0000 | [diff] [blame] | 2123 | static LRESULT WINAPI |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2124 | COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2125 | { |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 2126 | COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); |
| 2127 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 2128 | TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 2129 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2130 | if (!infoPtr) { |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 2131 | if (uMsg == WM_CREATE) |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2132 | return COMBOEX_Create (hwnd, (LPCREATESTRUCTA)lParam); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 2133 | if (uMsg == WM_NCCREATE) |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2134 | COMBOEX_NCCreate (hwnd); |
| 2135 | return DefWindowProcW (hwnd, uMsg, wParam, lParam); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 2136 | } |
Gerard Patel | a1b2fc2 | 2000-05-10 01:34:53 +0000 | [diff] [blame] | 2137 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2138 | switch (uMsg) |
| 2139 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2140 | case CBEM_DELETEITEM: |
| 2141 | return COMBOEX_DeleteItem (infoPtr, wParam); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2142 | |
| 2143 | case CBEM_GETCOMBOCONTROL: |
Michael Stefaniuc | 025c0b7 | 2002-09-06 19:41:17 +0000 | [diff] [blame] | 2144 | return (LRESULT)infoPtr->hwndCombo; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2145 | |
| 2146 | case CBEM_GETEDITCONTROL: |
Michael Stefaniuc | 025c0b7 | 2002-09-06 19:41:17 +0000 | [diff] [blame] | 2147 | return (LRESULT)infoPtr->hwndEdit; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2148 | |
| 2149 | case CBEM_GETEXTENDEDSTYLE: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2150 | return infoPtr->dwExtStyle; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2151 | |
| 2152 | case CBEM_GETIMAGELIST: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2153 | return (LRESULT)infoPtr->himl; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2154 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2155 | case CBEM_GETITEMA: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2156 | return (LRESULT)COMBOEX_GetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2157 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2158 | case CBEM_GETITEMW: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2159 | return (LRESULT)COMBOEX_GetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2160 | |
Andreas Mohr | 7a6228d | 1998-12-11 09:16:48 +0000 | [diff] [blame] | 2161 | case CBEM_GETUNICODEFORMAT: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2162 | return infoPtr->unicode; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2163 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2164 | case CBEM_HASEDITCHANGED: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2165 | return COMBOEX_HasEditChanged (infoPtr); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2166 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2167 | case CBEM_INSERTITEMA: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2168 | return COMBOEX_InsertItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2169 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2170 | case CBEM_INSERTITEMW: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2171 | return COMBOEX_InsertItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2172 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2173 | case CBEM_SETEXSTYLE: |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2174 | case CBEM_SETEXTENDEDSTYLE: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2175 | return COMBOEX_SetExtendedStyle (infoPtr, (DWORD)wParam, (DWORD)lParam); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2176 | |
| 2177 | case CBEM_SETIMAGELIST: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2178 | return (LRESULT)COMBOEX_SetImageList (infoPtr, (HIMAGELIST)lParam); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2179 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2180 | case CBEM_SETITEMA: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2181 | return COMBOEX_SetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 2182 | |
Marcus Meissner | 643fcff | 2000-11-06 20:22:06 +0000 | [diff] [blame] | 2183 | case CBEM_SETITEMW: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2184 | return COMBOEX_SetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); |
Marcus Meissner | 643fcff | 2000-11-06 20:22:06 +0000 | [diff] [blame] | 2185 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2186 | case CBEM_SETUNICODEFORMAT: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2187 | return COMBOEX_SetUnicodeFormat (infoPtr, wParam); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2188 | |
Dimitrie O. Paun | 43230a2 | 2002-04-08 20:16:01 +0000 | [diff] [blame] | 2189 | /*case CBEM_SETWINDOWTHEME: |
| 2190 | FIXME("CBEM_SETWINDOWTHEME: stub\n");*/ |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2191 | |
Dmitry Timoshkov | 2f2e4fa | 2002-08-13 18:07:02 +0000 | [diff] [blame] | 2192 | case WM_SETTEXT: |
| 2193 | case WM_GETTEXT: |
| 2194 | return SendMessageW(infoPtr->hwndEdit, uMsg, wParam, lParam); |
| 2195 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2196 | /* Combo messages we are not sure if we need to process or just forward */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2197 | case CB_GETDROPPEDCONTROLRECT: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2198 | case CB_GETITEMHEIGHT: |
| 2199 | case CB_GETLBTEXT: |
| 2200 | case CB_GETLBTEXTLEN: |
| 2201 | case CB_GETEXTENDEDUI: |
| 2202 | case CB_LIMITTEXT: |
| 2203 | case CB_RESETCONTENT: |
| 2204 | case CB_SELECTSTRING: |
Eric Kohl | 66ef011 | 1998-11-22 17:58:40 +0000 | [diff] [blame] | 2205 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2206 | /* Combo messages OK to just forward to the regular COMBO */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2207 | case CB_GETCOUNT: |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2208 | case CB_GETCURSEL: |
Guy L. Albertelli | a7a006a | 2001-03-16 16:41:56 +0000 | [diff] [blame] | 2209 | case CB_GETDROPPEDSTATE: |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2210 | case CB_SETDROPPEDWIDTH: |
| 2211 | case CB_SETEXTENDEDUI: |
| 2212 | case CB_SHOWDROPDOWN: |
Dimitrie O. Paun | d5d431f | 2002-04-11 17:33:47 +0000 | [diff] [blame] | 2213 | return SendMessageW (infoPtr->hwndCombo, uMsg, wParam, lParam); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2214 | |
| 2215 | /* Combo messages we need to process specially */ |
| 2216 | case CB_FINDSTRINGEXACT: |
Dimitrie O. Paun | 9ff6e77 | 2002-08-26 21:46:25 +0000 | [diff] [blame] | 2217 | return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCWSTR)lParam); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2218 | |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 2219 | case CB_GETITEMDATA: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2220 | return COMBOEX_GetItemData (infoPtr, (INT)wParam); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 2221 | |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2222 | case CB_SETCURSEL: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2223 | return COMBOEX_SetCursel (infoPtr, (INT)wParam); |
Guy L. Albertelli | a249595 | 2001-01-26 21:00:10 +0000 | [diff] [blame] | 2224 | |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 2225 | case CB_SETITEMDATA: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2226 | return COMBOEX_SetItemData (infoPtr, (INT)wParam, (DWORD)lParam); |
Guy L. Albertelli | bad7590 | 2001-04-20 18:27:19 +0000 | [diff] [blame] | 2227 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2228 | case CB_SETITEMHEIGHT: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2229 | return COMBOEX_SetItemHeight (infoPtr, (INT)wParam, (UINT)lParam); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2230 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2231 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2232 | |
| 2233 | /* Window messages passed to parent */ |
Guy L. Albertelli | 762ed03 | 2000-12-18 03:12:31 +0000 | [diff] [blame] | 2234 | case WM_COMMAND: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2235 | return COMBOEX_Command (infoPtr, wParam, lParam); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2236 | |
Guy L. Albertelli | 762ed03 | 2000-12-18 03:12:31 +0000 | [diff] [blame] | 2237 | case WM_NOTIFY: |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 2238 | if (infoPtr->NtfUnicode) |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 2239 | return SendMessageW (infoPtr->hwndNotify, uMsg, wParam, lParam); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 2240 | else |
Dimitrie O. Paun | c594043 | 2003-11-20 22:04:13 +0000 | [diff] [blame] | 2241 | return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam); |
Guy L. Albertelli | 762ed03 | 2000-12-18 03:12:31 +0000 | [diff] [blame] | 2242 | |
| 2243 | |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2244 | /* Window messages we need to process */ |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2245 | case WM_DELETEITEM: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2246 | return COMBOEX_WM_DeleteItem (infoPtr, (DELETEITEMSTRUCT *)lParam); |
Guy L. Albertelli | 45e6f62 | 2001-02-20 01:53:43 +0000 | [diff] [blame] | 2247 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2248 | case WM_DRAWITEM: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2249 | return COMBOEX_DrawItem (infoPtr, (DRAWITEMSTRUCT *)lParam); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2250 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2251 | case WM_DESTROY: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2252 | return COMBOEX_Destroy (infoPtr); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2253 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2254 | case WM_MEASUREITEM: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2255 | return COMBOEX_MeasureItem (infoPtr, (MEASUREITEMSTRUCT *)lParam); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2256 | |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 2257 | case WM_NOTIFYFORMAT: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2258 | return COMBOEX_NotifyFormat (infoPtr, lParam); |
Guy L. Albertelli | b2207c7 | 2001-06-24 00:22:20 +0000 | [diff] [blame] | 2259 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2260 | case WM_SIZE: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2261 | return COMBOEX_Size (infoPtr, LOWORD(lParam), HIWORD(lParam)); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2262 | |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2263 | case WM_WINDOWPOSCHANGING: |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2264 | return COMBOEX_WindowPosChanging (infoPtr, (WINDOWPOS *)lParam); |
Guy L. Albertelli | c6c53cd | 2000-10-29 01:16:53 +0000 | [diff] [blame] | 2265 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2266 | default: |
Guy L. Albertelli | 23739a3 | 2002-07-16 01:23:59 +0000 | [diff] [blame] | 2267 | if ((uMsg >= WM_USER) && (uMsg < WM_APP)) |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2268 | ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam); |
| 2269 | return DefWindowProcW (hwnd, uMsg, wParam, lParam); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2270 | } |
| 2271 | return 0; |
| 2272 | } |
| 2273 | |
| 2274 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2275 | void COMBOEX_Register (void) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2276 | { |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2277 | WNDCLASSW wndClass; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2278 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2279 | ZeroMemory (&wndClass, sizeof(WNDCLASSW)); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2280 | wndClass.style = CS_GLOBALCLASS; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2281 | wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc; |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2282 | wndClass.cbClsExtra = 0; |
| 2283 | wndClass.cbWndExtra = sizeof(COMBOEX_INFO *); |
Alexandre Julliard | cf52644 | 2003-09-10 03:56:47 +0000 | [diff] [blame] | 2284 | wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2285 | wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2286 | wndClass.lpszClassName = WC_COMBOBOXEXW; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2287 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2288 | RegisterClassW (&wndClass); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2289 | } |
| 2290 | |
Eric Kohl | 9d8e864 | 1998-10-24 10:49:27 +0000 | [diff] [blame] | 2291 | |
Dimitrie O. Paun | 7c3fca1 | 2002-04-05 21:16:19 +0000 | [diff] [blame] | 2292 | void COMBOEX_Unregister (void) |
Eric Kohl | 9d8e864 | 1998-10-24 10:49:27 +0000 | [diff] [blame] | 2293 | { |
Francois Gouget | d2667a4 | 2002-12-02 18:10:57 +0000 | [diff] [blame] | 2294 | UnregisterClassW (WC_COMBOBOXEXW, NULL); |
Eric Kohl | 9d8e864 | 1998-10-24 10:49:27 +0000 | [diff] [blame] | 2295 | } |