Changeset 5630 for trunk/src/comctl32/comboex.c
- Timestamp:
- Apr 29, 2001, 12:30:59 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/comboex.c
r5416 r5630 19 19 20 20 /* 21 * ComboBoxEx control v2 (mod 4)21 * ComboBoxEx control v2 (mod5) 22 22 * 23 23 * Copyright 1998, 1999 Eric Kohl … … 59 59 * 5. The LBN_SELCHANGE is just for documentation purposes. 60 60 * 61 * mod 5 62 * 1. Add support for CB_GETITEMDATA to a Comboex. Returns the LPARAM 63 * passed during insert of item. 64 * 2. Remember selected item and don't issue CB_SETCURSEL unless needed. 65 * 3. Add initial support for WM_NCCREATE to remove unwanted window styles 66 * (Currently just WS_VSCROLL and WS_HSCROLL, but probably should be 67 * more.) 68 * 4. Improve some traces. 69 * 5. Add support for CB_SETITEMDATA sets LPARAM value from item. 70 * 61 71 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe), 62 * and IE 4.0.72 * WinRAR, and IE 4.0. 63 73 * 64 74 */ … … 69 79 #include "debugtools.h" 70 80 #include "wine/unicode.h" 71 72 81 #ifdef __WIN32OS2__ 73 82 #include "ccbase.h" … … 109 118 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */ 110 119 DWORD dwExtStyle; 120 INT selected; /* index of selected item */ 111 121 DWORD flags; /* WINE internal flags */ 112 122 HFONT font; … … 882 892 883 893 static LRESULT 894 COMBOEX_GetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam) 895 { 896 INT index = wParam; 897 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 898 CBE_ITEMDATA *item1, *item2; 899 LRESULT lret = 0; 900 901 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 902 wParam, lParam); 903 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { 904 item2 = COMBOEX_FindItem (infoPtr, index); 905 if (item2 != item1) { 906 ERR("data structures damaged!\n"); 907 return CB_ERR; 908 } 909 if (item1->mask & CBEIF_LPARAM) 910 lret = (LRESULT) item1->lParam; 911 TRACE("returning 0x%08lx\n", lret); 912 return lret; 913 } 914 lret = (LRESULT)item1; 915 TRACE("non-valid result from combo, returning 0x%08lx\n", lret); 916 return lret; 917 } 918 919 920 static LRESULT 884 921 COMBOEX_SetCursel (HWND hwnd, WPARAM wParam, LPARAM lParam) 885 922 { … … 896 933 TRACE("selecting item %d text=%s\n", index, (item->pszText) ? 897 934 debugstr_w(item->pszText) : "<null>"); 935 infoPtr->selected = index; 898 936 899 937 lret = SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, wParam, lParam); 900 938 COMBOEX_SetEditText (infoPtr, item); 901 939 return lret; 940 } 941 942 943 static LRESULT 944 COMBOEX_SetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam) 945 { 946 INT index = wParam; 947 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 948 CBE_ITEMDATA *item1, *item2; 949 950 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 951 wParam, lParam); 952 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { 953 item2 = COMBOEX_FindItem (infoPtr, index); 954 if (item2 != item1) { 955 ERR("data structures damaged!\n"); 956 return CB_ERR; 957 } 958 item1->mask |= CBEIF_LPARAM; 959 item1->lParam = lParam; 960 TRACE("setting lparam to 0x%08lx\n", lParam); 961 return 0; 962 } 963 TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1); 964 return (LRESULT)item1; 902 965 } 903 966 … … 968 1031 infoPtr->nb_items = 0; 969 1032 infoPtr->hwndSelf = hwnd; 1033 infoPtr->selected = -1; 970 1034 971 1035 SetWindowLongA (hwnd, 0, (DWORD)infoPtr); … … 975 1039 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD); 976 1040 977 TRACE("combo style=%08lx, additional style=%08lx\n", dwComboStyle, 1041 GetWindowRect(hwnd, &wnrc1); 1042 GetClientRect(hwnd, &clrc1); 1043 TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n", 1044 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom, 1045 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom); 1046 TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle, 978 1047 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | 979 1048 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | … … 1077 1146 GetClientRect(hwnd, &clrc1); 1078 1147 GetWindowRect(infoPtr->hwndCombo, &cmbwrc); 1079 TRACE("E x wnd=(%d,%d)-(%d,%d) Ex clt=(%d,%d)-(%d,%d) Cbwnd=(%d,%d)-(%d,%d)\n",1148 TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) CB wnd=(%d,%d)-(%d,%d)\n", 1080 1149 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom, 1081 1150 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom, … … 1086 1155 1087 1156 GetWindowRect(infoPtr->hwndCombo, &cmbwrc); 1088 TRACE(" Ex wnd=(%d,%d)-(%d,%d)\n",1157 TRACE("CB window=(%d,%d)-(%d,%d)\n", 1089 1158 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom); 1090 1159 SetWindowPos(hwnd, HWND_TOP, … … 1118 1187 INT cursel, n, oldItem; 1119 1188 NMCBEENDEDITA cbeend; 1189 DWORD oldflags; 1120 1190 1121 1191 TRACE("for command %d\n", command); … … 1171 1241 } 1172 1242 } 1173 if (infoPtr->flags & WCBE_ACTEDIT) { 1243 1244 /* Save flags for testing and reset them */ 1245 oldflags = infoPtr->flags; 1246 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); 1247 1248 if (oldflags & WCBE_ACTEDIT) { 1174 1249 WideCharToMultiByte (CP_ACP, 0, item->pszText, -1, 1175 1250 cbeend.szText, sizeof(cbeend.szText), 1176 1251 NULL, NULL); 1177 cbeend.fChanged = ( infoPtr->flags & WCBE_EDITCHG);1252 cbeend.fChanged = (oldflags & WCBE_EDITCHG); 1178 1253 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, 1179 1254 CB_GETCURSEL, 0, 0); 1180 1255 cbeend.iWhy = CBENF_DROPDOWN; 1181 1256 1182 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);1183 1257 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA, 1184 1258 (NMHDR *)&cbeend, FALSE)) { … … 1188 1262 } 1189 1263 } 1190 SendMessageW (hwnd, CB_SETCURSEL, cursel, 0); 1191 SetFocus(infoPtr->hwndCombo); 1264 1265 /* if selection has changed the set the new current selection */ 1266 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); 1267 if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) { 1268 infoPtr->selected = cursel; 1269 SendMessageW (hwnd, CB_SETCURSEL, cursel, 0); 1270 SetFocus(infoPtr->hwndCombo); 1271 } 1192 1272 return 0; 1193 1273 … … 1210 1290 ERR("item %d not found. Problem!\n", oldItem); 1211 1291 break; 1212 } 1292 } 1293 infoPtr->selected = oldItem; 1213 1294 COMBOEX_SetEditText (infoPtr, item); 1214 1295 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, … … 1619 1700 1620 1701 static LRESULT 1702 COMBOEX_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) 1703 { 1704 /* WARNING: The COMBOEX_INFO structure is not yet created */ 1705 DWORD oldstyle, newstyle; 1706 1707 oldstyle = (DWORD)GetWindowLongA (hwnd, GWL_STYLE); 1708 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL); 1709 if (newstyle != oldstyle) { 1710 TRACE("req style %08lx, reseting style %08lx\n", 1711 oldstyle, newstyle); 1712 SetWindowLongA (hwnd, GWL_STYLE, newstyle); 1713 } 1714 return 1; 1715 } 1716 1717 1718 static LRESULT 1621 1719 COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) 1622 1720 { … … 1656 1754 - (cbx_crect.right-cbx_crect.left); 1657 1755 1756 TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n", 1757 wp->x, wp->y, wp->cx, wp->cy, wp->flags); 1658 1758 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n", 1659 1759 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom, … … 1771 1871 break; 1772 1872 } 1773 1873 infoPtr->selected = oldItem; 1774 1874 COMBOEX_SetEditText (infoPtr, item); 1775 1875 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | … … 2110 2210 { 2111 2211 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam); 2112 if (!COMBOEX_GetInfoPtr (hwnd) && (uMsg != WM_CREATE)) 2212 2213 if (!COMBOEX_GetInfoPtr (hwnd)) { 2214 if (uMsg == WM_CREATE) 2215 return COMBOEX_Create (hwnd, wParam, lParam); 2216 if (uMsg == WM_NCCREATE) 2217 COMBOEX_NCCreate (hwnd, wParam, lParam); 2113 2218 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 2219 } 2114 2220 2115 2221 switch (uMsg) … … 2167 2273 /* Combo messages we are not sure if we need to process or just forward */ 2168 2274 case CB_GETDROPPEDCONTROLRECT: 2169 case CB_GETITEMDATA:2170 2275 case CB_GETITEMHEIGHT: 2171 2276 case CB_GETLBTEXT: … … 2175 2280 case CB_RESETCONTENT: 2176 2281 case CB_SELECTSTRING: 2177 case CB_SETITEMDATA:2178 2282 case WM_SETTEXT: 2179 2283 case WM_GETTEXT: 2180 FIXME("(0x%x 0x%x 0x%lx): possibl e missing fucntion\n",2284 FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n", 2181 2285 uMsg, wParam, lParam); 2182 2286 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam); … … 2196 2300 wParam, lParam); 2197 2301 2302 case CB_GETITEMDATA: 2303 return COMBOEX_GetItemData (hwnd, wParam, lParam); 2304 2198 2305 case CB_SETCURSEL: 2199 2306 return COMBOEX_SetCursel (hwnd, wParam, lParam); 2307 2308 case CB_SETITEMDATA: 2309 return COMBOEX_SetItemData (hwnd, wParam, lParam); 2200 2310 2201 2311 case CB_SETITEMHEIGHT: … … 2213 2323 2214 2324 /* Window messages we need to process */ 2215 case WM_CREATE:2216 return COMBOEX_Create (hwnd, wParam, lParam);2217 2218 2325 case WM_DELETEITEM: 2219 2326 return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam); … … 2241 2348 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); 2242 2349 #else 2243 2350 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 2244 2351 #endif 2245 2352 }
Note:
See TracChangeset
for help on using the changeset viewer.