Changeset 8382 for trunk/src/comctl32/listview.c
- Timestamp:
- May 8, 2002, 1:26:30 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/listview.c
r8096 r8382 5 5 * Copyright 1999 Luc Tourangeau 6 6 * Copyright 2000 Jason Mawdsley 7 * Copyright 2001 Codeweavers Inc. 8 * Copyright 2002 Dimitrie O. Paun 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 7 23 * 8 24 * NOTES 9 * Listview control implementation. 25 * Listview control implementation. 10 26 * 11 27 * TODO: … … 19 35 * Data structure: 20 36 * LISTVIEW_SetItemCount : not completed for non OWNERDATA 21 * 22 * Unicode: 23 * LISTVIEW_SetItemW : no unicode support 24 * LISTVIEW_InsertItemW : no unicode support 25 * LISTVIEW_InsertColumnW : no unicode support 26 * LISTVIEW_GetColumnW : no unicode support 27 * LISTVIEW_SetColumnW : no unicode support 28 * 37 * 29 38 * Advanced functionality: 30 39 * LISTVIEW_GetNumberOfWorkAreas : not implemented 31 40 * LISTVIEW_GetHotCursor : not implemented 32 * LISTVIEW_GetISearchString : not implemented 41 * LISTVIEW_GetISearchString : not implemented 33 42 * LISTVIEW_GetBkImage : not implemented 34 43 * LISTVIEW_SetBkImage : not implemented … … 37 46 * LISTVIEW_Arrange : empty stub 38 47 * LISTVIEW_ApproximateViewRect : incomplete 39 * LISTVIEW_Scroll : not implemented 48 * LISTVIEW_Scroll : not implemented 40 49 * LISTVIEW_Update : not completed 50 * 51 * Known differences in message stream from native control (not known if 52 * these differences cause problems): 53 * LVM_INSERTITEM issues LVM_SETITEMSTATE and LVM_SETITEM in certain cases. 54 * LVM_SETITEM does not always issue LVN_ITEMCHANGING/LVN_ITEMCHANGED. 55 * WM_PAINT does LVN_GETDISPINFO in item order 0->n, native does n->0. 56 * WM_SETREDRAW(True) native does LVN_GETDISPINFO for all items and 57 * does *not* invoke DefWindowProc 58 * WM_CREATE does not issue WM_QUERYUISTATE and associated registry 59 * processing for "USEDOUBLECLICKTIME". 41 60 */ 42 61 … … 44 63 #include <string.h> 45 64 #include <stdlib.h> 65 #include <stdio.h> 46 66 47 67 #include "winbase.h" 68 #include "winnt.h" 48 69 #include "heap.h" 49 70 #include "commctrl.h" 50 #include "debugtools.h" 71 #include "wine/debug.h" 72 73 WINE_DEFAULT_DEBUG_CHANNEL(listview); 51 74 52 75 #ifdef __WIN32OS2__ … … 55 78 #include "header.h" 56 79 57 #undef ListView_SetItemState58 #define ListView_SetItemState ListView_SetItemStateWine59 60 80 typedef struct 61 81 { … … 69 89 #endif 70 90 71 DEFAULT_DEBUG_CHANNEL(listview); 72 73 /* Some definitions for inline edit control */ 74 typedef BOOL (*EditlblCallback)(HWND, LPSTR, DWORD); 91 /* Some definitions for inline edit control */ 92 typedef BOOL (*EditlblCallbackW)(HWND, LPWSTR, DWORD); 93 typedef BOOL (*EditlblCallbackA)(HWND, LPWSTR, DWORD); 94 95 typedef struct tagLV_INTHIT 96 { 97 LVHITTESTINFO ht; 98 DWORD distance; /* distance to closest item */ 99 INT iDistItem; /* item number that is closest */ 100 } LV_INTHIT, *LPLV_INTHIT; 101 75 102 76 103 typedef struct tagEDITLABEL_ITEM 77 104 { 78 79 80 EditlblCallbackEditLblCb;105 WNDPROC EditWndProc; 106 DWORD param; 107 EditlblCallbackW EditLblCb; 81 108 } EDITLABEL_ITEM; 82 109 83 110 typedef struct tagLISTVIEW_SUBITEM 84 111 { 85 LPSTR pszText; 86 INT iImage; 87 INT iSubItem; 88 112 LPWSTR pszText; 113 INT iImage; 114 INT iSubItem; 89 115 } LISTVIEW_SUBITEM; 90 116 … … 92 118 { 93 119 UINT state; 94 LP STR pszText;120 LPWSTR pszText; 95 121 INT iImage; 96 122 LPARAM lParam; … … 123 149 DWORD internalFlags; 124 150 #endif 125 COLORREF clrBk; 126 COLORREF clrText; 127 COLORREF clrTextBk; 128 HIMAGELIST himlNormal; 129 HIMAGELIST himlSmall; 130 HIMAGELIST himlState; 131 BOOL bLButtonDown; 132 BOOL bRButtonDown; 133 INT nFocusedItem; 134 HDPA hdpaSelectionRanges; 135 INT nItemHeight; 136 INT nItemWidth; 137 INT nSelectionMark; 138 INT nHotItem; 139 SHORT notifyFormat; 140 RECT rcList; 141 RECT rcView; 142 SIZE iconSize; 143 SIZE iconSpacing; 144 UINT uCallbackMask; 145 HWND hwndHeader; 146 HFONT hDefaultFont; 147 HFONT hFont; 148 BOOL bFocus; 149 DWORD dwExStyle; /* extended listview style */ 150 HDPA hdpaItems; 151 PFNLVCOMPARE pfnCompare; 152 LPARAM lParamSort; 153 HWND hwndEdit; 154 INT nEditLabelItem; 155 EDITLABEL_ITEM *pedititem; 156 DWORD dwHoverTime; 157 INT nColumnCount; /* the number of columns in this control */ 158 159 DWORD lastKeyPressTimestamp; /* Added */ 160 WPARAM charCode; /* Added */ 161 INT nSearchParamLength; /* Added */ 162 CHAR szSearchParam[ MAX_PATH ]; /* Added */ 151 HWND hwndSelf; 152 COLORREF clrBk; 153 COLORREF clrText; 154 COLORREF clrTextBk; 155 HIMAGELIST himlNormal; 156 HIMAGELIST himlSmall; 157 HIMAGELIST himlState; 158 BOOL bLButtonDown; 159 BOOL bRButtonDown; 160 INT nFocusedItem; 161 HDPA hdpaSelectionRanges; 162 INT nItemHeight; 163 INT nItemWidth; 164 INT nSelectionMark; 165 INT nHotItem; 166 SHORT notifyFormat; 167 RECT rcList; 168 RECT rcView; 169 SIZE iconSize; 170 SIZE iconSpacing; 171 UINT uCallbackMask; 172 HWND hwndHeader; 173 HFONT hDefaultFont; 174 HFONT hFont; 175 INT ntmHeight; /* from GetTextMetrics from above font */ 176 INT ntmAveCharWidth; /* from GetTextMetrics from above font */ 177 BOOL bFocus; 178 DWORD dwExStyle; /* extended listview style */ 179 HDPA hdpaItems; 180 PFNLVCOMPARE pfnCompare; 181 LPARAM lParamSort; 182 HWND hwndEdit; 183 INT nEditLabelItem; 184 EDITLABEL_ITEM *pedititem; 185 DWORD dwHoverTime; 186 INT nColumnCount; /* the number of columns in this control */ 187 188 DWORD lastKeyPressTimestamp; /* Added */ 189 WPARAM charCode; /* Added */ 190 INT nSearchParamLength; /* Added */ 191 WCHAR szSearchParam[ MAX_PATH ]; /* Added */ 163 192 } LISTVIEW_INFO; 164 193 165 194 /* 166 * constants 195 * constants 167 196 */ 168 197 … … 179 208 #define REPORT_MARGINX 2 180 209 181 /* padding for icon in large icon display mode */ 182 #define ICON_TOP_PADDING 2 183 #define ICON_BOTTOM_PADDING 2 184 185 /* padding for label in large icon display mode */ 186 #define LABEL_VERT_OFFSET 2 210 /* padding for icon in large icon display mode 211 * ICON_TOP_PADDING_NOTHITABLE - space between top of box and area 212 * that HITTEST will see. 213 * ICON_TOP_PADDING_HITABLE - spacing between above and icon. 214 * ICON_TOP_PADDING - sum of the two above. 215 * ICON_BOTTOM_PADDING - between bottom of icon and top of text 216 * LABEL_VERT_OFFSET - between bottom of text and end of box 217 */ 218 #define ICON_TOP_PADDING_NOTHITABLE 2 219 #define ICON_TOP_PADDING_HITABLE 2 220 #define ICON_TOP_PADDING ICON_TOP_PADDING_NOTHITABLE + ICON_TOP_PADDING_HITABLE 221 #define ICON_BOTTOM_PADDING 4 222 #define LABEL_VERT_OFFSET 10 187 223 188 224 /* default label width for items in list and small icon display modes */ … … 190 226 191 227 /* default column width for items in list display mode */ 192 #define DEFAULT_COLUMN_WIDTH 96 228 #define DEFAULT_COLUMN_WIDTH 96 193 229 194 230 /* Increment size of the horizontal scroll bar */ … … 203 239 /* Border for the icon caption */ 204 240 #define CAPTION_BORDER 2 205 /* 241 /* 206 242 * macros 207 243 */ 208 #define ListView_LVNotify(hwnd,lCtrlId,plvnm) \209 (BOOL)SendMessageA((hwnd),WM_NOTIFY,(WPARAM)(INT)lCtrlId,(LPARAM)(LPNMLISTVIEW)(plvnm))210 #define ListView_Notify(hwnd,lCtrlId,pnmh) \211 (BOOL)SendMessageA((hwnd),WM_NOTIFY,(WPARAM)(INT)lCtrlId,(LPARAM)(LPNMHDR)(pnmh))212 244 /* retrieve the number of items in the listview */ 213 245 #define GETITEMCOUNT(infoPtr) ((infoPtr)->hdpaItems->nItemCount) 214 215 HWND CreateEditLabel(LPCSTR text, DWORD style, INT x, INT y, 216 INT width, INT height, HWND parent, HINSTANCE hinst, 217 EditlblCallback EditLblCb, DWORD param); 218 219 /* 220 * forward declarations 221 */ 222 static LRESULT LISTVIEW_GetItemA(HWND hwnd, LPLVITEMA lpLVItem, BOOL internal); 246 #define HDM_INSERTITEMT(isW) ( (isW) ? HDM_INSERTITEMW : HDM_INSERTITEMA ) 247 248 HWND CreateEditLabelT(LPCWSTR text, DWORD style, INT x, INT y, 249 INT width, INT height, HWND parent, HINSTANCE hinst, 250 EditlblCallbackW EditLblCb, DWORD param, BOOL isW); 251 252 /* 253 * forward declarations 254 */ 255 static LRESULT LISTVIEW_GetItemT(HWND hwnd, LPLVITEMW lpLVItem, BOOL internal, BOOL isW); 256 static INT LISTVIEW_SuperHitTestItem(HWND, LPLV_INTHIT, BOOL); 223 257 static INT LISTVIEW_HitTestItem(HWND, LPLVHITTESTINFO, BOOL); 224 258 static INT LISTVIEW_GetCountPerRow(HWND); … … 228 262 static VOID LISTVIEW_AddGroupSelection(HWND, INT); 229 263 static VOID LISTVIEW_AddSelection(HWND, INT); 230 static BOOL LISTVIEW_AddSubItem (HWND, LPLVITEMA);264 static BOOL LISTVIEW_AddSubItemT(HWND, LPLVITEMW, BOOL); 231 265 static INT LISTVIEW_FindInsertPosition(HDPA, INT); 232 266 static INT LISTVIEW_GetItemHeight(HWND); 267 static BOOL LISTVIEW_GetItemBoundBox(HWND, INT, LPRECT); 233 268 static BOOL LISTVIEW_GetItemPosition(HWND, INT, LPPOINT); 234 269 static LRESULT LISTVIEW_GetItemRect(HWND, INT, LPRECT); … … 239 274 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItem(HDPA, INT); 240 275 static LRESULT LISTVIEW_GetViewRect(HWND, LPRECT); 241 static BOOL LISTVIEW_InitItem (HWND, LISTVIEW_ITEM *, LPLVITEMA);242 static BOOL LISTVIEW_InitSubItem (HWND, LISTVIEW_SUBITEM *, LPLVITEMA);276 static BOOL LISTVIEW_InitItemT(HWND, LISTVIEW_ITEM *, LPLVITEMW, BOOL); 277 static BOOL LISTVIEW_InitSubItemT(HWND, LISTVIEW_SUBITEM *, LPLVITEMW, BOOL); 243 278 static LRESULT LISTVIEW_MouseSelection(HWND, POINT); 244 279 static BOOL LISTVIEW_RemoveColumn(HDPA, INT); 245 280 static BOOL LISTVIEW_RemoveSubItem(HDPA, INT); 246 281 static VOID LISTVIEW_SetGroupSelection(HWND, INT); 247 static BOOL LISTVIEW_SetItem (HWND, LPLVITEMA);282 static BOOL LISTVIEW_SetItemT(HWND, LPLVITEMW, BOOL); 248 283 static BOOL LISTVIEW_SetItemFocus(HWND, INT); 249 284 static BOOL LISTVIEW_SetItemPosition(HWND, INT, LONG, LONG); 250 285 static VOID LISTVIEW_UpdateScroll(HWND); 251 286 static VOID LISTVIEW_SetSelection(HWND, INT); 252 static VOIDLISTVIEW_UpdateSize(HWND);253 static BOOL LISTVIEW_SetSubItem (HWND, LPLVITEMA);287 static BOOL LISTVIEW_UpdateSize(HWND); 288 static BOOL LISTVIEW_SetSubItemT(HWND, LPLVITEMW, BOOL); 254 289 static LRESULT LISTVIEW_SetViewRect(HWND, LPRECT); 255 290 static BOOL LISTVIEW_ToggleSelection(HWND, INT); 256 291 static VOID LISTVIEW_UnsupportedStyles(LONG lStyle); 257 static HWND LISTVIEW_EditLabelA(HWND hwnd, INT nItem); 258 static BOOL LISTVIEW_EndEditLabel(HWND hwnd, LPSTR pszText, DWORD nItem); 292 static HWND LISTVIEW_EditLabelT(HWND hwnd, INT nItem, BOOL isW); 293 static BOOL LISTVIEW_EndEditLabelW(HWND hwnd, LPWSTR pszText, DWORD nItem); 294 static BOOL LISTVIEW_EndEditLabelA(HWND hwnd, LPSTR pszText, DWORD nItem); 259 295 static LRESULT LISTVIEW_Command(HWND hwnd, WPARAM wParam, LPARAM lParam); 260 static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam); 261 #ifdef __WIN32OS2__ 262 static LRESULT LISTVIEW_GetStringWidth(HWND hwnd,HDC hdc,LPWSTR lpszText,BOOL unicode); 263 #define LISTVIEW_GetStringWidthA(a,b) LISTVIEW_GetStringWidth(a,0,(LPWSTR)b,FALSE) 264 #else 265 static LRESULT LISTVIEW_GetStringWidthA(HWND hwnd, LPCSTR lpszText); 266 #endif 296 static LRESULT LISTVIEW_SortItems(HWND hwnd, PFNLVCOMPARE pfnCompare, LPARAM lParamSort); 297 static LRESULT LISTVIEW_GetStringWidthT(HWND hwnd, LPCWSTR lpszText, BOOL isW); 267 298 static INT LISTVIEW_ProcessLetterKeys( HWND hwnd, WPARAM charCode, LPARAM keyData ); 268 299 static BOOL LISTVIEW_KeySelection(HWND hwnd, INT nItem); 269 300 static LRESULT LISTVIEW_GetItemState(HWND hwnd, INT nItem, UINT uMask); 270 static LRESULT LISTVIEW_SetItemState(HWND hwnd, INT nItem, LPLVITEM AlpLVItem);301 static LRESULT LISTVIEW_SetItemState(HWND hwnd, INT nItem, LPLVITEMW lpLVItem); 271 302 static BOOL LISTVIEW_IsSelected(HWND hwnd, INT nItem); 272 303 static VOID LISTVIEW_RemoveSelectionRange(HWND hwnd, INT lItem, INT uItem); 273 304 static void LISTVIEW_FillBackground(HWND hwnd, HDC hdc, LPRECT rc); 305 static void ListView_UpdateLargeItemLabelRect (HWND hwnd, const LISTVIEW_INFO* infoPtr, int nItem, RECT *rect); 306 static LRESULT LISTVIEW_GetColumnT(HWND, INT, LPLVCOLUMNW, BOOL); 274 307 275 308 /******** Defines that LISTVIEW_ProcessLetterKeys uses ****************/ 276 309 #define KEY_DELAY 450 277 310 311 #define COUNTOF(array) (sizeof(array)/sizeof(array[0])) 312 313 static inline BOOL is_textW(LPCWSTR text) 314 { 315 return text != NULL && text != LPSTR_TEXTCALLBACKW; 316 } 317 318 static inline BOOL is_textT(LPCWSTR text, BOOL isW) 319 { 320 /* we can ignore isW since LPSTR_TEXTCALLBACKW == LPSTR_TEXTCALLBACKA */ 321 return is_textW(text); 322 } 323 324 static inline int textlenT(LPCWSTR text, BOOL isW) 325 { 326 return !is_textT(text, isW) ? 0 : 327 isW ? lstrlenW(text) : lstrlenA((LPCSTR)text); 328 } 329 330 static inline void textcpynT(LPWSTR dest, BOOL isDestW, LPCWSTR src, BOOL isSrcW, INT max) 331 { 332 if (isDestW) 333 if (isSrcW) lstrcpynW(dest, src, max); 334 else MultiByteToWideChar(CP_ACP, 0, (LPCSTR)src, -1, dest, max); 335 else 336 if (isSrcW) WideCharToMultiByte(CP_ACP, 0, src, -1, (LPSTR)dest, max, NULL, NULL); 337 else lstrcpynA((LPSTR)dest, (LPCSTR)src, max); 338 } 339 340 static inline LPCSTR debugstr_t(LPCWSTR text, BOOL isW) 341 { 342 return NULL; 343 } 344 345 static inline LPCSTR debugstr_tn(LPCWSTR text, BOOL isW, INT n) 346 { 347 return NULL; 348 } 349 350 static inline LPWSTR textdupTtoW(LPCWSTR text, BOOL isW) 351 { 352 LPWSTR wstr = (LPWSTR)text; 353 354 TRACE("(text=%s, isW=%d)\n", debugstr_t(text, isW), isW); 355 if (!isW && text) 356 { 357 INT len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text, -1, NULL, 0); 358 wstr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); 359 if (wstr) MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text, -1, wstr, len); 360 } 361 TRACE(" wstr=%s\n", debugstr_w(wstr)); 362 return wstr; 363 } 364 365 static inline void textfreeT(LPWSTR wstr, BOOL isW) 366 { 367 if (!isW && wstr) HeapFree(GetProcessHeap(), 0, wstr); 368 } 369 370 /* 371 * dest is a pointer to a Unicode string 372 * src is a pointer to a string (Unicode if isW, ANSI if !isW) 373 */ 374 static inline BOOL textsetptrT(LPWSTR *dest, LPWSTR src, BOOL isW) 375 { 376 LPWSTR pszText = textdupTtoW(src, isW); 377 BOOL bResult = TRUE; 378 if (*dest == LPSTR_TEXTCALLBACKW) *dest = NULL; 379 bResult = Str_SetPtrW(dest, pszText); 380 textfreeT(pszText, isW); 381 return bResult; 382 } 383 384 static inline LRESULT CallWindowProcT(WNDPROC proc, HWND hwnd, UINT uMsg, 385 WPARAM wParam, LPARAM lParam, BOOL isW) 386 { 387 if (isW) 388 return CallWindowProcW(proc, hwnd, uMsg, wParam, lParam); 389 else 390 return CallWindowProcA(proc, hwnd, uMsg, wParam, lParam); 391 } 392 393 static inline BOOL notify(HWND self, INT code, LPNMHDR pnmh) 394 { 395 pnmh->hwndFrom = self; 396 pnmh->idFrom = GetWindowLongW(self, GWL_ID); 397 pnmh->code = code; 398 return (BOOL)SendMessageW(GetParent(self), WM_NOTIFY, 399 (WPARAM)pnmh->idFrom, (LPARAM)pnmh); 400 } 401 402 static inline BOOL hdr_notify(HWND self, INT code) 403 { 404 NMHDR nmh; 405 return notify(self, code, &nmh); 406 } 407 408 static inline BOOL listview_notify(HWND self, INT code, LPNMLISTVIEW plvnm) 409 { 410 return notify(self, code, (LPNMHDR)plvnm); 411 } 412 413 static int tabNotification[] = { 414 LVN_BEGINLABELEDITW, LVN_BEGINLABELEDITA, 415 LVN_ENDLABELEDITW, LVN_ENDLABELEDITA, 416 LVN_GETDISPINFOW, LVN_GETDISPINFOA, 417 LVN_SETDISPINFOW, LVN_SETDISPINFOA, 418 LVN_ODFINDITEMW, LVN_ODFINDITEMA, 419 LVN_GETINFOTIPW, LVN_GETINFOTIPA, 420 0 421 }; 422 423 static int get_ansi_notification(INT unicodeNotificationCode) 424 { 425 int *pTabNotif = tabNotification; 426 while (*pTabNotif && (unicodeNotificationCode != *pTabNotif++)); 427 if (*pTabNotif) return *pTabNotif; 428 ERR("unknown notification %x\n", unicodeNotificationCode); 429 return unicodeNotificationCode; 430 } 431 432 /* 433 Send notification. depends on dispinfoW having same 434 structure as dispinfoA. 435 self : listview handle 436 notificationCode : *Unicode* notification code 437 pdi : dispinfo structure (can be unicode or ansi) 438 isW : TRUE if dispinfo is Unicode 439 */ 440 static BOOL dispinfo_notifyT(HWND self, INT notificationCode, LPNMLVDISPINFOW pdi, BOOL isW) 441 { 442 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(self, 0); 443 BOOL bResult = FALSE; 444 BOOL convertToAnsi = FALSE, convertToUnicode = FALSE; 445 INT realNotifCode; 446 INT cchTempBufMax = 0, savCchTextMax = 0; 447 LPWSTR pszTempBuf = NULL, savPszText = NULL; 448 449 TRACE("(self=%x, code=%x, pdi=%p, isW=%d)\n", self, notificationCode, pdi, isW); 450 TRACE(" notifyFormat=%s\n", 451 infoPtr->notifyFormat == NFR_UNICODE ? "NFR_UNICODE" : 452 infoPtr->notifyFormat == NFR_ANSI ? "NFR_ANSI" : "(not set)"); 453 if (infoPtr->notifyFormat == NFR_ANSI) 454 realNotifCode = get_ansi_notification(notificationCode); 455 else 456 realNotifCode = notificationCode; 457 458 if (is_textT(pdi->item.pszText, isW)) 459 { 460 if (isW && infoPtr->notifyFormat == NFR_ANSI) 461 convertToAnsi = TRUE; 462 if (!isW && infoPtr->notifyFormat == NFR_UNICODE) 463 convertToUnicode = TRUE; 464 } 465 466 if (convertToAnsi || convertToUnicode) 467 { 468 TRACE(" we have to convert the text to the correct format\n"); 469 if (notificationCode != LVN_GETDISPINFOW) 470 { /* length of existing text */ 471 cchTempBufMax = convertToUnicode ? 472 MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0): 473 WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL); 474 } 475 else 476 cchTempBufMax = pdi->item.cchTextMax; 477 478 pszTempBuf = HeapAlloc(GetProcessHeap(), 0, 479 (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax); 480 if (!pszTempBuf) return FALSE; 481 if (convertToUnicode) 482 MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, 483 pszTempBuf, cchTempBufMax); 484 else 485 WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) pszTempBuf, 486 cchTempBufMax, NULL, NULL); 487 TRACE(" text=%s\n", debugstr_t(pszTempBuf, convertToUnicode)); 488 savCchTextMax = pdi->item.cchTextMax; 489 savPszText = pdi->item.pszText; 490 pdi->item.pszText = pszTempBuf; 491 pdi->item.cchTextMax = cchTempBufMax; 492 } 493 494 bResult = notify(self, realNotifCode, (LPNMHDR)pdi); 495 496 if (convertToUnicode || convertToAnsi) 497 { /* convert back result */ 498 TRACE(" returned text=%s\n", debugstr_t(pdi->item.pszText, convertToUnicode)); 499 if (convertToUnicode) /* note : pointer can be changed by app ! */ 500 WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) savPszText, 501 savCchTextMax, NULL, NULL); 502 else 503 MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1, 504 savPszText, savCchTextMax); 505 pdi->item.pszText = savPszText; /* restores our buffer */ 506 pdi->item.cchTextMax = savCchTextMax; 507 HeapFree(GetProcessHeap(), 0, pszTempBuf); 508 } 509 return bResult; 510 } 511 512 static inline LRESULT LISTVIEW_GetItemW(HWND hwnd, LPLVITEMW lpLVItem, BOOL internal) 513 { 514 return LISTVIEW_GetItemT(hwnd, lpLVItem, internal, TRUE); 515 } 516 517 static inline int lstrncmpiW(LPCWSTR s1, LPCWSTR s2, int n) 518 { 519 int res; 520 521 n = min(min(n, strlenW(s1)), strlenW(s2)); 522 res = CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, s1, n, s2, n); 523 return res ? res - 2 : res; 524 } 525 526 static char* debuglvitem_t(LPLVITEMW lpLVItem, BOOL isW) 527 { 528 static int index = 0; 529 static char buffers[20][256]; 530 char* buf = buffers[index++ % 20]; 531 if (lpLVItem == NULL) return "(null)"; 532 return buf; 533 } 534 535 static char* debuglvcolumn_t(LPLVCOLUMNW lpColumn, BOOL isW) 536 { 537 static int index = 0; 538 static char buffers[20][256]; 539 char* buf = buffers[index++ % 20]; 540 if (lpColumn == NULL) return "(null)"; 541 return buf; 542 } 543 544 static void LISTVIEW_DumpListview(LISTVIEW_INFO *iP, INT line) 545 { 546 DWORD dwStyle = GetWindowLongW (iP->hwndSelf, GWL_STYLE); 547 TRACE("listview %08x at line %d, clrBk=0x%06lx, clrText=0x%06lx, clrTextBk=0x%06lx, ItemHeight=%d, ItemWidth=%d, Style=0x%08lx\n", 548 iP->hwndSelf, line, iP->clrBk, iP->clrText, iP->clrTextBk, 549 iP->nItemHeight, iP->nItemWidth, dwStyle); 550 TRACE("listview %08x at line %d, himlNor=%p, himlSml=%p, himlState=%p, Focused=%d, Hot=%d, exStyle=0x%08lx\n", 551 iP->hwndSelf, line, iP->himlNormal, iP->himlSmall, iP->himlState, 552 iP->nFocusedItem, iP->nHotItem, iP->dwExStyle); 553 } 278 554 279 555 static BOOL … … 281 557 RECT rc) 282 558 { 283 LISTVIEW_INFO *infoPtr ;559 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 284 560 NMLVCUSTOMDRAW nmcdhdr; 285 561 LPNMCUSTOMDRAW nmcd; 286 562 287 TRACE("drawstage:%lx hdc:%x\n", dwDrawStage, hdc); 288 289 infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 563 TRACE("(hwnd=%x, dwDrawStage=%lx, hdc=%x, rc=?)\n", hwnd, dwDrawStage, hdc); 290 564 291 565 nmcd= & nmcdhdr.nmcd; 292 566 nmcd->hdr.hwndFrom = hwnd; 293 nmcd->hdr.idFrom = GetWindowLong A( hwnd, GWL_ID);567 nmcd->hdr.idFrom = GetWindowLongW( hwnd, GWL_ID); 294 568 nmcd->hdr.code = NM_CUSTOMDRAW; 295 569 nmcd->dwDrawStage= dwDrawStage; … … 305 579 nmcdhdr.clrTextBk= infoPtr->clrBk; 306 580 307 return (BOOL)SendMessage A(GetParent (hwnd), WM_NOTIFY,308 (WPARAM) GetWindowLong A( hwnd, GWL_ID), (LPARAM)&nmcdhdr);581 return (BOOL)SendMessageW (GetParent (hwnd), WM_NOTIFY, 582 (WPARAM) GetWindowLongW( hwnd, GWL_ID), (LPARAM)&nmcdhdr); 309 583 } 310 584 311 585 static BOOL 312 586 LISTVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc, 313 UINT iItem, UINT iSubItem, 587 UINT iItem, UINT iSubItem, 314 588 UINT uItemDrawState) 315 589 { … … 321 595 INT retval; 322 596 RECT itemRect; 323 LVITEM Aitem;324 325 infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);326 327 ZeroMemory(&item,sizeof( LVITEMA));597 LVITEMW item; 598 599 infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 600 601 ZeroMemory(&item,sizeof(item)); 328 602 item.iItem = iItem; 329 603 item.mask = LVIF_PARAM; 330 ListView_GetItem A(hwnd,&item);604 ListView_GetItemW(hwnd,&item); 331 605 332 606 dwDrawStage=CDDS_ITEM | uItemDrawState; … … 343 617 nmcd= & nmcdhdr.nmcd; 344 618 nmcd->hdr.hwndFrom = hwnd; 345 nmcd->hdr.idFrom = GetWindowLong A( hwnd, GWL_ID);619 nmcd->hdr.idFrom = GetWindowLongW( hwnd, GWL_ID); 346 620 nmcd->hdr.code = NM_CUSTOMDRAW; 347 621 nmcd->dwDrawStage= dwDrawStage; 348 nmcd->hdc 622 nmcd->hdc = hdc; 349 623 nmcd->rc.left = itemRect.left; 350 624 nmcd->rc.right = itemRect.right; … … 358 632 nmcdhdr.iSubItem =iSubItem; 359 633 360 TRACE("drawstage :%lx hdc:%x item:%lx, itemstate:%x, lItemlParam:%lx\n",361 362 363 364 retval=SendMessage A(GetParent (hwnd), WM_NOTIFY,365 (WPARAM) GetWindowLong A( hwnd, GWL_ID), (LPARAM)&nmcdhdr);634 TRACE("drawstage=%lx hdc=%x item=%lx, itemstate=%x, lItemlParam=%lx\n", 635 nmcd->dwDrawStage, nmcd->hdc, nmcd->dwItemSpec, 636 nmcd->uItemState, nmcd->lItemlParam); 637 638 retval=SendMessageW (GetParent (hwnd), WM_NOTIFY, 639 (WPARAM) GetWindowLongW( hwnd, GWL_ID), (LPARAM)&nmcdhdr); 366 640 367 641 infoPtr->clrText=nmcdhdr.clrText; … … 372 646 373 647 /************************************************************************* 374 * 375 * 376 * Processes keyboard messages generated by pressing the letter keys 648 * LISTVIEW_ProcessLetterKeys 649 * 650 * Processes keyboard messages generated by pressing the letter keys 377 651 * on the keyboard. 378 * What this does is perform a case insensitive search from the 652 * What this does is perform a case insensitive search from the 379 653 * current position with the following quirks: 380 * - If two chars or more are pressed in quick succession we search 654 * - If two chars or more are pressed in quick succession we search 381 655 * for the corresponding string (e.g. 'abc'). 382 * - If there is a delay we wipe away the current search string and 656 * - If there is a delay we wipe away the current search string and 383 657 * restart with just that char. 384 * - If the user keeps pressing the same character, whether slowly or 385 * fast, so that the search string is entirely composed of this 386 * character ('aaaaa' for instance), then we search for first item 658 * - If the user keeps pressing the same character, whether slowly or 659 * fast, so that the search string is entirely composed of this 660 * character ('aaaaa' for instance), then we search for first item 387 661 * that starting with that character. 388 * - If the user types the above character in quick succession, then 389 * we must also search for the corresponding string ('aaaaa'), and 662 * - If the user types the above character in quick succession, then 663 * we must also search for the corresponding string ('aaaaa'), and 390 664 * go to that string if there is a match. 391 665 * … … 396 670 * BUGS 397 671 * 398 * - The current implementation has a list of characters it will 399 * accept and it ignores averything else. In particular it will 400 * ignore accentuated characters which seems to match what 401 * Windows does. But I'm not sure it makes sense to follow 672 * - The current implementation has a list of characters it will 673 * accept and it ignores averything else. In particular it will 674 * ignore accentuated characters which seems to match what 675 * Windows does. But I'm not sure it makes sense to follow 402 676 * Windows there. 403 677 * - We don't sound a beep when the search fails. … … 417 691 INT nSize; 418 692 INT endidx,idx; 419 LVITEM Aitem;420 CHAR buffer[MAX_PATH];693 LVITEMW item; 694 WCHAR buffer[MAX_PATH]; 421 695 DWORD timestamp,elapsed; 422 696 … … 425 699 return 0; 426 700 427 infoPtr=(LISTVIEW_INFO*)GetWindowLong A(hwnd, 0);701 infoPtr=(LISTVIEW_INFO*)GetWindowLongW(hwnd, 0); 428 702 if (!infoPtr) 429 703 return 0; … … 458 732 infoPtr->lastKeyPressTimestamp=timestamp; 459 733 if (elapsed < KEY_DELAY) { 460 if (infoPtr->nSearchParamLength < sizeof(infoPtr->szSearchParam)) {734 if (infoPtr->nSearchParamLength < COUNTOF(infoPtr->szSearchParam)) { 461 735 infoPtr->szSearchParam[infoPtr->nSearchParamLength++]=charCode; 462 736 } … … 499 773 item.iSubItem = 0; 500 774 item.pszText = buffer; 501 item.cchTextMax = sizeof(buffer);502 ListView_GetItem A( hwnd, &item );775 item.cchTextMax = COUNTOF(buffer); 776 ListView_GetItemW( hwnd, &item ); 503 777 504 778 /* check for a match */ 505 if ( strncasecmp(item.pszText,infoPtr->szSearchParam,infoPtr->nSearchParamLength) == 0) {779 if (lstrncmpiW(item.pszText,infoPtr->szSearchParam,infoPtr->nSearchParamLength) == 0) { 506 780 nItem=idx; 507 781 break; 508 782 } else if ( (charCode != 0) && (nItem == -1) && (nItem != infoPtr->nFocusedItem) && 509 ( strncasecmp(item.pszText,infoPtr->szSearchParam,1) == 0) ) {783 (lstrncmpiW(item.pszText,infoPtr->szSearchParam,1) == 0) ) { 510 784 /* This would work but we must keep looking for a longer match */ 511 785 nItem=idx; … … 526 800 527 801 /************************************************************************* 528 * LISTVIEW_UpdateHeaderSize [Internal] 802 * LISTVIEW_UpdateHeaderSize [Internal] 529 803 * 530 804 * Function to resize the header control … … 541 815 static VOID LISTVIEW_UpdateHeaderSize(HWND hwnd, INT nNewScrollPos) 542 816 { 543 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);817 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 544 818 RECT winRect; 545 819 POINT point[2]; … … 559 833 point[1].x += (nNewScrollPos * LISTVIEW_SCROLL_DIV_SIZE); 560 834 #endif 561 562 835 SetWindowPos(infoPtr->hwndHeader,0, 563 836 point[0].x,point[0].y,point[1].x,point[1].y, … … 567 840 /*** 568 841 * DESCRIPTION: 569 * Update the scrollbars. This functions should be called whenever 842 * Update the scrollbars. This functions should be called whenever 570 843 * the content, size or view changes. 571 * 844 * 572 845 * PARAMETER(S): 573 846 * [I] HWND : window handle … … 579 852 static VOID LISTVIEW_UpdateScroll(HWND hwnd) 580 853 { 581 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);854 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 582 855 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 583 856 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 584 857 SCROLLINFO scrollInfo; 585 LONG dwStyle = GetWindowLong A(hwnd, GWL_STYLE);858 LONG dwStyle = GetWindowLongW(hwnd, GWL_STYLE); 586 859 UINT uView = dwStyle & LVS_TYPEMASK; 587 860 … … 697 970 static VOID LISTVIEW_UpdateScroll(HWND hwnd) 698 971 { 699 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);700 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);972 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 973 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 701 974 UINT uView = lStyle & LVS_TYPEMASK; 702 975 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; … … 704 977 SCROLLINFO scrollInfo; 705 978 706 979 if (lStyle & LVS_NOSCROLL) return; 980 707 981 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 708 982 scrollInfo.cbSize = sizeof(SCROLLINFO); … … 719 993 if((nNumOfItems % nCountPerColumn) == 0) 720 994 { 721 scrollInfo.nMax--; 995 scrollInfo.nMax--; 996 } 997 else 998 { 999 scrollInfo.nMax++; 722 1000 } 723 1001 scrollInfo.nPos = ListView_GetTopIndex(hwnd) / nCountPerColumn; … … 739 1017 /* update horizontal scrollbar */ 740 1018 nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 741 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE 1019 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE 742 1020 || GETITEMCOUNT(infoPtr) == 0) 743 1021 { 744 1022 scrollInfo.nPos = 0; 745 } 1023 } 746 1024 scrollInfo.nMin = 0; 747 scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE ; 1025 scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE ; 748 1026 scrollInfo.nPage = nListWidth / LISTVIEW_SCROLL_DIV_SIZE; 749 1027 scrollInfo.nMax = max(infoPtr->nItemWidth / LISTVIEW_SCROLL_DIV_SIZE, 0)-1; 750 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 1028 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 751 1029 752 1030 /* Update the Header Control */ … … 800 1078 * Prints a message for unsupported window styles. 801 1079 * A kind of TODO list for window styles. 802 * 1080 * 803 1081 * PARAMETER(S): 804 1082 * [I] LONG : window style … … 809 1087 static VOID LISTVIEW_UnsupportedStyles(LONG lStyle) 810 1088 { 811 if ((LVS_TYPEMASK & lStyle) == LVS_EDITLABELS) 812 { 1089 if ((LVS_TYPESTYLEMASK & lStyle) == LVS_NOSCROLL) 1090 FIXME(" LVS_NOSCROLL\n"); 1091 1092 if (lStyle & LVS_EDITLABELS) 813 1093 FIXME(" LVS_EDITLABELS\n"); 814 } 815 816 if ((LVS_TYPEMASK & lStyle) == LVS_NOLABELWRAP) 817 { 1094 1095 if (lStyle & LVS_NOLABELWRAP) 818 1096 FIXME(" LVS_NOLABELWRAP\n"); 819 } 820 821 if ((LVS_TYPEMASK & lStyle) == LVS_NOSCROLL) 822 { 823 FIXME(" LVS_NOSCROLL\n"); 824 } 825 826 if ((LVS_TYPEMASK & lStyle) == LVS_NOSORTHEADER) 827 { 828 FIXME(" LVS_NOSORTHEADER\n"); 829 } 830 831 if ((LVS_TYPEMASK & lStyle) == LVS_OWNERDRAWFIXED) 832 { 833 FIXME(" LVS_OWNERDRAWFIXED\n"); 834 } 835 836 if ((LVS_TYPEMASK & lStyle) == LVS_SHAREIMAGELISTS) 837 { 1097 1098 if (lStyle & LVS_SHAREIMAGELISTS) 838 1099 FIXME(" LVS_SHAREIMAGELISTS\n"); 839 } 840 841 if ((LVS_TYPEMASK & lStyle) == LVS_SORTASCENDING) 842 { 1100 1101 if (lStyle & LVS_SORTASCENDING) 843 1102 FIXME(" LVS_SORTASCENDING\n"); 844 } 845 846 if ((LVS_TYPEMASK & lStyle) == LVS_SORTDESCENDING) 847 { 1103 1104 if (lStyle & LVS_SORTDESCENDING) 848 1105 FIXME(" LVS_SORTDESCENDING\n"); 849 }850 1106 } 851 1107 … … 853 1109 * DESCRIPTION: 854 1110 * Aligns the items with the top edge of the window. 855 * 1111 * 856 1112 * PARAMETER(S): 857 1113 * [I] HWND : window handle … … 862 1118 static VOID LISTVIEW_AlignTop(HWND hwnd) 863 1119 { 864 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);865 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;1120 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1121 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 866 1122 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 867 1123 POINT ptItem; 868 1124 RECT rcView; 869 INT i ;870 1125 INT i, off_x=0, off_y=0; 1126 871 1127 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 872 1128 { 873 ZeroMemory(&ptItem, sizeof(POINT)); 1129 /* Since SetItemPosition uses upper-left of icon, and for 1130 style=LVS_ICON the icon is not left adjusted, get the offset */ 1131 if (uView == LVS_ICON) 1132 { 1133 off_y = ICON_TOP_PADDING; 1134 off_x = (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; 1135 } 1136 ptItem.x = off_x; 1137 ptItem.y = off_y; 874 1138 ZeroMemory(&rcView, sizeof(RECT)); 875 1139 … … 880 1144 if (ptItem.x + infoPtr->nItemWidth > nListWidth) 881 1145 { 882 ptItem.x = 0;1146 ptItem.x = off_x; 883 1147 ptItem.y += infoPtr->nItemHeight; 884 1148 } 885 886 L istView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);1149 1150 LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y); 887 1151 ptItem.x += infoPtr->nItemWidth; 888 1152 rcView.right = max(rcView.right, ptItem.x); … … 895 1159 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 896 1160 { 897 L istView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);1161 LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y); 898 1162 ptItem.y += infoPtr->nItemHeight; 899 1163 } … … 910 1174 * DESCRIPTION: 911 1175 * Aligns the items with the left edge of the window. 912 * 1176 * 913 1177 * PARAMETER(S): 914 1178 * [I] HWND : window handle … … 919 1183 static VOID LISTVIEW_AlignLeft(HWND hwnd) 920 1184 { 921 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);922 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;1185 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1186 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 923 1187 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 924 1188 POINT ptItem; 925 1189 RECT rcView; 926 INT i ;927 1190 INT i, off_x=0, off_y=0; 1191 928 1192 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 929 1193 { 930 ZeroMemory(&ptItem, sizeof(POINT)); 1194 /* Since SetItemPosition uses upper-left of icon, and for 1195 style=LVS_ICON the icon is not left adjusted, get the offset */ 1196 if (uView == LVS_ICON) 1197 { 1198 off_y = ICON_TOP_PADDING; 1199 off_x = (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; 1200 } 1201 ptItem.x = off_x; 1202 ptItem.y = off_y; 931 1203 ZeroMemory(&rcView, sizeof(RECT)); 932 1204 … … 937 1209 if (ptItem.y + infoPtr->nItemHeight > nListHeight) 938 1210 { 939 ptItem.y = 0;1211 ptItem.y = off_y; 940 1212 ptItem.x += infoPtr->nItemWidth; 941 1213 } 942 1214 943 L istView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);1215 LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y); 944 1216 ptItem.y += infoPtr->nItemHeight; 945 1217 rcView.bottom = max(rcView.bottom, ptItem.y); … … 952 1224 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 953 1225 { 954 L istView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);1226 LISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y); 955 1227 ptItem.x += infoPtr->nItemWidth; 956 1228 } … … 967 1239 * DESCRIPTION: 968 1240 * Set the bounding rectangle of all the items. 969 * 1241 * 970 1242 * PARAMETER(S): 971 1243 * [I] HWND : window handle … … 978 1250 static LRESULT LISTVIEW_SetViewRect(HWND hwnd, LPRECT lprcView) 979 1251 { 980 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLong A(hwnd, 0);1252 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongW(hwnd, 0); 981 1253 BOOL bResult = FALSE; 982 1254 983 TRACE("(hwnd=%x, left=%d, top=%d, right=%d, bottom=%d)\n", hwnd, 1255 TRACE("(hwnd=%x, left=%d, top=%d, right=%d, bottom=%d)\n", hwnd, 984 1256 lprcView->left, lprcView->top, lprcView->right, lprcView->bottom); 985 1257 986 1258 if (lprcView != NULL) 987 1259 { … … 999 1271 * DESCRIPTION: 1000 1272 * Retrieves the bounding rectangle of all the items. 1001 * 1273 * 1002 1274 * PARAMETER(S): 1003 1275 * [I] HWND : window handle … … 1010 1282 static LRESULT LISTVIEW_GetViewRect(HWND hwnd, LPRECT lprcView) 1011 1283 { 1012 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLong A(hwnd, 0);1284 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongW(hwnd, 0); 1013 1285 BOOL bResult = FALSE; 1014 1286 POINT ptOrigin; … … 1027 1299 } 1028 1300 1029 TRACE("(left=%d, top=%d, right=%d, bottom=%d)\n", 1301 TRACE("(left=%d, top=%d, right=%d, bottom=%d)\n", 1030 1302 lprcView->left, lprcView->top, lprcView->right, lprcView->bottom); 1031 1303 } … … 1037 1309 * DESCRIPTION: 1038 1310 * Retrieves the subitem pointer associated with the subitem index. 1039 * 1311 * 1040 1312 * PARAMETER(S): 1041 1313 * [I] HDPA : DPA handle for a specific item … … 1046 1318 * FAILURE : NULL 1047 1319 */ 1048 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItemPtr(HDPA hdpaSubItems, 1320 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItemPtr(HDPA hdpaSubItems, 1049 1321 INT nSubItem) 1050 1322 { … … 1070 1342 * DESCRIPTION: 1071 1343 * Calculates the width of an item. 1072 * 1344 * 1073 1345 * PARAMETER(S): 1074 1346 * [I] HWND : window handle … … 1080 1352 static INT LISTVIEW_GetItemWidth(HWND hwnd) 1081 1353 { 1082 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1083 LONG style = GetWindowLong A(hwnd, GWL_STYLE);1084 UINT uView = style & LVS_TYPEMASK; 1354 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1355 LONG style = GetWindowLongW(hwnd, GWL_STYLE); 1356 UINT uView = style & LVS_TYPEMASK; 1085 1357 INT nHeaderItemCount; 1086 1358 RECT rcHeaderItem; … … 1117 1389 { 1118 1390 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 1119 { 1391 { 1120 1392 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, i); 1121 1393 nItemWidth = max(nItemWidth, nLabelWidth); 1122 1394 } 1123 1395 1124 1396 /* default label size */ 1125 1397 if (GETITEMCOUNT(infoPtr) == 0) … … 1137 1409 /* add padding */ 1138 1410 nItemWidth += WIDTH_PADDING; 1139 1411 1140 1412 if (infoPtr->himlSmall != NULL) 1141 1413 { … … 1161 1433 * DESCRIPTION: 1162 1434 * Calculates the width of a specific item. 1163 * 1164 * PARAMETER(S): 1165 * [I] HWND : window handle 1166 * [I] LPSTR : string 1435 * 1436 * PARAMETER(S): 1437 * [I] HWND : window handle 1438 * [I] LPSTR : string 1167 1439 * 1168 1440 * RETURN: … … 1171 1443 static INT LISTVIEW_CalculateWidth(HWND hwnd, INT nItem) 1172 1444 { 1173 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1174 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;1445 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1446 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 1175 1447 INT nHeaderItemCount; 1176 1448 RECT rcHeaderItem; … … 1216 1488 /* add padding */ 1217 1489 nItemWidth += WIDTH_PADDING; 1218 1490 1219 1491 if (infoPtr->himlSmall != NULL) 1220 1492 { … … 1229 1501 } 1230 1502 } 1231 1503 1232 1504 return nItemWidth; 1233 1505 } … … 1235 1507 /*** 1236 1508 * DESCRIPTION: 1509 * Retrieves and saves important text metrics info for the current 1510 * Listview font. 1511 * 1512 * PARAMETER(S): 1513 * [I] HWND : window handle 1514 * 1515 */ 1516 static VOID LISTVIEW_SaveTextMetrics(HWND hwnd) 1517 { 1518 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1519 TEXTMETRICW tm; 1520 HDC hdc = GetDC(hwnd); 1521 HFONT hOldFont = SelectObject(hdc, infoPtr->hFont); 1522 INT oldHeight, oldACW; 1523 1524 GetTextMetricsW(hdc, &tm); 1525 1526 oldHeight = infoPtr->ntmHeight; 1527 oldACW = infoPtr->ntmAveCharWidth; 1528 infoPtr->ntmHeight = tm.tmHeight; 1529 infoPtr->ntmAveCharWidth = tm.tmAveCharWidth; 1530 1531 SelectObject(hdc, hOldFont); 1532 ReleaseDC(hwnd, hdc); 1533 TRACE("tmHeight old=%d,new=%d; tmAveCharWidth old=%d,new=%d\n", 1534 oldHeight, infoPtr->ntmHeight, oldACW, infoPtr->ntmAveCharWidth); 1535 } 1536 1537 1538 /*** 1539 * DESCRIPTION: 1237 1540 * Calculates the height of an item. 1238 * 1239 * PARAMETER(S): 1240 * [I] HWND : window handle 1241 * [I] LONG : window style 1541 * 1542 * PARAMETER(S): 1543 * [I] HWND : window handle 1242 1544 * 1243 1545 * RETURN: … … 1246 1548 static INT LISTVIEW_GetItemHeight(HWND hwnd) 1247 1549 { 1248 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1550 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1249 1551 #ifdef __WIN32OS2__ 1250 1552 DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); … … 1261 1563 else 1262 1564 { 1263 TEXTMETRICA tm;1264 HDC hdc = GetDC(hwnd);1265 HFONT hOldFont = SelectObject(hdc, infoPtr->hFont);1266 GetTextMetricsA(hdc, &tm);1267 1268 1565 if(infoPtr->himlState || infoPtr->himlSmall) 1269 nItemHeight = max( tm.tmHeight, infoPtr->iconSize.cy) + HEIGHT_PADDING;1566 nItemHeight = max(infoPtr->ntmHeight, infoPtr->iconSize.cy) + HEIGHT_PADDING; 1270 1567 else 1271 nItemHeight = tm.tmHeight; 1272 1273 SelectObject(hdc, hOldFont); 1274 ReleaseDC(hwnd, hdc); 1568 nItemHeight = infoPtr->ntmHeight; 1275 1569 #ifdef __WIN32OS2__ 1276 1570 if(dwStyle & LVS_OWNERDRAWFIXED) { 1277 1571 /* Get item height */ 1278 1572 … … 1290 1584 #endif 1291 1585 } 1292 1293 1586 return nItemHeight; 1294 1587 } … … 1297 1590 static void LISTVIEW_PrintSelectionRanges(HWND hwnd) 1298 1591 { 1299 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1592 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1300 1593 LISTVIEW_SELECTION *selection; 1301 1594 INT topSelection = infoPtr->hdpaSelectionRanges->nItemCount; … … 1324 1617 * 0 : if Item 1 == Item 2 1325 1618 */ 1326 static INT CALLBACK LISTVIEW_CompareSelectionRanges(LPVOID range1, LPVOID range2, 1619 static INT CALLBACK LISTVIEW_CompareSelectionRanges(LPVOID range1, LPVOID range2, 1327 1620 LPARAM flags) 1328 1621 { … … 1330 1623 int l2 = ((LISTVIEW_SELECTION*)(range2))->lower; 1331 1624 int u1 = ((LISTVIEW_SELECTION*)(range1))->upper; 1332 int u2 = ((LISTVIEW_SELECTION*)(range2))->upper; 1625 int u2 = ((LISTVIEW_SELECTION*)(range2))->upper; 1333 1626 int rc=0; 1334 1627 1335 1628 if (u1 < l2) 1336 1629 rc= -1; 1337 1630 1338 1631 if (u2 < l1) 1339 1632 rc= 1; … … 1345 1638 * DESCRIPTION: 1346 1639 * Adds a selection range. 1347 * 1640 * 1348 1641 * PARAMETER(S): 1349 1642 * [I] HWND : window handle 1350 1643 * [I] INT : lower item index 1351 * [I] INT : upper item index 1644 * [I] INT : upper item index 1352 1645 * 1353 1646 * RETURN: … … 1356 1649 static VOID LISTVIEW_AddSelectionRange(HWND hwnd, INT lItem, INT uItem) 1357 1650 { 1358 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1651 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1359 1652 LISTVIEW_SELECTION *selection; 1360 1653 INT topSelection = infoPtr->hdpaSelectionRanges->nItemCount; … … 1365 1658 selection->upper = uItem; 1366 1659 1367 TRACE("Add range %i - %i\n", lItem,uItem);1660 TRACE("Add range %i - %i\n", lItem, uItem); 1368 1661 if (topSelection) 1369 1662 { … … 1383 1676 LISTVIEW_CompareSelectionRanges, 1384 1677 0,0); 1385 selection->upper --; 1678 selection->upper --; 1386 1679 if (lowerzero) 1387 1680 lowerzero=FALSE; … … 1394 1687 TRACE("Merge with index %i (%lu - %lu)\n",index,checkselection->lower, 1395 1688 checkselection->upper); 1396 1689 1397 1690 checkselection->lower = min(selection->lower,checkselection->lower); 1398 1691 checkselection->upper = max(selection->upper,checkselection->upper); 1399 1400 TRACE("New range (%lu - %lu)\n", checkselection->lower, 1692 1693 TRACE("New range (%lu - %lu)\n", checkselection->lower, 1401 1694 checkselection->upper); 1402 1695 1403 COMCTL32_Free(selection); 1404 1696 COMCTL32_Free(selection); 1697 1405 1698 /* merge now common selection ranges in the lower group*/ 1406 1699 do 1407 1700 { 1408 checkselection->upper ++; 1701 checkselection->upper ++; 1409 1702 if (checkselection->lower == 0) 1410 1703 lowerzero = TRUE; … … 1412 1705 checkselection->lower --; 1413 1706 1414 TRACE("search lower range (%lu - %lu)\n", checkselection->lower, 1707 TRACE("search lower range (%lu - %lu)\n", checkselection->lower, 1415 1708 checkselection->upper); 1416 1709 … … 1420 1713 0); 1421 1714 1422 checkselection->upper --; 1715 checkselection->upper --; 1423 1716 if (lowerzero) 1424 1717 lowerzero = FALSE; 1425 1718 else 1426 1427 1428 1719 checkselection->lower ++; 1720 1721 if (mergeindex >=0 && mergeindex != index) 1429 1722 { 1430 1723 TRACE("Merge with index %i\n",mergeindex); 1431 1724 checkselection2 = DPA_GetPtr(infoPtr->hdpaSelectionRanges, 1432 1725 mergeindex); 1433 checkselection->lower = min(checkselection->lower, 1726 checkselection->lower = min(checkselection->lower, 1434 1727 checkselection2->lower); 1435 1728 checkselection->upper = max(checkselection->upper, … … 1448 1741 if (checkselection->lower == 0) 1449 1742 lowerzero = TRUE; 1450 else 1743 else 1451 1744 checkselection->lower --; 1452 1745 1453 TRACE("search upper range %i (%lu - %lu)\n",index, 1746 TRACE("search upper range %i (%lu - %lu)\n",index, 1454 1747 checkselection->lower, checkselection->upper); 1455 1748 … … 1457 1750 mergeindex = DPA_Search(infoPtr->hdpaSelectionRanges, checkselection, 1458 1751 index+1, 1459 1460 1461 1462 checkselection->upper --; 1752 LISTVIEW_CompareSelectionRanges, 0, 1753 0); 1754 1755 checkselection->upper --; 1463 1756 if (lowerzero) 1464 1757 lowerzero = FALSE; … … 1468 1761 if (mergeindex >=0 && mergeindex !=index) 1469 1762 { 1470 1471 1472 1473 checkselection->lower = min(checkselection->lower, 1474 1475 1476 1477 1478 1763 TRACE("Merge with index %i\n",mergeindex); 1764 checkselection2 = DPA_GetPtr(infoPtr->hdpaSelectionRanges, 1765 mergeindex); 1766 checkselection->lower = min(checkselection->lower, 1767 checkselection2->lower); 1768 checkselection->upper = max(checkselection->upper, 1769 checkselection2->upper); 1770 COMCTL32_Free(checkselection2); 1771 DPA_DeletePtr(infoPtr->hdpaSelectionRanges,mergeindex); 1479 1772 } 1480 1773 } … … 1485 1778 1486 1779 index = DPA_Search(infoPtr->hdpaSelectionRanges, selection, 0, 1487 LISTVIEW_CompareSelectionRanges, 0, 1780 LISTVIEW_CompareSelectionRanges, 0, 1488 1781 DPAS_INSERTAFTER); 1489 1782 … … 1491 1784 if (index == -1) 1492 1785 index = 0; 1493 DPA_InsertPtr(infoPtr->hdpaSelectionRanges,index,selection); 1786 DPA_InsertPtr(infoPtr->hdpaSelectionRanges,index,selection); 1494 1787 } 1495 } 1788 } 1496 1789 else 1497 1790 { … … 1499 1792 } 1500 1793 /* 1501 * Incase of error 1794 * Incase of error 1502 1795 */ 1503 1796 DPA_Sort(infoPtr->hdpaSelectionRanges,LISTVIEW_CompareSelectionRanges,0); … … 1508 1801 * DESCRIPTION: 1509 1802 * check if a specified index is selected. 1510 * 1803 * 1511 1804 * PARAMETER(S): 1512 1805 * [I] HWND : window handle 1513 * [I] INT : item index 1806 * [I] INT : item index 1514 1807 * 1515 1808 * RETURN: … … 1518 1811 static BOOL LISTVIEW_IsSelected(HWND hwnd, INT nItem) 1519 1812 { 1520 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1813 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1521 1814 LISTVIEW_SELECTION selection; 1522 1815 INT index; … … 1547 1840 static LRESULT LISTVIEW_RemoveAllSelections(HWND hwnd) 1548 1841 { 1549 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1842 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1550 1843 LISTVIEW_SELECTION *selection; 1551 1844 INT i; 1552 LVITEM Aitem;1553 1845 LVITEMW item; 1846 1554 1847 TRACE("(0x%x)\n",hwnd); 1555 1848 1556 ZeroMemory(&item,sizeof( LVITEMA));1849 ZeroMemory(&item,sizeof(item)); 1557 1850 item.stateMask = LVIS_SELECTED; 1558 1851 … … 1567 1860 LISTVIEW_RemoveSelectionRange(hwnd,selection->lower,selection->upper); 1568 1861 } 1569 } 1862 } 1570 1863 while (infoPtr->hdpaSelectionRanges->nItemCount>0); 1571 1864 1572 1865 TRACE("done\n"); 1573 return TRUE; 1866 return TRUE; 1574 1867 } 1575 1868 … … 1577 1870 * DESCRIPTION: 1578 1871 * Removes a range selections. 1579 * 1872 * 1580 1873 * PARAMETER(S): 1581 1874 * [I] HWND : window handle 1582 1875 * [I] INT : lower item index 1583 * [I] INT : upper item index 1876 * [I] INT : upper item index 1584 1877 * 1585 1878 * RETURN: … … 1588 1881 static VOID LISTVIEW_RemoveSelectionRange(HWND hwnd, INT lItem, INT uItem) 1589 1882 { 1590 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1883 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1591 1884 LISTVIEW_SELECTION removeselection,*checkselection; 1592 1885 INT index; … … 1601 1894 LISTVIEW_CompareSelectionRanges, 1602 1895 0,0); 1603 1896 1604 1897 if (index == -1) 1605 1898 return; 1606 1899 1607 1900 1608 1901 checkselection = DPA_GetPtr(infoPtr->hdpaSelectionRanges, 1609 1902 index); … … 1613 1906 1614 1907 /* case 1: Same */ 1615 if ((checkselection->upper == removeselection.upper) && 1908 if ((checkselection->upper == removeselection.upper) && 1616 1909 (checkselection->lower == removeselection.lower)) 1617 1910 { … … 1620 1913 } 1621 1914 /* case 2: engulf */ 1622 else if (((checkselection->upper < removeselection.upper) && 1915 else if (((checkselection->upper < removeselection.upper) && 1623 1916 (checkselection->lower > removeselection.lower))|| 1624 1917 ((checkselection->upper <= removeselection.upper) && … … 1658 1951 /* bisect the range */ 1659 1952 LISTVIEW_SELECTION *newselection; 1660 1953 1661 1954 newselection = (LISTVIEW_SELECTION *) 1662 1955 COMCTL32_Alloc(sizeof(LISTVIEW_SELECTION)); … … 1674 1967 * DESCRIPTION: 1675 1968 * Updates the various indices after an item has been inserted or deleted. 1676 * 1969 * 1677 1970 * PARAMETER(S): 1678 1971 * [I] HWND : window handle 1679 * [I] INT : item index 1972 * [I] INT : item index 1680 1973 * [I] INT : Direction of shift, +1 or -1. 1681 1974 * … … 1685 1978 static VOID LISTVIEW_ShiftIndices(HWND hwnd, INT nItem, INT direction) 1686 1979 { 1687 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1980 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1688 1981 LISTVIEW_SELECTION selection,*checkselection; 1689 1982 INT index; … … 1698 1991 0,DPAS_SORTED|DPAS_INSERTAFTER); 1699 1992 1700 while ((index < infoPtr->hdpaSelectionRanges->nItemCount)&&(index != -1)) 1993 while ((index < infoPtr->hdpaSelectionRanges->nItemCount)&&(index != -1)) 1701 1994 { 1702 1995 checkselection = DPA_GetPtr(infoPtr->hdpaSelectionRanges,index); … … 1742 2035 * DESCRIPTION: 1743 2036 * Adds a block of selections. 1744 * 1745 * PARAMETER(S): 1746 * [I] HWND : window handle 1747 * [I] INT : item index 2037 * 2038 * PARAMETER(S): 2039 * [I] HWND : window handle 2040 * [I] INT : item index 1748 2041 * 1749 2042 * RETURN: … … 1752 2045 static VOID LISTVIEW_AddGroupSelection(HWND hwnd, INT nItem) 1753 2046 { 1754 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2047 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1755 2048 INT nFirst = min(infoPtr->nSelectionMark, nItem); 1756 2049 INT nLast = max(infoPtr->nSelectionMark, nItem); 1757 2050 INT i; 1758 LVITEM Aitem;2051 LVITEMW item; 1759 2052 1760 2053 if (nFirst == -1) 1761 2054 nFirst = nItem; 1762 2055 1763 ZeroMemory(&item,sizeof( LVITEMA));2056 ZeroMemory(&item,sizeof(item)); 1764 2057 item.stateMask = LVIS_SELECTED; 1765 2058 item.state = LVIS_SELECTED; 1766 2059 1767 2060 for (i = nFirst; i <= nLast; i++) 1768 {1769 2061 LISTVIEW_SetItemState(hwnd,i,&item); 1770 }1771 2062 1772 2063 LISTVIEW_SetItemFocus(hwnd, nItem); … … 1778 2069 * DESCRIPTION: 1779 2070 * Adds a single selection. 1780 * 1781 * PARAMETER(S): 1782 * [I] HWND : window handle 1783 * [I] INT : item index 2071 * 2072 * PARAMETER(S): 2073 * [I] HWND : window handle 2074 * [I] INT : item index 1784 2075 * 1785 2076 * RETURN: … … 1788 2079 static VOID LISTVIEW_AddSelection(HWND hwnd, INT nItem) 1789 2080 { 1790 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1791 LVITEM Aitem;1792 1793 ZeroMemory(&item,sizeof( LVITEMA));2081 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 2082 LVITEMW item; 2083 2084 ZeroMemory(&item,sizeof(item)); 1794 2085 item.state = LVIS_SELECTED; 1795 2086 item.stateMask = LVIS_SELECTED; … … 1804 2095 * DESCRIPTION: 1805 2096 * Selects or unselects an item. 1806 * 1807 * PARAMETER(S): 1808 * [I] HWND : window handle 1809 * [I] INT : item index 1810 * 1811 * RETURN: 1812 * SELECT: TRUE 2097 * 2098 * PARAMETER(S): 2099 * [I] HWND : window handle 2100 * [I] INT : item index 2101 * 2102 * RETURN: 2103 * SELECT: TRUE 1813 2104 * UNSELECT : FALSE 1814 2105 */ 1815 2106 static BOOL LISTVIEW_ToggleSelection(HWND hwnd, INT nItem) 1816 2107 { 1817 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2108 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1818 2109 BOOL bResult; 1819 LVITEM Aitem;1820 1821 ZeroMemory(&item,sizeof( LVITEMA));2110 LVITEMW item; 2111 2112 ZeroMemory(&item,sizeof(item)); 1822 2113 item.stateMask = LVIS_SELECTED; 1823 2114 1824 2115 if (LISTVIEW_IsSelected(hwnd,nItem)) 1825 2116 { 1826 1827 2117 LISTVIEW_SetItemState(hwnd,nItem,&item); 1828 2118 bResult = FALSE; … … 1843 2133 /*** 1844 2134 * DESCRIPTION: 1845 * Selects items based on view coordinates. 1846 * 1847 * PARAMETER(S): 1848 * [I] HWND : window handle 1849 * [I] RECT : selection rectangle 2135 * Selects items based on view coordinates. 2136 * 2137 * PARAMETER(S): 2138 * [I] HWND : window handle 2139 * [I] RECT : selection rectangle 1850 2140 * 1851 2141 * RETURN: … … 1854 2144 static VOID LISTVIEW_SetSelectionRect(HWND hwnd, RECT rcSelRect) 1855 2145 { 1856 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2146 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1857 2147 POINT ptItem; 1858 2148 INT i; 1859 LVITEM Aitem;1860 1861 ZeroMemory(&item,sizeof( LVITEMA));2149 LVITEMW item; 2150 2151 ZeroMemory(&item,sizeof(item)); 1862 2152 item.stateMask = LVIS_SELECTED; 1863 2153 … … 1867 2157 1868 2158 if (PtInRect(&rcSelRect, ptItem) != FALSE) 1869 {1870 2159 item.state = LVIS_SELECTED; 1871 LISTVIEW_SetItemState(hwnd,i,&item);1872 }1873 2160 else 1874 {1875 2161 item.state = 0; 1876 LISTVIEW_SetItemState(hwnd,i,&item); 1877 } 2162 LISTVIEW_SetItemState(hwnd,i,&item); 1878 2163 } 1879 2164 } … … 1882 2167 * DESCRIPTION: 1883 2168 * Sets a single group selection. 1884 * 1885 * PARAMETER(S): 1886 * [I] HWND : window handle 1887 * [I] INT : item index 1888 * 1889 * RETURN: 1890 * None 2169 * 2170 * PARAMETER(S): 2171 * [I] HWND : window handle 2172 * [I] INT : item index 2173 * 2174 * RETURN: 2175 * None 1891 2176 */ 1892 2177 static VOID LISTVIEW_SetGroupSelection(HWND hwnd, INT nItem) 1893 2178 { 1894 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);1895 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;1896 LVITEM Aitem;1897 1898 ZeroMemory(&item,sizeof( LVITEMA));2179 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 2180 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 2181 LVITEMW item; 2182 2183 ZeroMemory(&item,sizeof(item)); 1899 2184 item.stateMask = LVIS_SELECTED; 1900 2185 … … 1917 2202 { 1918 2203 if ((i < nFirst) || (i > nLast)) 1919 {1920 2204 item.state = 0; 1921 LISTVIEW_SetItemState(hwnd,i,&item);1922 }1923 2205 else 1924 {1925 2206 item.state = LVIS_SELECTED; 1926 LISTVIEW_SetItemState(hwnd,i,&item); 1927 } 2207 LISTVIEW_SetItemState(hwnd,i,&item); 1928 2208 } 1929 2209 } 1930 2210 else 1931 2211 { 1932 POINT ptItem;1933 POINT ptSelMark;2212 RECT rcItem; 2213 RECT rcSelMark; 1934 2214 RECT rcSel; 1935 LISTVIEW_GetItem Position(hwnd, nItem, &ptItem);1936 LISTVIEW_GetItem Position(hwnd, infoPtr->nSelectionMark, &ptSelMark);1937 rcSel.left = min( ptSelMark.x, ptItem.x);1938 rcSel.top = min( ptSelMark.y, ptItem.y);1939 rcSel.right = max( ptSelMark.x, ptItem.x) + infoPtr->nItemWidth;1940 rcSel.bottom = max( ptSelMark.y, ptItem.y) + infoPtr->nItemHeight;2215 LISTVIEW_GetItemBoundBox(hwnd, nItem, &rcItem); 2216 LISTVIEW_GetItemBoundBox(hwnd, infoPtr->nSelectionMark, &rcSelMark); 2217 rcSel.left = min(rcSelMark.left, rcItem.left); 2218 rcSel.top = min(rcSelMark.top, rcItem.top); 2219 rcSel.right = max(rcSelMark.right, rcItem.right); 2220 rcSel.bottom = max(rcSelMark.bottom, rcItem.bottom); 1941 2221 LISTVIEW_SetSelectionRect(hwnd, rcSel); 2222 TRACE("item %d (%d,%d)-(%d,%d), mark %d (%d,%d)-(%d,%d), sel (%d,%d)-(%d,%d)\n", 2223 nItem, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom, 2224 infoPtr->nSelectionMark, 2225 rcSelMark.left, rcSelMark.top, rcSelMark.right, rcSelMark.bottom, 2226 rcSel.left, rcSel.top, rcSel.right, rcSel.bottom); 2227 1942 2228 } 1943 2229 … … 1948 2234 * DESCRIPTION: 1949 2235 * Manages the item focus. 1950 * 1951 * PARAMETER(S): 1952 * [I] HWND : window handle 1953 * [I] INT : item index 2236 * 2237 * PARAMETER(S): 2238 * [I] HWND : window handle 2239 * [I] INT : item index 1954 2240 * 1955 2241 * RETURN: … … 1959 2245 static BOOL LISTVIEW_SetItemFocus(HWND hwnd, INT nItem) 1960 2246 { 1961 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2247 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 1962 2248 BOOL bResult = FALSE; 1963 LVITEM AlvItem;2249 LVITEMW lvItem; 1964 2250 1965 2251 if (infoPtr->nFocusedItem != nItem) … … 1970 2256 bResult = TRUE; 1971 2257 infoPtr->nFocusedItem = -1; 1972 ZeroMemory(&lvItem, sizeof( LVITEMA));2258 ZeroMemory(&lvItem, sizeof(lvItem)); 1973 2259 lvItem.stateMask = LVIS_FOCUSED; 1974 ListView_SetItemState(hwnd, oldFocus, &lvItem); 2260 ListView_SetItemState(hwnd, oldFocus, &lvItem); 1975 2261 1976 2262 } … … 1983 2269 ListView_EnsureVisible(hwnd, nItem, FALSE); 1984 2270 } 1985 1986 return bResult; 2271 2272 return bResult; 1987 2273 } 1988 2274 … … 1990 2276 * DESCRIPTION: 1991 2277 * Sets a single selection. 1992 * 1993 * PARAMETER(S): 1994 * [I] HWND : window handle 1995 * [I] INT : item index 2278 * 2279 * PARAMETER(S): 2280 * [I] HWND : window handle 2281 * [I] INT : item index 1996 2282 * 1997 2283 * RETURN: … … 2000 2286 static VOID LISTVIEW_SetSelection(HWND hwnd, INT nItem) 2001 2287 { 2002 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2003 LVITEM AlvItem;2004 2005 ZeroMemory(&lvItem, sizeof( LVITEMA));2288 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 2289 LVITEMW lvItem; 2290 2291 ZeroMemory(&lvItem, sizeof(lvItem)); 2006 2292 lvItem.stateMask = LVIS_FOCUSED; 2007 ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem); 2293 ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem); 2008 2294 2009 2295 LISTVIEW_RemoveAllSelections(hwnd); … … 2020 2306 * DESCRIPTION: 2021 2307 * Set selection(s) with keyboard. 2022 * 2023 * PARAMETER(S): 2024 * [I] HWND : window handle 2025 * [I] INT : item index 2308 * 2309 * PARAMETER(S): 2310 * [I] HWND : window handle 2311 * [I] INT : item index 2026 2312 * 2027 2313 * RETURN: … … 2031 2317 static BOOL LISTVIEW_KeySelection(HWND hwnd, INT nItem) 2032 2318 { 2033 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2034 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);2319 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 2320 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 2035 2321 WORD wShift = HIWORD(GetKeyState(VK_SHIFT)); 2036 2322 WORD wCtrl = HIWORD(GetKeyState(VK_CONTROL)); … … 2042 2328 { 2043 2329 bResult = TRUE; 2044 LISTVIEW_SetSelection(hwnd, nItem); 2330 LISTVIEW_SetSelection(hwnd, nItem); 2045 2331 ListView_EnsureVisible(hwnd, nItem, FALSE); 2046 2332 } … … 2050 2336 { 2051 2337 bResult = TRUE; 2052 LISTVIEW_SetGroupSelection(hwnd, nItem); 2338 LISTVIEW_SetGroupSelection(hwnd, nItem); 2053 2339 } 2054 2340 else if (wCtrl) … … 2059 2345 { 2060 2346 bResult = TRUE; 2061 LISTVIEW_SetSelection(hwnd, nItem); 2347 LISTVIEW_SetSelection(hwnd, nItem); 2062 2348 ListView_EnsureVisible(hwnd, nItem, FALSE); 2063 2349 } … … 2084 2370 * LVS_EX_TRACKSELECT: An item is automatically selected when the cursor remains 2085 2371 * over the item for a certain period of time. 2086 * 2372 * 2087 2373 */ 2088 2374 static LRESULT LISTVIEW_MouseHover(HWND hwnd, WPARAM wParam, LPARAM lParam) 2089 2375 { 2090 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2376 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 2091 2377 POINT pt; 2092 2378 … … 2116 2402 static LRESULT LISTVIEW_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam) 2117 2403 { 2118 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2404 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 2119 2405 TRACKMOUSEEVENT trackinfo; 2120 2406 2121 2407 /* see if we are supposed to be tracking mouse hovering */ 2122 2408 if(infoPtr->dwExStyle & LVS_EX_TRACKSELECT) { … … 2137 2423 } 2138 2424 } 2139 2425 2140 2426 return 0; 2141 2427 } … … 2144 2430 * DESCRIPTION: 2145 2431 * Selects an item based on coordinates. 2146 * 2432 * 2147 2433 * PARAMETER(S): 2148 2434 * [I] HWND : window handle … … 2155 2441 static LRESULT LISTVIEW_MouseSelection(HWND hwnd, POINT pt) 2156 2442 { 2157 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2443 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 2158 2444 RECT rcItem; 2159 2445 INT i,topindex,bottomindex; 2160 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);2446 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 2161 2447 UINT uView = lStyle & LVS_TYPEMASK; 2162 2448 … … 2164 2450 if (uView == LVS_REPORT) 2165 2451 { 2166 bottomindex = topindex + LISTVIEW_GetCountPerColumn(hwnd) + 1; 2452 bottomindex = topindex + LISTVIEW_GetCountPerColumn(hwnd) + 1; 2167 2453 bottomindex = min(bottomindex,GETITEMCOUNT(infoPtr)); 2168 2454 } … … 2172 2458 } 2173 2459 2174 for (i = topindex; i < bottomindex; i++) 2460 for (i = topindex; i < bottomindex; i++) 2175 2461 { 2176 2462 rcItem.left = LVIR_SELECTBOUNDS; … … 2190 2476 * DESCRIPTION: 2191 2477 * Removes a column. 2192 * 2478 * 2193 2479 * PARAMETER(S): 2194 2480 * [IO] HDPA : dynamic pointer array handle … … 2216 2502 } 2217 2503 } 2218 2504 2219 2505 return bResult; 2220 2506 } … … 2223 2509 * DESCRIPTION: 2224 2510 * Removes a subitem at a given position. 2225 * 2511 * 2226 2512 * PARAMETER(S): 2227 2513 * [IO] HDPA : dynamic pointer array handle … … 2245 2531 { 2246 2532 /* free string */ 2247 if ((lpSubItem->pszText != NULL) && 2248 (lpSubItem->pszText != LPSTR_TEXTCALLBACKA)) 2249 { 2533 if (is_textW(lpSubItem->pszText)) 2250 2534 COMCTL32_Free(lpSubItem->pszText); 2251 } 2252 2535 2253 2536 /* free item */ 2254 2537 COMCTL32_Free(lpSubItem); … … 2256 2539 /* free dpa memory */ 2257 2540 if (DPA_DeletePtr(hdpaSubItems, i) == NULL) 2258 {2259 2541 return FALSE; 2260 }2261 2542 } 2262 2543 else if (lpSubItem->iSubItem > nSubItem) 2263 {2264 2544 return TRUE; 2265 } 2266 } 2267 } 2268 2545 } 2546 } 2547 2269 2548 return TRUE; 2270 2549 } … … 2273 2552 * DESCRIPTION: 2274 2553 * Compares the item information. 2275 * 2276 * PARAMETER(S): 2277 * [I] LISTVIEW_ITEM *: destination item 2554 * 2555 * PARAMETER(S): 2556 * [I] LISTVIEW_ITEM *: destination item 2278 2557 * [I] LPLVITEM : source item 2558 * [I] isW : TRUE if lpLVItem is Unicode, FALSE it it's ANSI 2279 2559 * 2280 2560 * RETURN: … … 2283 2563 */ 2284 2564 #ifdef __WIN32OS2__ 2285 static UINT LISTVIEW_GetItemChanges (LISTVIEW_ITEM *lpItem, LPLVITEMA lpLVItem, DWORD lStyle)2565 static UINT LISTVIEW_GetItemChangesT(LISTVIEW_ITEM *lpItem, LPLVITEMW lpLVItem, BOOL isW, DWORD lStyle) 2286 2566 #else 2287 static UINT LISTVIEW_GetItemChanges (LISTVIEW_ITEM *lpItem, LPLVITEMA lpLVItem)2567 static UINT LISTVIEW_GetItemChangesT(LISTVIEW_ITEM *lpItem, LPLVITEMW lpLVItem, BOOL isW) 2288 2568 #endif 2289 2569 { … … 2294 2574 if (lpLVItem->mask & LVIF_STATE) 2295 2575 { 2296 if ((lpItem->state & lpLVItem->stateMask) != 2576 if ((lpItem->state & lpLVItem->stateMask) != 2297 2577 (lpLVItem->state & lpLVItem->stateMask)) 2578 uChanged |= LVIF_STATE; 2579 } 2580 2581 if (lpLVItem->mask & LVIF_IMAGE) 2582 { 2583 if (lpItem->iImage != lpLVItem->iImage) 2584 uChanged |= LVIF_IMAGE; 2585 } 2586 2587 if (lpLVItem->mask & LVIF_PARAM) 2588 { 2589 if (lpItem->lParam != lpLVItem->lParam) 2590 uChanged |= LVIF_PARAM; 2591 } 2592 2593 if (lpLVItem->mask & LVIF_INDENT) 2594 { 2595 if (lpItem->iIndent != lpLVItem->iIndent) 2596 uChanged |= LVIF_INDENT; 2597 } 2598 2599 if (lpLVItem->mask & LVIF_TEXT) 2600 { 2601 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKW) 2298 2602 { 2299 uChanged |= LVIF_STATE; 2300 } 2301 } 2302 2303 if (lpLVItem->mask & LVIF_IMAGE) 2304 { 2305 if (lpItem->iImage != lpLVItem->iImage) 2306 { 2307 uChanged |= LVIF_IMAGE; 2308 } 2309 } 2310 2311 if (lpLVItem->mask & LVIF_PARAM) 2312 { 2313 if (lpItem->lParam != lpLVItem->lParam) 2314 { 2315 uChanged |= LVIF_PARAM; 2316 } 2317 } 2318 2319 if (lpLVItem->mask & LVIF_INDENT) 2320 { 2321 if (lpItem->iIndent != lpLVItem->iIndent) 2322 { 2323 uChanged |= LVIF_INDENT; 2324 } 2325 } 2326 2327 if (lpLVItem->mask & LVIF_TEXT) 2328 { 2329 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 2330 { 2331 if (lpItem->pszText != LPSTR_TEXTCALLBACKA) 2332 { 2333 uChanged |= LVIF_TEXT; 2334 } 2603 if (lpItem->pszText != LPSTR_TEXTCALLBACKW) 2604 uChanged |= LVIF_TEXT; 2335 2605 } 2336 2606 else 2337 2607 { 2338 if (lpItem->pszText == LPSTR_TEXTCALLBACK A)2608 if (lpItem->pszText == LPSTR_TEXTCALLBACKW) 2339 2609 { 2340 uChanged |= LVIF_TEXT; 2610 uChanged |= LVIF_TEXT; 2341 2611 } 2342 2343 2344 2345 2612 else 2613 { 2614 if (lpLVItem->pszText) 2615 { 2346 2616 #ifdef __WIN32OS2__ 2347 2617 if(lStyle & LVS_OWNERDRAWFIXED) { … … 2355 2625 else 2356 2626 #endif 2357 if (lpItem->pszText) 2358 { 2359 if (strcmp(lpLVItem->pszText, lpItem->pszText) != 0) 2360 { 2361 uChanged |= LVIF_TEXT; 2362 } 2363 } 2364 else 2365 { 2366 uChanged |= LVIF_TEXT; 2367 } 2627 if (lpItem->pszText) 2628 { 2629 LPWSTR pszText = textdupTtoW(lpLVItem->pszText, isW); 2630 if (pszText && strcmpW(pszText, lpItem->pszText)) 2631 uChanged |= LVIF_TEXT; 2632 textfreeT(pszText, isW); 2633 } 2634 else 2635 { 2636 uChanged |= LVIF_TEXT; 2637 } 2638 } 2639 else 2640 { 2641 if (lpItem->pszText) 2642 uChanged |= LVIF_TEXT; 2643 } 2644 } 2368 2645 } 2369 else2370 {2371 if (lpItem->pszText)2372 {2373 uChanged |= LVIF_TEXT;2374 }2375 }2376 }2377 }2378 2646 } 2379 2647 } … … 2384 2652 * DESCRIPTION: 2385 2653 * Initializes item attributes. 2386 * 2387 * PARAMETER(S): 2388 * [I] HWND : window handle 2389 * [O] LISTVIEW_ITEM *: destination item 2390 * [I] LPLVITEM : source item 2654 * 2655 * PARAMETER(S): 2656 * [I] HWND : window handle 2657 * [O] LISTVIEW_ITEM *: destination item 2658 * [I] LPLVITEM : source item 2659 * [I] isW : TRUE if lpLVItem is Unicode, FALSE if it's ANSI 2391 2660 * 2392 2661 * RETURN: … … 2394 2663 * FAILURE : FALSE 2395 2664 */ 2396 static BOOL LISTVIEW_InitItem (HWND hwnd, LISTVIEW_ITEM *lpItem,2397 LPLVITEM A lpLVItem)2398 { 2399 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);2665 static BOOL LISTVIEW_InitItemT(HWND hwnd, LISTVIEW_ITEM *lpItem, 2666 LPLVITEMW lpLVItem, BOOL isW) 2667 { 2668 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 2400 2669 BOOL bResult = FALSE; 2401 2670 … … 2403 2672 { 2404 2673 bResult = TRUE; 2405 2674 2406 2675 if (lpLVItem->mask & LVIF_STATE) 2407 2676 { … … 2409 2678 lpItem->state |= (lpLVItem->state & lpLVItem->stateMask); 2410 2679 } 2411 2680 2412 2681 if (lpLVItem->mask & LVIF_IMAGE) 2413 {2414 2682 lpItem->iImage = lpLVItem->iImage; 2415 } 2416 2683 2417 2684 if (lpLVItem->mask & LVIF_PARAM) 2418 {2419 2685 lpItem->lParam = lpLVItem->lParam; 2420 } 2421 2686 2422 2687 if (lpLVItem->mask & LVIF_INDENT) 2423 {2424 2688 lpItem->iIndent = lpLVItem->iIndent; 2425 } 2426 2427 if (lpLVItem->mask & LVIF_TEXT) 2428 { 2429 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 2689 2690 if (lpLVItem->mask & LVIF_TEXT) 2691 { 2692 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKW) 2430 2693 { 2431 2694 if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING)) 2432 {2433 2695 return FALSE; 2434 } 2435 2436 if ((lpItem->pszText != NULL) && 2437 (lpItem->pszText != LPSTR_TEXTCALLBACKA)) 2438 { 2696 2697 if (is_textW(lpItem->pszText)) 2439 2698 COMCTL32_Free(lpItem->pszText); 2440 } 2441 2442 lpItem->pszText = LPSTR_TEXTCALLBACKA; 2699 2700 lpItem->pszText = LPSTR_TEXTCALLBACKW; 2443 2701 } 2444 else 2445 { 2446 if (lpItem->pszText == LPSTR_TEXTCALLBACKA) 2447 { 2448 lpItem->pszText = NULL; 2449 } 2450 2451 bResult = Str_SetPtrA(&lpItem->pszText, lpLVItem->pszText); 2452 } 2702 else 2703 bResult = textsetptrT(&lpItem->pszText, lpLVItem->pszText, isW); 2453 2704 } 2454 2705 } … … 2468 2719 * [O] LISTVIEW_SUBITEM *: destination subitem 2469 2720 * [I] LPLVITEM : source subitem 2721 * [I] isW : TRUE if lpLVItem is Unicode, FALSE if it's ANSI 2470 2722 * 2471 2723 * RETURN: … … 2473 2725 * FAILURE : FALSE 2474 2726 */ 2475 static BOOL LISTVIEW_InitSubItem (HWND hwnd, LISTVIEW_SUBITEM *lpSubItem,2476 LPLVITEMA lpLVItem)2477 { 2478 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);2727 static BOOL LISTVIEW_InitSubItemT(HWND hwnd, LISTVIEW_SUBITEM *lpSubItem, 2728 LPLVITEMW lpLVItem, BOOL isW) 2729 { 2730 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 2479 2731 BOOL bResult = FALSE; 2480 2732 2733 TRACE("(hwnd=%x, lpSubItem=%p, lpLVItem=%s, isW=%d)\n", 2734 hwnd, lpSubItem, debuglvitem_t(lpLVItem, isW), isW); 2735 2481 2736 if ((lpSubItem != NULL) && (lpLVItem != NULL)) 2482 2737 { … … 2488 2743 2489 2744 if (lpLVItem->mask & LVIF_IMAGE) 2745 lpSubItem->iImage = lpLVItem->iImage; 2746 2747 if (lpLVItem->mask & LVIF_TEXT) 2490 2748 { 2491 lpSubItem->iImage = lpLVItem->iImage; 2492 } 2493 2494 if (lpLVItem->mask & LVIF_TEXT) 2495 { 2496 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA) 2749 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKW) 2497 2750 { 2498 2751 if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING)) 2499 {2500 2752 return FALSE; 2501 } 2502 2503 if ((lpSubItem->pszText != NULL) && 2504 (lpSubItem->pszText != LPSTR_TEXTCALLBACKA)) 2505 { 2753 2754 if (is_textW(lpSubItem->pszText)) 2506 2755 COMCTL32_Free(lpSubItem->pszText); 2507 } 2508 2509 lpSubItem->pszText = LPSTR_TEXTCALLBACKA; 2756 2757 lpSubItem->pszText = LPSTR_TEXTCALLBACKW; 2510 2758 } 2511 else 2512 { 2513 if (lpSubItem->pszText == LPSTR_TEXTCALLBACKA) 2514 { 2515 lpSubItem->pszText = NULL; 2516 } 2517 #ifdef __WIN32OS2__ 2518 else { 2519 //No need to change anything if text is the same 2520 if(lpSubItem->pszText && !strcmp(lpSubItem->pszText, lpLVItem->pszText)) { 2521 return FALSE; 2522 } 2523 } 2524 #endif 2525 bResult = Str_SetPtrA(&lpSubItem->pszText, lpLVItem->pszText); 2526 } 2759 else 2760 bResult = textsetptrT(&lpSubItem->pszText, lpLVItem->pszText, isW); 2527 2761 } 2528 2762 } … … 2535 2769 * DESCRIPTION: 2536 2770 * Adds a subitem at a given position (column index). 2537 * 2538 * PARAMETER(S): 2539 * [I] HWND : window handle 2540 * [I] LPLVITEM : new subitem atttributes 2771 * 2772 * PARAMETER(S): 2773 * [I] HWND : window handle 2774 * [I] LPLVITEM : new subitem atttributes 2775 * [I] isW : TRUE if lpLVItem is Unicode, FALSE if it's ANSI 2541 2776 * 2542 2777 * RETURN: … … 2544 2779 * FAILURE : FALSE 2545 2780 */ 2546 static BOOL LISTVIEW_AddSubItem (HWND hwnd, LPLVITEMA lpLVItem)2547 { 2548 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2781 static BOOL LISTVIEW_AddSubItemT(HWND hwnd, LPLVITEMW lpLVItem, BOOL isW) 2782 { 2783 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 2549 2784 LISTVIEW_SUBITEM *lpSubItem = NULL; 2550 2785 BOOL bResult = FALSE; 2551 2786 HDPA hdpaSubItems; 2552 2787 INT nPosition, nItem; 2553 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 2554 2788 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 2789 2790 TRACE("(hwnd=%x, lpLVItem=%s, isW=%d)\n", hwnd, debuglvitem_t(lpLVItem, isW), isW); 2791 2555 2792 if (lStyle & LVS_OWNERDATA) 2556 2793 return FALSE; … … 2564 2801 if (lpSubItem != NULL) 2565 2802 { 2566 2567 if (LISTVIEW_InitSubItem (hwnd, lpSubItem, lpLVItem) != FALSE)2803 ZeroMemory(lpSubItem, sizeof(LISTVIEW_SUBITEM)); 2804 if (LISTVIEW_InitSubItemT(hwnd, lpSubItem, lpLVItem, isW)) 2568 2805 { 2569 nPosition = LISTVIEW_FindInsertPosition(hdpaSubItems, 2806 nPosition = LISTVIEW_FindInsertPosition(hdpaSubItems, 2570 2807 lpSubItem->iSubItem); 2571 2808 nItem = DPA_InsertPtr(hdpaSubItems, nPosition, lpSubItem); 2572 if (nItem != -1) 2573 { 2574 bResult = TRUE; 2575 } 2809 if (nItem != -1) bResult = TRUE; 2576 2810 } 2577 2811 } 2578 2812 } 2579 2813 } 2580 2581 /* cleanup if unsuccessful */ 2582 if ((bResult == FALSE) && (lpSubItem != NULL)) 2583 { 2584 COMCTL32_Free(lpSubItem); 2585 } 2586 2814 2815 /* cleanup if unsuccessful */ 2816 if (!bResult && lpSubItem) COMCTL32_Free(lpSubItem); 2817 2587 2818 return bResult; 2588 2819 } … … 2591 2822 * DESCRIPTION: 2592 2823 * Finds the dpa insert position (array index). 2593 * 2824 * 2594 2825 * PARAMETER(S): 2595 2826 * [I] HWND : window handle … … 2608 2839 { 2609 2840 lpSubItem = (LISTVIEW_SUBITEM *)DPA_GetPtr(hdpaSubItems, i); 2610 if (lpSubItem != NULL) 2611 { 2612 if (lpSubItem->iSubItem > nSubItem) 2613 { 2614 return i; 2615 } 2616 } 2841 if (lpSubItem && lpSubItem->iSubItem > nSubItem) 2842 return i; 2617 2843 } 2618 2844 … … 2623 2849 * DESCRIPTION: 2624 2850 * Retrieves a listview subitem at a given position (column index). 2625 * 2851 * 2626 2852 * PARAMETER(S): 2627 2853 * [I] HWND : window handle … … 2643 2869 { 2644 2870 if (lpSubItem->iSubItem == nSubItem) 2645 {2646 2871 return lpSubItem; 2647 }2648 2872 else if (lpSubItem->iSubItem > nSubItem) 2649 {2650 2873 return NULL; 2651 } 2652 } 2653 } 2654 2874 } 2875 } 2876 2655 2877 return NULL; 2656 2878 } … … 2659 2881 * DESCRIPTION: 2660 2882 * Sets item attributes. 2661 * 2662 * PARAMETER(S): 2663 * [I] HWND : window handle 2664 * [I] LPLVITEM : new item atttributes 2883 * 2884 * PARAMETER(S): 2885 * [I] HWND : window handle 2886 * [I] LPLVITEM : new item atttributes 2887 * [I] isW : TRUE if lpLVItem is Unicode, FALSE if it's ANSI 2665 2888 * 2666 2889 * RETURN: … … 2668 2891 * FAILURE : FALSE 2669 2892 */ 2670 static BOOL LISTVIEW_Set Item(HWND hwnd, LPLVITEMA lpLVItem)2671 { 2672 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);2893 static BOOL LISTVIEW_SetMainItemT(HWND hwnd, LPLVITEMW lpLVItem, BOOL isW) 2894 { 2895 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 2673 2896 BOOL bResult = FALSE; 2674 2897 HDPA hdpaSubItems; 2675 2898 LISTVIEW_ITEM *lpItem; 2676 2899 NMLISTVIEW nmlv; 2677 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID); 2678 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 2900 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 2679 2901 UINT uChanged; 2680 2902 UINT uView = lStyle & LVS_TYPEMASK; … … 2682 2904 RECT rcItem; 2683 2905 2906 TRACE("(hwnd=%x, lpLVItem=%s, isW=%d)\n", hwnd, debuglvitem_t(lpLVItem, isW), isW); 2907 2684 2908 if (lStyle & LVS_OWNERDATA) 2685 2909 { 2686 2910 if ((lpLVItem->iSubItem == 0)&&(lpLVItem->mask == LVIF_STATE)) 2687 2911 { 2688 LVITEM Aitm;2689 2690 ZeroMemory(&itm, sizeof(LVITEMA));2912 LVITEMW itm; 2913 2914 ZeroMemory(&itm, sizeof(itm)); 2691 2915 itm.mask = LVIF_STATE | LVIF_PARAM; 2692 2916 itm.stateMask = LVIS_FOCUSED | LVIS_SELECTED; 2693 2917 itm.iItem = lpLVItem->iItem; 2694 2918 itm.iSubItem = 0; 2695 ListView_GetItem A(hwnd,&itm);2696 2919 ListView_GetItemW(hwnd, &itm); 2920 2697 2921 2698 2922 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); 2699 nmlv.hdr.hwndFrom = hwnd;2700 nmlv.hdr.idFrom = lCtrlId;2701 nmlv.hdr.code = LVN_ITEMCHANGING;2702 2923 nmlv.uNewState = lpLVItem->state; 2703 2924 nmlv.uOldState = itm.state; … … 2706 2927 nmlv.iItem = lpLVItem->iItem; 2707 2928 2708 if ((itm.state & lpLVItem->stateMask) != 2929 if ((itm.state & lpLVItem->stateMask) != 2709 2930 (lpLVItem->state & lpLVItem->stateMask)) 2710 2931 { 2711 2932 /* send LVN_ITEMCHANGING notification */ 2712 if (! ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv))2933 if (!listview_notify(hwnd, LVN_ITEMCHANGING, &nmlv)) 2713 2934 { 2714 2935 if (lpLVItem->stateMask & LVIS_FOCUSED) … … 2723 2944 if (lpLVItem->state & LVIS_SELECTED) 2724 2945 { 2725 if (lStyle & LVS_SINGLESEL) 2726 { 2727 LISTVIEW_RemoveAllSelections(hwnd); 2728 } 2946 if (lStyle & LVS_SINGLESEL) LISTVIEW_RemoveAllSelections(hwnd); 2729 2947 LISTVIEW_AddSelectionRange(hwnd,lpLVItem->iItem,lpLVItem->iItem); 2730 2948 } … … 2734 2952 } 2735 2953 2736 nmlv.hdr.code = LVN_ITEMCHANGED; 2737 2738 ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv); 2739 2740 rcItem.left = LVIR_BOUNDS; 2741 LISTVIEW_GetItemRect(hwnd, lpLVItem->iItem, &rcItem); 2954 listview_notify(hwnd, LVN_ITEMCHANGED, &nmlv); 2955 2956 rcItem.left = LVIR_BOUNDS; 2957 LISTVIEW_GetItemRect(hwnd, lpLVItem->iItem, &rcItem); 2742 2958 #ifdef __WIN32OS2__ 2743 if(lStyle & LVS_OWNERDRAWFIXED && rcItem.left == REPORT_MARGINX) {2744 rcItem.left = 0;2745 }2959 if(lStyle & LVS_OWNERDRAWFIXED && rcItem.left == REPORT_MARGINX) { 2960 rcItem.left = 0; 2961 } 2746 2962 #endif 2747 2963 InvalidateRect(hwnd, &rcItem, TRUE); 2748 2964 } 2749 2965 } … … 2764 2980 { 2765 2981 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); 2766 nmlv.hdr.hwndFrom = hwnd;2767 nmlv.hdr.idFrom = lCtrlId;2768 nmlv.hdr.code = LVN_ITEMCHANGING;2769 2982 nmlv.lParam = lpItem->lParam; 2770 2983 #ifdef __WIN32OS2__ 2771 uChanged = LISTVIEW_GetItemChanges (lpItem, lpLVItem, lStyle);2984 uChanged = LISTVIEW_GetItemChangesT(lpItem, lpLVItem, isW, lStyle); 2772 2985 #else 2773 uChanged = LISTVIEW_GetItemChanges (lpItem, lpLVItem);2986 uChanged = LISTVIEW_GetItemChangesT(lpItem, lpLVItem, isW); 2774 2987 #endif 2775 2988 if (uChanged != 0) … … 2789 3002 */ 2790 3003 if (lStyle & LVS_SINGLESEL) 2791 {2792 3004 LISTVIEW_RemoveAllSelections(hwnd); 2793 } 2794 2795 LISTVIEW_AddSelectionRange(hwnd,lpLVItem->iItem, 3005 3006 LISTVIEW_AddSelectionRange(hwnd,lpLVItem->iItem, 2796 3007 lpLVItem->iItem); 2797 3008 } … … 2801 3012 lpLVItem->iItem); 2802 3013 } 2803 3014 if (nmlv.uNewState & LVIS_FOCUSED) 2804 3015 { 2805 3016 /* 2806 3017 * This is a fun hoop to jump to try to catch if 2807 3018 * the user is calling us directly to call focus or if 2808 * this function is being called as a result of a 2809 * SetItemFocus call. 3019 * this function is being called as a result of a 3020 * SetItemFocus call. 2810 3021 */ 2811 3022 #ifdef __WIN32OS2__ … … 2820 3031 LISTVIEW_SetItemFocus(hwnd, lpLVItem->iItem); 2821 3032 #endif 2822 } 3033 } 2823 3034 } 2824 3035 2825 3036 nmlv.uChanged = uChanged; 2826 3037 nmlv.iItem = lpLVItem->iItem; 2827 3038 nmlv.lParam = lpItem->lParam; 2828 3039 /* send LVN_ITEMCHANGING notification */ 2829 ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);3040 listview_notify(hwnd, LVN_ITEMCHANGING, &nmlv); 2830 3041 2831 3042 /* copy information */ 2832 bResult = LISTVIEW_InitItem (hwnd, lpItem, lpLVItem);3043 bResult = LISTVIEW_InitItemT(hwnd, lpItem, lpLVItem, isW); 2833 3044 2834 3045 /* if LVS_LIST or LVS_SMALLICON, update the width of the items … … 2836 3047 if((uView == LVS_LIST) || (uView == LVS_SMALLICON)) 2837 3048 { 2838 item_width = LISTVIEW_GetStringWidth A(hwnd, lpItem->pszText);3049 item_width = LISTVIEW_GetStringWidthT(hwnd, lpItem->pszText, TRUE); 2839 3050 2840 3051 if(item_width > infoPtr->nItemWidth) … … 2843 3054 2844 3055 /* send LVN_ITEMCHANGED notification */ 2845 nmlv.hdr.code = LVN_ITEMCHANGED; 2846 ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv); 3056 listview_notify(hwnd, LVN_ITEMCHANGED, &nmlv); 2847 3057 } 2848 3058 else … … 2850 3060 bResult = TRUE; 2851 3061 } 2852 3062 2853 3063 if (uChanged) 2854 3064 { 2855 3065 rcItem.left = LVIR_BOUNDS; 2856 3066 LISTVIEW_GetItemRect(hwnd, lpLVItem->iItem, &rcItem); 2857 3067 #ifdef __WIN32OS2__ 2858 3068 if(lStyle & LVS_OWNERDRAWFIXED && rcItem.left == REPORT_MARGINX) { … … 2873 3083 * DESCRIPTION: 2874 3084 * Sets subitem attributes. 2875 * 2876 * PARAMETER(S): 2877 * [I] HWND : window handle 2878 * [I] LPLVITEM : new subitem atttributes 3085 * 3086 * PARAMETER(S): 3087 * [I] HWND : window handle 3088 * [I] LPLVITEM : new subitem atttributes 3089 * [I] isW : TRUE if lpLVItem is Unicode, FALSE if it's ANSI 2879 3090 * 2880 3091 * RETURN: … … 2882 3093 * FAILURE : FALSE 2883 3094 */ 2884 static BOOL LISTVIEW_SetSubItem(HWND hwnd, LPLVITEMA lpLVItem) 2885 { 2886 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3095 static BOOL LISTVIEW_SetSubItemT(HWND hwnd, LPLVITEMW lpLVItem, BOOL isW) 3096 { 3097 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 3098 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 2887 3099 BOOL bResult = FALSE; 2888 3100 HDPA hdpaSubItems; 2889 3101 LISTVIEW_SUBITEM *lpSubItem; 2890 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);2891 3102 RECT rcItem; 2892 3103 3104 TRACE("(hwnd=%x, lpLVItem=%s, isW=%d)\n", hwnd, debuglvitem_t(lpLVItem, isW), isW); 3105 2893 3106 if (lStyle & LVS_OWNERDATA) 2894 3107 return FALSE; … … 2906 3119 lpSubItem = LISTVIEW_GetSubItem(hdpaSubItems, lpLVItem->iSubItem); 2907 3120 if (lpSubItem != NULL) 2908 { 2909 bResult = LISTVIEW_InitSubItem(hwnd, lpSubItem, lpLVItem); 2910 } 3121 bResult = LISTVIEW_InitSubItemT(hwnd, lpSubItem, lpLVItem, isW); 2911 3122 else 2912 { 2913 bResult = LISTVIEW_AddSubItem(hwnd, lpLVItem); 2914 } 2915 3123 bResult = LISTVIEW_AddSubItemT(hwnd, lpLVItem, isW); 2916 3124 #ifdef __WIN32OS2__ 2917 3125 if(bResult) { 2918 3126 #endif 2919 3127 rcItem.left = LVIR_BOUNDS; 2920 2921 3128 LISTVIEW_GetItemRect(hwnd, lpLVItem->iItem, &rcItem); 3129 InvalidateRect(hwnd, &rcItem, FALSE); 2922 3130 #ifdef __WIN32OS2__ 2923 3131 } 2924 3132 #endif 2925 } 3133 } 2926 3134 } 2927 3135 } … … 2933 3141 /*** 2934 3142 * DESCRIPTION: 3143 * Sets item attributes. 3144 * 3145 * PARAMETER(S): 3146 * [I] HWND : window handle 3147 * [I] LPLVITEM : new item atttributes 3148 * [I] isW : TRUE if lpLVItem is Unicode, FALSE if it's ANSI 3149 * 3150 * RETURN: 3151 * SUCCESS : TRUE 3152 * FAILURE : FALSE 3153 */ 3154 static BOOL LISTVIEW_SetItemT(HWND hwnd, LPLVITEMW lpLVItem, BOOL isW) 3155 { 3156 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 3157 3158 if (!lpLVItem || lpLVItem->iItem < 0 || 3159 lpLVItem->iItem>=GETITEMCOUNT(infoPtr)) 3160 return FALSE; 3161 if (lpLVItem->iSubItem == 0) 3162 return LISTVIEW_SetMainItemT(hwnd, lpLVItem, isW); 3163 else 3164 return LISTVIEW_SetSubItemT(hwnd, lpLVItem, isW); 3165 } 3166 3167 /*** 3168 * DESCRIPTION: 2935 3169 * Retrieves the index of the item at coordinate (0, 0) of the client area. 2936 * 3170 * 2937 3171 * PARAMETER(S): 2938 3172 * [I] HWND : window handle … … 2943 3177 static INT LISTVIEW_GetTopIndex(HWND hwnd) 2944 3178 { 2945 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);3179 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 2946 3180 UINT uView = lStyle & LVS_TYPEMASK; 2947 3181 INT nItem = 0; … … 2951 3185 scrollInfo.cbSize = sizeof(SCROLLINFO); 2952 3186 scrollInfo.fMask = SIF_POS; 2953 3187 2954 3188 if (uView == LVS_LIST) 2955 3189 { 2956 if (lStyle & WS_HSCROLL) 2957 { 2958 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 2959 { 2960 nItem = scrollInfo.nPos * LISTVIEW_GetCountPerColumn(hwnd); 2961 } 2962 } 3190 if ((lStyle & WS_HSCROLL) && GetScrollInfo(hwnd, SB_HORZ, &scrollInfo)) 3191 nItem = scrollInfo.nPos * LISTVIEW_GetCountPerColumn(hwnd); 2963 3192 } 2964 3193 else if (uView == LVS_REPORT) 2965 3194 { 2966 if (lStyle & WS_VSCROLL) 2967 { 2968 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE) 2969 { 2970 nItem = scrollInfo.nPos; 2971 } 2972 } 2973 } 2974 3195 if ((lStyle & WS_VSCROLL) && GetScrollInfo(hwnd, SB_VERT, &scrollInfo)) 3196 nItem = scrollInfo.nPos; 3197 } 3198 2975 3199 return nItem; 2976 3200 } … … 2979 3203 * DESCRIPTION: 2980 3204 * Draws a subitem. 2981 * 3205 * 2982 3206 * PARAMETER(S): 2983 3207 * [I] HWND : window handle … … 2990 3214 * None 2991 3215 */ 2992 static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem, 3216 static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem, 2993 3217 RECT rcItem, BOOL Selected) 2994 3218 { 2995 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2996 CHAR szDispText[DISP_TEXT_SIZE]; 2997 LVITEMA lvItem; 3219 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 3220 WCHAR szDispText[DISP_TEXT_SIZE]; 3221 LVITEMW lvItem; 3222 LVCOLUMNW lvColumn; 2998 3223 UINT textoutOptions = ETO_CLIPPED | ETO_OPAQUE; 2999 3224 RECT rcTemp; 3225 INT textLeft; 3226 INT nLabelWidth = 0; 3000 3227 3001 3228 TRACE("(hwnd=%x, hdc=%x, nItem=%d, nSubItem=%d)\n", hwnd, hdc, … … 3003 3230 3004 3231 /* get information needed for drawing the item */ 3005 ZeroMemory(&lvItem, sizeof( LVITEMA));3232 ZeroMemory(&lvItem, sizeof(lvItem)); 3006 3233 lvItem.mask = LVIF_TEXT; 3007 3234 lvItem.iItem = nItem; … … 3009 3236 lvItem.cchTextMax = DISP_TEXT_SIZE; 3010 3237 lvItem.pszText = szDispText; 3011 LISTVIEW_GetItemA(hwnd, &lvItem, TRUE); 3238 *lvItem.pszText = '\0'; 3239 LISTVIEW_GetItemW(hwnd, &lvItem, TRUE); 3240 TRACE(" lvItem=%s\n", debuglvitem_t(&lvItem, TRUE)); 3241 3242 ZeroMemory(&lvColumn, sizeof(lvColumn)); 3243 lvColumn.mask = LVCF_FMT; 3244 LISTVIEW_GetColumnT(hwnd, nSubItem, &lvColumn, TRUE); 3245 textLeft = rcItem.left; 3246 if (lvColumn.fmt != LVCFMT_LEFT) 3247 { 3248 if ((nLabelWidth = LISTVIEW_GetStringWidthT(hwnd, lvItem.pszText, TRUE))) 3249 { 3250 if (lvColumn.fmt == LVCFMT_RIGHT) 3251 textLeft = rcItem.right - nLabelWidth; 3252 else 3253 textLeft = rcItem.left + (rcItem.right-rcItem.left-nLabelWidth)/2; 3254 } 3255 } 3256 3012 3257 3013 3258 /* redraw the background of the item */ 3014 3259 rcTemp = rcItem; 3015 3260 if(infoPtr->nColumnCount == (nSubItem + 1)) 3016 rcTemp.right = infoPtr->rcList.right;3261 rcTemp.right = infoPtr->rcList.right; 3017 3262 else 3018 rcTemp.right +=WIDTH_PADDING;3263 rcTemp.right += WIDTH_PADDING; 3019 3264 3020 3265 LISTVIEW_FillBackground(hwnd, hdc, &rcTemp); … … 3050 3295 } 3051 3296 3052 ExtTextOut A(hdc, rcItem.left, rcItem.top, textoutOptions,3053 &rcItem, lvItem.pszText, lstrlen A(lvItem.pszText), NULL);3297 ExtTextOutW(hdc, textLeft, rcItem.top, textoutOptions, 3298 &rcItem, lvItem.pszText, lstrlenW(lvItem.pszText), NULL); 3054 3299 3055 3300 if (Selected) … … 3062 3307 rec.left = rec.right; 3063 3308 rec.right = rec.left+REPORT_MARGINX; 3064 ExtTextOut A(hdc, rec.left , rec.top, textoutOptions,3309 ExtTextOutW(hdc, rec.left , rec.top, textoutOptions, 3065 3310 &rec, NULL, 0, NULL); 3066 3311 } … … 3068 3313 rec.right = rec.left; 3069 3314 rec.left = rec.left - REPORT_MARGINX; 3070 ExtTextOut A(hdc, rec.left , rec.top, textoutOptions,3315 ExtTextOutW(hdc, rec.left , rec.top, textoutOptions, 3071 3316 &rec, NULL, 0, NULL); 3072 3317 } … … 3077 3322 * DESCRIPTION: 3078 3323 * Draws an item. 3079 * 3324 * 3080 3325 * PARAMETER(S): 3081 3326 * [I] HWND : window handle … … 3089 3334 static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem, BOOL FullSelect, RECT* SuggestedFocus) 3090 3335 { 3091 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);3092 CHAR szDispText[DISP_TEXT_SIZE];3336 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 3337 WCHAR szDispText[DISP_TEXT_SIZE]; 3093 3338 INT nLabelWidth; 3094 LVITEM AlvItem;3339 LVITEMW lvItem; 3095 3340 INT nMixMode; 3096 3341 DWORD dwBkColor; … … 3105 3350 3106 3351 /* get information needed for drawing the item */ 3107 ZeroMemory(&lvItem, sizeof( LVITEMA));3352 ZeroMemory(&lvItem, sizeof(lvItem)); 3108 3353 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_INDENT; 3109 3354 lvItem.stateMask = LVIS_SELECTED | LVIS_STATEIMAGEMASK; … … 3112 3357 lvItem.cchTextMax = DISP_TEXT_SIZE; 3113 3358 lvItem.pszText = szDispText; 3114 LISTVIEW_GetItemA(hwnd, &lvItem, TRUE); 3359 *lvItem.pszText = '\0'; 3360 LISTVIEW_GetItemW(hwnd, &lvItem, TRUE); 3361 TRACE(" lvItem=%s\n", debuglvitem_t(&lvItem, TRUE)); 3115 3362 3116 3363 /* redraw the background of the item */ … … 3126 3373 if (lvItem.iIndent>0 && infoPtr->iconSize.cx > 0) 3127 3374 { 3128 rcItem.left += infoPtr->iconSize.cx * lvItem.iIndent; 3375 rcItem.left += infoPtr->iconSize.cx * lvItem.iIndent; 3129 3376 3130 3377 if (SuggestedFocus) 3131 3378 SuggestedFocus->left += infoPtr->iconSize.cx * lvItem.iIndent; 3132 } 3379 } 3133 3380 3134 3381 /* state icons */ 3135 3382 if (infoPtr->himlState != NULL) 3136 3383 { 3137 UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12; 3384 UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12; 3138 3385 if (uStateImage > 0) 3139 3386 { 3140 ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcItem.left, 3387 ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcItem.left, 3141 3388 rcItem.top, ILD_NORMAL); 3142 3389 } 3143 3144 rcItem.left += infoPtr->iconSize.cx; 3390 3391 rcItem.left += infoPtr->iconSize.cx; 3145 3392 if (SuggestedFocus) 3146 3393 SuggestedFocus->left += infoPtr->iconSize.cx; 3147 3394 bImage = TRUE; 3148 3395 } 3149 3396 3150 3397 /* small icons */ 3151 3398 if (infoPtr->himlSmall != NULL) … … 3155 3402 { 3156 3403 ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE); 3157 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 3404 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 3158 3405 rcItem.top, ILD_SELECTED); 3159 3406 } … … 3161 3408 { 3162 3409 ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE); 3163 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 3410 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 3164 3411 rcItem.top, ILD_NORMAL); 3165 3412 } 3166 3167 rcItem.left += infoPtr->iconSize.cx; 3413 3414 rcItem.left += infoPtr->iconSize.cx; 3168 3415 3169 3416 if (SuggestedFocus) … … 3178 3425 if ((lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus != FALSE)) 3179 3426 { 3180 /* set item colors */ 3427 /* set item colors */ 3181 3428 dwBkColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); 3182 3429 dwTextColor = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); … … 3184 3431 nMixMode = SetROP2(hdc, R2_XORPEN); 3185 3432 } 3186 else if ((GetWindowLong A(hwnd, GWL_STYLE) & LVS_SHOWSELALWAYS) &&3433 else if ((GetWindowLongW(hwnd, GWL_STYLE) & LVS_SHOWSELALWAYS) && 3187 3434 (lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus == FALSE)) 3188 3435 { … … 3211 3458 nMixMode = SetROP2(hdc, R2_COPYPEN); 3212 3459 } 3213 3214 nLabelWidth = ListView_GetStringWidth A(hwnd, lvItem.pszText);3460 3461 nLabelWidth = ListView_GetStringWidthW(hwnd, lvItem.pszText); 3215 3462 if (rcItem.left + nLabelWidth < rcItem.right) 3216 3463 { … … 3220 3467 rcItem.right += IMAGE_PADDING; 3221 3468 } 3222 3223 /* draw label */ 3469 3470 /* draw label */ 3224 3471 dwTextX = rcItem.left + 1; 3225 3472 if (bImage) … … 3227 3474 3228 3475 if (lvItem.pszText) 3229 ExtTextOut A(hdc, dwTextX, rcItem.top, textoutOptions,3230 &rcItem, lvItem.pszText, lstrlen A(lvItem.pszText), NULL);3476 ExtTextOutW(hdc, dwTextX, rcItem.top, textoutOptions, 3477 &rcItem, lvItem.pszText, lstrlenW(lvItem.pszText), NULL); 3231 3478 3232 3479 if ((FullSelect)&&(Header_GetItemCount(infoPtr->hwndHeader) > 1)) … … 3237 3484 rec.left = rec.right; 3238 3485 rec.right = rec.left+REPORT_MARGINX; 3239 ExtTextOut A(hdc, rec.left , rec.top, textoutOptions,3486 ExtTextOutW(hdc, rec.left , rec.top, textoutOptions, 3240 3487 &rec, NULL, 0, NULL); 3241 3488 } 3242 3489 3243 3490 if (!FullSelect) 3244 3491 CopyRect(SuggestedFocus,&rcItem); … … 3257 3504 * DESCRIPTION: 3258 3505 * Draws an item when in large icon display mode. 3259 * 3506 * 3260 3507 * PARAMETER(S): 3261 3508 * [I] HWND : window handle 3262 3509 * [I] HDC : device context handle 3263 * [I] LISTVIEW_ITEM * : item3264 3510 * [I] INT : item index 3265 * [I] RECT * : clipping rectangle 3511 * [I] RECT : clipping rectangle 3512 * [O] RECT * : The text rectangle about which to draw the focus 3266 3513 * 3267 3514 * RETURN: … … 3271 3518 RECT *SuggestedFocus) 3272 3519 { 3273 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3274 CHAR szDispText[DISP_TEXT_SIZE]; 3275 INT nDrawPosX = rcItem.left; 3276 INT nLabelWidth, rcWidth; 3277 TEXTMETRICA tm; 3278 LVITEMA lvItem; 3279 UINT textoutOptions = ETO_CLIPPED | ETO_OPAQUE; 3520 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 3521 WCHAR szDispText[DISP_TEXT_SIZE] = { '\0' }; 3522 LVITEMW lvItem; 3523 UINT uFormat = DT_TOP | DT_CENTER | DT_WORDBREAK | DT_NOPREFIX | 3524 DT_EDITCONTROL ; 3525 /* Maintain this format in line with the one in LISTVIEW_UpdateLargeItemLabelRect*/ 3280 3526 RECT rcTemp; 3281 3527 3282 3528 TRACE("(hwnd=%x, hdc=%x, nItem=%d, left=%d, top=%d, right=%d, bottom=%d)\n", 3283 hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right, 3284 rcItem.bottom); 3529 hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom); 3285 3530 3286 3531 /* get information needed for drawing the item */ 3287 ZeroMemory(&lvItem, sizeof( LVITEMA));3532 ZeroMemory(&lvItem, sizeof(lvItem)); 3288 3533 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE; 3289 3534 lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED; … … 3292 3537 lvItem.cchTextMax = DISP_TEXT_SIZE; 3293 3538 lvItem.pszText = szDispText; 3294 LISTVIEW_GetItemA(hwnd, &lvItem, TRUE); 3539 *lvItem.pszText = '\0'; 3540 LISTVIEW_GetItemW(hwnd, &lvItem, FALSE); 3541 TRACE(" lvItem=%s\n", debuglvitem_t(&lvItem, TRUE)); 3295 3542 3296 3543 /* redraw the background of the item */ … … 3300 3547 else 3301 3548 rcTemp.right+=WIDTH_PADDING; 3302 3549 /* The comment doesn't say WIDTH_PADDING applies to large icons */ 3550 3551 TRACE("background rect (%d,%d)-(%d,%d)\n", 3552 rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom); 3553 3303 3554 LISTVIEW_FillBackground(hwnd, hdc, &rcTemp); 3304 3555 3556 3557 /* Figure out text colours etc. depending on state 3558 * At least the following states exist; there may be more. 3559 * Many items may be selected 3560 * At most one item may have the focus 3561 * The application may not actually be active currently 3562 * 1. The item is not selected in any way 3563 * 2. The cursor is flying over the icon or text and the text is being 3564 * expanded because it is not fully displayed currently. 3565 * 3. The item is selected and is focussed, i.e. the user has not clicked 3566 * in the blank area of the window, and the window (or application?) 3567 * still has the focus. 3568 * 4. As 3 except that a different window has the focus 3569 * 5. The item is the selected item of all the items, but the user has 3570 * clicked somewhere else on the window. 3571 * Only a few of these are handled currently. In particular 2 is not yet 3572 * handled since we do not support the functionality currently (or at least 3573 * we didn't when I wrote this) 3574 */ 3575 3305 3576 if (lvItem.state & LVIS_SELECTED) 3306 3577 { 3307 /* set item colors */ 3578 /* set item colors */ 3308 3579 SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); 3309 3580 SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); 3581 SetBkMode (hdc, OPAQUE); 3310 3582 /* set raster mode */ 3311 3583 SetROP2(hdc, R2_XORPEN); 3584 /* When exactly is it in XOR? while being dragged? */ 3312 3585 } 3313 3586 else … … 3317 3590 { 3318 3591 SetBkMode(hdc, TRANSPARENT); 3319 textoutOptions &= ~ETO_OPAQUE;3320 3592 } 3321 3593 else … … 3330 3602 } 3331 3603 3604 /* In cases 2,3 and 5 (see above) the full text is displayed, with word 3605 * wrapping and long words split. 3606 * In cases 1 and 4 only a portion of the text is displayed with word 3607 * wrapping and both word and end ellipsis. (I don't yet know about path 3608 * ellipsis) 3609 */ 3610 uFormat |= ( (lvItem.state & LVIS_FOCUSED) && infoPtr->bFocus) ? 3611 DT_NOCLIP 3612 : 3613 DT_WORD_ELLIPSIS | DT_END_ELLIPSIS; 3614 3615 /* draw the icon */ 3332 3616 if (infoPtr->himlNormal != NULL) 3333 3617 { 3334 rcItem.top += ICON_TOP_PADDING; 3335 nDrawPosX += (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; 3336 if ((lvItem.state & LVIS_SELECTED) && (lvItem.iImage>=0)) 3337 { 3338 ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 3339 rcItem.top, ILD_SELECTED); 3340 } 3341 else if (lvItem.iImage>=0) 3342 { 3343 ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 3344 rcItem.top, ILD_NORMAL); 3345 } 3346 } 3618 if (lvItem.iImage >= 0) 3619 { 3620 ImageList_Draw (infoPtr->himlNormal, lvItem.iImage, hdc, rcItem.left, 3621 rcItem.top, 3622 (lvItem.state & LVIS_SELECTED) ? ILD_SELECTED : ILD_NORMAL); 3623 } 3624 } 3625 3626 /* Draw the text below the icon */ 3347 3627 3348 3628 /* Don't bother painting item being edited */ 3349 if (infoPtr->hwndEdit && lvItem.state & LVIS_FOCUSED) 3629 if ((infoPtr->hwndEdit && (lvItem.state & LVIS_FOCUSED)) || 3630 !lstrlenW(lvItem.pszText)) 3631 { 3632 SetRectEmpty(SuggestedFocus); 3350 3633 return; 3351 3634 } 3635 3636 /* Since rcItem.left is left point of icon, compute left point of item box */ 3637 rcItem.left -= ((infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2); 3638 rcItem.right = rcItem.left + infoPtr->nItemWidth; 3639 rcItem.bottom = rcItem.top + infoPtr->nItemHeight; 3640 TRACE("bound box for text+icon (%d,%d)-(%d,%d), iS.cx=%ld, nItemWidth=%d\n", 3641 rcItem.left, rcItem.top, rcItem.right, rcItem.bottom, 3642 infoPtr->iconSize.cx, infoPtr->nItemWidth); 3643 TRACE("rcList (%d,%d)-(%d,%d), rcView (%d,%d)-(%d,%d)\n", 3644 infoPtr->rcList.left, infoPtr->rcList.top, 3645 infoPtr->rcList.right, infoPtr->rcList.bottom, 3646 infoPtr->rcView.left, infoPtr->rcView.top, 3647 infoPtr->rcView.right, infoPtr->rcView.bottom); 3648 3352 3649 InflateRect(&rcItem, -(2*CAPTION_BORDER), 0); 3353 rcItem.top += infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; 3354 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 3355 GetTextMetricsA(hdc, &tm); 3356 3357 /* append an ellipse ('...') if the caption won't fit in the rect */ 3358 rcWidth = max(0, rcItem.right - rcItem.left); 3359 if (nLabelWidth > rcWidth) 3360 { 3361 INT i, len, eos, nCharsFit; 3362 /* give or take a couple, how many average sized chars would fit? */ 3363 nCharsFit = tm.tmAveCharWidth > 0 ? (rcWidth/tm.tmAveCharWidth)+2 : 0; 3364 /* place the ellipse accordingly, without overrunning the buffer */ 3365 len = strlen(szDispText); 3366 eos = min((nCharsFit > 1 && nCharsFit < len) ? nCharsFit+3 : len+2, 3367 sizeof(szDispText)-1); 3368 3369 nLabelWidth = ListView_GetStringWidthA(hwnd, szDispText); 3370 while ((nLabelWidth > rcWidth) && (eos > 3)) 3371 { 3372 for (i = 1; i < 4; i++) 3373 szDispText[eos-i] = '.'; 3374 /* shift the ellipse one char to the left for each iteration */ 3375 szDispText[eos--] = '\0'; 3376 nLabelWidth = ListView_GetStringWidthA(hwnd, szDispText); 3377 } 3378 } 3379 3380 InflateRect(&rcItem, 2*CAPTION_BORDER, 0); 3381 nDrawPosX = infoPtr->iconSpacing.cx - 2*CAPTION_BORDER - nLabelWidth; 3382 if (nDrawPosX > 1) 3383 { 3384 rcItem.left += nDrawPosX / 2; 3385 rcItem.right = rcItem.left + nLabelWidth + 2*CAPTION_BORDER; 3386 } 3387 else 3388 { 3389 rcItem.left += 1; 3390 rcItem.right = rcItem.left + infoPtr->iconSpacing.cx - 1; 3391 } 3392 3393 /* draw label */ 3394 rcItem.bottom = rcItem.top + tm.tmHeight + HEIGHT_PADDING; 3395 3396 ExtTextOutA(hdc, rcItem.left + CAPTION_BORDER, rcItem.top, textoutOptions, 3397 &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL); 3398 3399 3400 CopyRect(SuggestedFocus,&rcItem); 3650 rcItem.top += infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; 3651 3652 3653 /* draw label */ 3654 3655 /* I am sure of most of the uFormat values. However I am not sure about 3656 * whether we need or do not need the following: 3657 * DT_EXTERNALLEADING, DT_INTERNAL, DT_CALCRECT, DT_NOFULLWIDTHCHARBREAK, 3658 * DT_PATH_ELLIPSIS, DT_RTLREADING, 3659 * We certainly do not need 3660 * DT_BOTTOM, DT_VCENTER, DT_MODIFYSTRING, DT_LEFT, DT_RIGHT, DT_PREFIXONLY, 3661 * DT_SINGLELINE, DT_TABSTOP, DT_EXPANDTABS 3662 */ 3663 3664 /* If the text is being drawn without clipping (i.e. the full text) then we 3665 * need to jump through a few hoops to ensure that it all gets displayed and 3666 * that the background is complete 3667 */ 3668 if (uFormat & DT_NOCLIP) 3669 { 3670 RECT rcBack=rcItem; 3671 HBRUSH hBrush = CreateSolidBrush(GetBkColor (hdc)); 3672 int dx, dy, old_wid, new_wid; 3673 DrawTextW (hdc, lvItem.pszText, -1, &rcItem, uFormat | DT_CALCRECT); 3674 /* Microsoft, in their great wisdom, have decided that the rectangle 3675 * returned by DrawText on DT_CALCRECT will only guarantee the dimension, 3676 * not the location. So we have to do the centring ourselves (and take 3677 * responsibility for agreeing off-by-one consistency with them). 3678 */ 3679 old_wid = rcItem.right-rcItem.left; 3680 new_wid = rcBack.right - rcBack.left; 3681 dx = rcBack.left - rcItem.left + (new_wid-old_wid)/2; 3682 dy = rcBack.top - rcItem.top; 3683 OffsetRect (&rcItem, dx, dy); 3684 FillRect(hdc, &rcItem, hBrush); 3685 DeleteObject(hBrush); 3686 } 3687 /* else ? What if we are losing the focus? will we not get a complete 3688 * background? 3689 */ 3690 DrawTextW (hdc, lvItem.pszText, -1, &rcItem, uFormat); 3691 3692 CopyRect(SuggestedFocus, &rcItem); 3401 3693 } 3402 3694 … … 3404 3696 * DESCRIPTION: 3405 3697 * Draws listview items when in report display mode. 3406 * 3407 * PARAMETER(S): 3408 * [I] HWND : window handle 3409 * [I] HDC : device context handle 3698 * 3699 * PARAMETER(S): 3700 * [I] HWND : window handle 3701 * [I] HDC : device context handle 3410 3702 * 3411 3703 * RETURN: … … 3414 3706 static VOID LISTVIEW_RefreshReport(HWND hwnd, HDC hdc, DWORD cdmode) 3415 3707 { 3416 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd,0);3708 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd,0); 3417 3709 SCROLLINFO scrollInfo; 3418 3710 INT nDrawPosY = infoPtr->rcList.top; … … 3424 3716 BOOL FullSelected; 3425 3717 DWORD cditemmode = CDRF_DODEFAULT; 3426 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);3718 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 3427 3719 INT scrollOffset; 3428 3720 … … 3438 3730 3439 3731 /* send cache hint notification */ 3440 if (GetWindowLong A(hwnd,GWL_STYLE) & LVS_OWNERDATA)3732 if (GetWindowLongW(hwnd,GWL_STYLE) & LVS_OWNERDATA) 3441 3733 { 3442 3734 NMLVCACHEHINT nmlv; 3443 3735 3444 3736 nmlv.hdr.hwndFrom = hwnd; 3445 nmlv.hdr.idFrom = GetWindowLong A(hwnd,GWL_ID);3737 nmlv.hdr.idFrom = GetWindowLongW(hwnd,GWL_ID); 3446 3738 nmlv.hdr.code = LVN_ODCACHEHINT; 3447 3739 nmlv.iFrom = nItem; 3448 3740 nmlv.iTo = nLast; 3449 3741 3450 SendMessage A(GetParent(hwnd), WM_NOTIFY, (WPARAM)nmlv.hdr.idFrom,3742 SendMessageW(GetParent(hwnd), WM_NOTIFY, (WPARAM)nmlv.hdr.idFrom, 3451 3743 (LPARAM)&nmlv); 3452 3744 } … … 3475 3767 if (lStyle & LVS_OWNERDRAWFIXED) 3476 3768 { 3477 UINT uID = GetWindowLong A( hwnd, GWL_ID);3769 UINT uID = GetWindowLongW( hwnd, GWL_ID); 3478 3770 DRAWITEMSTRUCT dis; 3479 LVITEM Aitem;3771 LVITEMW item; 3480 3772 RECT br; 3481 3773 3482 TRACE("Owner Drawn\n"); 3774 TRACE("Owner Drawn\n"); 3483 3775 dis.CtlType = ODT_LISTVIEW; 3484 3776 dis.CtlID = uID; … … 3486 3778 dis.itemAction = ODA_DRAWENTIRE; 3487 3779 dis.itemState = 0; 3488 3780 3489 3781 if (LISTVIEW_IsSelected(hwnd,nItem)) dis.itemState|=ODS_SELECTED; 3490 3782 if (nItem==infoPtr->nFocusedItem) dis.itemState|=ODS_FOCUS; … … 3495 3787 Header_GetItemRect(infoPtr->hwndHeader, nColumnCount-1, &br); 3496 3788 3497 dis.rcItem.left = -scrollOffset; 3789 dis.rcItem.left = -scrollOffset; 3498 3790 dis.rcItem.right = max(dis.rcItem.left, br.right - scrollOffset); 3499 3791 dis.rcItem.top = nDrawPosY; 3500 3792 dis.rcItem.bottom = dis.rcItem.top + infoPtr->nItemHeight; 3501 3502 ZeroMemory(&item,sizeof( LVITEMA));3793 3794 ZeroMemory(&item,sizeof(item)); 3503 3795 item.iItem = nItem; 3504 3796 item.mask = LVIF_PARAM; 3505 ListView_GetItem A(hwnd,&item);3797 ListView_GetItemW(hwnd, &item); 3506 3798 3507 3799 dis.itemData = item.lParam; 3508 3800 3509 if (SendMessage A(GetParent(hwnd),WM_DRAWITEM,(WPARAM)uID,(LPARAM)&dis))3801 if (SendMessageW(GetParent(hwnd),WM_DRAWITEM,(WPARAM)uID,(LPARAM)&dis)) 3510 3802 { 3511 3803 nDrawPosY += infoPtr->nItemHeight; … … 3525 3817 ir.top = nDrawPosY; 3526 3818 ir.bottom = ir.top + infoPtr->nItemHeight; 3527 3819 3528 3820 CopyRect(&SuggestedFocusRect,&ir); 3529 3821 } … … 3551 3843 { 3552 3844 LISTVIEW_DrawItem(hwnd, hdc, nItem, rcItem, FullSelected, 3553 &SuggestedFocusRect); 3845 &SuggestedFocusRect); 3554 3846 } 3555 else 3847 else 3556 3848 { 3557 LISTVIEW_DrawSubItem(hwnd, hdc, nItem, j, rcItem, 3558 FullSelected); 3849 LISTVIEW_DrawSubItem(hwnd, hdc, nItem, j, rcItem, FullSelected); 3559 3850 } 3560 3851 3561 3852 if (cditemmode & CDRF_NOTIFYPOSTPAINT) 3562 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, nItem, 0, 3563 3853 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, nItem, 0, 3854 CDDS_ITEMPOSTPAINT); 3564 3855 } 3565 3856 /* … … 3572 3863 rop = SetROP2(hdc, R2_XORPEN); 3573 3864 3574 Rectangle(hdc, SuggestedFocusRect.left, SuggestedFocusRect.top, 3575 SuggestedFocusRect.right,SuggestedFocusRect.bottom); 3865 Rectangle(hdc, SuggestedFocusRect.left, SuggestedFocusRect.top, 3866 SuggestedFocusRect.right,SuggestedFocusRect.bottom); 3576 3867 3577 3868 if (rop) … … 3585 3876 * DESCRIPTION: 3586 3877 * Retrieves the number of items that can fit vertically in the client area. 3587 * 3878 * 3588 3879 * PARAMETER(S): 3589 3880 * [I] HWND : window handle … … 3594 3885 static INT LISTVIEW_GetCountPerRow(HWND hwnd) 3595 3886 { 3596 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd,0);3597 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;3887 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd,0); 3888 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3598 3889 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 3599 3890 INT nCountPerRow = 1; … … 3601 3892 if (nListWidth > 0) 3602 3893 { 3603 if (uView == LVS_REPORT) 3604 { 3605 nCountPerRow = 1; 3606 } 3607 else 3894 if (uView != LVS_REPORT) 3608 3895 { 3609 3896 nCountPerRow = nListWidth / infoPtr->nItemWidth; 3610 if (nCountPerRow == 0) 3611 { 3612 nCountPerRow = 1; 3613 } 3897 if (nCountPerRow == 0) nCountPerRow = 1; 3614 3898 } 3615 3899 } … … 3620 3904 /*** 3621 3905 * DESCRIPTION: 3622 * Retrieves the number of items that can fit horizontally in the client 3906 * Retrieves the number of items that can fit horizontally in the client 3623 3907 * area. 3624 * 3908 * 3625 3909 * PARAMETER(S): 3626 3910 * [I] HWND : window handle … … 3631 3915 static INT LISTVIEW_GetCountPerColumn(HWND hwnd) 3632 3916 { 3633 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd,0);3917 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd,0); 3634 3918 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 3635 3919 INT nCountPerColumn = 1; … … 3643 3927 { 3644 3928 nCountPerColumn = nListHeight / infoPtr->nItemHeight; 3645 if (nCountPerColumn == 0) 3646 { 3647 nCountPerColumn = 1; 3648 } 3929 if (nCountPerColumn == 0) nCountPerColumn = 1; 3649 3930 } 3650 3931 … … 3654 3935 /*** 3655 3936 * DESCRIPTION: 3656 * Retrieves the number of columns needed to display all the items when in 3937 * Retrieves the number of columns needed to display all the items when in 3657 3938 * list display mode. 3658 * 3939 * 3659 3940 * PARAMETER(S): 3660 3941 * [I] HWND : window handle … … 3665 3946 static INT LISTVIEW_GetColumnCount(HWND hwnd) 3666 3947 { 3667 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);3668 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);3948 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 3949 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 3669 3950 INT nColumnCount = 0; 3670 3951 3671 3952 if ((lStyle & LVS_TYPEMASK) == LVS_LIST) 3672 3953 { 3673 if (infoPtr->rcList.right % infoPtr->nItemWidth == 0) 3674 { 3675 nColumnCount = infoPtr->rcList.right / infoPtr->nItemWidth; 3676 } 3677 else 3678 { 3679 nColumnCount = infoPtr->rcList.right / infoPtr->nItemWidth + 1; 3680 } 3954 nColumnCount = infoPtr->rcList.right / infoPtr->nItemWidth; 3955 if (infoPtr->rcList.right % infoPtr->nItemWidth) nColumnCount++; 3681 3956 } 3682 3957 3683 3958 return nColumnCount; 3684 } 3685 3959 } 3960 3686 3961 3687 3962 /*** 3688 3963 * DESCRIPTION: 3689 3964 * Draws listview items when in list display mode. 3690 * 3691 * PARAMETER(S): 3692 * [I] HWND : window handle 3693 * [I] HDC : device context handle 3965 * 3966 * PARAMETER(S): 3967 * [I] HWND : window handle 3968 * [I] HDC : device context handle 3694 3969 * 3695 3970 * RETURN: … … 3698 3973 static VOID LISTVIEW_RefreshList(HWND hwnd, HDC hdc, DWORD cdmode) 3699 3974 { 3700 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);3975 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 3701 3976 RECT rcItem, FocusRect, rcTemp; 3702 3977 INT i, j; … … 3744 4019 */ 3745 4020 if (LISTVIEW_GetItemState(hwnd,nItem,LVIS_FOCUSED) && infoPtr->bFocus) 3746 Rectangle(hdc, FocusRect.left, FocusRect.top, 4021 Rectangle(hdc, FocusRect.left, FocusRect.top, 3747 4022 FocusRect.right,FocusRect.bottom); 3748 4023 3749 4024 if (cditemmode & CDRF_NOTIFYPOSTPAINT) 3750 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, nItem, 0, 4025 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, nItem, 0, 3751 4026 CDDS_ITEMPOSTPAINT); 3752 4027 3753 4028 } 3754 4029 } … … 3758 4033 * DESCRIPTION: 3759 4034 * Draws listview items when in icon or small icon display mode. 3760 * 3761 * PARAMETER(S): 3762 * [I] HWND : window handle 3763 * [I] HDC : device context handle 4035 * 4036 * PARAMETER(S): 4037 * [I] HWND : window handle 4038 * [I] HDC : device context handle 3764 4039 * 3765 4040 * RETURN: … … 3768 4043 static VOID LISTVIEW_RefreshIcon(HWND hwnd, HDC hdc, BOOL bSmall, DWORD cdmode) 3769 4044 { 3770 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);4045 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 3771 4046 POINT ptPosition; 3772 4047 POINT ptOrigin; … … 3798 4073 ptPosition.x += ptOrigin.x; 3799 4074 ptPosition.y += ptOrigin.y; 3800 4075 3801 4076 if (ptPosition.y + infoPtr->nItemHeight > infoPtr->rcList.top) 3802 4077 { … … 3811 4086 rcItem.bottom = rcItem.top + infoPtr->nItemHeight; 3812 4087 rcItem.right = rcItem.left + infoPtr->nItemWidth; 3813 if (bSmall == FALSE) 3814 { 4088 if (bSmall) 4089 LISTVIEW_DrawItem(hwnd, hdc, i, rcItem, FALSE, &SuggestedFocus); 4090 else 3815 4091 LISTVIEW_DrawLargeItem(hwnd, hdc, i, rcItem, &SuggestedFocus); 3816 }3817 else3818 {3819 LISTVIEW_DrawItem(hwnd, hdc, i, rcItem, FALSE, &SuggestedFocus);3820 }3821 4092 /* 3822 4093 * Draw Focus Rect 3823 4094 */ 3824 if (LISTVIEW_GetItemState(hwnd,i,LVIS_FOCUSED) && 3825 infoPtr->bFocus )3826 Rectangle(hdc, SuggestedFocus.left, SuggestedFocus.top, 3827 SuggestedFocus.right,SuggestedFocus.bottom); 4095 if (LISTVIEW_GetItemState(hwnd,i,LVIS_FOCUSED) && 4096 infoPtr->bFocus && !IsRectEmpty(&SuggestedFocus)) 4097 Rectangle(hdc, SuggestedFocus.left, SuggestedFocus.top, 4098 SuggestedFocus.right,SuggestedFocus.bottom); 3828 4099 } 3829 4100 } … … 3831 4102 } 3832 4103 if (cditemmode & CDRF_NOTIFYPOSTPAINT) 3833 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, i, 0, 4104 LISTVIEW_SendCustomDrawItemNotify(hwnd, hdc, i, 0, 3834 4105 CDDS_ITEMPOSTPAINT); 3835 4106 } … … 3839 4110 * DESCRIPTION: 3840 4111 * Draws listview items. 3841 * 3842 * PARAMETER(S): 3843 * [I] HWND : window handle 3844 * [I] HDC : device context handle 4112 * 4113 * PARAMETER(S): 4114 * [I] HWND : window handle 4115 * [I] HDC : device context handle 3845 4116 * 3846 4117 * RETURN: … … 3849 4120 static VOID LISTVIEW_Refresh(HWND hwnd, HDC hdc) 3850 4121 { 3851 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);3852 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;4122 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 4123 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3853 4124 HFONT hOldFont; 3854 4125 HPEN hPen, hOldPen; … … 3860 4131 #endif 3861 4132 4133 LISTVIEW_DumpListview (infoPtr, __LINE__); 4134 3862 4135 GetClientRect(hwnd, &rect); 3863 4136 cdmode = LISTVIEW_SendCustomDrawNotify(hwnd,CDDS_PREPAINT,hdc,rect); … … 3873 4146 3874 4147 /* select transparent brush (for drawing the focus box) */ 3875 SelectObject(hdc, GetStockObject(NULL_BRUSH)); 4148 SelectObject(hdc, GetStockObject(NULL_BRUSH)); 3876 4149 3877 4150 if (uView == LVS_LIST) 3878 { 3879 LISTVIEW_RefreshList(hwnd, hdc, cdmode); 3880 } 4151 LISTVIEW_RefreshList(hwnd, hdc, cdmode); 3881 4152 else if (uView == LVS_REPORT) 3882 {3883 4153 LISTVIEW_RefreshReport(hwnd, hdc, cdmode); 3884 }3885 4154 else if (uView == LVS_SMALLICON) 3886 {3887 4155 LISTVIEW_RefreshIcon(hwnd, hdc, TRUE, cdmode); 3888 }3889 4156 else if (uView == LVS_ICON) 3890 {3891 4157 LISTVIEW_RefreshIcon(hwnd, hdc, FALSE, cdmode); 3892 }3893 4158 3894 4159 /* unselect objects */ 3895 4160 SelectObject(hdc, hOldFont); 3896 4161 SelectObject(hdc, hOldPen); 3897 4162 3898 4163 /* delete pen */ 3899 4164 DeleteObject(hPen); 3900 4165 3901 4166 if (cdmode & CDRF_NOTIFYPOSTPAINT) 3902 4167 LISTVIEW_SendCustomDrawNotify(hwnd, CDDS_POSTPAINT, hdc, rect); … … 3907 4172 * DESCRIPTION: 3908 4173 * Calculates the approximate width and height of a given number of items. 3909 * 4174 * 3910 4175 * PARAMETER(S): 3911 4176 * [I] HWND : window handle … … 3917 4182 * Returns a DWORD. The width in the low word and the height in high word. 3918 4183 */ 3919 static LRESULT LISTVIEW_ApproximateViewRect(HWND hwnd, INT nItemCount, 4184 static LRESULT LISTVIEW_ApproximateViewRect(HWND hwnd, INT nItemCount, 3920 4185 WORD wWidth, WORD wHeight) 3921 4186 { 3922 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);3923 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;4187 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 4188 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3924 4189 INT nItemCountPerColumn = 1; 3925 4190 INT nColumnCount = 0; … … 3927 4192 3928 4193 if (nItemCount == -1) 3929 {3930 4194 nItemCount = GETITEMCOUNT(infoPtr); 3931 }3932 4195 3933 4196 if (uView == LVS_LIST) … … 3940 4203 3941 4204 if (wHeight < infoPtr->nItemHeight) 3942 {3943 4205 wHeight = infoPtr->nItemHeight; 3944 }3945 4206 3946 4207 if (nItemCount > 0) … … 3950 4211 nItemCountPerColumn = wHeight / infoPtr->nItemHeight; 3951 4212 if (nItemCountPerColumn == 0) 3952 {3953 4213 nItemCountPerColumn = 1; 3954 } 3955 4214 3956 4215 if (nItemCount % nItemCountPerColumn != 0) 3957 {3958 4216 nColumnCount = nItemCount / nItemCountPerColumn; 3959 }3960 4217 else 3961 {3962 4218 nColumnCount = nItemCount / nItemCountPerColumn + 1; 3963 }3964 4219 } 3965 4220 } … … 3972 4227 } 3973 4228 else if (uView == LVS_REPORT) 3974 { 3975 /* TO DO */ 3976 } 4229 FIXME("uView == LVS_REPORT: not implemented\n"); 3977 4230 else if (uView == LVS_SMALLICON) 3978 { 3979 /* TO DO */ 3980 } 4231 FIXME("uView == LVS_SMALLICON: not implemented\n"); 3981 4232 else if (uView == LVS_ICON) 3982 { 3983 /* TO DO */ 3984 } 3985 4233 FIXME("uView == LVS_ICON: not implemented\n"); 4234 3986 4235 return dwViewRect; 3987 4236 } … … 3990 4239 * DESCRIPTION: 3991 4240 * Arranges listview items in icon display mode. 3992 * 4241 * 3993 4242 * PARAMETER(S): 3994 4243 * [I] HWND : window handle … … 4001 4250 static LRESULT LISTVIEW_Arrange(HWND hwnd, INT nAlignCode) 4002 4251 { 4003 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;4252 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 4004 4253 BOOL bResult = FALSE; 4005 4254 … … 4009 4258 { 4010 4259 case LVA_ALIGNLEFT: 4011 /* TO DO */4260 FIXME("nAlignCode=LVA_ALIGNLEFT: not implemented\n"); 4012 4261 break; 4013 4262 case LVA_ALIGNTOP: 4014 /* TO DO */4263 FIXME("nAlignCode=LVA_ALIGNTOP: not implemented\n"); 4015 4264 break; 4016 4265 case LVA_DEFAULT: 4017 /* TO DO */4266 FIXME("nAlignCode=LVA_DEFAULT: not implemented\n"); 4018 4267 break; 4019 4268 case LVA_SNAPTOGRID: 4020 /* TO DO */4269 FIXME("nAlignCode=LVA_SNAPTOGRID: not implemented\n"); 4021 4270 break; 4022 4271 } … … 4032 4281 * DESCRIPTION: 4033 4282 * Removes all listview items and subitems. 4034 * 4283 * 4035 4284 * PARAMETER(S): 4036 4285 * [I] HWND : window handle … … 4042 4291 static LRESULT LISTVIEW_DeleteAllItems(HWND hwnd) 4043 4292 { 4044 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 4045 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID); 4046 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 4293 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 4294 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 4047 4295 UINT uView = lStyle & LVS_TYPEMASK; 4048 4296 LISTVIEW_ITEM *lpItem; … … 4051 4299 BOOL bSuppress; 4052 4300 BOOL bResult = FALSE; 4053 INT i;4054 INT j;4055 4301 HDPA hdpaSubItems; 4056 4302 … … 4071 4317 if (GETITEMCOUNT(infoPtr) > 0) 4072 4318 { 4073 /* initialize memory */ 4319 INT i, j; 4320 4321 /* send LVN_DELETEALLITEMS notification */ 4322 /* verify if subsequent LVN_DELETEITEM notifications should be 4323 suppressed */ 4074 4324 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); 4075 4076 /* send LVN_DELETEALLITEMS notification */4077 nmlv.hdr.hwndFrom = hwnd;4078 nmlv.hdr.idFrom = lCtrlId;4079 nmlv.hdr.code = LVN_DELETEALLITEMS;4080 4325 nmlv.iItem = -1; 4081 4082 /* verify if subsequent LVN_DELETEITEM notifications should be 4083 suppressed */ 4084 bSuppress = ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv); 4326 bSuppress = listview_notify(hwnd, LVN_DELETEALLITEMS, &nmlv); 4085 4327 4086 4328 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) … … 4095 4337 { 4096 4338 /* free subitem string */ 4097 if ((lpSubItem->pszText != NULL) && 4098 (lpSubItem->pszText != LPSTR_TEXTCALLBACKA)) 4099 { 4339 if (is_textW(lpSubItem->pszText)) 4100 4340 COMCTL32_Free(lpSubItem->pszText); 4101 } 4102 4341 4103 4342 /* free subitem */ 4104 4343 COMCTL32_Free(lpSubItem); 4105 } 4344 } 4106 4345 } 4107 4346 … … 4109 4348 if (lpItem != NULL) 4110 4349 { 4111 if ( bSuppress == FALSE)4350 if (!bSuppress) 4112 4351 { 4113 4352 /* send LVN_DELETEITEM notification */ 4114 nmlv.hdr.code = LVN_DELETEITEM;4115 4353 nmlv.iItem = i; 4116 4354 nmlv.lParam = lpItem->lParam; 4117 ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);4355 listview_notify(hwnd, LVN_DELETEITEM, &nmlv); 4118 4356 } 4119 4357 4120 4358 /* free item string */ 4121 if ((lpItem->pszText != NULL) && 4122 (lpItem->pszText != LPSTR_TEXTCALLBACKA)) 4123 { 4359 if (is_textW(lpItem->pszText)) 4124 4360 COMCTL32_Free(lpItem->pszText); 4125 } 4126 4361 4127 4362 /* free item */ 4128 4363 COMCTL32_Free(lpItem); 4129 4364 } 4130 4365 4131 4366 DPA_Destroy(hdpaSubItems); 4132 4367 } … … 4135 4370 /* reinitialize listview memory */ 4136 4371 bResult = DPA_DeleteAllPtrs(infoPtr->hdpaItems); 4137 4372 4138 4373 /* align items (set position of each item) */ 4139 4374 if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) … … 4148 4383 } 4149 4384 } 4150 4385 4151 4386 LISTVIEW_UpdateScroll(hwnd); 4152 4387 … … 4154 4389 InvalidateRect(hwnd, NULL, TRUE); 4155 4390 } 4156 4391 4157 4392 return bResult; 4158 4393 } … … 4161 4396 * DESCRIPTION: 4162 4397 * Removes a column from the listview control. 4163 * 4398 * 4164 4399 * PARAMETER(S): 4165 4400 * [I] HWND : window handle … … 4172 4407 static LRESULT LISTVIEW_DeleteColumn(HWND hwnd, INT nColumn) 4173 4408 { 4174 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);4175 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;4176 UINT uOwnerData = GetWindowLong A(hwnd, GWL_STYLE) & LVS_OWNERDATA;4409 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 4410 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 4411 UINT uOwnerData = GetWindowLongW(hwnd, GWL_STYLE) & LVS_OWNERDATA; 4177 4412 BOOL bResult = FALSE; 4178 4413 … … 4202 4437 * DESCRIPTION: 4203 4438 * Removes an item from the listview control. 4204 * 4205 * PARAMETER(S): 4206 * [I] HWND : window handle 4207 * [I] INT : item index 4439 * 4440 * PARAMETER(S): 4441 * [I] HWND : window handle 4442 * [I] INT : item index 4208 4443 * 4209 4444 * RETURN: … … 4213 4448 static LRESULT LISTVIEW_DeleteItem(HWND hwnd, INT nItem) 4214 4449 { 4215 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);4216 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);4450 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 4451 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 4217 4452 UINT uView = lStyle & LVS_TYPEMASK; 4218 LONG lCtrlId = GetWindowLong A(hwnd, GWL_ID);4453 LONG lCtrlId = GetWindowLongW(hwnd, GWL_ID); 4219 4454 NMLISTVIEW nmlv; 4220 4455 BOOL bResult = FALSE; … … 4223 4458 LISTVIEW_SUBITEM *lpSubItem; 4224 4459 INT i; 4225 LVITEM Aitem;4226 4227 TRACE("(hwnd=%x, nItem=%d)\n", hwnd, nItem);4228 4229 4460 LVITEMW item; 4461 4462 TRACE("(hwnd=%x, nItem=%d)\n", hwnd, nItem); 4463 4464 4230 4465 /* First, send LVN_DELETEITEM notification. */ 4231 4466 memset(&nmlv, 0, sizeof (NMLISTVIEW)); … … 4234 4469 nmlv.hdr.code = LVN_DELETEITEM; 4235 4470 nmlv.iItem = nItem; 4236 SendMessage A(GetParent(hwnd), WM_NOTIFY, (WPARAM)lCtrlId,4471 SendMessageW(GetParent(hwnd), WM_NOTIFY, (WPARAM)lCtrlId, 4237 4472 (LPARAM)&nmlv); 4238 4473 4239 4474 4240 4475 /* remove it from the selection range */ 4241 ZeroMemory(&item,sizeof( LVITEMA));4476 ZeroMemory(&item,sizeof(item)); 4242 4477 item.stateMask = LVIS_SELECTED; 4243 4478 LISTVIEW_SetItemState(hwnd,nItem,&item); … … 4264 4499 { 4265 4500 /* free item string */ 4266 if ((lpSubItem->pszText != NULL) && 4267 (lpSubItem->pszText != LPSTR_TEXTCALLBACKA)) 4268 { 4501 if (is_textW(lpSubItem->pszText)) 4269 4502 COMCTL32_Free(lpSubItem->pszText); 4270 } 4271 4503 4272 4504 /* free item */ 4273 4505 COMCTL32_Free(lpSubItem); 4274 } 4506 } 4275 4507 } 4276 4508 4277 4509 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 4278 4510 if (lpItem != NULL) 4279 4511 { 4280 4512 /* free item string */ 4281 if ((lpItem->pszText != NULL) && 4282 (lpItem->pszText != LPSTR_TEXTCALLBACKA)) 4283 { 4513 if (is_textW(lpItem->pszText)) 4284 4514 COMCTL32_Free(lpItem->pszText); 4285 } 4286 4515 4287 4516 /* free item */ 4288 4517 COMCTL32_Free(lpItem); 4289 4518 } 4290 4519 4291 4520 bResult = DPA_Destroy(hdpaSubItems); 4292 4521 } … … 4298 4527 { 4299 4528 if (lStyle & LVS_ALIGNLEFT) 4300 {4301 4529 LISTVIEW_AlignLeft(hwnd); 4302 }4303 4530 else 4304 {4305 4531 LISTVIEW_AlignTop(hwnd); 4306 }4307 4532 } 4308 4533 … … 4312 4537 InvalidateRect(hwnd, NULL, TRUE); 4313 4538 } 4314 4539 4315 4540 return bResult; 4316 4541 } … … 4330 4555 static LRESULT LISTVIEW_GetEditControl(HWND hwnd) 4331 4556 { 4332 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);4557 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 4333 4558 return infoPtr->hwndEdit; 4334 4559 } … … 4343 4568 * [I] LPSTR : modified text 4344 4569 * [I] DWORD : item index 4570 * [I] isW : TRUE if psxText is Unicode, FALSE if it's ANSI 4345 4571 * 4346 4572 * RETURN: … … 4348 4574 * FAILURE : FALSE 4349 4575 */ 4350 4351 static BOOL LISTVIEW_EndEditLabel(HWND hwnd, LPSTR pszText, DWORD nItem) 4352 { 4353 NMLVDISPINFOA dispInfo; 4576 static BOOL LISTVIEW_EndEditLabelT(HWND hwnd, LPWSTR pszText, DWORD nItem, BOOL isW) 4577 { 4578 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 4579 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 4580 NMLVDISPINFOW dispInfo; 4354 4581 LISTVIEW_ITEM *lpItem; 4355 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);4356 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);4357 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);4358 4582 HDPA hdpaSubItems; 4359 BOOL bUpdateItemText;4360 4583 LISTVIEW_ITEM lvItemRef; 4361 LVITEMA item; 4362 4363 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA)); 4364 4584 LVITEMW item; 4585 BOOL bResult = TRUE; 4586 4587 TRACE("(hwnd=%x, pszText=%s, nItem=%ld, isW=%d)\n", hwnd, debugstr_t(pszText, isW), nItem, isW); 4588 4365 4589 if (!(lStyle & LVS_OWNERDATA)) 4366 4590 { 4367 if ( NULL ==(hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem)))4368 4369 4370 if ( NULL ==(lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0)))4371 4591 if (!(hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem))) 4592 return FALSE; 4593 4594 if (!(lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0))) 4595 return FALSE; 4372 4596 } 4373 4597 else 4374 4598 { 4375 4599 ZeroMemory(&lvItemRef,sizeof(LISTVIEW_ITEM)); 4376 ZeroMemory(&item,sizeof( LVITEMA));4600 ZeroMemory(&item,sizeof(item)); 4377 4601 item.iItem = nItem; 4378 4602 item.iSubItem = 0; 4379 4603 item.mask = LVIF_PARAM | LVIF_STATE; 4380 ListView_GetItem A(hwnd,&item);4604 ListView_GetItemW(hwnd, &item); 4381 4605 lvItemRef.state = item.state; 4382 4606 lvItemRef.iImage = item.iImage; … … 4385 4609 } 4386 4610 4387 dispInfo.hdr.hwndFrom = hwnd; 4388 dispInfo.hdr.idFrom = nCtrlId; 4389 dispInfo.hdr.code = LVN_ENDLABELEDITA; 4611 ZeroMemory(&dispInfo, sizeof(dispInfo)); 4390 4612 dispInfo.item.mask = 0; 4391 4613 dispInfo.item.iItem = nItem; … … 4393 4615 dispInfo.item.stateMask = 0; 4394 4616 dispInfo.item.pszText = pszText; 4395 dispInfo.item.cchTextMax = pszText ? strlen(pszText) : 0;4617 dispInfo.item.cchTextMax = textlenT(pszText, isW); 4396 4618 dispInfo.item.iImage = lpItem->iImage; 4397 4619 dispInfo.item.lParam = lpItem->lParam; 4398 4620 infoPtr->hwndEdit = 0; 4399 4621 4400 bUpdateItemText = ListView_Notify(GetParent(hwnd), nCtrlId, &dispInfo);4401 4402 4622 /* Do we need to update the Item Text */ 4403 if(bUpdateItemText) 4404 { 4405 if ((lpItem->pszText != LPSTR_TEXTCALLBACKA)&&(!(lStyle & LVS_OWNERDATA))) 4406 { 4407 Str_SetPtrA(&lpItem->pszText, pszText); 4408 } 4409 } 4410 4411 return TRUE; 4412 } 4413 4414 /*** 4415 * DESCRIPTION: 4416 * Begin in place editing of specified list view item 4417 * 4418 * PARAMETER(S): 4419 * [I] HWND : window handle 4420 * [I] INT : item index 4623 if(dispinfo_notifyT(hwnd, LVN_ENDLABELEDITW, &dispInfo, isW)) 4624 if (lpItem->pszText != LPSTR_TEXTCALLBACKW && !(lStyle & LVS_OWNERDATA)) 4625 bResult = textsetptrT(&lpItem->pszText, pszText, isW); 4626 4627 return bResult; 4628 } 4629 4630 /*** 4631 * DESCRIPTION: 4632 * Callback implementation for editlabel control 4633 * 4634 * PARAMETER(S): 4635 * [I] HWND : window handle 4636 * [I] LPSTR : modified text 4637 * [I] DWORD : item index 4421 4638 * 4422 4639 * RETURN: … … 4424 4641 * FAILURE : FALSE 4425 4642 */ 4426 4427 static HWND LISTVIEW_EditLabelA(HWND hwnd, INT nItem) 4428 { 4429 NMLVDISPINFOA dispInfo; 4643 static BOOL LISTVIEW_EndEditLabelW(HWND hwnd, LPWSTR pszText, DWORD nItem) 4644 { 4645 return LISTVIEW_EndEditLabelT(hwnd, pszText, nItem, TRUE); 4646 } 4647 4648 /*** 4649 * DESCRIPTION: 4650 * Callback implementation for editlabel control 4651 * 4652 * PARAMETER(S): 4653 * [I] HWND : window handle 4654 * [I] LPSTR : modified text 4655 * [I] DWORD : item index 4656 * 4657 * RETURN: 4658 * SUCCESS : TRUE 4659 * FAILURE : FALSE 4660 */ 4661 static BOOL LISTVIEW_EndEditLabelA(HWND hwnd, LPSTR pszText, DWORD nItem) 4662 { 4663 return LISTVIEW_EndEditLabelT(hwnd, (LPWSTR)pszText, nItem, FALSE); 4664 } 4665 4666 /*** 4667 * DESCRIPTION: 4668 * Begin in place editing of specified list view item 4669 * 4670 * PARAMETER(S): 4671 * [I] HWND : window handle 4672 * [I] INT : item index 4673 * [I] isW : TRUE if it's a Unicode req, FALSE if ASCII 4674 * 4675 * RETURN: 4676 * SUCCESS : TRUE 4677 * FAILURE : FALSE 4678 */ 4679 static HWND LISTVIEW_EditLabelT(HWND hwnd, INT nItem, BOOL isW) 4680 { 4681 NMLVDISPINFOW dispInfo; 4430 4682 RECT rect; 4431 4683 LISTVIEW_ITEM *lpItem; 4432 HWND hedit; 4433 HINSTANCE hinst = GetWindowLongA(hwnd, GWL_HINSTANCE); 4434 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 4435 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 4684 HWND hedit; 4685 HINSTANCE hinst = GetWindowLongW(hwnd, GWL_HINSTANCE); 4686 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 4436 4687 HDPA hdpaSubItems; 4437 CHAR szDispText[DISP_TEXT_SIZE];4438 LVITEM A lvItem,item;4688 WCHAR szDispText[DISP_TEXT_SIZE]; 4689 LVITEMW lvItem; 4439 4690 LISTVIEW_ITEM lvItemRef; 4440 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);4441 4442 if (~GetWindowLong A(hwnd, GWL_STYLE) & LVS_EDITLABELS)4691 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 4692 4693 if (~GetWindowLongW(hwnd, GWL_STYLE) & LVS_EDITLABELS) 4443 4694 return FALSE; 4444 4695 4445 4696 /* Is the EditBox still there, if so remove it */ 4446 4697 if(infoPtr->hwndEdit != 0) 4447 {4448 4698 SetFocus(hwnd); 4449 }4450 4699 4451 4700 LISTVIEW_SetSelection(hwnd, nItem); 4452 4701 LISTVIEW_SetItemFocus(hwnd, nItem); 4453 4702 4454 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA));4455 4703 if (!(lStyle & LVS_OWNERDATA)) 4456 4704 { 4457 4705 if (NULL == (hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem))) 4458 4706 return 0; 4459 4707 4460 4708 if (NULL == (lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0))) 4461 4462 } 4709 return 0; 4710 } 4463 4711 else 4464 4712 { 4713 LVITEMW item; 4465 4714 ZeroMemory(&lvItemRef,sizeof(LISTVIEW_ITEM)); 4466 ZeroMemory(&item, sizeof(LVITEMA));4715 ZeroMemory(&item, sizeof(item)); 4467 4716 item.iItem = nItem; 4468 4717 item.iSubItem = 0; 4469 4718 item.mask = LVIF_PARAM | LVIF_STATE; 4470 ListView_GetItem A(hwnd,&item);4719 ListView_GetItemW(hwnd, &item); 4471 4720 lvItemRef.iImage = item.iImage; 4472 4721 lvItemRef.state = item.state; … … 4476 4725 4477 4726 /* get information needed for drawing the item */ 4478 ZeroMemory(&lvItem, sizeof( LVITEMA));4727 ZeroMemory(&lvItem, sizeof(lvItem)); 4479 4728 lvItem.mask = LVIF_TEXT; 4480 4729 lvItem.iItem = nItem; … … 4482 4731 lvItem.cchTextMax = DISP_TEXT_SIZE; 4483 4732 lvItem.pszText = szDispText; 4484 ListView_GetItemA(hwnd, &lvItem); 4485 4486 dispInfo.hdr.hwndFrom = hwnd; 4487 dispInfo.hdr.idFrom = nCtrlId; 4488 dispInfo.hdr.code = LVN_BEGINLABELEDITA; 4733 *lvItem.pszText = '\0'; 4734 LISTVIEW_GetItemT(hwnd, &lvItem, FALSE, isW); 4735 4736 ZeroMemory(&dispInfo, sizeof(dispInfo)); 4489 4737 dispInfo.item.mask = 0; 4490 4738 dispInfo.item.iItem = nItem; … … 4492 4740 dispInfo.item.stateMask = 0; 4493 4741 dispInfo.item.pszText = lvItem.pszText; 4494 dispInfo.item.cchTextMax = strlen(lvItem.pszText);4742 dispInfo.item.cchTextMax = lstrlenW(lvItem.pszText); 4495 4743 dispInfo.item.iImage = lpItem->iImage; 4496 4744 dispInfo.item.lParam = lpItem->lParam; 4497 4745 4498 if ( ListView_LVNotify(GetParent(hwnd), nCtrlId, &dispInfo))4499 4746 if (dispinfo_notifyT(hwnd, LVN_BEGINLABELEDITW, &dispInfo, isW)) 4747 return 0; 4500 4748 4501 4749 rect.left = LVIR_LABEL; 4502 4750 if (!LISTVIEW_GetItemRect(hwnd, nItem, &rect)) 4503 4504 4505 if (!(hedit = CreateEditLabel (szDispText , WS_VISIBLE,4506 rect.left-2, rect.top-1, 0, 4507 rect.bottom - rect.top+2,4508 hwnd, hinst, LISTVIEW_EndEditLabel, nItem)))4509 4751 return 0; 4752 4753 if (!(hedit = CreateEditLabelT(szDispText , WS_VISIBLE, 4754 rect.left-2, rect.top-1, 0, rect.bottom - rect.top+2, hwnd, hinst, 4755 isW ? LISTVIEW_EndEditLabelW : (EditlblCallbackW)LISTVIEW_EndEditLabelA, 4756 nItem, isW))) 4757 return 0; 4510 4758 4511 4759 infoPtr->hwndEdit = hedit; 4512 SetFocus(hedit); 4513 SendMessage A(hedit, EM_SETSEL, 0, -1);4760 SetFocus(hedit); 4761 SendMessageW(hedit, EM_SETSEL, 0, -1); 4514 4762 4515 4763 return hedit; … … 4520 4768 * DESCRIPTION: 4521 4769 * Ensures the specified item is visible, scrolling into view if necessary. 4522 * 4770 * 4523 4771 * PARAMETER(S): 4524 4772 * [I] HWND : window handle … … 4849 5097 } 4850 5098 #endif 5099 4851 5100 /*** 4852 5101 * DESCRIPTION: 4853 5102 * Retrieves the nearest item, given a position and a direction. 4854 * 5103 * 4855 5104 * PARAMETER(S): 4856 5105 * [I] HWND : window handle … … 4863 5112 static INT LISTVIEW_GetNearestItem(HWND hwnd, POINT pt, UINT vkDirection) 4864 5113 { 4865 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);4866 LV HITTESTINFO lvHitTestInfo;5114 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5115 LV_INTHIT lvIntHit; 4867 5116 INT nItem = -1; 4868 5117 RECT rcView; 4869 5118 5119 TRACE("point %ld,%ld, direction %s\n", pt.x, pt.y, 5120 (vkDirection == VK_DOWN) ? "VK_DOWN" : 5121 ((vkDirection == VK_UP) ? "VK_UP" : 5122 ((vkDirection == VK_LEFT) ? "VK_LEFT" : "VK_RIGHT"))); 5123 4870 5124 if (LISTVIEW_GetViewRect(hwnd, &rcView) != FALSE) 4871 5125 { 4872 ZeroMemory(&lvHitTestInfo, sizeof(LVHITTESTINFO)); 4873 LISTVIEW_GetOrigin(hwnd, &lvHitTestInfo.pt); 4874 lvHitTestInfo.pt.x += pt.x; 4875 lvHitTestInfo.pt.y += pt.y; 4876 4877 do 4878 { 4879 if (vkDirection == VK_DOWN) 4880 { 4881 lvHitTestInfo.pt.y += infoPtr->nItemHeight; 4882 } 4883 else if (vkDirection == VK_UP) 4884 { 4885 lvHitTestInfo.pt.y -= infoPtr->nItemHeight; 4886 } 4887 else if (vkDirection == VK_LEFT) 4888 { 4889 lvHitTestInfo.pt.x -= infoPtr->nItemWidth; 4890 } 4891 else if (vkDirection == VK_RIGHT) 4892 { 4893 lvHitTestInfo.pt.x += infoPtr->nItemWidth; 4894 } 4895 4896 if (PtInRect(&rcView, lvHitTestInfo.pt) == FALSE) 4897 { 4898 return -1; 4899 } 4900 else 4901 { 4902 nItem = LISTVIEW_HitTestItem(hwnd, &lvHitTestInfo, TRUE); 4903 } 4904 4905 } 4906 while (nItem == -1); 5126 ZeroMemory(&lvIntHit, sizeof(lvIntHit)); 5127 LISTVIEW_GetOrigin(hwnd, &lvIntHit.ht.pt); 5128 lvIntHit.ht.pt.x += pt.x; 5129 lvIntHit.ht.pt.y += pt.y; 5130 5131 if (vkDirection == VK_DOWN) 5132 lvIntHit.ht.pt.y += infoPtr->nItemHeight; 5133 else if (vkDirection == VK_UP) 5134 lvIntHit.ht.pt.y -= infoPtr->nItemHeight; 5135 else if (vkDirection == VK_LEFT) 5136 lvIntHit.ht.pt.x -= infoPtr->nItemWidth; 5137 else if (vkDirection == VK_RIGHT) 5138 lvIntHit.ht.pt.x += infoPtr->nItemWidth; 5139 5140 if (PtInRect(&rcView, lvIntHit.ht.pt) == FALSE) 5141 return -1; 5142 else 5143 { 5144 nItem = LISTVIEW_SuperHitTestItem(hwnd, &lvIntHit, TRUE); 5145 return nItem == -1 ? lvIntHit.iDistItem : nItem; 5146 } 4907 5147 } 4908 5148 4909 5149 return nItem; 4910 } 5150 } 4911 5151 4912 5152 /*** 4913 5153 * DESCRIPTION: 4914 5154 * Searches for an item with specific characteristics. 4915 * 4916 * PARAMETER(S): 4917 * [I] HWND: window handle4918 * [I] INT: base item index4919 * [I] LPLVFINDINFO: item information to look for4920 * 5155 * 5156 * PARAMETER(S): 5157 * [I] hwnd : window handle 5158 * [I] nStart : base item index 5159 * [I] lpFindInfo : item information to look for 5160 * 4921 5161 * RETURN: 4922 5162 * SUCCESS : index of item 4923 5163 * FAILURE : -1 4924 5164 */ 4925 static LRESULT LISTVIEW_FindItem (HWND hwnd, INT nStart,4926 LPLVFINDINFOlpFindInfo)4927 { 4928 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5165 static LRESULT LISTVIEW_FindItemW(HWND hwnd, INT nStart, 5166 LPLVFINDINFOW lpFindInfo) 5167 { 5168 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 4929 5169 POINT ptItem; 4930 CHAR szDispText[DISP_TEXT_SIZE];4931 LVITEM AlvItem;5170 WCHAR szDispText[DISP_TEXT_SIZE] = { '\0' }; 5171 LVITEMW lvItem; 4932 5172 BOOL bWrap = FALSE; 4933 5173 INT nItem = nStart; … … 4936 5176 if ((nItem >= -1) && (lpFindInfo != NULL)) 4937 5177 { 4938 ZeroMemory(&lvItem, sizeof( LVITEMA));5178 ZeroMemory(&lvItem, sizeof(lvItem)); 4939 5179 4940 5180 if (lpFindInfo->flags & LVFI_PARAM) … … 4942 5182 lvItem.mask |= LVIF_PARAM; 4943 5183 } 4944 4945 if (lpFindInfo->flags & LVFI_STRING)5184 5185 if (lpFindInfo->flags & (LVFI_STRING | LVFI_PARTIAL)) 4946 5186 { 4947 5187 lvItem.mask |= LVIF_TEXT; … … 4950 5190 } 4951 5191 4952 if (lpFindInfo->flags & LVFI_PARTIAL)4953 {4954 lvItem.mask |= LVIF_TEXT;4955 lvItem.pszText = szDispText;4956 lvItem.cchTextMax = DISP_TEXT_SIZE;4957 }4958 4959 5192 if (lpFindInfo->flags & LVFI_WRAP) 4960 {4961 5193 bWrap = TRUE; 4962 }4963 5194 4964 5195 if (lpFindInfo->flags & LVFI_NEARESTXY) … … 4974 5205 if (lpFindInfo->flags & LVFI_NEARESTXY) 4975 5206 { 4976 nItem = LISTVIEW_GetNearestItem(hwnd, ptItem, 5207 nItem = LISTVIEW_GetNearestItem(hwnd, ptItem, 4977 5208 lpFindInfo->vkDirection); 4978 5209 if (nItem != -1) … … 4989 5220 nItem++; 4990 5221 } 4991 5222 4992 5223 lvItem.iItem = nItem; 4993 5224 lvItem.iSubItem = 0; 4994 if (LISTVIEW_GetItem A(hwnd, &lvItem, TRUE) != FALSE)5225 if (LISTVIEW_GetItemW(hwnd, &lvItem, TRUE)) 4995 5226 { 4996 5227 if (lvItem.mask & LVIF_TEXT) … … 4998 5229 if (lpFindInfo->flags & LVFI_PARTIAL) 4999 5230 { 5000 if (strstr (lvItem.pszText, lpFindInfo->psz) == NULL)5231 if (strstrW(lvItem.pszText, lpFindInfo->psz) == NULL) 5001 5232 continue; 5002 5233 } 5003 5234 else 5004 5235 { 5005 if ( strcmp(lvItem.pszText, lpFindInfo->psz) != 0)5236 if (lstrcmpW(lvItem.pszText, lpFindInfo->psz) != 0) 5006 5237 continue; 5007 5238 } 5008 5239 } 5009 5240 5010 5241 if (lvItem.mask & LVIF_PARAM) 5011 5242 { … … 5013 5244 continue; 5014 5245 } 5015 5246 5016 5247 return nItem; 5017 5248 } 5018 5249 } 5019 5250 5020 if (bWrap != FALSE)5251 if (bWrap) 5021 5252 { 5022 5253 nItem = -1; … … 5027 5258 { 5028 5259 return -1; 5029 } 5030 } 5031 } 5032 5033 return -1; 5260 } 5261 } 5262 } 5263 5264 return -1; 5265 } 5266 5267 /*** 5268 * DESCRIPTION: 5269 * Searches for an item with specific characteristics. 5270 * 5271 * PARAMETER(S): 5272 * [I] hwnd : window handle 5273 * [I] nStart : base item index 5274 * [I] lpFindInfo : item information to look for 5275 * 5276 * RETURN: 5277 * SUCCESS : index of item 5278 * FAILURE : -1 5279 */ 5280 static LRESULT LISTVIEW_FindItemA(HWND hwnd, INT nStart, 5281 LPLVFINDINFOA lpFindInfo) 5282 { 5283 BOOL hasText = lpFindInfo->flags & (LVFI_STRING | LVFI_PARTIAL); 5284 LVFINDINFOW fiw; 5285 LRESULT res; 5286 5287 memcpy(&fiw, lpFindInfo, sizeof(fiw)); 5288 if (hasText) fiw.psz = textdupTtoW((LPCWSTR)lpFindInfo->psz, FALSE); 5289 res = LISTVIEW_FindItemW(hwnd, nStart, &fiw); 5290 if (hasText) textfreeT((LPWSTR)fiw.psz, FALSE); 5291 return res; 5034 5292 } 5035 5293 … … 5037 5295 * DESCRIPTION: 5038 5296 * Retrieves the background color of the listview control. 5039 * 5297 * 5040 5298 * PARAMETER(S): 5041 5299 * [I] HWND : window handle … … 5046 5304 static LRESULT LISTVIEW_GetBkColor(HWND hwnd) 5047 5305 { 5048 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5306 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5049 5307 5050 5308 return infoPtr->clrBk; … … 5054 5312 * DESCRIPTION: 5055 5313 * Retrieves the background image of the listview control. 5056 * 5314 * 5057 5315 * PARAMETER(S): 5058 5316 * [I] HWND : window handle … … 5072 5330 * DESCRIPTION: 5073 5331 * Retrieves the callback mask. 5074 * 5332 * 5075 5333 * PARAMETER(S): 5076 5334 * [I] HWND : window handle … … 5081 5339 static UINT LISTVIEW_GetCallbackMask(HWND hwnd) 5082 5340 { 5083 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5341 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5084 5342 5085 5343 return infoPtr->uCallbackMask; … … 5089 5347 * DESCRIPTION: 5090 5348 * Retrieves column attributes. 5091 * 5349 * 5092 5350 * PARAMETER(S): 5093 5351 * [I] HWND : window handle 5094 5352 * [I] INT : column index 5095 * [IO] LPLVCOLUMNA : column information 5353 * [IO] LPLVCOLUMNW : column information 5354 * [I] isW : if TRUE, then lpColumn is a LPLVCOLUMNW 5355 * otherwise it is in fact a LPLVCOLUMNA 5096 5356 * 5097 5357 * RETURN: … … 5099 5359 * FAILURE : FALSE 5100 5360 */ 5101 static LRESULT LISTVIEW_GetColumn A(HWND hwnd, INT nItem, LPLVCOLUMNA lpColumn)5102 { 5103 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5104 HDITEM Ahdi;5361 static LRESULT LISTVIEW_GetColumnT(HWND hwnd, INT nItem, LPLVCOLUMNW lpColumn, BOOL isW) 5362 { 5363 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5364 HDITEMW hdi; 5105 5365 BOOL bResult = FALSE; 5106 5366 5107 5367 if (lpColumn != NULL) 5108 5368 { 5369 5370 TRACE("(hwnd=%x, col=%d, lpColumn=%s, isW=%d)\n", 5371 hwnd, nItem, debuglvcolumn_t(lpColumn, isW), isW); 5372 5109 5373 /* initialize memory */ 5110 ZeroMemory(&hdi, sizeof( HDITEMA));5111 5374 ZeroMemory(&hdi, sizeof(hdi)); 5375 5112 5376 if (lpColumn->mask & LVCF_FMT) 5113 {5114 5377 hdi.mask |= HDI_FORMAT; 5115 }5116 5378 5117 5379 if (lpColumn->mask & LVCF_WIDTH) 5118 {5119 5380 hdi.mask |= HDI_WIDTH; 5120 }5121 5381 5122 5382 if (lpColumn->mask & LVCF_TEXT) … … 5128 5388 5129 5389 if (lpColumn->mask & LVCF_IMAGE) 5130 {5131 5390 hdi.mask |= HDI_IMAGE; 5132 }5133 5391 5134 5392 if (lpColumn->mask & LVCF_ORDER) 5135 {5136 5393 hdi.mask |= HDI_ORDER; 5137 } 5138 5139 bResult = Header_GetItemA(infoPtr->hwndHeader, nItem, &hdi); 5394 5395 if (isW) 5396 bResult = Header_GetItemW(infoPtr->hwndHeader, nItem, &hdi); 5397 else 5398 bResult = Header_GetItemA(infoPtr->hwndHeader, nItem, &hdi); 5399 5140 5400 if (bResult != FALSE) 5141 5401 { 5142 if (lpColumn->mask & LVCF_FMT) 5402 if (lpColumn->mask & LVCF_FMT) 5143 5403 { 5144 5404 lpColumn->fmt = 0; 5145 5405 5146 5406 if (hdi.fmt & HDF_LEFT) 5147 {5148 5407 lpColumn->fmt |= LVCFMT_LEFT; 5149 }5150 5408 else if (hdi.fmt & HDF_RIGHT) 5151 {5152 5409 lpColumn->fmt |= LVCFMT_RIGHT; 5153 }5154 5410 else if (hdi.fmt & HDF_CENTER) 5155 {5156 5411 lpColumn->fmt |= LVCFMT_CENTER; 5157 }5158 5412 5159 5413 if (hdi.fmt & HDF_IMAGE) 5160 {5161 5414 lpColumn->fmt |= LVCFMT_COL_HAS_IMAGES; 5162 } 5163 5164 if (hdi.fmt & HDF_BITMAP_ON_RIGHT) 5165 { 5166 lpColumn->fmt |= LVCFMT_BITMAP_ON_RIGHT; 5167 } 5415 5416 if (hdi.fmt & HDF_BITMAP_ON_RIGHT) 5417 lpColumn->fmt |= LVCFMT_BITMAP_ON_RIGHT; 5168 5418 } 5169 5419 5170 5420 if (lpColumn->mask & LVCF_WIDTH) 5171 {5172 5421 lpColumn->cx = hdi.cxy; 5173 } 5174 5422 5175 5423 if (lpColumn->mask & LVCF_IMAGE) 5176 {5177 5424 lpColumn->iImage = hdi.iImage; 5178 }5179 5425 5180 5426 if (lpColumn->mask & LVCF_ORDER) 5181 {5182 5427 lpColumn->iOrder = hdi.iOrder; 5183 }5184 5428 } 5185 5429 } … … 5188 5432 } 5189 5433 5190 /* LISTVIEW_GetColumnW */5191 5192 5434 5193 5435 static LRESULT LISTVIEW_GetColumnOrderArray(HWND hwnd, INT iCount, LPINT lpiArray) 5194 5436 { 5195 /* LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0); */5437 /* LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); */ 5196 5438 INT i; 5197 5439 5198 5440 if (!lpiArray) 5199 5441 return FALSE; 5200 5442 5201 5443 /* little hack */ 5202 5444 for (i = 0; i < iCount; i++) 5203 5445 lpiArray[i] = i; 5204 5446 5205 5447 return TRUE; … … 5209 5451 * DESCRIPTION: 5210 5452 * Retrieves the column width. 5211 * 5453 * 5212 5454 * PARAMETER(S): 5213 5455 * [I] HWND : window handle … … 5216 5458 * RETURN: 5217 5459 * SUCCESS : column width 5218 * FAILURE : zero 5460 * FAILURE : zero 5219 5461 */ 5220 5462 static LRESULT LISTVIEW_GetColumnWidth(HWND hwnd, INT nColumn) 5221 5463 { 5222 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5223 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;5464 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5465 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 5224 5466 INT nColumnWidth = 0; 5225 HDITEM Ahdi;5467 HDITEMW hdi; 5226 5468 5227 5469 if (uView == LVS_LIST) … … 5232 5474 { 5233 5475 /* get column width from header */ 5234 ZeroMemory(&hdi, sizeof( HDITEMA));5476 ZeroMemory(&hdi, sizeof(hdi)); 5235 5477 hdi.mask = HDI_WIDTH; 5236 if (Header_GetItemA(infoPtr->hwndHeader, nColumn, &hdi) != FALSE) 5237 { 5478 if (Header_GetItemW(infoPtr->hwndHeader, nColumn, &hdi) != FALSE) 5238 5479 nColumnWidth = hdi.cxy; 5239 }5240 5480 } 5241 5481 … … 5245 5485 /*** 5246 5486 * DESCRIPTION: 5247 * In list or report display mode, retrieves the number of items that can fit 5248 * vertically in the visible area. In icon or small icon display mode, 5487 * In list or report display mode, retrieves the number of items that can fit 5488 * vertically in the visible area. In icon or small icon display mode, 5249 5489 * retrieves the total number of visible items. 5250 * 5490 * 5251 5491 * PARAMETER(S): 5252 5492 * [I] HWND : window handle … … 5257 5497 static LRESULT LISTVIEW_GetCountPerPage(HWND hwnd) 5258 5498 { 5259 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5260 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;5499 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5500 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 5261 5501 INT nItemCount = 0; 5262 5502 … … 5265 5505 if (infoPtr->rcList.right > infoPtr->nItemWidth) 5266 5506 { 5267 nItemCount = LISTVIEW_GetCountPerRow(hwnd) * 5507 nItemCount = LISTVIEW_GetCountPerRow(hwnd) * 5268 5508 LISTVIEW_GetCountPerColumn(hwnd); 5269 5509 } … … 5299 5539 5300 5540 /* make sure we can get the listview info */ 5301 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0)))5302 5541 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0))) 5542 return (0); 5303 5543 5304 5544 return (infoPtr->dwExStyle); … … 5308 5548 * DESCRIPTION: 5309 5549 * Retrieves the handle to the header control. 5310 * 5550 * 5311 5551 * PARAMETER(S): 5312 5552 * [I] HWND : window handle … … 5317 5557 static LRESULT LISTVIEW_GetHeader(HWND hwnd) 5318 5558 { 5319 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5559 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5320 5560 5321 5561 return infoPtr->hwndHeader; … … 5338 5578 static LRESULT LISTVIEW_GetHoverTime(HWND hwnd) 5339 5579 { 5340 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5580 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5341 5581 5342 5582 return infoPtr->dwHoverTime; … … 5346 5586 * DESCRIPTION: 5347 5587 * Retrieves an image list handle. 5348 * 5349 * PARAMETER(S): 5350 * [I] HWND : window handle 5351 * [I] INT : image list identifier 5352 * 5588 * 5589 * PARAMETER(S): 5590 * [I] HWND : window handle 5591 * [I] INT : image list identifier 5592 * 5353 5593 * RETURN: 5354 5594 * SUCCESS : image list handle … … 5357 5597 static LRESULT LISTVIEW_GetImageList(HWND hwnd, INT nImageList) 5358 5598 { 5359 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5599 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5360 5600 HIMAGELIST himl = NULL; 5361 5601 5362 switch (nImageList) 5602 switch (nImageList) 5363 5603 { 5364 5604 case LVSIL_NORMAL: … … 5381 5621 * DESCRIPTION: 5382 5622 * Retrieves item attributes. 5383 * 5384 * PARAMETER(S): 5385 * [I] HWND: window handle5386 * [IO] LPLVITEMA: item info5623 * 5624 * PARAMETER(S): 5625 * [I] hwnd : window handle 5626 * [IO] lpLVItem : item info 5387 5627 * [I] internal : if true then we will use tricks that avoid copies 5388 5628 * but are not compatible with the regular interface 5389 * 5390 * RETURN: 5391 * SUCCESS : TRUE 5629 * [I] isW : if TRUE, then lpLVItem is a LPLVITEMW, 5630 * if FALSE, the lpLVItem is a LPLVITEMA. 5631 * 5632 * RETURN: 5633 * SUCCESS : TRUE 5392 5634 * FAILURE : FALSE 5393 5635 */ 5394 static LRESULT LISTVIEW_GetItem A(HWND hwnd, LPLVITEMA lpLVItem, BOOL internal)5395 { 5396 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5397 LONG l CtrlId = GetWindowLongA(hwnd, GWL_ID);5398 NMLVDISPINFO AdispInfo;5636 static LRESULT LISTVIEW_GetItemT(HWND hwnd, LPLVITEMW lpLVItem, BOOL internal, BOOL isW) 5637 { 5638 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5639 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 5640 NMLVDISPINFOW dispInfo; 5399 5641 LISTVIEW_SUBITEM *lpSubItem; 5400 5642 LISTVIEW_ITEM *lpItem; 5401 INT* piImage;5402 LPSTR* ppszText;5403 LPARAM *plParam;5404 5643 HDPA hdpaSubItems; 5405 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 5644 void* null = NULL; 5645 INT* piImage = (INT*)&null; 5646 LPWSTR* ppszText= (LPWSTR*)&null; 5647 LPARAM* plParam = (LPARAM*)&null; 5648 5649 if (internal && !isW) 5650 { 5651 ERR("We can't have internal non-Unicode GetItem!\n"); 5652 return FALSE; 5653 } 5654 5406 5655 /* In the following: 5407 5656 * lpLVItem describes the information requested by the user 5408 5657 * lpItem/lpSubItem is what we have 5409 * dispInfo is a structure we use to request the missing 5658 * dispInfo is a structure we use to request the missing 5410 5659 * information from the application 5411 5660 */ 5412 5661 5413 TRACE("(hwnd=%x, lpLVItem=%p)\n", hwnd, lpLVItem); 5414 5415 if ((lpLVItem == NULL) || 5416 (lpLVItem->iItem < 0) || 5417 (lpLVItem->iItem >= GETITEMCOUNT(infoPtr)) 5418 ) 5662 TRACE("(hwnd=%x, lpLVItem=%s, internal=%d, isW=%d)\n", 5663 hwnd, debuglvitem_t(lpLVItem, isW), internal, isW); 5664 5665 if ((lpLVItem == NULL) || (lpLVItem->iItem < 0) || 5666 (lpLVItem->iItem >= GETITEMCOUNT(infoPtr))) 5419 5667 return FALSE; 5420 5668 5669 ZeroMemory(&dispInfo, sizeof(dispInfo)); 5670 5421 5671 if (lStyle & LVS_OWNERDATA) 5422 5672 { 5423 5673 if (lpLVItem->mask & ~LVIF_STATE) 5424 5674 { 5425 dispInfo.hdr.hwndFrom = hwnd; 5426 dispInfo.hdr.idFrom = lCtrlId; 5427 dispInfo.hdr.code = LVN_GETDISPINFOA; 5428 memcpy(&dispInfo.item,lpLVItem,sizeof(LVITEMA)); 5429 5430 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 5431 memcpy(lpLVItem,&dispInfo.item,sizeof(LVITEMA)); 5675 memcpy(&dispInfo.item, lpLVItem, sizeof(LVITEMW)); 5676 dispinfo_notifyT(hwnd, LVN_GETDISPINFOW, &dispInfo, isW); 5677 memcpy(lpLVItem, &dispInfo.item, sizeof(LVITEMW)); 5678 TRACE(" getdispinfo(1):lpLVItem=%s\n", debuglvitem_t(lpLVItem, isW)); 5432 5679 } 5433 5680 5434 5681 if ((lpLVItem->mask & LVIF_STATE)&&(lpLVItem->iSubItem == 0)) 5435 5682 { 5436 lpLVItem->state = 0; 5683 lpLVItem->state = 0; 5437 5684 if (infoPtr->nFocusedItem == lpLVItem->iItem) 5438 5685 lpLVItem->state |= LVIS_FOCUSED; … … 5444 5691 } 5445 5692 5446 5447 5693 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem); 5448 if (hdpaSubItems == NULL) 5694 if (hdpaSubItems == NULL) return FALSE; 5695 5696 if ( (lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0)) == NULL) 5449 5697 return FALSE; 5450 5698 5451 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 5452 if (lpItem == NULL) 5453 return FALSE; 5454 5455 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA)); 5699 ZeroMemory(&dispInfo.item, sizeof(LVITEMW)); 5456 5700 if (lpLVItem->iSubItem == 0) 5457 5701 { … … 5459 5703 ppszText=&lpItem->pszText; 5460 5704 plParam=&lpItem->lParam; 5461 if (( infoPtr->uCallbackMask != 0) && (lpLVItem->mask & LVIF_STATE))5462 { 5705 if ((lpLVItem->mask & LVIF_STATE) && infoPtr->uCallbackMask) 5706 { 5463 5707 dispInfo.item.mask |= LVIF_STATE; 5464 dispInfo.item.stateMask = infoPtr->uCallbackMask; 5708 dispInfo.item.stateMask = infoPtr->uCallbackMask; 5465 5709 } 5466 5710 } … … 5472 5716 piImage=&lpSubItem->iImage; 5473 5717 ppszText=&lpSubItem->pszText; 5474 plParam=NULL; 5475 } 5476 else 5477 { 5478 piImage=NULL; 5479 ppszText=NULL; 5480 plParam=NULL; 5481 } 5482 } 5483 5484 if ((lpLVItem->mask & LVIF_IMAGE) && 5485 ((piImage==NULL) || (*piImage == I_IMAGECALLBACK))) 5718 } 5719 } 5720 5721 if ((lpLVItem->mask & LVIF_IMAGE) && (*piImage==I_IMAGECALLBACK)) 5486 5722 { 5487 5723 dispInfo.item.mask |= LVIF_IMAGE; 5488 5724 } 5489 5725 5490 if ((lpLVItem->mask & LVIF_TEXT) && 5491 ((ppszText==NULL) || (*ppszText == LPSTR_TEXTCALLBACKA))) 5726 if ((lpLVItem->mask & LVIF_TEXT) && !is_textW(*ppszText)) 5492 5727 { 5493 5728 dispInfo.item.mask |= LVIF_TEXT; 5494 5729 dispInfo.item.pszText = lpLVItem->pszText; 5495 5730 dispInfo.item.cchTextMax = lpLVItem->cchTextMax; 5731 if (dispInfo.item.pszText && lpLVItem->cchTextMax > 0) 5732 *dispInfo.item.pszText = '\0'; 5733 if (dispInfo.item.pszText && (*ppszText == NULL)) 5734 *dispInfo.item.pszText = '\0'; 5496 5735 } 5497 5736 … … 5499 5738 { 5500 5739 /* We don't have all the requested info, query the application */ 5501 dispInfo.hdr.hwndFrom = hwnd;5502 dispInfo.hdr.idFrom = lCtrlId;5503 dispInfo.hdr.code = LVN_GETDISPINFOA;5504 5740 dispInfo.item.iItem = lpLVItem->iItem; 5505 5741 dispInfo.item.iSubItem = lpLVItem->iSubItem; 5506 5742 dispInfo.item.lParam = lpItem->lParam; 5507 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 5743 dispinfo_notifyT(hwnd, LVN_GETDISPINFOW, &dispInfo, isW); 5744 TRACE(" getdispinfo(2):lpLVItem=%s\n", debuglvitem_t(&dispInfo.item, isW)); 5508 5745 } 5509 5746 … … 5511 5748 { 5512 5749 lpLVItem->iImage = dispInfo.item.iImage; 5513 if ((dispInfo.item.mask & LVIF_DI_SETITEM) && piImage) 5514 { 5750 if ((dispInfo.item.mask & LVIF_DI_SETITEM) && (*piImage==I_IMAGECALLBACK)) 5515 5751 *piImage = dispInfo.item.iImage; 5516 }5517 5752 } 5518 5753 else if (lpLVItem->mask & LVIF_IMAGE) … … 5524 5759 { 5525 5760 lpLVItem->lParam = dispInfo.item.lParam; 5526 if ((dispInfo.item.mask & LVIF_DI_SETITEM) && plParam) 5527 { 5761 if (dispInfo.item.mask & LVIF_DI_SETITEM) 5528 5762 *plParam = dispInfo.item.lParam; 5529 }5530 5763 } 5531 5764 else if (lpLVItem->mask & LVIF_PARAM) 5532 {5533 5765 lpLVItem->lParam = lpItem->lParam; 5534 }5535 5766 5536 5767 #ifdef __WIN32OS2__ … … 5542 5773 if (dispInfo.item.mask & LVIF_TEXT) 5543 5774 { 5544 if ((dispInfo.item.mask & LVIF_DI_SETITEM) && (ppszText != NULL)) 5545 { 5546 #ifdef __WIN32OS2__ 5547 dprintf(("LISTVIEW_GetItemA *ppszText (%x), dispInfo.item.pszText (%x);", *ppszText, dispInfo.item.pszText)); 5548 if (ppszText && (UINT)*ppszText != -1) { 5549 Str_SetPtrA(ppszText, dispInfo.item.pszText); 5550 } /* endif */ 5551 #else 5552 Str_SetPtrA(ppszText, dispInfo.item.pszText); 5553 #endif 5554 } 5775 if ((dispInfo.item.mask & LVIF_DI_SETITEM) && *ppszText) 5776 textsetptrT(ppszText, dispInfo.item.pszText, isW); 5777 5555 5778 /* If lpLVItem->pszText==dispInfo.item.pszText a copy is unnecessary, but */ 5556 5779 /* some apps give a new pointer in ListView_Notify so we can't be sure. */ 5557 if (lpLVItem->pszText!=dispInfo.item.pszText) { 5558 lstrcpynA(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax); 5559 } 5560 5561 if (ppszText == NULL) 5562 { 5563 lstrcpynA(lpLVItem->pszText, "", lpLVItem->cchTextMax); 5564 } 5780 if (lpLVItem->pszText != dispInfo.item.pszText) 5781 textcpynT(lpLVItem->pszText, isW, dispInfo.item.pszText, isW, lpLVItem->cchTextMax); 5782 5565 5783 } 5566 5784 else if (lpLVItem->mask & LVIF_TEXT) 5567 5785 { 5568 if (internal==TRUE) 5569 { 5570 lpLVItem->pszText=*ppszText; 5571 } else { 5572 lstrcpynA(lpLVItem->pszText, *ppszText, lpLVItem->cchTextMax); 5573 } 5786 if (internal) lpLVItem->pszText = *ppszText; 5787 else textcpynT(lpLVItem->pszText, isW, *ppszText, TRUE, lpLVItem->cchTextMax); 5574 5788 } 5575 5789 … … 5583 5797 5584 5798 lpLVItem->state &= ~LVIS_SELECTED; 5585 if ((dispInfo.item.stateMask & LVIS_SELECTED) && 5586 (LISTVIEW_IsSelected(hwnd,dispInfo.item.iItem)))5799 if ((dispInfo.item.stateMask & LVIS_SELECTED) && 5800 LISTVIEW_IsSelected(hwnd,dispInfo.item.iItem)) 5587 5801 lpLVItem->state |= LVIS_SELECTED; 5588 5802 } … … 5592 5806 5593 5807 lpLVItem->state &= ~LVIS_SELECTED; 5594 if ((lpLVItem->stateMask & LVIS_SELECTED) && 5595 (LISTVIEW_IsSelected(hwnd,lpLVItem->iItem)))5808 if ((lpLVItem->stateMask & LVIS_SELECTED) && 5809 LISTVIEW_IsSelected(hwnd,lpLVItem->iItem)) 5596 5810 lpLVItem->state |= LVIS_SELECTED; 5597 5811 } 5598 5812 5599 5813 if (lpLVItem->mask & LVIF_PARAM) 5600 {5601 5814 lpLVItem->lParam = lpItem->lParam; 5602 }5603 5815 5604 5816 if (lpLVItem->mask & LVIF_INDENT) 5605 {5606 5817 lpLVItem->iIndent = lpItem->iIndent; 5607 }5608 5818 } 5609 5819 … … 5611 5821 } 5612 5822 5613 /* LISTVIEW_GetItemW */5614 5823 /* LISTVIEW_GetHotCursor */ 5615 5824 … … 5627 5836 static LRESULT LISTVIEW_GetHotItem(HWND hwnd) 5628 5837 { 5629 LISTVIEW_INFO *infoPtr; 5630 5631 /* make sure we can get the listview info */ 5632 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 5633 return (-1); 5634 5635 return (infoPtr->nHotItem); 5838 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5839 5840 return infoPtr->nHotItem; 5636 5841 } 5637 5842 … … 5641 5846 * DESCRIPTION: 5642 5847 * Retrieves the number of items in the listview control. 5643 * 5644 * PARAMETER(S): 5645 * [I] HWND : window handle 5646 * 5848 * 5849 * PARAMETER(S): 5850 * [I] HWND : window handle 5851 * 5647 5852 * RETURN: 5648 5853 * Number of items. … … 5650 5855 static LRESULT LISTVIEW_GetItemCount(HWND hwnd) 5651 5856 { 5652 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5857 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5653 5858 5654 5859 return GETITEMCOUNT(infoPtr); … … 5657 5862 /*** 5658 5863 * DESCRIPTION: 5659 * Retrieves the position (upper-left) of the listview control item.5660 * 5864 * Retrieves the rectangle enclosing the item icon and text. 5865 * 5661 5866 * PARAMETER(S): 5662 5867 * [I] HWND : window handle 5663 5868 * [I] INT : item index 5664 * [O] LP POINT : coordinate information5869 * [O] LPRECT : coordinate information 5665 5870 * 5666 5871 * RETURN: … … 5668 5873 * FAILURE : FALSE 5669 5874 */ 5670 static BOOL LISTVIEW_GetItem Position(HWND hwnd, INT nItem,5671 LPPOINT lpptPosition) 5672 { 5673 L ISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);5674 UINT uView = GetWindowLongA(hwnd, GWL_STYLE)& LVS_TYPEMASK;5875 static BOOL LISTVIEW_GetItemBoundBox(HWND hwnd, INT nItem, LPRECT lpRect) 5876 { 5877 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 5878 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 5879 UINT uView = lStyle & LVS_TYPEMASK; 5675 5880 BOOL bResult = FALSE; 5676 5881 HDPA hdpaSubItems; … … 5679 5884 INT nRow; 5680 5885 5681 TRACE("(hwnd=%x,nItem=%d,lpptPosition=%p)\n", hwnd, nItem, 5682 lpptPosition); 5683 5684 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && 5685 (lpptPosition != NULL)) 5886 TRACE("(hwnd=%x,nItem=%d,lpRect=%p)\n", hwnd, nItem, lpRect); 5887 5888 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && 5889 (lpRect != NULL)) 5686 5890 { 5687 5891 if (uView == LVS_LIST) … … 5695 5899 if (nRow == 0) 5696 5900 { 5697 lp ptPosition->x= nItem / nCountPerColumn * infoPtr->nItemWidth;5698 lp ptPosition->y= 0;5901 lpRect->left = nItem / nCountPerColumn * infoPtr->nItemWidth; 5902 lpRect->top = 0; 5699 5903 } 5700 5904 else 5701 5905 { 5702 lp ptPosition->x= (nItem / nCountPerColumn -1) * infoPtr->nItemWidth;5703 lp ptPosition->y= (nRow + nCountPerColumn) * infoPtr->nItemHeight;5906 lpRect->left = (nItem / nCountPerColumn -1) * infoPtr->nItemWidth; 5907 lpRect->top = (nRow + nCountPerColumn) * infoPtr->nItemHeight; 5704 5908 } 5705 5909 } 5706 5910 else 5707 5911 { 5708 lp ptPosition->x= nItem / nCountPerColumn * infoPtr->nItemWidth;5709 lp ptPosition->y= nItem % nCountPerColumn * infoPtr->nItemHeight;5912 lpRect->left = nItem / nCountPerColumn * infoPtr->nItemWidth; 5913 lpRect->top = nItem % nCountPerColumn * infoPtr->nItemHeight; 5710 5914 } 5711 5915 } 5712 5916 else if (uView == LVS_REPORT) 5713 5917 { 5714 SCROLLINFO scrollInfo;5715 5918 bResult = TRUE; 5716 lp ptPosition->x= REPORT_MARGINX;5717 lp ptPosition->y = ((nItem - ListView_GetTopIndex(hwnd)) *5919 lpRect->left = REPORT_MARGINX; 5920 lpRect->top = ((nItem - ListView_GetTopIndex(hwnd)) * 5718 5921 infoPtr->nItemHeight) + infoPtr->rcList.top; 5719 5922 5720 /* Adjust position by scrollbar offset */ 5721 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 5722 scrollInfo.cbSize = sizeof(SCROLLINFO); 5723 scrollInfo.fMask = SIF_POS; 5724 GetScrollInfo(hwnd, SB_HORZ, &scrollInfo); 5725 lpptPosition->x -= scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 5726 } 5727 else 5728 { 5729 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem); 5730 if (hdpaSubItems != NULL) 5923 if (!(lStyle & LVS_NOSCROLL)) 5731 5924 { 5732 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 5733 if (lpItem != NULL) 5925 SCROLLINFO scrollInfo; 5926 /* Adjust position by scrollbar offset */ 5927 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 5928 scrollInfo.cbSize = sizeof(SCROLLINFO); 5929 scrollInfo.fMask = SIF_POS; 5930 GetScrollInfo(hwnd, SB_HORZ, &scrollInfo); 5931 lpRect->left -= scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 5932 } 5933 } 5934 else /* either LVS_ICON or LVS_SMALLICON */ 5935 { 5936 if ((hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem))) 5937 { 5938 if ((lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0))) 5734 5939 { 5735 5940 bResult = TRUE; 5736 lp ptPosition->x= lpItem->ptPosition.x;5737 lp ptPosition->y= lpItem->ptPosition.y;5941 lpRect->left = lpItem->ptPosition.x; 5942 lpRect->top = lpItem->ptPosition.y; 5738 5943 } 5739 5944 } 5740 5945 } 5741 5946 } 5947 lpRect->right = lpRect->left + infoPtr->nItemWidth; 5948 lpRect->bottom = lpRect->top + infoPtr->nItemHeight; 5949 TRACE("result %s: (%d,%d)-(%d,%d)\n", bResult ? "TRUE" : "FALSE", 5950 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); 5742 5951 return bResult; 5743 5952 } … … 5745 5954 /*** 5746 5955 * DESCRIPTION: 5956 * Retrieves the position (upper-left) of the listview control item. 5957 * Note that for LVS_ICON style, the upper-left is that of the icon 5958 * and not the bounding box. 5959 * 5960 * PARAMETER(S): 5961 * [I] HWND : window handle 5962 * [I] INT : item index 5963 * [O] LPPOINT : coordinate information 5964 * 5965 * RETURN: 5966 * SUCCESS : TRUE 5967 * FAILURE : FALSE 5968 */ 5969 static BOOL LISTVIEW_GetItemPosition(HWND hwnd, INT nItem, LPPOINT lpptPosition) 5970 { 5971 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5972 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 5973 BOOL bResult = FALSE; 5974 RECT rcBounding; 5975 5976 TRACE("(hwnd=%x, nItem=%d, lpptPosition=%p)\n", hwnd, nItem, lpptPosition); 5977 5978 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && 5979 (lpptPosition != NULL)) 5980 { 5981 bResult = LISTVIEW_GetItemBoundBox(hwnd, nItem, &rcBounding); 5982 lpptPosition->x = rcBounding.left; 5983 lpptPosition->y = rcBounding.top; 5984 if (uView == LVS_ICON) 5985 { 5986 lpptPosition->y += ICON_TOP_PADDING; 5987 lpptPosition->x += (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; 5988 } 5989 TRACE("result %s (%ld,%ld)\n", bResult ? "TRUE" : "FALSE", 5990 lpptPosition->x, lpptPosition->y); 5991 } 5992 return bResult; 5993 } 5994 5995 /*** 5996 * Update the bounding rectangle around the text under a large icon. 5997 * This depends on whether it has the focus or not. 5998 * On entry the rectangle's top, left and right should be set. 5999 * On return the bottom will also be set and the width may have been 6000 * modified. 6001 * 6002 * This appears to be weird, even in the Microsoft implementation. 6003 */ 6004 6005 static void ListView_UpdateLargeItemLabelRect ( 6006 HWND hwnd, /* The window of the listview */ 6007 const LISTVIEW_INFO *infoPtr, /* The listview itself */ 6008 int nItem, /* The item for which we are calculating this */ 6009 RECT *rect) /* The rectangle to be updated */ 6010 { 6011 HDC hdc = GetDC (hwnd); 6012 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont); 6013 6014 if (infoPtr->bFocus && infoPtr->nFocusedItem == nItem) 6015 { 6016 /* We (aim to) display the full text. In Windows 95 it appears to 6017 * calculate the size assuming the specified font and then it draws 6018 * the text in that region with the specified font except scaled to 6019 * 10 point (or the height of the system font or ...). Thus if the 6020 * window has 24 point Helvetica the highlit rectangle will be 6021 * taller than the text and if it is 7 point Helvetica then the text 6022 * will be clipped. 6023 * For now we will simply say that it is the correct size to display 6024 * the text in the specified font. 6025 */ 6026 LVITEMW lvItem; 6027 lvItem.mask = LVIF_TEXT; 6028 lvItem.iItem = nItem; 6029 lvItem.iSubItem = 0; 6030 /* We will specify INTERNAL and so will receive back a const 6031 * pointer to the text, rather than specifying a buffer to which 6032 * to copy it. 6033 */ 6034 LISTVIEW_GetItemW (hwnd, &lvItem, TRUE); 6035 DrawTextW (hdc, lvItem.pszText, -1, rect, DT_CALCRECT | 6036 DT_NOCLIP | DT_EDITCONTROL | DT_TOP | DT_CENTER | 6037 DT_WORDBREAK | DT_NOPREFIX); 6038 /* Maintain this DT_* list in line with LISTVIEW_DrawLargeItem */ 6039 } 6040 else 6041 { 6042 /* As far as I can see the text region seems to be trying to be 6043 * "tall enough for two lines of text". Once again (comctl32.dll ver 6044 * 5.81?) it measures this on the basis of the selected font and then 6045 * draws it with the same font except in 10 point size. This can lead 6046 * to more or less than the two rows appearing. 6047 * Question; are we supposed to be including DT_EXTERNALLEADING? 6048 * Question; should the width be shrunk to the space required to 6049 * display the two lines? 6050 */ 6051 rect->bottom = rect->top + 2 * infoPtr->ntmHeight; 6052 } 6053 6054 SelectObject (hdc, hOldFont); 6055 ReleaseDC (hwnd, hdc); 6056 } 6057 6058 /*** 6059 * DESCRIPTION: 5747 6060 * Retrieves the bounding rectangle for a listview control item. 5748 * 6061 * 5749 6062 * PARAMETER(S): 5750 6063 * [I] HWND : window handle … … 5759 6072 * LVIR_LABEL Returns the bounding rectangle of the item text. 5760 6073 * LVIR_SELECTBOUNDS Returns the union of the LVIR_ICON and LVIR_LABEL 5761 * 5762 * 6074 * rectangles, but excludes columns in report view. 6075 * 5763 6076 * RETURN: 5764 6077 * SUCCESS : TRUE 5765 6078 * FAILURE : FALSE 6079 * 6080 * NOTES 6081 * Note that the bounding rectangle of the label in the LVS_ICON view depends 6082 * upon whether the window has the focus currently and on whether the item 6083 * is the one with the focus. Ensure that the control's record of which 6084 * item has the focus agrees with the items' records. 5766 6085 */ 5767 6086 static LRESULT LISTVIEW_GetItemRect(HWND hwnd, INT nItem, LPRECT lprc) 5768 6087 { 5769 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);5770 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;6088 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6089 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 5771 6090 BOOL bResult = FALSE; 5772 6091 POINT ptOrigin; 5773 6092 POINT ptItem; 5774 HDC hdc;5775 HFONT hOldFont;5776 6093 INT nLeftPos; 5777 6094 INT nLabelWidth; 5778 6095 INT nIndent; 5779 TEXTMETRICA tm;5780 LVITEMA lvItem;6096 LVITEMW lvItem; 6097 RECT rcInternal; 5781 6098 5782 6099 TRACE("(hwnd=%x, nItem=%d, lprc=%p)\n", hwnd, nItem, lprc); … … 5784 6101 if (uView & LVS_REPORT) 5785 6102 { 5786 ZeroMemory(&lvItem, sizeof( LVITEMA));6103 ZeroMemory(&lvItem, sizeof(lvItem)); 5787 6104 lvItem.mask = LVIF_INDENT; 5788 6105 lvItem.iItem = nItem; 5789 6106 lvItem.iSubItem = 0; 5790 LISTVIEW_GetItem A(hwnd, &lvItem, TRUE);6107 LISTVIEW_GetItemW(hwnd, &lvItem, TRUE); 5791 6108 5792 6109 /* do indent */ 5793 6110 if (lvItem.iIndent>0 && infoPtr->iconSize.cx > 0) 5794 { 5795 nIndent = infoPtr->iconSize.cx * lvItem.iIndent; 5796 } 6111 nIndent = infoPtr->iconSize.cx * lvItem.iIndent; 5797 6112 else 5798 nIndent = 0;6113 nIndent = 0; 5799 6114 } 5800 6115 else 5801 6116 nIndent = 0; 5802 6117 5803 6118 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && (lprc != NULL)) 5804 6119 { 5805 if (ListView_GetItemPosition(hwnd, nItem, &ptItem) != FALSE) 5806 { 5807 switch(lprc->left) 5808 { 6120 switch(lprc->left) 6121 { 5809 6122 case LVIR_ICON: 6123 if (!ListView_GetItemPosition(hwnd, nItem, &ptItem)) break; 5810 6124 if (uView == LVS_ICON) 5811 6125 { … … 5818 6132 lprc->top = ptItem.y + ptOrigin.y; 5819 6133 lprc->right = lprc->left + infoPtr->iconSize.cx; 5820 lprc->bottom = (lprc->top + infoPtr->iconSize.cy + 6134 lprc->bottom = (lprc->top + infoPtr->iconSize.cy + 5821 6135 ICON_BOTTOM_PADDING + ICON_TOP_PADDING); 5822 6136 } … … 5834 6148 if (infoPtr->himlState != NULL) 5835 6149 lprc->left += infoPtr->iconSize.cx; 5836 6150 5837 6151 if (infoPtr->himlSmall != NULL) 5838 6152 lprc->right = lprc->left + infoPtr->iconSize.cx; … … 5841 6155 } 5842 6156 } 5843 else 6157 else 5844 6158 { 5845 6159 bResult = TRUE; … … 5851 6165 5852 6166 if (infoPtr->himlState != NULL) 5853 {5854 6167 lprc->left += infoPtr->iconSize.cx; 5855 } 5856 6168 5857 6169 if (infoPtr->himlSmall != NULL) 5858 {5859 6170 lprc->right = lprc->left + infoPtr->iconSize.cx; 5860 }5861 6171 else 5862 {5863 6172 lprc->right = lprc->left; 5864 }5865 6173 } 5866 6174 break; 5867 6175 5868 6176 case LVIR_LABEL: 6177 if (!ListView_GetItemPosition(hwnd, nItem, &ptItem)) break; 5869 6178 if (uView == LVS_ICON) 5870 6179 { … … 5876 6185 lprc->left = ptItem.x + ptOrigin.x; 5877 6186 lprc->top = (ptItem.y + ptOrigin.y + infoPtr->iconSize.cy + 5878 ICON_BOTTOM_PADDING + ICON_TOP_PADDING);6187 ICON_BOTTOM_PADDING); 5879 6188 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5880 6189 if (infoPtr->iconSpacing.cx - nLabelWidth > 1) … … 5887 6196 lprc->left += 1; 5888 6197 lprc->right = lprc->left + infoPtr->iconSpacing.cx - 1; 6198 ListView_UpdateLargeItemLabelRect (hwnd, infoPtr, nItem, lprc); 5889 6199 } 5890 5891 hdc = GetDC(hwnd); 5892 hOldFont = SelectObject(hdc, infoPtr->hFont); 5893 GetTextMetricsA(hdc, &tm); 5894 lprc->bottom = lprc->top + tm.tmHeight + HEIGHT_PADDING; 5895 SelectObject(hdc, hOldFont); 5896 ReleaseDC(hwnd, hdc); 5897 } 6200 } 5898 6201 } 5899 6202 } … … 5903 6206 { 5904 6207 bResult = TRUE; 5905 nLeftPos = lprc->left = ptItem.x + ptOrigin.x; 6208 nLeftPos = lprc->left = ptItem.x + ptOrigin.x; 5906 6209 lprc->top = ptItem.y + ptOrigin.y; 5907 6210 lprc->bottom = lprc->top + infoPtr->nItemHeight; 5908 6211 5909 6212 if (infoPtr->himlState != NULL) 5910 {5911 6213 lprc->left += infoPtr->iconSize.cx; 5912 } 5913 6214 5914 6215 if (infoPtr->himlSmall != NULL) 5915 {5916 6216 lprc->left += infoPtr->iconSize.cx; 5917 } 5918 6217 5919 6218 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5920 6219 nLabelWidth += TRAILING_PADDING; 5921 6220 if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 5922 {5923 6221 lprc->right = lprc->left + nLabelWidth; 5924 }5925 6222 else 5926 {5927 6223 lprc->right = nLeftPos + infoPtr->nItemWidth; 5928 }5929 6224 } 5930 6225 } … … 5932 6227 { 5933 6228 bResult = TRUE; 5934 if (uView &LVS_REPORT)6229 if (uView == LVS_REPORT) 5935 6230 nLeftPos = lprc->left = ptItem.x + nIndent; 5936 else 5937 nLeftPos = lprc->left = ptItem.x; 6231 else 6232 nLeftPos = lprc->left = ptItem.x; 5938 6233 lprc->top = ptItem.y; 5939 6234 lprc->bottom = lprc->top + infoPtr->nItemHeight; 5940 6235 5941 6236 if (infoPtr->himlState != NULL) 6237 lprc->left += infoPtr->iconSize.cx; 6238 6239 if (infoPtr->himlSmall != NULL) 6240 lprc->left += infoPtr->iconSize.cx; 6241 6242 if (uView != LVS_REPORT) 5942 6243 { 5943 lprc->left += infoPtr->iconSize.cx; 6244 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 6245 nLabelWidth += TRAILING_PADDING; 6246 if (infoPtr->himlSmall) 6247 nLabelWidth += IMAGE_PADDING; 5944 6248 } 5945 5946 if (infoPtr->himlSmall != NULL) 5947 { 5948 lprc->left += infoPtr->iconSize.cx; 5949 } 5950 5951 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5952 nLabelWidth += TRAILING_PADDING; 5953 if (infoPtr->himlSmall) 5954 nLabelWidth += IMAGE_PADDING; 5955 if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 5956 { 5957 lprc->right = lprc->left + nLabelWidth; 5958 } 5959 else 5960 { 5961 lprc->right = nLeftPos + infoPtr->nItemWidth; 5962 } 6249 else 6250 nLabelWidth = LISTVIEW_GetColumnWidth(hwnd, 0)-lprc->left; 6251 if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 6252 lprc->right = lprc->left + nLabelWidth; 6253 else 6254 lprc->right = nLeftPos + infoPtr->nItemWidth; 5963 6255 } 5964 6256 break; 5965 6257 5966 6258 case LVIR_BOUNDS: 6259 if (!LISTVIEW_GetItemBoundBox(hwnd, nItem, &rcInternal)) break; 6260 ptItem.x = rcInternal.left; 6261 ptItem.y = rcInternal.top; 6262 if (uView == LVS_ICON) 6263 { 6264 if (infoPtr->himlNormal != NULL) 6265 { 6266 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 6267 { 6268 RECT label_rect; 6269 INT text_left, text_right, icon_left, text_pos_x; 6270 /* for style LVS_ICON bounds 6271 * left = min(icon.left, text.left) 6272 * right = max(icon.right, text.right) 6273 * top = boundbox.top + NOTHITABLE 6274 * bottom = text.bottom + 1 6275 */ 6276 bResult = TRUE; 6277 icon_left = text_left = ptItem.x; 6278 6279 /* Correct ptItem to icon upper-left */ 6280 icon_left += (infoPtr->nItemWidth - infoPtr->iconSize.cx)/2; 6281 ptItem.y += ICON_TOP_PADDING; 6282 6283 /* Compute the label left and right */ 6284 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 6285 text_pos_x = infoPtr->iconSpacing.cx - 2*CAPTION_BORDER - nLabelWidth; 6286 if (text_pos_x > 1) 6287 { 6288 text_left += text_pos_x / 2; 6289 text_right = text_left + nLabelWidth + 2*CAPTION_BORDER; 6290 } 6291 else 6292 { 6293 text_left += 1; 6294 text_right = text_left + infoPtr->iconSpacing.cx - 1; 6295 } 6296 6297 /* Compute rectangle w/o the text height */ 6298 lprc->left = min(icon_left, text_left) + ptOrigin.x; 6299 lprc->right = max(icon_left + infoPtr->iconSize.cx, 6300 text_right) + ptOrigin.x; 6301 lprc->top = ptItem.y + ptOrigin.y - ICON_TOP_PADDING_HITABLE; 6302 lprc->bottom = lprc->top + ICON_TOP_PADDING_HITABLE 6303 + infoPtr->iconSize.cy + 1 6304 + ICON_BOTTOM_PADDING; 6305 6306 CopyRect (&label_rect, lprc); 6307 label_rect.top = lprc->bottom; 6308 ListView_UpdateLargeItemLabelRect (hwnd, infoPtr, nItem, &label_rect); 6309 UnionRect (lprc, lprc, &label_rect); 6310 } 6311 } 6312 } 6313 else if (uView == LVS_SMALLICON) 6314 { 6315 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 6316 { 6317 bResult = TRUE; 6318 lprc->left = ptItem.x + ptOrigin.x; 6319 lprc->right = lprc->left; 6320 lprc->top = ptItem.y + ptOrigin.y; 6321 lprc->bottom = lprc->top + infoPtr->nItemHeight; 6322 if (infoPtr->himlState != NULL) 6323 lprc->right += infoPtr->iconSize.cx; 6324 if (infoPtr->himlSmall != NULL) 6325 lprc->right += infoPtr->iconSize.cx; 6326 6327 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 6328 nLabelWidth += TRAILING_PADDING; 6329 if (infoPtr->himlSmall) 6330 nLabelWidth += IMAGE_PADDING; 6331 if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth) 6332 lprc->right += nLabelWidth; 6333 else 6334 lprc->right = lprc->left + infoPtr->nItemWidth; 6335 } 6336 } 6337 else 6338 { 6339 bResult = TRUE; 6340 lprc->left = ptItem.x; 6341 if (!(infoPtr->dwExStyle&LVS_EX_FULLROWSELECT) && uView&LVS_REPORT) 6342 lprc->left += nIndent; 6343 lprc->right = lprc->left; 6344 lprc->top = ptItem.y; 6345 lprc->bottom = lprc->top + infoPtr->nItemHeight; 6346 6347 if ((infoPtr->dwExStyle & LVS_EX_FULLROWSELECT) || (uView == LVS_REPORT)) 6348 { 6349 RECT br; 6350 int nColumnCount = Header_GetItemCount(infoPtr->hwndHeader); 6351 Header_GetItemRect(infoPtr->hwndHeader, nColumnCount-1, &br); 6352 6353 lprc->right = max(lprc->left, br.right - REPORT_MARGINX); 6354 } 6355 else 6356 { 6357 if (infoPtr->himlState != NULL) 6358 lprc->right += infoPtr->iconSize.cx; 6359 6360 if (infoPtr->himlSmall != NULL) 6361 lprc->right += infoPtr->iconSize.cx; 6362 6363 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 6364 nLabelWidth += TRAILING_PADDING; 6365 if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth) 6366 lprc->right += nLabelWidth; 6367 else 6368 lprc->right = lprc->left + infoPtr->nItemWidth; 6369 } 6370 } 6371 break; 6372 6373 case LVIR_SELECTBOUNDS: 6374 if (!ListView_GetItemPosition(hwnd, nItem, &ptItem)) break; 5967 6375 if (uView == LVS_ICON) 5968 6376 { … … 5977 6385 lprc->bottom = lprc->top + infoPtr->iconSpacing.cy; 5978 6386 } 5979 } 6387 } 5980 6388 } 5981 6389 else if (uView == LVS_SMALLICON) … … 5984 6392 { 5985 6393 bResult = TRUE; 5986 lprc->left = ptItem.x + ptOrigin.x; 5987 lprc->right = lprc->left; 6394 nLeftPos= lprc->left = ptItem.x + ptOrigin.x; 5988 6395 lprc->top = ptItem.y + ptOrigin.y; 5989 6396 lprc->bottom = lprc->top + infoPtr->nItemHeight; 6397 5990 6398 if (infoPtr->himlState != NULL) 5991 lprc->right += infoPtr->iconSize.cx; 6399 lprc->left += infoPtr->iconSize.cx; 6400 6401 lprc->right = lprc->left; 6402 5992 6403 if (infoPtr->himlSmall != NULL) 5993 6404 lprc->right += infoPtr->iconSize.cx; 5994 5995 6405 6406 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 5996 6407 nLabelWidth += TRAILING_PADDING; 5997 if (infoPtr->himlSmall) 5998 nLabelWidth += IMAGE_PADDING; 5999 if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth) 6000 { 6001 lprc->right += nLabelWidth; 6002 } 6003 else 6004 { 6005 lprc->right = lprc->left + infoPtr->nItemWidth; 6006 } 6007 } 6008 } 6009 else 6010 { 6011 bResult = TRUE; 6012 lprc->left = ptItem.x; 6013 if (!(infoPtr->dwExStyle&LVS_EX_FULLROWSELECT) && uView&LVS_REPORT) 6014 lprc->left += nIndent; 6015 lprc->right = lprc->left; 6016 lprc->top = ptItem.y; 6017 lprc->bottom = lprc->top + infoPtr->nItemHeight; 6018 6019 if (infoPtr->dwExStyle & LVS_EX_FULLROWSELECT) 6020 { 6021 RECT br; 6022 int nColumnCount = Header_GetItemCount(infoPtr->hwndHeader); 6023 Header_GetItemRect(infoPtr->hwndHeader, nColumnCount-1, &br); 6024 6025 lprc->right = max(lprc->left, br.right - REPORT_MARGINX); 6026 } 6027 else 6028 { 6029 if (infoPtr->himlState != NULL) 6030 { 6031 lprc->right += infoPtr->iconSize.cx; 6032 } 6033 6034 if (infoPtr->himlSmall != NULL) 6035 { 6036 lprc->right += infoPtr->iconSize.cx; 6037 } 6038 6039 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 6040 nLabelWidth += TRAILING_PADDING; 6041 if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth) 6042 { 6043 lprc->right += nLabelWidth; 6044 } 6045 else 6046 { 6047 lprc->right = lprc->left + infoPtr->nItemWidth; 6048 } 6049 } 6050 } 6051 break; 6052 6053 case LVIR_SELECTBOUNDS: 6054 if (uView == LVS_ICON) 6055 { 6056 if (infoPtr->himlNormal != NULL) 6057 { 6058 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 6059 { 6060 bResult = TRUE; 6061 lprc->left = ptItem.x + ptOrigin.x; 6062 lprc->top = ptItem.y + ptOrigin.y; 6063 lprc->right = lprc->left + infoPtr->iconSpacing.cx; 6064 lprc->bottom = lprc->top + infoPtr->iconSpacing.cy; 6065 } 6066 } 6067 } 6068 else if (uView == LVS_SMALLICON) 6069 { 6070 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 6071 { 6072 bResult = TRUE; 6073 nLeftPos= lprc->left = ptItem.x + ptOrigin.x; 6074 lprc->top = ptItem.y + ptOrigin.y; 6075 lprc->bottom = lprc->top + infoPtr->nItemHeight; 6076 6077 if (infoPtr->himlState != NULL) 6078 { 6079 lprc->left += infoPtr->iconSize.cx; 6080 } 6081 6082 lprc->right = lprc->left; 6083 6084 if (infoPtr->himlSmall != NULL) 6085 { 6086 lprc->right += infoPtr->iconSize.cx; 6087 } 6088 6089 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 6090 nLabelWidth += TRAILING_PADDING; 6091 if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 6092 { 6093 lprc->right += nLabelWidth; 6094 } 6095 else 6096 { 6097 lprc->right = nLeftPos + infoPtr->nItemWidth; 6098 } 6408 if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 6409 lprc->right += nLabelWidth; 6410 else 6411 lprc->right = nLeftPos + infoPtr->nItemWidth; 6099 6412 } 6100 6413 } … … 6103 6416 bResult = TRUE; 6104 6417 if (!(infoPtr->dwExStyle&LVS_EX_FULLROWSELECT) && (uView&LVS_REPORT)) 6105 nLeftPos = lprc->left = ptItem.x + nIndent; 6418 nLeftPos = lprc->left = ptItem.x + nIndent; 6106 6419 else 6107 nLeftPos = lprc->left = ptItem.x; 6420 nLeftPos = lprc->left = ptItem.x; 6108 6421 lprc->top = ptItem.y; 6109 6422 lprc->bottom = lprc->top + infoPtr->nItemHeight; 6110 6423 6111 6424 if (infoPtr->himlState != NULL) 6112 {6113 6425 lprc->left += infoPtr->iconSize.cx; 6114 } 6115 6426 6116 6427 lprc->right = lprc->left; 6117 6428 6118 6429 if (infoPtr->dwExStyle & LVS_EX_FULLROWSELECT) 6119 6430 { 6120 6121 6122 6431 RECT br; 6432 int nColumnCount = Header_GetItemCount(infoPtr->hwndHeader); 6433 Header_GetItemRect(infoPtr->hwndHeader, nColumnCount-1, &br); 6123 6434 6124 6435 lprc->right = max(lprc->left, br.right - REPORT_MARGINX); … … 6127 6438 { 6128 6439 if (infoPtr->himlSmall != NULL) 6129 {6130 6440 lprc->right += infoPtr->iconSize.cx; 6131 } 6132 6133 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 6441 6442 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 6134 6443 nLabelWidth += TRAILING_PADDING; 6135 6444 if (infoPtr->himlSmall) 6136 6445 nLabelWidth += IMAGE_PADDING; 6137 if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 6138 { 6139 lprc->right += nLabelWidth; 6140 } 6141 else 6142 { 6143 lprc->right = nLeftPos + infoPtr->nItemWidth; 6144 } 6446 if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 6447 lprc->right += nLabelWidth; 6448 else 6449 lprc->right = nLeftPos + infoPtr->nItemWidth; 6145 6450 } 6146 6451 } 6147 6452 break; 6148 6453 } 6149 }6150 6454 } 6151 6455 #ifdef __WIN32OS2__ … … 6154 6458 } 6155 6459 #endif 6460 TRACE("result %s (%d,%d)-(%d,%d)\n", bResult ? "TRUE" : "FALSE", 6461 lprc->left, lprc->top, lprc->right, lprc->bottom); 6462 6156 6463 return bResult; 6157 6464 } … … 6160 6467 * DESCRIPTION: 6161 6468 * Retrieves the width of a label. 6162 * 6163 * PARAMETER(S): 6164 * [I] HWND : window handle 6165 * 6469 * 6470 * PARAMETER(S): 6471 * [I] HWND : window handle 6472 * 6166 6473 * RETURN: 6167 6474 * SUCCESS : string width (in pixels) … … 6170 6477 static INT LISTVIEW_GetLabelWidth(HWND hwnd, INT nItem) 6171 6478 { 6172 CHAR szDispText[DISP_TEXT_SIZE];6479 WCHAR szDispText[DISP_TEXT_SIZE] = { '\0' }; 6173 6480 INT nLabelWidth = 0; 6174 LVITEM AlvItem;6481 LVITEMW lvItem; 6175 6482 6176 6483 TRACE("(hwnd=%x, nItem=%d)\n", hwnd, nItem); 6177 6484 6178 ZeroMemory(&lvItem, sizeof( LVITEMA));6485 ZeroMemory(&lvItem, sizeof(lvItem)); 6179 6486 lvItem.mask = LVIF_TEXT; 6180 6487 lvItem.iItem = nItem; 6181 6488 lvItem.cchTextMax = DISP_TEXT_SIZE; 6182 6489 lvItem.pszText = szDispText; 6183 if (LISTVIEW_GetItemA(hwnd, &lvItem, TRUE) != FALSE) 6184 { 6185 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 6186 } 6187 6490 if (LISTVIEW_GetItemW(hwnd, &lvItem, TRUE)) 6491 nLabelWidth = ListView_GetStringWidthW(hwnd, lvItem.pszText); 6492 6188 6493 return nLabelWidth; 6189 6494 } … … 6192 6497 * DESCRIPTION: 6193 6498 * Retrieves the spacing between listview control items. 6194 * 6195 * PARAMETER(S): 6196 * [I] HWND : window handle 6197 * [I] BOOL : flag for small or large icon 6499 * 6500 * PARAMETER(S): 6501 * [I] HWND : window handle 6502 * [I] BOOL : flag for small or large icon 6198 6503 * 6199 6504 * RETURN: … … 6202 6507 static LRESULT LISTVIEW_GetItemSpacing(HWND hwnd, BOOL bSmall) 6203 6508 { 6204 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);6509 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6205 6510 LONG lResult; 6206 6511 … … 6211 6516 else 6212 6517 { 6213 LONG style = GetWindowLong A(hwnd, GWL_STYLE);6518 LONG style = GetWindowLongW(hwnd, GWL_STYLE); 6214 6519 if ((style & LVS_TYPEMASK) == LVS_ICON) 6215 {6216 6520 lResult = MAKELONG(DEFAULT_COLUMN_WIDTH, GetSystemMetrics(SM_CXSMICON)+HEIGHT_PADDING); 6217 }6218 6521 else 6219 {6220 6522 lResult = MAKELONG(infoPtr->nItemWidth, infoPtr->nItemHeight); 6221 }6222 6523 } 6223 6524 return lResult; … … 6227 6528 * DESCRIPTION: 6228 6529 * Retrieves the state of a listview control item. 6229 * 6530 * 6230 6531 * PARAMETER(S): 6231 6532 * [I] HWND : window handle 6232 6533 * [I] INT : item index 6233 6534 * [I] UINT : state mask 6234 * 6535 * 6235 6536 * RETURN: 6236 6537 * State specified by the mask. … … 6238 6539 static LRESULT LISTVIEW_GetItemState(HWND hwnd, INT nItem, UINT uMask) 6239 6540 { 6240 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);6241 LVITEM AlvItem;6541 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6542 LVITEMW lvItem; 6242 6543 UINT uState = 0; 6243 6544 6244 6545 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr))) 6245 6546 { 6246 ZeroMemory(&lvItem, sizeof( LVITEMA));6547 ZeroMemory(&lvItem, sizeof(lvItem)); 6247 6548 lvItem.iItem = nItem; 6248 6549 lvItem.stateMask = uMask; 6249 6550 lvItem.mask = LVIF_STATE; 6250 if (LISTVIEW_GetItemA(hwnd, &lvItem, TRUE) != FALSE) 6251 { 6551 if (LISTVIEW_GetItemW(hwnd, &lvItem, TRUE)) 6252 6552 uState = lvItem.state; 6253 }6254 6553 } 6255 6554 … … 6259 6558 /*** 6260 6559 * DESCRIPTION: 6261 * Retrieves the text of a listview control item or subitem. 6262 * 6263 * PARAMETER(S): 6264 * [I] HWND : window handle 6265 * [I] INT : item index 6266 * [IO] LPLVITEMA : item information 6267 * 6560 * Retrieves the text of a listview control item or subitem. 6561 * 6562 * PARAMETER(S): 6563 * [I] hwnd : window handle 6564 * [I] nItem : item index 6565 * [IO] lpLVItem : item information 6566 * [I] isW : TRUE if lpLVItem is Unicode 6567 * 6268 6568 * RETURN: 6269 6569 * SUCCESS : string length 6270 6570 * FAILURE : 0 6271 6571 */ 6272 static LRESULT LISTVIEW_GetItemText A(HWND hwnd, INT nItem, LPLVITEMA lpLVItem)6273 { 6274 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);6572 static LRESULT LISTVIEW_GetItemTextT(HWND hwnd, INT nItem, LPLVITEMW lpLVItem, BOOL isW) 6573 { 6574 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6275 6575 INT nLength = 0; 6276 6576 6277 6577 if (lpLVItem != NULL) 6278 6578 { … … 6281 6581 lpLVItem->mask = LVIF_TEXT; 6282 6582 lpLVItem->iItem = nItem; 6283 if (LISTVIEW_GetItemA(hwnd, lpLVItem, FALSE) != FALSE) 6284 { 6285 nLength = lstrlenA(lpLVItem->pszText); 6286 } 6583 if (LISTVIEW_GetItemT(hwnd, lpLVItem, FALSE, isW)) 6584 nLength = textlenT(lpLVItem->pszText, isW); 6287 6585 } 6288 6586 } … … 6294 6592 * DESCRIPTION: 6295 6593 * Searches for an item based on properties + relationships. 6296 * 6594 * 6297 6595 * PARAMETER(S): 6298 6596 * [I] HWND : window handle 6299 6597 * [I] INT : item index 6300 6598 * [I] INT : relationship flag 6301 * 6599 * 6302 6600 * RETURN: 6303 6601 * SUCCESS : item index … … 6306 6604 static LRESULT LISTVIEW_GetNextItem(HWND hwnd, INT nItem, UINT uFlags) 6307 6605 { 6308 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);6309 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;6606 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6607 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 6310 6608 UINT uMask = 0; 6311 LVFINDINFO lvFindInfo;6609 LVFINDINFOW lvFindInfo; 6312 6610 INT nCountPerColumn; 6313 6611 INT i; 6314 6612 6315 6613 if ((nItem >= -1) && (nItem < GETITEMCOUNT(infoPtr))) 6316 { 6317 ZeroMemory(&lvFindInfo, sizeof( LVFINDINFO));6614 { 6615 ZeroMemory(&lvFindInfo, sizeof(lvFindInfo)); 6318 6616 6319 6617 if (uFlags & LVNI_CUT) 6320 6618 uMask |= LVIS_CUT; 6321 6619 6322 6620 if (uFlags & LVNI_DROPHILITED) 6323 6621 uMask |= LVIS_DROPHILITED; 6324 6622 6325 6623 if (uFlags & LVNI_FOCUSED) 6326 6624 uMask |= LVIS_FOCUSED; … … 6345 6643 lvFindInfo.vkDirection = VK_UP; 6346 6644 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 6347 while ((nItem = ListView_FindItem (hwnd, nItem, &lvFindInfo)) != -1)6645 while ((nItem = ListView_FindItemW(hwnd, nItem, &lvFindInfo)) != -1) 6348 6646 { 6349 6647 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) … … 6368 6666 lvFindInfo.vkDirection = VK_DOWN; 6369 6667 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 6370 while ((nItem = ListView_FindItem (hwnd, nItem, &lvFindInfo)) != -1)6668 while ((nItem = ListView_FindItemW(hwnd, nItem, &lvFindInfo)) != -1) 6371 6669 { 6372 6670 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) … … 6392 6690 lvFindInfo.vkDirection = VK_LEFT; 6393 6691 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 6394 while ((nItem = ListView_FindItem (hwnd, nItem, &lvFindInfo)) != -1)6692 while ((nItem = ListView_FindItemW(hwnd, nItem, &lvFindInfo)) != -1) 6395 6693 { 6396 6694 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) … … 6416 6714 lvFindInfo.vkDirection = VK_RIGHT; 6417 6715 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 6418 while ((nItem = ListView_FindItem (hwnd, nItem, &lvFindInfo)) != -1)6716 while ((nItem = ListView_FindItemW(hwnd, nItem, &lvFindInfo)) != -1) 6419 6717 { 6420 6718 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) … … 6444 6742 * DESCRIPTION: 6445 6743 * Retrieves the origin coordinates when in icon or small icon display mode. 6446 * 6744 * 6447 6745 * PARAMETER(S): 6448 6746 * [I] HWND : window handle 6449 6747 * [O] LPPOINT : coordinate information 6450 * 6748 * 6451 6749 * RETURN: 6452 6750 * SUCCESS : TRUE … … 6455 6753 static LRESULT LISTVIEW_GetOrigin(HWND hwnd, LPPOINT lpptOrigin) 6456 6754 { 6457 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);6755 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 6458 6756 UINT uView = lStyle & LVS_TYPEMASK; 6459 6757 BOOL bResult = FALSE; 6460 6758 6461 6759 TRACE("(hwnd=%x, lpptOrigin=%p)\n", hwnd, lpptOrigin); 6462 6760 … … 6471 6769 { 6472 6770 scrollInfo.fMask = SIF_POS; 6473 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 6474 { 6475 lpptOrigin->x = -scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 6476 } 6771 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 6772 lpptOrigin->x = -scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 6477 6773 } 6478 6774 … … 6481 6777 scrollInfo.fMask = SIF_POS; 6482 6778 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE) 6483 {6484 6779 lpptOrigin->y = -scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 6485 } 6486 } 6487 6780 } 6781 6488 6782 bResult = TRUE; 6489 6783 } 6490 6784 6491 6785 return bResult; 6492 6786 } … … 6495 6789 * DESCRIPTION: 6496 6790 * Retrieves the number of items that are marked as selected. 6497 * 6498 * PARAMETER(S): 6499 * [I] HWND : window handle 6500 * 6791 * 6792 * PARAMETER(S): 6793 * [I] HWND : window handle 6794 * 6501 6795 * RETURN: 6502 6796 * Number of items selected. … … 6505 6799 { 6506 6800 /* REDO THIS */ 6507 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);6801 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6508 6802 INT nSelectedCount = 0; 6509 6803 INT i; … … 6512 6806 { 6513 6807 if (ListView_GetItemState(hwnd, i, LVIS_SELECTED) & LVIS_SELECTED) 6514 {6515 6808 nSelectedCount++; 6516 } 6517 } 6518 6809 } 6810 6519 6811 return nSelectedCount; 6520 6812 } … … 6523 6815 * DESCRIPTION: 6524 6816 * Retrieves item index that marks the start of a multiple selection. 6525 * 6526 * PARAMETER(S): 6527 * [I] HWND : window handle 6528 * 6817 * 6818 * PARAMETER(S): 6819 * [I] HWND : window handle 6820 * 6529 6821 * RETURN: 6530 6822 * Index number or -1 if there is no selection mark. … … 6532 6824 static LRESULT LISTVIEW_GetSelectionMark(HWND hwnd) 6533 6825 { 6534 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);6826 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6535 6827 6536 6828 return infoPtr->nSelectionMark; 6537 6829 } 6538 6830 6831 6539 6832 /*** 6540 6833 * DESCRIPTION: 6541 6834 * Retrieves the width of a string. 6542 * 6543 * PARAMETER(S): 6544 * [I] HWND : window handle 6545 * 6835 * 6836 * PARAMETER(S): 6837 * [I] hwnd : window handle 6838 * [I] lpszText : text string to process 6839 * [I] isW : TRUE if lpszText is Unicode, FALSE otherwise 6840 * 6546 6841 * RETURN: 6547 6842 * SUCCESS : string width (in pixels) 6548 6843 * FAILURE : zero 6549 6844 */ 6845 static LRESULT LISTVIEW_GetStringWidthT(HWND hwnd, LPCWSTR lpszText, BOOL isW) 6846 { 6847 if (is_textT(lpszText, isW)) 6848 { 6849 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6850 HFONT hFont = infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont; 6851 HDC hdc = GetDC(hwnd); 6852 HFONT hOldFont = SelectObject(hdc, hFont); 6853 DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); 6854 SIZE stringSize; 6855 ZeroMemory(&stringSize, sizeof(SIZE)); 6856 if (isW) 6857 GetTextExtentPointW(hdc, lpszText, lstrlenW(lpszText), &stringSize); 6858 else 6859 GetTextExtentPointA(hdc, (LPCSTR)lpszText, lstrlenA((LPCSTR)lpszText), &stringSize); 6860 SelectObject(hdc, hOldFont); 6861 ReleaseDC(hwnd, hdc); 6550 6862 #ifdef __WIN32OS2__ 6551 static LRESULT LISTVIEW_GetStringWidth(HWND hwnd,HDC hdc,LPWSTR lpszText,BOOL unicode)6552 {6553 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);6554 DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);6555 HFONT hFont, hOldFont;6556 SIZE stringSize;6557 BOOL ownDC = FALSE;6558 6559 ZeroMemory(&stringSize,sizeof(SIZE));6560 if (lpszText != NULL && lpszText != LPSTR_TEXTCALLBACKA)6561 {6562 if (!hdc)6563 {6564 hFont = infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont;6565 hdc = GetDC(hwnd);6566 hOldFont = SelectObject(hdc, hFont);6567 ownDC = TRUE;6568 }6569 if (unicode)6570 GetTextExtentPointW(hdc,lpszText,lstrlenW(lpszText),&stringSize);6571 else6572 GetTextExtentPointA(hdc,(LPSTR)lpszText,lstrlenA((LPSTR)lpszText),&stringSize);6573 if (ownDC)6574 {6575 SelectObject(hdc, hOldFont);6576 ReleaseDC(hwnd, hdc);6577 }6578 6863 if(dwStyle & LVS_OWNERDRAWFIXED) { 6579 6864 /* Get item width */ … … 6587 6872 mis.itemHeight = 0; 6588 6873 mis.itemWidth = 0; 6589 SendMessageA(GetParent(hwnd), WM_MEASUREITEM, id, (LPARAM)&mis ); 6874 if (isW) 6875 SendMessageW(GetParent(hwnd), WM_MEASUREITEM, id, (LPARAM)&mis ); 6876 else 6877 SendMessageA(GetParent(hwnd), WM_MEASUREITEM, id, (LPARAM)&mis ); 6590 6878 stringSize.cx = (mis.itemWidth) ? mis.itemWidth : infoPtr->nItemWidth; 6591 6879 } 6592 }6593 6594 return stringSize.cx;6595 }6596 #else6597 static LRESULT LISTVIEW_GetStringWidthA(HWND hwnd, LPCSTR lpszText)6598 {6599 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);6600 HFONT hFont, hOldFont;6601 SIZE stringSize;6602 HDC hdc;6603 6604 ZeroMemory(&stringSize, sizeof(SIZE));6605 if (lpszText != NULL && lpszText != LPSTR_TEXTCALLBACKA)6606 {6607 hFont = infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont;6608 hdc = GetDC(hwnd);6609 hOldFont = SelectObject(hdc, hFont);6610 GetTextExtentPointA(hdc, lpszText, lstrlenA(lpszText), &stringSize);6611 SelectObject(hdc, hOldFont);6612 ReleaseDC(hwnd, hdc);6613 }6614 6615 return stringSize.cx;6616 }6617 6880 #endif 6881 return stringSize.cx; 6882 } 6883 return 0; 6884 } 6618 6885 6619 6886 /*** 6620 6887 * DESCRIPTION: 6621 6888 * Retrieves the text backgound color. 6622 * 6623 * PARAMETER(S): 6624 * [I] HWND : window handle 6625 * 6889 * 6890 * PARAMETER(S): 6891 * [I] HWND : window handle 6892 * 6626 6893 * RETURN: 6627 6894 * COLORREF associated with the the background. … … 6629 6896 static LRESULT LISTVIEW_GetTextBkColor(HWND hwnd) 6630 6897 { 6631 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLong A(hwnd, 0);6898 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongW(hwnd, 0); 6632 6899 6633 6900 return infoPtr->clrTextBk; … … 6637 6904 * DESCRIPTION: 6638 6905 * Retrieves the text color. 6639 * 6640 * PARAMETER(S): 6641 * [I] HWND : window handle 6642 * 6906 * 6907 * PARAMETER(S): 6908 * [I] HWND : window handle 6909 * 6643 6910 * RETURN: 6644 6911 * COLORREF associated with the text. … … 6646 6913 static LRESULT LISTVIEW_GetTextColor(HWND hwnd) 6647 6914 { 6648 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLong A(hwnd, 0);6915 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongW(hwnd, 0); 6649 6916 6650 6917 return infoPtr->clrText; … … 6653 6920 /*** 6654 6921 * DESCRIPTION: 6655 * Determines which section of the item was selected (if any).6656 * 6657 * PARAMETER(S): 6658 * [I] HWND : window handle 6659 * [IO] LPLV HITTESTINFO: hit test information6922 * Determines item if a hit or closest if not 6923 * 6924 * PARAMETER(S): 6925 * [I] HWND : window handle 6926 * [IO] LPLV_INTHIT : hit test information 6660 6927 * [I] subitem : fill out iSubItem. 6661 6928 * 6662 6929 * RETURN: 6663 * SUCCESS : item index 6930 * SUCCESS : item index of hit 6664 6931 * FAILURE : -1 6665 6932 */ 6666 static INT LISTVIEW_HitTestItem( 6667 HWND hwnd, LPLVHITTESTINFO lpHitTestInfo, BOOL subitem 6668 ) { 6669 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6933 static INT LISTVIEW_SuperHitTestItem(HWND hwnd, LPLV_INTHIT lpInt, BOOL subitem) 6934 { 6935 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6936 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 6937 UINT uView = lStyle & LVS_TYPEMASK; 6938 INT i,topindex,bottomindex; 6670 6939 RECT rcItem; 6671 INT i,topindex,bottomindex; 6672 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 6673 UINT uView = lStyle & LVS_TYPEMASK; 6674 6675 6676 TRACE("(hwnd=%x, x=%ld, y=%ld)\n", hwnd, lpHitTestInfo->pt.x, 6677 lpHitTestInfo->pt.y); 6940 DWORD xterm, yterm, dist; 6941 6942 TRACE("(hwnd=%x, x=%ld, y=%ld)\n", hwnd, lpInt->ht.pt.x, lpInt->ht.pt.y); 6678 6943 6679 6944 topindex = ListView_GetTopIndex(hwnd); 6680 6945 if (uView == LVS_REPORT) 6681 6946 { 6682 bottomindex = topindex + LISTVIEW_GetCountPerColumn(hwnd) + 1; 6947 bottomindex = topindex + LISTVIEW_GetCountPerColumn(hwnd) + 1; 6683 6948 bottomindex = min(bottomindex,GETITEMCOUNT(infoPtr)); 6684 6949 } … … 6688 6953 } 6689 6954 6955 lpInt->distance = 0x7fffffff; 6956 lpInt->iDistItem = -1; 6957 6690 6958 for (i = topindex; i < bottomindex; i++) 6691 6959 { 6692 6960 rcItem.left = LVIR_BOUNDS; 6693 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE)6694 { 6695 if (PtInRect(&rcItem, lp HitTestInfo->pt) != FALSE)6961 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem)) 6962 { 6963 if (PtInRect(&rcItem, lpInt->ht.pt)) 6696 6964 { 6697 6965 rcItem.left = LVIR_ICON; 6698 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE)6966 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem)) 6699 6967 { 6700 if (PtInRect(&rcItem, lp HitTestInfo->pt) != FALSE)6968 if (PtInRect(&rcItem, lpInt->ht.pt)) 6701 6969 { 6702 lp HitTestInfo->flags = LVHT_ONITEMICON;6703 lp HitTestInfo->iItem = i;6704 if (subitem) lp HitTestInfo->iSubItem = 0;6970 lpInt->ht.flags = LVHT_ONITEMICON; 6971 lpInt->ht.iItem = i; 6972 if (subitem) lpInt->ht.iSubItem = 0; 6705 6973 return i; 6706 6974 } 6707 6975 } 6708 6976 6709 6977 rcItem.left = LVIR_LABEL; 6710 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE)6978 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem)) 6711 6979 { 6712 if (PtInRect(&rcItem, lp HitTestInfo->pt) != FALSE)6980 if (PtInRect(&rcItem, lpInt->ht.pt)) 6713 6981 { 6714 lp HitTestInfo->flags = LVHT_ONITEMLABEL;6715 lp HitTestInfo->iItem = i;6716 if (subitem) lp HitTestInfo->iSubItem = 0;6982 lpInt->ht.flags = LVHT_ONITEMLABEL; 6983 lpInt->ht.iItem = i; 6984 if (subitem) lpInt->ht.iSubItem = 0; 6717 6985 return i; 6718 6986 } 6719 6987 } 6720 6721 lp HitTestInfo->flags = LVHT_ONITEMSTATEICON;6722 lp HitTestInfo->iItem = i;6723 if (subitem) lp HitTestInfo->iSubItem = 0;6988 6989 lpInt->ht.flags = LVHT_ONITEMSTATEICON; 6990 lpInt->ht.iItem = i; 6991 if (subitem) lpInt->ht.iSubItem = 0; 6724 6992 return i; 6725 6993 } 6726 } 6727 } 6728 6729 lpHitTestInfo->flags = LVHT_NOWHERE; 6994 else 6995 { 6996 /* 6997 * Now compute distance from point to center of boundary 6998 * box. Since we are only interested in the relative 6999 * distance, we can skip the nasty square root operation 7000 */ 7001 xterm = rcItem.left + (rcItem.right - rcItem.left)/2 - lpInt->ht.pt.x; 7002 yterm = rcItem.top + (rcItem.bottom - rcItem.top)/2 - lpInt->ht.pt.y; 7003 dist = xterm * xterm + yterm * yterm; 7004 if (dist < lpInt->distance) 7005 { 7006 lpInt->distance = dist; 7007 lpInt->iDistItem = i; 7008 } 7009 } 7010 } 7011 } 7012 7013 lpInt->ht.flags = LVHT_NOWHERE; 7014 TRACE("no hit, closest item %d, distance %ld\n", lpInt->iDistItem, lpInt->distance); 6730 7015 6731 7016 return -1; 6732 7017 } 6733 7018 7019 /*** 7020 * DESCRIPTION: 7021 * Determines which section of the item was selected (if any). 7022 * 7023 * PARAMETER(S): 7024 * [I] HWND : window handle 7025 * [IO] LPLVHITTESTINFO : hit test information 7026 * [I] subitem : fill out iSubItem. 7027 * 7028 * RETURN: 7029 * SUCCESS : item index 7030 * FAILURE : -1 7031 */ 7032 static INT LISTVIEW_HitTestItem(HWND hwnd, LPLVHITTESTINFO lpHitTestInfo, BOOL subitem) 7033 { 7034 INT ret; 7035 LV_INTHIT lv_inthit; 7036 7037 TRACE("(hwnd=%x, x=%ld, y=%ld)\n", hwnd, lpHitTestInfo->pt.x, 7038 lpHitTestInfo->pt.y); 7039 7040 memcpy(&lv_inthit, lpHitTestInfo, sizeof(LVHITTESTINFO)); 7041 ret = LISTVIEW_SuperHitTestItem(hwnd, &lv_inthit, subitem); 7042 memcpy(lpHitTestInfo, &lv_inthit, sizeof(LVHITTESTINFO)); 7043 return ret; 7044 } 7045 6734 7046 /*** 6735 7047 * DESCRIPTION: 6736 7048 * Determines which listview item is located at the specified position. 6737 * 7049 * 6738 7050 * PARAMETER(S): 6739 7051 * [I] HWND : window handle … … 6746 7058 static LRESULT LISTVIEW_HitTest(HWND hwnd, LPLVHITTESTINFO lpHitTestInfo) 6747 7059 { 6748 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);7060 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6749 7061 INT nItem = -1; 6750 7062 … … 6752 7064 6753 7065 if (infoPtr->rcList.left > lpHitTestInfo->pt.x) 6754 {6755 7066 lpHitTestInfo->flags = LVHT_TOLEFT; 6756 } 6757 else if (infoPtr->rcList.right < lpHitTestInfo->pt.x) 6758 { 7067 else if (infoPtr->rcList.right < lpHitTestInfo->pt.x) 6759 7068 lpHitTestInfo->flags = LVHT_TORIGHT; 6760 }6761 7069 if (infoPtr->rcList.top > lpHitTestInfo->pt.y) 6762 {6763 7070 lpHitTestInfo->flags |= LVHT_ABOVE; 6764 } 6765 else if (infoPtr->rcList.bottom < lpHitTestInfo->pt.y) 6766 { 7071 else if (infoPtr->rcList.bottom < lpHitTestInfo->pt.y) 6767 7072 lpHitTestInfo->flags |= LVHT_BELOW; 6768 }6769 7073 6770 7074 if (lpHitTestInfo->flags == 0) 6771 7075 { 6772 /* NOTE (mm 20001022): We must not allow iSubItem to be touched, for 7076 /* NOTE (mm 20001022): We must not allow iSubItem to be touched, for 6773 7077 * an app might pass only a structure with space up to iItem! 6774 7078 * (MS Office 97 does that for instance in the file open dialog) … … 6776 7080 nItem = LISTVIEW_HitTestItem(hwnd, lpHitTestInfo, FALSE); 6777 7081 } 6778 7082 6779 7083 return nItem; 6780 7084 } … … 6783 7087 * DESCRIPTION: 6784 7088 * Inserts a new column. 6785 * 7089 * 6786 7090 * PARAMETER(S): 6787 7091 * [I] HWND : window handle 6788 7092 * [I] INT : column index 6789 * [I] LPLVCOLUMN A: column information7093 * [I] LPLVCOLUMNW : column information 6790 7094 * 6791 7095 * RETURN: … … 6793 7097 * FAILURE : -1 6794 7098 */ 6795 static LRESULT LISTVIEW_InsertColumnA(HWND hwnd, INT nColumn, 6796 LPLVCOLUMNA lpColumn) 6797 { 6798 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6799 HDITEMA hdi; 7099 static LRESULT LISTVIEW_InsertColumnT(HWND hwnd, INT nColumn, 7100 LPLVCOLUMNW lpColumn, BOOL isW) 7101 { 7102 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 6800 7103 INT nNewColumn = -1; 6801 6802 TRACE("(hwnd=%x, nColumn=%d, lpColumn=%p)\n",hwnd, nColumn, 6803 6804 6805 if (lpColumn != NULL) 7104 HDITEMW hdi; 7105 7106 TRACE("(hwnd=%x, nColumn=%d, lpColumn=%p)\n",hwnd, nColumn, lpColumn); 7107 7108 if (lpColumn != NULL) 6806 7109 { 6807 7110 /* initialize memory */ 6808 ZeroMemory(&hdi, sizeof( HDITEMA));6809 6810 if (lpColumn->mask & LVCF_FMT) 7111 ZeroMemory(&hdi, sizeof(hdi)); 7112 7113 if (lpColumn->mask & LVCF_FMT) 6811 7114 { 6812 7115 /* format member is valid */ … … 6833 7136 } 6834 7137 } 6835 7138 6836 7139 if (lpColumn->fmt & LVCFMT_BITMAP_ON_RIGHT) 6837 7140 { … … 6844 7147 /* ??? */ 6845 7148 } 6846 7149 6847 7150 if (lpColumn->fmt & LVCFMT_IMAGE) 6848 7151 { … … 6852 7155 } 6853 7156 6854 if (lpColumn->mask & LVCF_WIDTH) 7157 if (lpColumn->mask & LVCF_WIDTH) 6855 7158 { 6856 7159 hdi.mask |= HDI_WIDTH; 6857 hdi.cxy = lpColumn->cx; 6858 } 6859 6860 if (lpColumn->mask & LVCF_TEXT) 7160 if(lpColumn->cx == LVSCW_AUTOSIZE_USEHEADER) 7161 { 7162 /* make it fill the remainder of the controls width */ 7163 HDITEMW hdit; 7164 RECT rcHeader; 7165 INT item_index; 7166 7167 ZeroMemory(&hdit, sizeof(hdit)); 7168 7169 /* get the width of every item except the current one */ 7170 hdit.mask = HDI_WIDTH; 7171 hdi.cxy = 0; 7172 7173 for(item_index = 0; item_index < (nColumn - 1); item_index++) { 7174 Header_GetItemW(infoPtr->hwndHeader, item_index, (LPARAM)(&hdit)); 7175 hdi.cxy+=hdit.cxy; 7176 } 7177 7178 /* retrieve the layout of the header */ 7179 GetClientRect(hwnd, &rcHeader); 7180 /* GetWindowRect(infoPtr->hwndHeader, &rcHeader);*/ 7181 TRACE("start cxy=%d left=%d right=%d\n", hdi.cxy, rcHeader.left, rcHeader.right); 7182 7183 hdi.cxy = (rcHeader.right - rcHeader.left) - hdi.cxy; 7184 } 7185 else 7186 hdi.cxy = lpColumn->cx; 7187 } 7188 7189 if (lpColumn->mask & LVCF_TEXT) 6861 7190 { 6862 7191 hdi.mask |= HDI_TEXT | HDI_FORMAT; 6863 7192 hdi.pszText = lpColumn->pszText; 6864 hdi.cchTextMax = ((lpColumn->pszText!=NULL) && (lpColumn->pszText!=LPSTR_TEXTCALLBACKA) ? strlen(lpColumn->pszText) : 0);7193 hdi.cchTextMax = textlenT(lpColumn->pszText, isW); 6865 7194 hdi.fmt |= HDF_STRING; 6866 7195 } 6867 6868 if (lpColumn->mask & LVCF_IMAGE) 7196 7197 if (lpColumn->mask & LVCF_IMAGE) 6869 7198 { 6870 7199 hdi.mask |= HDI_IMAGE; … … 6872 7201 } 6873 7202 6874 if (lpColumn->mask & LVCF_ORDER) 7203 if (lpColumn->mask & LVCF_ORDER) 6875 7204 { 6876 7205 hdi.mask |= HDI_ORDER; … … 6879 7208 6880 7209 /* insert item in header control */ 6881 nNewColumn = SendMessage A(infoPtr->hwndHeader, HDM_INSERTITEMA,7210 nNewColumn = SendMessageW(infoPtr->hwndHeader, HDM_INSERTITEMT(isW), 6882 7211 (WPARAM)nColumn, (LPARAM)&hdi); 6883 7212 6884 7213 /* Need to reset the item width when inserting a new column */ 6885 7214 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); … … 6890 7219 6891 7220 return nNewColumn; 6892 }6893 6894 static LRESULT LISTVIEW_InsertColumnW(HWND hwnd, INT nColumn,6895 LPLVCOLUMNW lpColumn)6896 {6897 LVCOLUMNA lvca;6898 LRESULT lres;6899 6900 memcpy(&lvca,lpColumn,sizeof(lvca));6901 if (lpColumn->mask & LVCF_TEXT) {6902 if (lpColumn->pszText == LPSTR_TEXTCALLBACKW)6903 lvca.pszText = LPSTR_TEXTCALLBACKA;6904 else6905 lvca.pszText = HEAP_strdupWtoA(GetProcessHeap(),0,lpColumn->pszText);6906 }6907 lres = LISTVIEW_InsertColumnA(hwnd,nColumn,&lvca);6908 if (lpColumn->mask & LVCF_TEXT) {6909 if (lpColumn->pszText != LPSTR_TEXTCALLBACKW)6910 HeapFree(GetProcessHeap(),0,lvca.pszText);6911 }6912 return lres;6913 7221 } 6914 7222 … … 6922 7230 (remarks on LVITEM: LVM_INSERTITEM will insert the new item in the proper sort postion... 6923 7231 if: 6924 LVS_SORTXXX must be specified, 6925 LVS_OWNERDRAW is not set, 7232 LVS_SORTXXX must be specified, 7233 LVS_OWNERDRAW is not set, 6926 7234 <item>.pszText is not LPSTR_TEXTCALLBACK. 6927 7235 6928 (LVS_SORT* flags): "For the LVS_SORTASCENDING... styles, item indices 6929 are sorted based on item text..." 7236 (LVS_SORT* flags): "For the LVS_SORTASCENDING... styles, item indices 7237 are sorted based on item text..." 6930 7238 */ 6931 7239 static INT WINAPI LISTVIEW_InsertCompare( LPVOID first, LPVOID second, LPARAM lParam) 6932 7240 { 6933 HDPA hdpa_first = (HDPA) first; 6934 HDPA hdpa_second = (HDPA) second; 6935 LISTVIEW_ITEM* lv_first = (LISTVIEW_ITEM*) DPA_GetPtr( hdpa_first, 0 ); 6936 LISTVIEW_ITEM* lv_second = (LISTVIEW_ITEM*) DPA_GetPtr( hdpa_second, 0 ); 6937 LONG lStyle = GetWindowLongA((HWND) lParam, GWL_STYLE); 6938 INT cmpv = lstrcmpA( lv_first->pszText, lv_second->pszText ); 7241 LONG lStyle = GetWindowLongW((HWND) lParam, GWL_STYLE); 7242 LISTVIEW_ITEM* lv_first = (LISTVIEW_ITEM*) DPA_GetPtr( (HDPA)first, 0 ); 7243 LISTVIEW_ITEM* lv_second = (LISTVIEW_ITEM*) DPA_GetPtr( (HDPA)second, 0 ); 7244 INT cmpv = lstrcmpW( lv_first->pszText, lv_second->pszText ); 6939 7245 /* if we're sorting descending, negate the return value */ 6940 7246 return (lStyle & LVS_SORTDESCENDING) ? -cmpv : cmpv; … … 6944 7250 * nESCRIPTION: 6945 7251 * Inserts a new item in the listview control. 6946 * 6947 * PARAMETER(S): 6948 * [I] HWND : window handle 6949 * [I] LPLVITEMA : item information 7252 * 7253 * PARAMETER(S): 7254 * [I] HWND : window handle 7255 * [I] LPLVITEMW : item information 7256 * [I] isW : TRUE if lpLVItem is Unicode, FALSE if it's ANSI 6950 7257 * 6951 7258 * RETURN: … … 6953 7260 * FAILURE : -1 6954 7261 */ 6955 static LRESULT LISTVIEW_InsertItem A(HWND hwnd, LPLVITEMA lpLVItem)6956 { 6957 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);6958 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);7262 static LRESULT LISTVIEW_InsertItemT(HWND hwnd, LPLVITEMW lpLVItem, BOOL isW) 7263 { 7264 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7265 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 6959 7266 UINT uView = lStyle & LVS_TYPEMASK; 6960 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID);6961 NMLISTVIEW nmlv;6962 7267 INT nItem = -1; 6963 7268 HDPA hdpaSubItems; … … 6965 7270 LISTVIEW_ITEM *lpItem = NULL; 6966 7271 6967 TRACE("(hwnd=%x,lpLVItem=%p)\n", hwnd, lpLVItem); 7272 TRACE("(hwnd=%x, lpLVItem=%s, isW=%d)\n", 7273 hwnd, debuglvitem_t(lpLVItem, isW), isW); 6968 7274 6969 7275 if (lStyle & LVS_OWNERDATA) … … 6979 7285 if (lpLVItem->iSubItem == 0) 6980 7286 { 6981 lpItem = (LISTVIEW_ITEM *)COMCTL32_Alloc(sizeof(LISTVIEW_ITEM)); 6982 if (lpItem != NULL) 7287 if ( (lpItem = (LISTVIEW_ITEM *)COMCTL32_Alloc(sizeof(LISTVIEW_ITEM))) ) 6983 7288 { 6984 7289 ZeroMemory(lpItem, sizeof(LISTVIEW_ITEM)); 6985 if (LISTVIEW_InitItem (hwnd, lpItem, lpLVItem) != FALSE)7290 if (LISTVIEW_InitItemT(hwnd, lpItem, lpLVItem, isW)) 6986 7291 { 6987 7292 /* insert item in listview control data structure */ 6988 hdpaSubItems = DPA_Create(8); 6989 if (hdpaSubItems != NULL) 7293 if ( (hdpaSubItems = DPA_Create(8)) ) 6990 7294 { 6991 nItem = DPA_InsertPtr(hdpaSubItems, 0, lpItem); 6992 if (nItem != -1) 7295 if ( (nItem = DPA_InsertPtr(hdpaSubItems, 0, lpItem)) != -1) 6993 7296 { 6994 7297 if ( ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING)) 6995 6996 && (LPSTR_TEXTCALLBACKA!= lpLVItem->pszText) )6997 6998 6999 7000 nItem = DPA_InsertPtr( infoPtr->hdpaItems, 7001 7002 7003 7004 7005 7006 7007 nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem, 7298 && !(lStyle & LVS_OWNERDRAWFIXED) 7299 && (LPSTR_TEXTCALLBACKW != lpLVItem->pszText) ) 7300 { 7301 /* Insert the item in the proper sort order based on the pszText 7302 member. See comments for LISTVIEW_InsertCompare() for greater detail */ 7303 nItem = DPA_InsertPtr( infoPtr->hdpaItems, 7304 GETITEMCOUNT( infoPtr ) + 1, hdpaSubItems ); 7305 DPA_Sort( infoPtr->hdpaItems, LISTVIEW_InsertCompare, hwnd ); 7306 nItem = DPA_GetPtrIndex( infoPtr->hdpaItems, hdpaSubItems ); 7307 } 7308 else 7309 { 7310 nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem, 7008 7311 hdpaSubItems); 7009 7312 } 7010 7313 if (nItem != -1) 7011 7314 { 7315 NMLISTVIEW nmlv; 7316 7012 7317 LISTVIEW_ShiftIndices(hwnd,nItem,1); 7013 7318 … … 7015 7320 if (lpLVItem->mask & LVIF_STATE) 7016 7321 { 7017 7322 lpItem->state &= ~(LVIS_FOCUSED|LVIS_SELECTED); 7018 7323 if (lpLVItem->stateMask & LVIS_SELECTED) 7019 {7020 7324 LISTVIEW_SetSelection(hwnd, nItem); 7021 } 7022 else if (lpLVItem->stateMask & LVIS_FOCUSED) 7023 { 7325 else if (lpLVItem->stateMask & LVIS_FOCUSED) 7024 7326 LISTVIEW_SetItemFocus(hwnd, nItem); 7025 }7026 7327 } 7027 7328 7028 7329 /* send LVN_INSERTITEM notification */ 7029 7330 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); 7030 nmlv.hdr.hwndFrom = hwnd;7031 nmlv.hdr.idFrom = lCtrlId;7032 nmlv.hdr.code = LVN_INSERTITEM;7033 7331 nmlv.iItem = nItem; 7034 nmlv.lParam = lpItem->lParam; ;7035 ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);7036 7332 nmlv.lParam = lpItem->lParam; 7333 listview_notify(hwnd, LVN_INSERTITEM, &nmlv); 7334 7037 7335 if ((uView == LVS_SMALLICON) || (uView == LVS_LIST)) 7038 { 7039 nItemWidth = LISTVIEW_CalculateWidth(hwnd, lpLVItem->iItem); 7040 if (nItemWidth > infoPtr->nItemWidth) 7041 { 7042 infoPtr->nItemWidth = nItemWidth; 7043 } 7044 } 7336 { 7337 nItemWidth = LISTVIEW_CalculateWidth(hwnd, lpLVItem->iItem); 7338 if (nItemWidth > infoPtr->nItemWidth) 7339 infoPtr->nItemWidth = nItemWidth; 7340 } 7045 7341 7046 7342 /* align items (set position of each item) */ … … 7048 7344 { 7049 7345 if (lStyle & LVS_ALIGNLEFT) 7050 {7051 7346 LISTVIEW_AlignLeft(hwnd); 7052 }7053 7347 else 7054 {7055 7348 LISTVIEW_AlignTop(hwnd); 7056 }7057 7349 } 7058 7350 7059 7351 LISTVIEW_UpdateScroll(hwnd); 7060 7352 /* refresh client area */ … … 7070 7362 /* free memory if unsuccessful */ 7071 7363 if ((nItem == -1) && (lpItem != NULL)) 7072 {7073 7364 COMCTL32_Free(lpItem); 7074 } 7075 7365 7076 7366 return nItem; 7077 7367 } 7078 7368 7079 static LRESULT LISTVIEW_InsertItemW(HWND hwnd, LPLVITEMW lpLVItem) {7080 LVITEMA lvia;7081 LRESULT lres;7082 7083 memcpy(&lvia,lpLVItem,sizeof(LVITEMA));7084 if (lvia.mask & LVIF_TEXT) {7085 if (lpLVItem->pszText == LPSTR_TEXTCALLBACKW)7086 lvia.pszText = LPSTR_TEXTCALLBACKA;7087 else7088 lvia.pszText = HEAP_strdupWtoA(GetProcessHeap(),0,lpLVItem->pszText);7089 }7090 lres = LISTVIEW_InsertItemA(hwnd, &lvia);7091 if (lvia.mask & LVIF_TEXT) {7092 if (lpLVItem->pszText != LPSTR_TEXTCALLBACKW)7093 HeapFree(GetProcessHeap(),0,lvia.pszText);7094 }7095 return lres;7096 }7097 7098 /* LISTVIEW_InsertItemW */7099 7100 7369 /*** 7101 7370 * DESCRIPTION: 7102 7371 * Redraws a range of items. 7103 * 7372 * 7104 7373 * PARAMETER(S): 7105 7374 * [I] HWND : window handle … … 7113 7382 static LRESULT LISTVIEW_RedrawItems(HWND hwnd, INT nFirst, INT nLast) 7114 7383 { 7115 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);7384 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7116 7385 BOOL bResult = FALSE; 7117 7386 RECT rcItem; 7387 INT i; 7118 7388 7119 7389 if (nFirst <= nLast) … … 7123 7393 if ((nLast >= 0) && (nLast < GETITEMCOUNT(infoPtr))) 7124 7394 { 7125 INT i; 7126 for (i = nFirst; i <= nLast; i++) 7127 { 7128 rcItem.left = LVIR_BOUNDS; 7129 LISTVIEW_GetItemRect(hwnd, i, &rcItem); 7130 InvalidateRect(hwnd, &rcItem, TRUE); 7131 } 7395 for (i = nFirst; i <= nLast; i++) 7396 { 7397 rcItem.left = LVIR_BOUNDS; 7398 LISTVIEW_GetItemRect(hwnd, i, &rcItem); 7399 InvalidateRect(hwnd, &rcItem, TRUE); 7400 } 7132 7401 } 7133 7402 } … … 7142 7411 * DESCRIPTION: 7143 7412 * Sets the background color. 7144 * 7413 * 7145 7414 * PARAMETER(S): 7146 7415 * [I] HWND : window handle … … 7153 7422 static LRESULT LISTVIEW_SetBkColor(HWND hwnd, COLORREF clrBk) 7154 7423 { 7155 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 7156 7157 infoPtr->clrBk = clrBk; 7158 InvalidateRect(hwnd, NULL, TRUE); 7159 7424 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7425 7426 if(infoPtr->clrBk!=clrBk){ 7427 infoPtr->clrBk = clrBk; 7428 InvalidateRect(hwnd, NULL, TRUE); 7429 } 7430 7160 7431 return TRUE; 7161 7432 } … … 7167 7438 * Sets the callback mask. This mask will be used when the parent 7168 7439 * window stores state information (some or all). 7169 * 7440 * 7170 7441 * PARAMETER(S): 7171 7442 * [I] HWND : window handle … … 7178 7449 static BOOL LISTVIEW_SetCallbackMask(HWND hwnd, UINT uMask) 7179 7450 { 7180 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);7451 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7181 7452 7182 7453 infoPtr->uCallbackMask = uMask; … … 7188 7459 * DESCRIPTION: 7189 7460 * Sets the attributes of a header item. 7190 * 7461 * 7191 7462 * PARAMETER(S): 7192 7463 * [I] HWND : window handle 7193 7464 * [I] INT : column index 7194 * [I] LPLVCOLUMNA : column attributes 7465 * [I] LPLVCOLUMNW : column attributes 7466 * [I] isW: if TRUE, the lpColumn is a LPLVCOLUMNW, 7467 * otherwise it is in fact a LPLVCOLUMNA 7195 7468 * 7196 7469 * RETURN: … … 7198 7471 * FAILURE : FALSE 7199 7472 */ 7200 static LRESULT LISTVIEW_SetColumn A(HWND hwnd, INT nColumn,7201 LPLVCOLUMN A lpColumn)7202 { 7203 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);7473 static LRESULT LISTVIEW_SetColumnT(HWND hwnd, INT nColumn, 7474 LPLVCOLUMNW lpColumn, BOOL isW) 7475 { 7476 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7204 7477 BOOL bResult = FALSE; 7205 HDITEM Ahdi, hdiget;7206 7207 if ((lpColumn != NULL) && (nColumn >= 0) && 7478 HDITEMW hdi, hdiget; 7479 7480 if ((lpColumn != NULL) && (nColumn >= 0) && 7208 7481 (nColumn < Header_GetItemCount(infoPtr->hwndHeader))) 7209 7482 { 7210 7483 /* initialize memory */ 7211 ZeroMemory(&hdi, sizeof( HDITEMA));7212 7213 if (lpColumn->mask & LVCF_FMT) 7484 ZeroMemory(&hdi, sizeof(hdi)); 7485 7486 if (lpColumn->mask & LVCF_FMT) 7214 7487 { 7215 7488 /* format member is valid */ … … 7218 7491 /* get current format first */ 7219 7492 hdiget.mask = HDI_FORMAT; 7220 if (Header_GetItem A(infoPtr->hwndHeader, nColumn, &hdiget))7221 7222 7493 if (Header_GetItemW(infoPtr->hwndHeader, nColumn, &hdiget)) 7494 /* preserve HDF_STRING if present */ 7495 hdi.fmt = hdiget.fmt & HDF_STRING; 7223 7496 7224 7497 /* set text alignment (leftmost column must be left-aligned) */ … … 7230 7503 { 7231 7504 if (lpColumn->fmt & LVCFMT_LEFT) 7232 {7233 7505 hdi.fmt |= HDF_LEFT; 7234 }7235 7506 else if (lpColumn->fmt & LVCFMT_RIGHT) 7236 {7237 7507 hdi.fmt |= HDF_RIGHT; 7238 }7239 7508 else if (lpColumn->fmt & LVCFMT_CENTER) 7240 {7241 7509 hdi.fmt |= HDF_CENTER; 7242 }7243 7510 } 7244 7511 7245 7512 if (lpColumn->fmt & LVCFMT_BITMAP_ON_RIGHT) 7246 {7247 7513 hdi.fmt |= HDF_BITMAP_ON_RIGHT; 7248 }7249 7514 7250 7515 if (lpColumn->fmt & LVCFMT_COL_HAS_IMAGES) 7251 {7252 7516 hdi.fmt |= HDF_IMAGE; 7253 } 7254 7517 7255 7518 if (lpColumn->fmt & LVCFMT_IMAGE) 7256 7519 { … … 7260 7523 } 7261 7524 7262 if (lpColumn->mask & LVCF_WIDTH) 7525 if (lpColumn->mask & LVCF_WIDTH) 7263 7526 { 7264 7527 hdi.mask |= HDI_WIDTH; 7265 7528 hdi.cxy = lpColumn->cx; 7266 7529 } 7267 7268 if (lpColumn->mask & LVCF_TEXT) 7530 7531 if (lpColumn->mask & LVCF_TEXT) 7269 7532 { 7270 7533 hdi.mask |= HDI_TEXT | HDI_FORMAT; 7271 7534 hdi.pszText = lpColumn->pszText; 7272 hdi.cchTextMax = ((lpColumn->pszText!=NULL) && (lpColumn->pszText!=LPSTR_TEXTCALLBACKA) ? strlen(lpColumn->pszText) : 0);7535 hdi.cchTextMax = textlenT(lpColumn->pszText, isW); 7273 7536 hdi.fmt |= HDF_STRING; 7274 7537 } 7275 7276 if (lpColumn->mask & LVCF_IMAGE) 7538 7539 if (lpColumn->mask & LVCF_IMAGE) 7277 7540 { 7278 7541 hdi.mask |= HDI_IMAGE; … … 7280 7543 } 7281 7544 7282 if (lpColumn->mask & LVCF_ORDER) 7545 if (lpColumn->mask & LVCF_ORDER) 7283 7546 { 7284 7547 hdi.mask |= HDI_ORDER; … … 7287 7550 7288 7551 /* set header item attributes */ 7289 bResult = Header_SetItemA(infoPtr->hwndHeader, nColumn, &hdi); 7290 } 7291 7552 if (isW) 7553 bResult = Header_SetItemW(infoPtr->hwndHeader, nColumn, &hdi); 7554 else 7555 bResult = Header_SetItemA(infoPtr->hwndHeader, nColumn, &hdi); 7556 } 7557 7292 7558 return bResult; 7293 7559 } 7294 7295 /* LISTVIEW_SetColumnW */7296 7560 7297 7561 /*** … … 7310 7574 static LRESULT LISTVIEW_SetColumnOrderArray(HWND hwnd, INT iCount, LPINT lpiArray) 7311 7575 { 7312 /* LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); */7313 7314 7315 7316 7576 /* LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); */ 7577 7578 FIXME("iCount %d lpiArray %p\n", iCount, lpiArray); 7579 7580 if (!lpiArray) 7317 7581 return FALSE; 7318 7582 7319 7583 return TRUE; 7320 7584 } 7321 7585 … … 7337 7601 { 7338 7602 LISTVIEW_INFO *infoPtr; 7339 HDITEM Ahdi;7603 HDITEMW hdi; 7340 7604 LRESULT lret; 7341 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);7342 UINT uView = lStyle & LVS_TYPEMASK; 7605 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 7606 UINT uView = lStyle & LVS_TYPEMASK; 7343 7607 HDC hdc; 7344 7608 HFONT header_font; 7345 7609 HFONT old_font; 7346 7610 SIZE size; 7347 CHAR text_buffer[DISP_TEXT_SIZE];7611 WCHAR text_buffer[DISP_TEXT_SIZE]; 7348 7612 INT header_item_count; 7349 7613 INT item_index; 7614 INT nLabelWidth; 7350 7615 RECT rcHeader; 7351 7616 LVITEMW lvItem; 7617 WCHAR szDispText[DISP_TEXT_SIZE]; 7352 7618 7353 7619 /* make sure we can get the listview info */ 7354 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0)))7620 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0))) 7355 7621 return (FALSE); 7356 7622 … … 7360 7626 /* set column width only if in report or list mode */ 7361 7627 if ((uView != LVS_REPORT) && (uView != LVS_LIST)) 7362 return (FALSE); 7363 7628 return (FALSE); 7629 7630 TRACE("(hwnd=%x, iCol=%d, cx=%d\n", hwnd, iCol, cx); 7631 7364 7632 /* take care of invalid cx values */ 7365 7633 if((uView == LVS_REPORT) && (cx < -2)) … … 7367 7635 else if (uView == LVS_LIST && (cx < 1)) 7368 7636 return FALSE; 7369 7637 7370 7638 /* resize all columns if in LVS_LIST mode */ 7371 7639 if(uView == LVS_LIST) { … … 7378 7646 if(cx == LVSCW_AUTOSIZE) 7379 7647 { 7380 /* set the width of the headerto the width of the widest item */7381 for(item_index = 0; item_index < GETITEMCOUNT(infoPtr); item_index++)7648 /* set the width of the column to the width of the widest item */ 7649 if (iCol == 0 || uView == LVS_LIST) 7382 7650 { 7383 if(cx < LISTVIEW_GetLabelWidth(hwnd, item_index)) 7384 cx = LISTVIEW_GetLabelWidth(hwnd, item_index); 7651 cx = 0; 7652 for(item_index = 0; item_index < GETITEMCOUNT(infoPtr); item_index++) 7653 { 7654 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, item_index); 7655 cx = (nLabelWidth>cx)?nLabelWidth:cx; 7656 } 7657 if (infoPtr->himlSmall) 7658 cx += infoPtr->iconSize.cx + IMAGE_PADDING; 7385 7659 } 7660 else 7661 { 7662 ZeroMemory(&lvItem, sizeof(lvItem)); 7663 lvItem.iSubItem = iCol; 7664 lvItem.mask = LVIF_TEXT; 7665 lvItem.cchTextMax = DISP_TEXT_SIZE; 7666 lvItem.pszText = szDispText; 7667 *lvItem.pszText = '\0'; 7668 cx = 0; 7669 for(item_index = 0; item_index < GETITEMCOUNT(infoPtr); item_index++) 7670 { 7671 lvItem.iItem = item_index; 7672 LISTVIEW_GetItemT(hwnd, &lvItem, FALSE, TRUE); 7673 nLabelWidth = LISTVIEW_GetStringWidthT(hwnd, lvItem.pszText, TRUE); 7674 cx = (nLabelWidth>cx)?nLabelWidth:cx; 7675 } 7676 } 7677 cx += TRAILING_PADDING; 7386 7678 } /* autosize based on listview header width */ 7387 7679 else if(cx == LVSCW_AUTOSIZE_USEHEADER) 7388 7680 { 7389 7681 header_item_count = Header_GetItemCount(infoPtr->hwndHeader); 7390 7682 7391 7683 /* if iCol is the last column make it fill the remainder of the controls width */ 7392 7684 if(iCol == (header_item_count - 1)) { … … 7394 7686 hdi.mask = HDI_WIDTH; 7395 7687 cx = 0; 7396 7688 7397 7689 for(item_index = 0; item_index < (header_item_count - 1); item_index++) { 7398 Header_GetItem A(infoPtr->hwndHeader, item_index, (LPARAM)(&hdi));7690 Header_GetItemW(infoPtr->hwndHeader, item_index, (LPARAM)(&hdi)); 7399 7691 cx+=hdi.cxy; 7400 7692 } 7401 7693 7402 7694 /* retrieve the layout of the header */ 7403 7695 GetWindowRect(infoPtr->hwndHeader, &rcHeader); 7404 7696 7405 7697 cx = (rcHeader.right - rcHeader.left) - cx; 7406 } 7698 } 7407 7699 else 7408 7700 { 7701 /* Despite what the MS docs say, if this is not the last 7702 column, then MS resizes the column to the width of the 7703 largest text string in the column, including headers 7704 and items. This is different from LVSCW_AUTOSIZE in that 7705 LVSCW_AUTOSIZE ignores the header string length. 7706 */ 7707 7409 7708 /* retrieve header font */ 7410 header_font = SendMessage A(infoPtr->hwndHeader, WM_GETFONT, 0L, 0L);7411 7709 header_font = SendMessageW(infoPtr->hwndHeader, WM_GETFONT, 0L, 0L); 7710 7412 7711 /* retrieve header text */ 7413 7712 hdi.mask = HDI_TEXT; 7414 hdi.cchTextMax = sizeof(text_buffer) ;7415 hdi.pszText = text_buffer; 7416 7417 Header_GetItem A(infoPtr->hwndHeader, iCol, (LPARAM)(&hdi));7418 7713 hdi.cchTextMax = sizeof(text_buffer)/sizeof(text_buffer[0]); 7714 hdi.pszText = text_buffer; 7715 7716 Header_GetItemW(infoPtr->hwndHeader, iCol, (LPARAM)(&hdi)); 7717 7419 7718 /* determine the width of the text in the header */ 7420 7719 hdc = GetDC(hwnd); 7421 7720 old_font = SelectObject(hdc, header_font); /* select the font into hdc */ 7422 7721 7423 GetTextExtentPoint32 A(hdc, text_buffer, strlen(text_buffer), &size);7424 7425 SelectObject(hdc, old_font); /* restore the old font */ 7722 GetTextExtentPoint32W(hdc, text_buffer, lstrlenW(text_buffer), &size); 7723 7724 SelectObject(hdc, old_font); /* restore the old font */ 7426 7725 ReleaseDC(hwnd, hdc); 7427 7428 /* set the width of this column to the width of the text */ 7726 7727 ZeroMemory(&lvItem, sizeof(lvItem)); 7728 lvItem.iSubItem = iCol; 7729 lvItem.mask = LVIF_TEXT; 7730 lvItem.cchTextMax = DISP_TEXT_SIZE; 7731 lvItem.pszText = szDispText; 7732 *lvItem.pszText = '\0'; 7429 7733 cx = size.cx; 7734 for(item_index = 0; item_index < GETITEMCOUNT(infoPtr); item_index++) 7735 { 7736 lvItem.iItem = item_index; 7737 LISTVIEW_GetItemT(hwnd, &lvItem, FALSE, TRUE); 7738 nLabelWidth = LISTVIEW_GetStringWidthT(hwnd, lvItem.pszText, TRUE); 7739 nLabelWidth += TRAILING_PADDING; 7740 /* While it is possible for subitems to have icons, even MS messes 7741 up the positioning, so I suspect no applications actually use 7742 them. */ 7743 if (item_index == 0 && infoPtr->himlSmall) 7744 nLabelWidth += infoPtr->iconSize.cx + IMAGE_PADDING; 7745 cx = (nLabelWidth>cx)?nLabelWidth:cx; 7746 } 7430 7747 } 7431 7748 } 7432 7749 7433 7750 /* call header to update the column change */ 7434 hdi.mask = HDI_WIDTH; 7751 hdi.mask = HDI_WIDTH; 7435 7752 7436 7753 hdi.cxy = cx; 7437 lret = Header_SetItem A(infoPtr->hwndHeader, (WPARAM)iCol, (LPARAM)&hdi);7438 7754 lret = Header_SetItemW(infoPtr->hwndHeader, (WPARAM)iCol, (LPARAM)&hdi); 7755 7439 7756 InvalidateRect(hwnd, NULL, TRUE); /* force redraw of the listview */ 7440 7757 7441 7758 return lret; 7442 7759 } … … 7457 7774 static LRESULT LISTVIEW_SetExtendedListViewStyle(HWND hwnd, DWORD dwMask, DWORD dwStyle) 7458 7775 { 7459 LISTVIEW_INFO *infoPtr; 7460 DWORD dwOldStyle; 7461 7462 /* make sure we can get the listview info */ 7463 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 7464 return (0); 7465 7466 /* store previous style */ 7467 dwOldStyle = infoPtr->dwExStyle; 7468 7469 /* set new style */ 7470 if (dwMask) 7471 infoPtr->dwExStyle = (dwOldStyle & ~dwMask) | (dwStyle & dwMask); 7472 else 7473 infoPtr->dwExStyle = dwStyle; 7474 7475 return (dwOldStyle); 7776 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7777 DWORD dwOldStyle = infoPtr->dwExStyle; 7778 7779 /* set new style */ 7780 if (dwMask) 7781 infoPtr->dwExStyle = (dwOldStyle & ~dwMask) | (dwStyle & dwMask); 7782 else 7783 infoPtr->dwExStyle = dwStyle; 7784 7785 return dwOldStyle; 7476 7786 } 7477 7787 … … 7492 7802 static LRESULT LISTVIEW_SetHotItem(HWND hwnd, INT iIndex) 7493 7803 { 7494 LISTVIEW_INFO *infoPtr; 7495 INT iOldIndex; 7496 7497 /* make sure we can get the listview info */ 7498 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 7499 return (-1); 7500 7501 /* store previous index */ 7502 iOldIndex = infoPtr->nHotItem; 7503 7504 /* set new style */ 7505 infoPtr->nHotItem = iIndex; 7506 7507 return (iOldIndex); 7804 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7805 INT iOldIndex = infoPtr->nHotItem; 7806 7807 /* set new style */ 7808 infoPtr->nHotItem = iIndex; 7809 7810 return iOldIndex; 7508 7811 } 7509 7812 … … 7521 7824 static LRESULT LISTVIEW_SetHoverTime(HWND hwnd, DWORD dwHoverTime) 7522 7825 { 7826 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7827 DWORD oldHoverTime = infoPtr->dwHoverTime; 7828 7829 infoPtr->dwHoverTime = dwHoverTime; 7830 7831 return oldHoverTime; 7832 } 7833 7834 /*** 7835 * DESCRIPTION: 7836 * Sets spacing for icons of LVS_ICON style. 7837 * 7838 * PARAMETER(S): 7839 * [I] HWND : window handle 7840 * [I] DWORD : MAKELONG(cx, cy) 7841 * 7842 * RETURN: 7843 * MAKELONG(oldcx, oldcy) 7844 */ 7845 #ifdef __WIN32OS2__ 7846 static LRESULT LISTVIEW_SetIconSpacing(HWND hwnd,WPARAM wParam,LPARAM lParam) 7847 { 7523 7848 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 7524 DWORD oldHoverTime = infoPtr->dwHoverTime; 7525 7526 infoPtr->dwHoverTime = dwHoverTime; 7527 7528 return oldHoverTime; 7529 } 7530 7531 /* LISTVIEW_SetIconSpacing */ 7849 UINT dwStyle = GetWindowLongA(hwnd, GWL_STYLE); 7850 UINT uView = dwStyle & LVS_TYPEMASK; 7851 DWORD oldIS = MAKELONG(infoPtr->iconSpacing.cx,infoPtr->iconSpacing.cy); 7852 INT cx = LOWORD(lParam),cy = HIWORD(lParam); 7853 7854 if (cx == -1) cx = GetSystemMetrics(SM_CXICONSPACING); 7855 if (cy == -1) cy = GetSystemMetrics(SM_CYICONSPACING); 7856 if ((cx != infoPtr->iconSpacing.cx) || (cy != infoPtr->iconSpacing.cy)) 7857 { 7858 infoPtr->iconSpacing.cx = cx; 7859 infoPtr->iconSpacing.cy = cy; 7860 if (((uView == LVS_ICON) || (uView == LVS_SMALLICON)) && (dwStyle & LVS_AUTOARRANGE)) 7861 { 7862 LISTVIEW_Arrange(hwnd,LVA_DEFAULT); 7863 } 7864 } 7865 return oldIS; 7866 } 7867 #else 7868 static LRESULT LISTVIEW_SetIconSpacing(HWND hwnd, DWORD spacing) 7869 { 7870 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 7871 INT cy = HIWORD(spacing); 7872 INT cx = LOWORD(spacing); 7873 DWORD oldspacing; 7874 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 7875 UINT uView = lStyle & LVS_TYPEMASK; 7876 7877 oldspacing = MAKELONG(infoPtr->iconSpacing.cx, infoPtr->iconSpacing.cy); 7878 if (cx == -1) /* set to default */ 7879 cx = GetSystemMetrics(SM_CXICONSPACING); 7880 if (cy == -1) /* set to default */ 7881 cy = GetSystemMetrics(SM_CYICONSPACING); 7882 7883 if (cx) 7884 infoPtr->iconSpacing.cx = cx; 7885 else 7886 { /* if 0 then compute width */ 7887 if (uView == LVS_ICON) 7888 FIXME("width computation not yet done\n"); 7889 /* 7890 * Should scan each item and determine max width of 7891 * icon or label, then make that the width 7892 */ 7893 else /* FIXME: unknown computation for non LVS_ICON - this is a guess */ 7894 infoPtr->iconSpacing.cx = LISTVIEW_GetItemWidth(hwnd); 7895 } 7896 if (cy) 7897 infoPtr->iconSpacing.cy = cy; 7898 else 7899 { /* if 0 then compute height */ 7900 if (uView == LVS_ICON) 7901 infoPtr->iconSpacing.cy = infoPtr->iconSize.cy + infoPtr->ntmHeight 7902 + ICON_BOTTOM_PADDING + ICON_TOP_PADDING + LABEL_VERT_OFFSET; 7903 /* FIXME. I don't think so; I think it is based on twice the ntmHeight */ 7904 else /* FIXME: unknown computation for non LVS_ICON - this is a guess */ 7905 infoPtr->iconSpacing.cy = LISTVIEW_GetItemHeight(hwnd); 7906 } 7907 7908 TRACE("old=(%d,%d), new=(%ld,%ld)\n", LOWORD(oldspacing), HIWORD(oldspacing), 7909 infoPtr->iconSpacing.cx, infoPtr->iconSpacing.cy); 7910 7911 /* these depend on the iconSpacing */ 7912 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); 7913 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd); 7914 7915 return oldspacing; 7916 } 7917 #endif 7532 7918 7533 7919 /*** 7534 7920 * DESCRIPTION: 7535 7921 * Sets image lists. 7536 * 7537 * PARAMETER(S): 7538 * [I] HWND : window handle 7539 * [I] INT : image list type 7922 * 7923 * PARAMETER(S): 7924 * [I] HWND : window handle 7925 * [I] INT : image list type 7540 7926 * [I] HIMAGELIST : image list handle 7541 7927 * … … 7544 7930 * FAILURE : NULL 7545 7931 */ 7546 static LRESULT LISTVIEW_SetImageList(HWND hwnd, INT nType, HIMAGELIST himl)7547 { 7548 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);7932 static HIMAGELIST LISTVIEW_SetImageList(HWND hwnd, INT nType, HIMAGELIST himl) 7933 { 7934 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7549 7935 HIMAGELIST himlOld = 0; 7550 7936 INT oldHeight; 7551 7937 7552 switch (nType) 7938 switch (nType) 7553 7939 { 7554 7940 case LVSIL_NORMAL: … … 7574 7960 LISTVIEW_UpdateScroll(hwnd); 7575 7961 7576 return (LRESULT)himlOld;7577 } 7578 7579 7580 /*** 7581 * DESCRIPTION:7582 * Sets the attributes of an item.7583 * 7584 * PARAMETER(S):7585 * [I] HWND : window handle7586 * [I] LPLVITEM : item information7962 return himlOld; 7963 } 7964 7965 /*** 7966 * DESCRIPTION: 7967 * Preallocates memory (does *not* set the actual count of items !) 7968 * 7969 * PARAMETER(S): 7970 * [I] HWND : window handle 7971 * [I] INT : item count (projected number of items to allocate) 7972 * [I] DWORD : update flags 7587 7973 * 7588 7974 * RETURN: … … 7590 7976 * FAILURE : FALSE 7591 7977 */ 7592 static LRESULT LISTVIEW_SetItemA(HWND hwnd, LPLVITEMA lpLVItem)7593 {7594 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);7595 BOOL bResult = FALSE;7596 7597 if (lpLVItem != NULL)7598 {7599 if ((lpLVItem->iItem >= 0) && (lpLVItem->iItem < GETITEMCOUNT(infoPtr)))7600 {7601 if (lpLVItem->iSubItem == 0)7602 {7603 bResult = LISTVIEW_SetItem(hwnd, lpLVItem);7604 }7605 else7606 {7607 bResult = LISTVIEW_SetSubItem(hwnd, lpLVItem);7608 }7609 }7610 }7611 7612 7613 return bResult;7614 }7615 7616 /* LISTVIEW_SetItemW */7617 7618 /***7619 * DESCRIPTION:7620 * Preallocates memory (does *not* set the actual count of items !)7621 *7622 * PARAMETER(S):7623 * [I] HWND : window handle7624 * [I] INT : item count (projected number of items to allocate)7625 * [I] DWORD : update flags7626 *7627 * RETURN:7628 * SUCCESS : TRUE7629 * FAILURE : FALSE7630 */7631 7978 static BOOL LISTVIEW_SetItemCount(HWND hwnd, INT nItems, DWORD dwFlags) 7632 7979 { 7633 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0); 7634 7635 if (GetWindowLongA(hwnd, GWL_STYLE) & LVS_OWNERDATA) 7980 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongW(hwnd, 0); 7981 7982 TRACE("(hwnd=%x, nItems=%d, dwFlags=%lx)\n", hwnd, nItems, dwFlags); 7983 7984 if (GetWindowLongW(hwnd, GWL_STYLE) & LVS_OWNERDATA) 7636 7985 { 7637 7986 int precount,topvisible; 7987 7638 7988 TRACE("LVS_OWNERDATA is set!\n"); 7989 if (dwFlags & (LVSICF_NOINVALIDATEALL | LVSICF_NOSCROLL)) 7990 FIXME("flags %s %s not implemented\n", 7991 (dwFlags & LVSICF_NOINVALIDATEALL) ? "LVSICF_NOINVALIDATEALL" 7992 : "", 7993 (dwFlags & LVSICF_NOSCROLL) ? "LVSICF_NOSCROLL" : ""); 7639 7994 7640 7995 /* 7641 * Internally remove all the selections. 7996 * Internally remove all the selections. 7642 7997 */ 7643 7998 do … … 7650 8005 } 7651 8006 while (infoPtr->hdpaSelectionRanges->nItemCount>0); 7652 8007 7653 8008 precount = infoPtr->hdpaItems->nItemCount; 7654 8009 topvisible = ListView_GetTopIndex(hwnd) + … … 7657 8012 infoPtr->hdpaItems->nItemCount = nItems; 7658 8013 8014 infoPtr->nItemWidth = max(LISTVIEW_GetItemWidth(hwnd), 8015 DEFAULT_COLUMN_WIDTH); 8016 7659 8017 LISTVIEW_UpdateSize(hwnd); 7660 8018 LISTVIEW_UpdateScroll(hwnd); 7661 if (min(precount,infoPtr->hdpaItems->nItemCount)<topvisible) 8019 8020 if (min(precount,infoPtr->hdpaItems->nItemCount)<topvisible) 7662 8021 InvalidateRect(hwnd, NULL, TRUE); 7663 8022 } 7664 8023 else 7665 8024 { 7666 FIXME("setitemcount not done for non-ownerdata\n"); 8025 /* According to MSDN for non-LVS_OWNERDATA this is just 8026 * a performance issue. The control allocates its internal 8027 * data structures for the number of items specified. It 8028 * cuts down on the number of memory allocations. Therefore 8029 * we will just issue a WARN here 8030 */ 8031 WARN("for non-ownerdata performance option not implemented.\n"); 7667 8032 } 7668 8033 … … 7673 8038 * DESCRIPTION: 7674 8039 * Sets the position of an item. 7675 * 8040 * 7676 8041 * PARAMETER(S): 7677 8042 * [I] HWND : window handle … … 7687 8052 LONG nPosX, LONG nPosY) 7688 8053 { 7689 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLong A(hwnd, 0);7690 UINT lStyle = GetWindowLong A(hwnd, GWL_STYLE);8054 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongW(hwnd, 0); 8055 UINT lStyle = GetWindowLongW(hwnd, GWL_STYLE); 7691 8056 UINT uView = lStyle & LVS_TYPEMASK; 7692 8057 LISTVIEW_ITEM *lpItem; … … 7694 8059 BOOL bResult = FALSE; 7695 8060 7696 TRACE("(hwnd=%x, nItem=%d,X=%ld,Y=%ld)\n", hwnd, nItem, nPosX, nPosY);7697 8061 TRACE("(hwnd=%x, nItem=%d, X=%ld, Y=%ld)\n", hwnd, nItem, nPosX, nPosY); 8062 7698 8063 if (lStyle & LVS_OWNERDATA) 7699 8064 return FALSE; … … 7703 8068 if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 7704 8069 { 7705 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem); 7706 if (hdpaSubItems != NULL) 8070 if ( (hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem)) ) 7707 8071 { 7708 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 7709 if (lpItem != NULL) 8072 if ( (lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0)) ) 7710 8073 { 8074 POINT orig; 7711 8075 bResult = TRUE; 8076 orig = lpItem->ptPosition; 8077 if ((nPosX == -1) && (nPosY == -1)) 8078 { 8079 /* This point value seems to be an undocumented feature. The 8080 * best guess is that it means either at the origin, or at 8081 * the true beginning of the list. I will assume the origin. 8082 */ 8083 POINT pt1; 8084 if (!LISTVIEW_GetOrigin(hwnd, &pt1)) 8085 { 8086 pt1.x = 0; 8087 pt1.y = 0; 8088 } 8089 nPosX = pt1.x; 8090 nPosY = pt1.y; 8091 if (uView == LVS_ICON) 8092 { 8093 nPosX += (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; 8094 nPosY += ICON_TOP_PADDING; 8095 } 8096 TRACE("requested special (-1,-1), set to origin (%ld,%ld)\n", 8097 nPosX, nPosY); 8098 } 8099 7712 8100 lpItem->ptPosition.x = nPosX; 7713 8101 lpItem->ptPosition.y = nPosY; 8102 if (uView == LVS_ICON) 8103 { 8104 lpItem->ptPosition.y -= ICON_TOP_PADDING; 8105 lpItem->ptPosition.x -= (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; 8106 if ((lpItem->ptPosition.y < 0) || (lpItem->ptPosition.x < 0)) 8107 { 8108 FIXME("failed orig (%ld,%ld), intent (%ld,%ld), is (%ld, %ld), setting neg to 0\n", 8109 orig.x, orig.y, nPosX, nPosY, lpItem->ptPosition.x, lpItem->ptPosition.y); 8110 8111 /* 8112 if (lpItem->ptPosition.x < 0) lpItem->ptPosition.x = 0; 8113 if (lpItem->ptPosition.y < 0) lpItem->ptPosition.y = 0; 8114 */ 8115 } 8116 else 8117 { 8118 TRACE("orig (%ld,%ld), intent (%ld,%ld), is (%ld,%ld)\n", 8119 orig.x, orig.y, nPosX, nPosY, lpItem->ptPosition.x, lpItem->ptPosition.y); 8120 } 8121 } 7714 8122 } 7715 8123 } … … 7723 8131 * DESCRIPTION: 7724 8132 * Sets the state of one or many items. 7725 * 8133 * 7726 8134 * PARAMETER(S): 7727 8135 * [I] HWND : window handle … … 7733 8141 * FAILURE : FALSE 7734 8142 */ 7735 static LRESULT LISTVIEW_SetItemState(HWND hwnd, INT nItem, LPLVITEMA lpLVItem) 7736 { 7737 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 7738 BOOL bResult = FALSE; 7739 LVITEMA lvItem; 7740 INT i; 8143 static LRESULT LISTVIEW_SetItemState(HWND hwnd, INT nItem, LPLVITEMW lpLVItem) 8144 { 8145 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8146 BOOL bResult = TRUE; 8147 LVITEMW lvItem; 8148 8149 TRACE("(hwnd=%x, nItem=%d, lpLVItem=%s)\n", 8150 hwnd, nItem, debuglvitem_t(lpLVItem, TRUE)); 8151 8152 ZeroMemory(&lvItem, sizeof(lvItem)); 8153 lvItem.mask = LVIF_STATE; 8154 lvItem.state = lpLVItem->state; 8155 lvItem.stateMask = lpLVItem->stateMask ; 8156 lvItem.iItem = nItem; 7741 8157 7742 8158 if (nItem == -1) 7743 8159 { 7744 bResult = TRUE;7745 ZeroMemory(&lvItem, sizeof(LVITEMA));7746 lvItem.mask = LVIF_STATE;7747 lvItem.state = lpLVItem->state;7748 lvItem.stateMask = lpLVItem->stateMask ;7749 7750 8160 /* apply to all items */ 7751 for (i = 0; i< GETITEMCOUNT(infoPtr); i++) 7752 { 7753 lvItem.iItem = i; 7754 if (ListView_SetItemA(hwnd, &lvItem) == FALSE) 7755 { 7756 bResult = FALSE; 7757 } 7758 } 8161 for (lvItem.iItem = 0; lvItem.iItem < GETITEMCOUNT(infoPtr); lvItem.iItem++) 8162 if (!ListView_SetItemW(hwnd, &lvItem)) bResult = FALSE; 7759 8163 } 7760 8164 else 7761 { 7762 ZeroMemory(&lvItem, sizeof(LVITEMA)); 7763 lvItem.mask = LVIF_STATE; 7764 lvItem.state = lpLVItem->state; 7765 lvItem.stateMask = lpLVItem->stateMask; 7766 lvItem.iItem = nItem; 7767 bResult = ListView_SetItemA(hwnd, &lvItem); 7768 } 8165 bResult = ListView_SetItemW(hwnd, &lvItem); 7769 8166 7770 8167 return bResult; … … 7774 8171 * DESCRIPTION: 7775 8172 * Sets the text of an item or subitem. 7776 * 7777 * PARAMETER(S): 7778 * [I] HWND : window handle 7779 * [I] INT : item index 7780 * [I] LPLVITEMA : item or subitem info 8173 * 8174 * PARAMETER(S): 8175 * [I] hwnd : window handle 8176 * [I] nItem : item index 8177 * [I] lpLVItem : item or subitem info 8178 * [I] isW : TRUE if input is Unicode 7781 8179 * 7782 8180 * RETURN: … … 7784 8182 * FAILURE : FALSE 7785 8183 */ 7786 static BOOL LISTVIEW_SetItemText A(HWND hwnd, INT nItem, LPLVITEMA lpLVItem)7787 { 7788 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);8184 static BOOL LISTVIEW_SetItemTextT(HWND hwnd, INT nItem, LPLVITEMW lpLVItem, BOOL isW) 8185 { 8186 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7789 8187 BOOL bResult = FALSE; 7790 LVITEMA lvItem; 7791 8188 LVITEMW lvItem; 8189 8190 TRACE("(hwnd=%x, nItem=%d, lpLVItem=%s, isW=%d)\n", 8191 hwnd, nItem, debuglvitem_t(lpLVItem, isW), isW); 8192 7792 8193 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr))) 7793 8194 { 7794 ZeroMemory(&lvItem, sizeof(LVITEM A));8195 ZeroMemory(&lvItem, sizeof(LVITEMW)); 7795 8196 lvItem.mask = LVIF_TEXT; 7796 8197 lvItem.pszText = lpLVItem->pszText; 7797 8198 lvItem.iItem = nItem; 7798 8199 lvItem.iSubItem = lpLVItem->iSubItem; 7799 bResult = ListView_SetItemA(hwnd, &lvItem); 7800 } 7801 8200 if(isW) bResult = ListView_SetItemW(hwnd, &lvItem); 8201 else bResult = ListView_SetItemA(hwnd, &lvItem); 8202 } 8203 7802 8204 return bResult; 7803 8205 } 7804 8206 7805 /* LISTVIEW_SetItemTextW */7806 7807 8207 /*** 7808 8208 * DESCRIPTION: … … 7818 8218 static LRESULT LISTVIEW_SetSelectionMark(HWND hwnd, INT nIndex) 7819 8219 { 7820 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);8220 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 7821 8221 INT nOldIndex = infoPtr->nSelectionMark; 7822 8222 8223 TRACE("(hwnd=%x, nIndex=%d)\n", hwnd, nIndex); 8224 7823 8225 infoPtr->nSelectionMark = nIndex; 7824 8226 … … 7829 8231 * DESCRIPTION: 7830 8232 * Sets the text background color. 7831 * 8233 * 7832 8234 * PARAMETER(S): 7833 8235 * [I] HWND : window handle … … 7840 8242 static LRESULT LISTVIEW_SetTextBkColor(HWND hwnd, COLORREF clrTextBk) 7841 8243 { 7842 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 7843 8244 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8245 8246 TRACE("(hwnd=%x, clrTextBk=%lx)\n", hwnd, clrTextBk); 8247 7844 8248 infoPtr->clrTextBk = clrTextBk; 7845 8249 InvalidateRect(hwnd, NULL, TRUE); … … 7851 8255 * DESCRIPTION: 7852 8256 * Sets the text foreground color. 7853 * 7854 * PARAMETER(S): 7855 * [I] HWND : window handle 7856 * [I] COLORREF : text color 8257 * 8258 * PARAMETER(S): 8259 * [I] HWND : window handle 8260 * [I] COLORREF : text color 7857 8261 * 7858 8262 * RETURN: … … 7862 8266 static LRESULT LISTVIEW_SetTextColor (HWND hwnd, COLORREF clrText) 7863 8267 { 7864 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8268 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8269 8270 TRACE("(hwnd=%x, clrText=%lx)\n", hwnd, clrText); 7865 8271 7866 8272 infoPtr->clrText = clrText; … … 7877 8283 * DESCRIPTION: 7878 8284 * Callback internally used by LISTVIEW_SortItems() 7879 * 8285 * 7880 8286 * PARAMETER(S): 7881 8287 * [I] LPVOID : first LISTVIEW_ITEM to compare … … 7888 8294 * if first and second are equivalent : zero 7889 8295 */ 7890 static INT WINAPI LISTVIEW_CallBackCompare( 7891 LPVOID first, 7892 LPVOID second, 7893 LPARAM lParam) 7894 { 8296 static INT WINAPI LISTVIEW_CallBackCompare(LPVOID first, LPVOID second, LPARAM lParam) 8297 { 8298 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW((HWND)lParam, 0); 8299 LISTVIEW_ITEM* lv_first = (LISTVIEW_ITEM*) DPA_GetPtr( (HDPA)first, 0 ); 8300 LISTVIEW_ITEM* lv_second = (LISTVIEW_ITEM*) DPA_GetPtr( (HDPA)second, 0 ); 8301 7895 8302 /* Forward the call to the client defined callback */ 7896 INT rv; 7897 HWND hwnd = (HWND)lParam; 7898 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 7899 HDPA hdpa_first = (HDPA) first; 7900 HDPA hdpa_second = (HDPA) second; 7901 LISTVIEW_ITEM* lv_first = (LISTVIEW_ITEM*) DPA_GetPtr( hdpa_first, 0 ); 7902 LISTVIEW_ITEM* lv_second = (LISTVIEW_ITEM*) DPA_GetPtr( hdpa_second, 0 ); 7903 7904 rv = (infoPtr->pfnCompare)( lv_first->lParam , lv_second->lParam, infoPtr->lParamSort ); 7905 7906 return rv; 8303 return (infoPtr->pfnCompare)( lv_first->lParam , lv_second->lParam, infoPtr->lParamSort ); 7907 8304 } 7908 8305 … … 7910 8307 * DESCRIPTION: 7911 8308 * Sorts the listview items. 7912 * 8309 * 7913 8310 * PARAMETER(S): 7914 8311 * [I] HWND : window handle … … 7920 8317 * FAILURE : FALSE 7921 8318 */ 7922 static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam) 7923 { 7924 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 7925 int nCount, i; 7926 UINT lStyle = GetWindowLongA(hwnd, GWL_STYLE); 8319 static LRESULT LISTVIEW_SortItems(HWND hwnd, PFNLVCOMPARE pfnCompare, LPARAM lParamSort) 8320 { 8321 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8322 UINT lStyle = GetWindowLongW(hwnd, GWL_STYLE); 7927 8323 HDPA hdpaSubItems=NULL; 7928 8324 LISTVIEW_ITEM *pLVItem=NULL; 7929 8325 LPVOID selectionMarkItem; 7930 7931 if (lStyle & LVS_OWNERDATA) 7932 return FALSE; 7933 7934 if (!infoPtr || !infoPtr->hdpaItems) 7935 return FALSE; 7936 8326 int nCount, i; 8327 8328 TRACE("(hwnd=%x, pfnCompare=%p, lParamSort=%lx)\n", hwnd, pfnCompare, lParamSort); 8329 8330 if (lStyle & LVS_OWNERDATA) return FALSE; 8331 8332 if (!infoPtr || !infoPtr->hdpaItems) return FALSE; 8333 7937 8334 nCount = GETITEMCOUNT(infoPtr); 7938 8335 /* if there are 0 or 1 items, there is no need to sort */ … … 7940 8337 return TRUE; 7941 8338 7942 infoPtr->pfnCompare = (PFNLVCOMPARE)lParam;7943 infoPtr->lParamSort = (LPARAM)wParam;8339 infoPtr->pfnCompare = pfnCompare; 8340 infoPtr->lParamSort = lParamSort; 7944 8341 DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompare, hwnd); 7945 8342 7946 /* Adjust selections and indices so that they are the way they should 7947 * be after the sort (otherwise, the list items move around, but 7948 * whatever is at the item's previous original position will be 8343 /* Adjust selections and indices so that they are the way they should 8344 * be after the sort (otherwise, the list items move around, but 8345 * whatever is at the item's previous original position will be 7949 8346 * selected instead) 7950 8347 */ … … 7980 8377 * DESCRIPTION: 7981 8378 * Updates an items or rearranges the listview control. 7982 * 8379 * 7983 8380 * PARAMETER(S): 7984 8381 * [I] HWND : window handle … … 7991 8388 static LRESULT LISTVIEW_Update(HWND hwnd, INT nItem) 7992 8389 { 7993 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);7994 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);8390 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8391 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 7995 8392 BOOL bResult = FALSE; 7996 8393 RECT rc; 7997 8394 8395 TRACE("(hwnd=%x, nItem=%d)\n", hwnd, nItem); 8396 7998 8397 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr))) 7999 8398 { … … 8020 8419 * DESCRIPTION: 8021 8420 * Creates the listview control. 8022 * 8421 * 8023 8422 * PARAMETER(S): 8024 8423 * [I] HWND : window handle … … 8027 8426 * Zero 8028 8427 */ 8029 static LRESULT LISTVIEW_Create(HWND hwnd, WPARAM wParam, LPARAM lParam) 8030 { 8031 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8032 LPCREATESTRUCTA lpcs = (LPCREATESTRUCTA)lParam; 8428 static LRESULT LISTVIEW_Create(HWND hwnd, LPCREATESTRUCTW lpcs) 8429 { 8430 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8033 8431 UINT uView = lpcs->style & LVS_TYPEMASK; 8034 LOGFONTA logFont; 8432 LOGFONTW logFont; 8433 8434 TRACE("(hwnd=%x, lpcs=%p)\n", hwnd, lpcs); 8035 8435 8036 8436 /* initialize info pointer */ … … 8038 8438 8039 8439 /* determine the type of structures to use */ 8040 infoPtr->notifyFormat = SendMessage A(GetParent(hwnd), WM_NOTIFYFORMAT,8440 infoPtr->notifyFormat = SendMessageW(GetParent(hwnd), WM_NOTIFYFORMAT, 8041 8441 (WPARAM)hwnd, (LPARAM)NF_QUERY); 8042 if (infoPtr->notifyFormat != NFR_ANSI) 8043 { 8044 FIXME("ANSI notify format is NOT used\n"); 8045 } 8046 8442 8047 8443 /* initialize color information */ 8048 8444 infoPtr->clrBk = GetSysColor(COLOR_WINDOW); … … 8051 8447 8052 8448 /* set default values */ 8449 infoPtr->hwndSelf = hwnd; 8053 8450 infoPtr->uCallbackMask = 0; 8054 8451 #ifdef __WIN32OS2__ … … 8067 8464 8068 8465 /* get default font (icon title) */ 8069 SystemParametersInfo A(SPI_GETICONTITLELOGFONT, 0, &logFont, 0);8070 infoPtr->hDefaultFont = CreateFontIndirect A(&logFont);8466 SystemParametersInfoW(SPI_GETICONTITLELOGFONT, 0, &logFont, 0); 8467 infoPtr->hDefaultFont = CreateFontIndirectW(&logFont); 8071 8468 infoPtr->hFont = infoPtr->hDefaultFont; 8072 8469 LISTVIEW_SaveTextMetrics(hwnd); 8470 8073 8471 /* create header */ 8074 infoPtr->hwndHeader = CreateWindowA(WC_HEADERA, (LPCSTR)NULL, 8075 WS_CHILD | HDS_HORZ | HDS_BUTTONS, 8076 0, 0, 0, 0, hwnd, (HMENU)0, 8077 lpcs->hInstance, NULL); 8472 infoPtr->hwndHeader = CreateWindowW(WC_HEADERW, (LPCWSTR)NULL, 8473 WS_CHILD | HDS_HORZ | (DWORD)((LVS_NOSORTHEADER & lpcs->style)?0:HDS_BUTTONS), 8474 0, 0, 0, 0, hwnd, (HMENU)0, 8475 lpcs->hInstance, NULL); 8476 8477 /* set header unicode format */ 8478 SendMessageW(infoPtr->hwndHeader, HDM_SETUNICODEFORMAT,(WPARAM)TRUE,(LPARAM)NULL); 8078 8479 8079 8480 /* set header font */ 8080 SendMessage A(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont,8481 SendMessageW(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont, 8081 8482 (LPARAM)TRUE); 8082 8483 8083 8484 if (uView == LVS_ICON) 8084 8485 { … … 8095 8496 { 8096 8497 /* set HDS_HIDDEN flag to hide the header bar */ 8097 SetWindowLong A(infoPtr->hwndHeader, GWL_STYLE,8098 GetWindowLong A(infoPtr->hwndHeader, GWL_STYLE) | HDS_HIDDEN);8099 } 8100 8498 SetWindowLongW(infoPtr->hwndHeader, GWL_STYLE, 8499 GetWindowLongW(infoPtr->hwndHeader, GWL_STYLE) | HDS_HIDDEN); 8500 } 8501 8101 8502 8102 8503 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); … … 8123 8524 8124 8525 /* initialize the hover time to -1(indicating the default system hover time) */ 8125 infoPtr->dwHoverTime = -1; 8526 infoPtr->dwHoverTime = -1; 8126 8527 8127 8528 #ifdef __WIN32OS2__ … … 8139 8540 * DESCRIPTION: 8140 8541 * Erases the background of the listview control. 8141 * 8542 * 8142 8543 * PARAMETER(S): 8143 8544 * [I] HWND : window handle 8144 8545 * [I] WPARAM : device context handle 8145 8546 * [I] LPARAM : not used 8146 * 8547 * 8147 8548 * RETURN: 8148 8549 * SUCCESS : TRUE 8149 8550 * FAILURE : FALSE 8150 8551 */ 8151 static LRESULT LISTVIEW_EraseBackground(HWND hwnd, WPARAM wParam, 8552 static LRESULT LISTVIEW_EraseBackground(HWND hwnd, WPARAM wParam, 8152 8553 LPARAM lParam) 8153 8554 { 8154 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);8555 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8155 8556 BOOL bResult; 8156 8557 8157 if (infoPtr->clrBk == CLR_NONE) 8158 { 8159 bResult = SendMessageA(GetParent(hwnd), WM_ERASEBKGND, wParam, lParam); 8160 } 8161 else 8558 TRACE("(hwnd=%x, wParam=%x, lParam=%lx)\n", hwnd, wParam, lParam); 8559 8560 if (infoPtr->clrBk == CLR_NONE) 8561 { 8562 bResult = SendMessageW(GetParent(hwnd), WM_ERASEBKGND, wParam, lParam); 8563 } 8564 else 8162 8565 { 8163 8566 RECT rc; … … 8175 8578 static void LISTVIEW_FillBackground(HWND hwnd, HDC hdc, LPRECT rc) 8176 8579 { 8177 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8178 8179 if (infoPtr->clrBk != CLR_NONE) 8580 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8581 8582 TRACE("(hwnd=%x, hdc=%x, rc=%p)\n", hwnd, hdc, rc); 8583 8584 if (infoPtr->clrBk != CLR_NONE) 8180 8585 { 8181 8586 HBRUSH hBrush = CreateSolidBrush(infoPtr->clrBk); … … 8188 8593 * DESCRIPTION: 8189 8594 * Retrieves the listview control font. 8190 * 8595 * 8191 8596 * PARAMETER(S): 8192 8597 * [I] HWND : window handle … … 8197 8602 static LRESULT LISTVIEW_GetFont(HWND hwnd) 8198 8603 { 8199 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8604 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8605 8606 TRACE("(hwnd=%x)\n", hwnd); 8200 8607 8201 8608 return infoPtr->hFont; … … 8205 8612 * DESCRIPTION: 8206 8613 * Performs vertical scrolling. 8207 * 8614 * 8208 8615 * PARAMETER(S): 8209 8616 * [I] HWND : window handle 8210 8617 * [I] INT : scroll code 8211 * [I] SHORT : current scroll position if scroll code is SB_THUMBPOSITION 8618 * [I] SHORT : current scroll position if scroll code is SB_THUMBPOSITION 8212 8619 * or SB_THUMBTRACK. 8213 8620 * [I] HWND : scrollbar control window handle … … 8219 8626 HWND hScrollWnd) 8220 8627 { 8628 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8221 8629 SCROLLINFO scrollInfo; 8222 8630 8223 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8224 SendMessageA(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0); 8631 TRACE("(hwnd=%x, nScrollCode=%d, nCurrentPos=%d, hScrollWnd=%x)\n", 8632 hwnd, nScrollCode, nCurrentPos, hScrollWnd); 8633 8634 SendMessageW(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0); 8225 8635 8226 8636 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); … … 8235 8645 case SB_LINEUP: 8236 8646 if (scrollInfo.nPos > scrollInfo.nMin) 8237 {8238 8647 scrollInfo.nPos--; 8239 }8240 8648 break; 8241 8649 8242 8650 case SB_LINEDOWN: 8243 8651 if (scrollInfo.nPos < scrollInfo.nMax) 8244 {8245 8652 scrollInfo.nPos++; 8246 }8247 8653 break; 8248 8654 8249 8655 case SB_PAGEUP: 8250 8656 if (scrollInfo.nPos > scrollInfo.nMin) 8251 8657 { 8252 8658 if (scrollInfo.nPos >= scrollInfo.nPage) 8253 {8254 8659 scrollInfo.nPos -= scrollInfo.nPage; 8255 }8256 8660 else 8257 {8258 8661 scrollInfo.nPos = scrollInfo.nMin; 8259 }8260 8662 } 8261 8663 break; 8262 8664 8263 8665 case SB_PAGEDOWN: 8264 8666 if (scrollInfo.nPos < scrollInfo.nMax) 8265 8667 { 8266 8668 if (scrollInfo.nPos <= scrollInfo.nMax - scrollInfo.nPage) 8267 {8268 8669 scrollInfo.nPos += scrollInfo.nPage; 8269 }8270 8670 else 8271 {8272 8671 scrollInfo.nPos = scrollInfo.nMax; 8273 }8274 8672 } 8275 8673 break; … … 8291 8689 scrollInfo.fMask = SIF_POS; 8292 8690 SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE); 8293 InvalidateRect(hwnd, NULL, TRUE); 8294 } 8295 } 8296 8691 if (IsWindowVisible(infoPtr->hwndHeader)) 8692 { 8693 RECT rListview, rcHeader, rDest; 8694 GetClientRect(hwnd, &rListview); 8695 GetWindowRect(infoPtr->hwndHeader, &rcHeader); 8696 MapWindowPoints((HWND) NULL, hwnd, (LPPOINT) &rcHeader, 2); 8697 SubtractRect(&rDest, &rListview, &rcHeader); 8698 InvalidateRect(hwnd, &rDest, TRUE); 8699 } 8700 else 8701 InvalidateRect(hwnd, NULL, TRUE); 8702 } 8703 } 8704 8297 8705 return 0; 8298 8706 } … … 8301 8709 * DESCRIPTION: 8302 8710 * Performs horizontal scrolling. 8303 * 8711 * 8304 8712 * PARAMETER(S): 8305 8713 * [I] HWND : window handle 8306 8714 * [I] INT : scroll code 8307 * [I] SHORT : current scroll position if scroll code is SB_THUMBPOSITION 8715 * [I] SHORT : current scroll position if scroll code is SB_THUMBPOSITION 8308 8716 * or SB_THUMBTRACK. 8309 8717 * [I] HWND : scrollbar control window handle … … 8315 8723 HWND hScrollWnd) 8316 8724 { 8725 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8317 8726 SCROLLINFO scrollInfo; 8318 8727 8319 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8320 SendMessageA(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0); 8321 8728 TRACE("(hwnd=%x, nScrollCode=%d, nCurrentPos=%d, hScrollWnd=%x)\n", 8729 hwnd, nScrollCode, nCurrentPos, hScrollWnd); 8730 8731 SendMessageW(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0); 8322 8732 8323 8733 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 8324 8734 scrollInfo.cbSize = sizeof(SCROLLINFO); 8325 8735 scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE; 8326 8736 8327 8737 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 8328 8738 { … … 8333 8743 case SB_LINELEFT: 8334 8744 if (scrollInfo.nPos > scrollInfo.nMin) 8335 {8336 8745 scrollInfo.nPos--; 8337 }8338 8746 break; 8339 8747 8340 8748 case SB_LINERIGHT: 8341 8749 if (scrollInfo.nPos < scrollInfo.nMax) 8342 {8343 8750 scrollInfo.nPos++; 8344 }8345 8751 break; 8346 8752 8347 8753 case SB_PAGELEFT: 8348 8754 if (scrollInfo.nPos > scrollInfo.nMin) 8349 8755 { 8350 8756 if (scrollInfo.nPos >= scrollInfo.nPage) 8351 {8352 8757 scrollInfo.nPos -= scrollInfo.nPage; 8353 }8354 8758 else 8355 {8356 8759 scrollInfo.nPos = scrollInfo.nMin; 8357 }8358 8760 } 8359 8761 break; 8360 8762 8361 8763 case SB_PAGERIGHT: 8362 8764 if (scrollInfo.nPos < scrollInfo.nMax) 8363 8765 { 8364 8766 if (scrollInfo.nPos <= scrollInfo.nMax - scrollInfo.nPage) 8365 {8366 8767 scrollInfo.nPos += scrollInfo.nPage; 8367 }8368 8768 else 8369 {8370 8769 scrollInfo.nPos = scrollInfo.nMax; 8371 }8372 8770 } 8373 8771 break; … … 8387 8785 if (nOldScrollPos != scrollInfo.nPos) 8388 8786 { 8389 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;8787 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 8390 8788 scrollInfo.fMask = SIF_POS; 8391 8789 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); … … 8399 8797 } 8400 8798 } 8401 8799 8402 8800 return 0; 8403 8801 } … … 8405 8803 static LRESULT LISTVIEW_MouseWheel(HWND hwnd, INT wheelDelta) 8406 8804 { 8805 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 8407 8806 INT gcWheelDelta = 0; 8408 8807 UINT pulScrollLines = 3; 8409 8808 SCROLLINFO scrollInfo; 8410 8809 8411 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;8810 TRACE("(hwnd=%x, wheelDelta=%d)\n", hwnd, wheelDelta); 8412 8811 8413 8812 SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0); … … 8451 8850 /*** 8452 8851 * DESCRIPTION: 8453 * ??? 8454 * 8455 * PARAMETER(S): 8456 * [I] HWND : window handle 8457 * [I] INT : virtual key 8852 * ??? 8853 * 8854 * PARAMETER(S): 8855 * [I] HWND : window handle 8856 * [I] INT : virtual key 8458 8857 * [I] LONG : key data 8459 8858 * … … 8463 8862 static LRESULT LISTVIEW_KeyDown(HWND hwnd, INT nVirtualKey, LONG lKeyData) 8464 8863 { 8465 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8864 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8865 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 8866 INT nItem = -1; 8466 8867 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 8868 NMLVKEYDOWN nmKeyDown; 8467 8869 HWND hwndParent = GetParent(hwnd); 8468 NMLVKEYDOWN nmKeyDown; 8469 NMHDR nmh; 8470 INT nItem = -1; 8471 BOOL bRedraw = FALSE; 8472 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 8473 UINT uView = lStyle & LVS_TYPEMASK; 8870 8871 TRACE("(hwnd=%x, nVirtualKey=%d, lKeyData=%ld)\n", hwnd, nVirtualKey, lKeyData); 8474 8872 8475 8873 /* send LVN_KEYDOWN notification */ 8476 ZeroMemory(&nmKeyDown, sizeof(NMLVKEYDOWN)); 8477 nmKeyDown.hdr.hwndFrom = hwnd; 8478 nmKeyDown.hdr.idFrom = nCtrlId; 8479 nmKeyDown.hdr.code = LVN_KEYDOWN; 8480 nmKeyDown.wVKey = nVirtualKey; 8874 nmKeyDown.wVKey = nVirtualKey; 8481 8875 nmKeyDown.flags = 0; 8482 8876 #ifdef __WIN32OS2__ … … 8486 8880 } 8487 8881 #else 8488 SendMessageA(hwndParent, WM_NOTIFY, (WPARAM)nCtrlId, (LPARAM)&nmKeyDown);8882 notify(hwnd, LVN_KEYDOWN, &nmKeyDown.hdr); 8489 8883 #endif 8490 8491 /* initialize */ 8492 nmh.hwndFrom = hwnd; 8493 nmh.idFrom = nCtrlId; 8494 8884 8495 8885 switch (nVirtualKey) 8496 8886 { … … 8498 8888 if ((GETITEMCOUNT(infoPtr) > 0) && (infoPtr->nFocusedItem != -1)) 8499 8889 { 8500 /* send NM_RETURN notification */ 8501 nmh.code = NM_RETURN; 8502 ListView_Notify(hwndParent, nCtrlId, &nmh); 8503 8504 /* send LVN_ITEMACTIVATE notification */ 8505 nmh.code = LVN_ITEMACTIVATE; 8506 ListView_Notify(hwndParent, nCtrlId, &nmh); 8890 hdr_notify(hwnd, NM_RETURN); /* NM_RETURN notification */ 8891 hdr_notify(hwnd, LVN_ITEMACTIVATE); /* LVN_ITEMACTIVATE notification */ 8507 8892 } 8508 8893 break; … … 8510 8895 case VK_HOME: 8511 8896 if (GETITEMCOUNT(infoPtr) > 0) 8512 {8513 8897 nItem = 0; 8514 }8515 8898 break; 8516 8899 8517 8900 case VK_END: 8518 8901 if (GETITEMCOUNT(infoPtr) > 0) 8519 {8520 8902 nItem = GETITEMCOUNT(infoPtr) - 1; 8521 }8522 8903 break; 8523 8904 … … 8529 8910 nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_ABOVE); 8530 8911 break; 8531 8912 8532 8913 case VK_RIGHT: 8533 8914 nItem = ListView_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TORIGHT); … … 8540 8921 case VK_PRIOR: 8541 8922 if (uView == LVS_REPORT) 8542 {8543 8923 nItem = infoPtr->nFocusedItem - LISTVIEW_GetCountPerColumn(hwnd); 8544 }8545 8924 else 8546 { 8547 nItem = infoPtr->nFocusedItem - LISTVIEW_GetCountPerColumn(hwnd) 8925 nItem = infoPtr->nFocusedItem - LISTVIEW_GetCountPerColumn(hwnd) 8548 8926 * LISTVIEW_GetCountPerRow(hwnd); 8549 }8550 8927 if(nItem < 0) nItem = 0; 8551 8928 break; … … 8553 8930 case VK_NEXT: 8554 8931 if (uView == LVS_REPORT) 8555 {8556 8932 nItem = infoPtr->nFocusedItem + LISTVIEW_GetCountPerColumn(hwnd); 8557 }8558 8933 else 8559 {8560 8934 nItem = infoPtr->nFocusedItem + LISTVIEW_GetCountPerColumn(hwnd) 8561 8935 * LISTVIEW_GetCountPerRow(hwnd); 8562 }8563 8936 if(nItem >= GETITEMCOUNT(infoPtr)) nItem = GETITEMCOUNT(infoPtr) - 1; 8564 8937 break; … … 8567 8940 if ((nItem != -1) && (nItem != infoPtr->nFocusedItem)) 8568 8941 { 8569 bRedraw = LISTVIEW_KeySelection(hwnd, nItem); 8570 if (bRedraw != FALSE) 8571 { 8572 /* refresh client area */ 8573 UpdateWindow(hwnd); 8574 } 8942 if (LISTVIEW_KeySelection(hwnd, nItem)) 8943 UpdateWindow(hwnd); /* update client area */ 8575 8944 } 8576 8945 … … 8581 8950 * DESCRIPTION: 8582 8951 * Kills the focus. 8583 * 8952 * 8584 8953 * PARAMETER(S): 8585 8954 * [I] HWND : window handle … … 8590 8959 static LRESULT LISTVIEW_KillFocus(HWND hwnd) 8591 8960 { 8592 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0); 8593 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 8594 NMHDR nmh; 8961 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongW(hwnd, 0); 8962 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 8595 8963 INT i,nTop,nBottom; 8596 RECT rcItem; 8597 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 8598 UINT uView = lStyle & LVS_TYPEMASK; 8599 8964 8600 8965 TRACE("(hwnd=%x)\n", hwnd); 8601 8966 8602 8967 /* send NM_KILLFOCUS notification */ 8603 nmh.hwndFrom = hwnd; 8604 nmh.idFrom = nCtrlId; 8605 nmh.code = NM_KILLFOCUS; 8606 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 8968 hdr_notify(hwnd, NM_KILLFOCUS); 8607 8969 8608 8970 /* set window focus flag */ … … 8611 8973 /* NEED drawing optimization ; redraw the selected items */ 8612 8974 if (uView & LVS_REPORT) 8613 { 8975 { 8614 8976 nTop = LISTVIEW_GetTopIndex(hwnd); 8615 nBottom = nTop + 8977 nBottom = nTop + 8616 8978 LISTVIEW_GetCountPerColumn(hwnd) + 1; 8617 8979 } … … 8625 8987 if (LISTVIEW_IsSelected(hwnd,i)) 8626 8988 { 8989 RECT rcItem; 8627 8990 rcItem.left = LVIR_BOUNDS; 8628 8991 LISTVIEW_GetItemRect(hwnd, i, &rcItem); … … 8637 9000 * DESCRIPTION: 8638 9001 * Processes double click messages (left mouse button). 8639 * 9002 * 8640 9003 * PARAMETER(S): 8641 9004 * [I] HWND : window handle … … 8647 9010 * Zero 8648 9011 */ 8649 static LRESULT LISTVIEW_LButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 9012 static LRESULT LISTVIEW_LButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 8650 9013 WORD wPosY) 8651 9014 { 8652 LONG nCtrlId = GetWindowLongA(hwnd, GWL_ID);8653 9015 LVHITTESTINFO htInfo; 8654 NMHDR nmh;8655 9016 NMLISTVIEW nmlv; 8656 INT ret; 8657 8658 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 9017 9018 TRACE("(hwnd=%x, key=%hu, X=%hu, Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 8659 9019 8660 9020 htInfo.pt.x = wPosX; … … 8663 9023 /* send NM_DBLCLK notification */ 8664 9024 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); 8665 nmlv.hdr.hwndFrom = hwnd; 8666 nmlv.hdr.idFrom = nCtrlId; 8667 nmlv.hdr.code = NM_DBLCLK; 8668 ret = LISTVIEW_HitTestItem(hwnd, &htInfo, TRUE); 8669 if (ret != -1) 9025 if (LISTVIEW_HitTestItem(hwnd, &htInfo, TRUE) != -1) 8670 9026 { 8671 9027 nmlv.iItem = htInfo.iItem; … … 8676 9032 nmlv.iItem = -1; 8677 9033 nmlv.iSubItem = 0; 8678 } 9034 } 8679 9035 nmlv.ptAction.x = wPosX; 8680 9036 nmlv.ptAction.y = wPosY; 8681 ListView_LVNotify(GetParent(hwnd), nCtrlId, &nmlv);9037 listview_notify(hwnd, NM_DBLCLK, &nmlv); 8682 9038 8683 9039 8684 9040 /* To send the LVN_ITEMACTIVATE, it must be on an Item */ 8685 if(ret != -1) 8686 { 8687 /* send LVN_ITEMACTIVATE notification */ 8688 nmh.hwndFrom = hwnd; 8689 nmh.idFrom = nCtrlId; 8690 nmh.code = LVN_ITEMACTIVATE; 8691 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 8692 } 9041 if(nmlv.iItem != -1) 9042 hdr_notify(hwnd, LVN_ITEMACTIVATE); 8693 9043 8694 9044 return 0; … … 8698 9048 * DESCRIPTION: 8699 9049 * Processes mouse down messages (left mouse button). 8700 * 9050 * 8701 9051 * PARAMETER(S): 8702 9052 * [I] HWND : window handle … … 8708 9058 * Zero 8709 9059 */ 8710 static LRESULT LISTVIEW_LButtonDown(HWND hwnd, WORD wKey, WORD wPosX, 9060 static LRESULT LISTVIEW_LButtonDown(HWND hwnd, WORD wKey, WORD wPosX, 8711 9061 WORD wPosY) 8712 9062 { 8713 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);8714 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);8715 INT nCtrlId = GetWindowLong A(hwnd, GWL_ID);9063 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9064 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 9065 INT nCtrlId = GetWindowLongW(hwnd, GWL_ID); 8716 9066 static BOOL bGroupSelect = TRUE; 8717 9067 POINT ptPosition; 8718 NMHDR nmh;8719 9068 INT nItem; 8720 9069 8721 TRACE("(hwnd=%x, key=%hu, X=%hu, Y=%hu)\n", hwnd, wKey, wPosX, 8722 wPosY); 9070 TRACE("(hwnd=%x, key=%hu, X=%hu, Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 8723 9071 8724 9072 /* send NM_RELEASEDCAPTURE notification */ 8725 nmh.hwndFrom = hwnd; 8726 nmh.idFrom = nCtrlId; 8727 nmh.code = NM_RELEASEDCAPTURE; 8728 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 8729 9073 hdr_notify(hwnd, NM_RELEASEDCAPTURE); 9074 8730 9075 if (infoPtr->bFocus == FALSE) 8731 {8732 9076 SetFocus(hwnd); 8733 }8734 9077 8735 9078 /* set left button down flag */ 8736 9079 infoPtr->bLButtonDown = TRUE; 8737 9080 8738 9081 ptPosition.x = wPosX; 8739 9082 ptPosition.y = wPosY; … … 8744 9087 { 8745 9088 if ((ListView_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED) 8746 && infoPtr->nEditLabelItem == -1) 8747 { 9089 && infoPtr->nEditLabelItem == -1) 8748 9090 infoPtr->nEditLabelItem = nItem; 8749 }8750 9091 else 8751 {8752 9092 LISTVIEW_SetSelection(hwnd, nItem); 8753 }8754 9093 } 8755 9094 else … … 8757 9096 if ((wKey & MK_CONTROL) && (wKey & MK_SHIFT)) 8758 9097 { 8759 if (bGroupSelect != FALSE) 8760 { 9098 if (bGroupSelect) 8761 9099 LISTVIEW_AddGroupSelection(hwnd, nItem); 8762 }8763 9100 else 8764 {8765 9101 LISTVIEW_AddSelection(hwnd, nItem); 8766 }8767 9102 } 8768 9103 else if (wKey & MK_CONTROL) … … 8776 9111 else 8777 9112 { 8778 8779 8780 8781 9113 BOOL was_selected = 9114 (ListView_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED); 9115 9116 /* set selection (clears other pre-existing selections) */ 8782 9117 LISTVIEW_SetSelection(hwnd, nItem); 8783 9118 8784 9119 if (was_selected && infoPtr->nEditLabelItem == -1) 8785 {8786 9120 infoPtr->nEditLabelItem = nItem; 8787 }8788 9121 } 8789 9122 } … … 8809 9142 * DESCRIPTION: 8810 9143 * Processes mouse up messages (left mouse button). 8811 * 9144 * 8812 9145 * PARAMETER(S): 8813 9146 * [I] HWND : window handle … … 8819 9152 * Zero 8820 9153 */ 8821 static LRESULT LISTVIEW_LButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 9154 static LRESULT LISTVIEW_LButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 8822 9155 WORD wPosY) 8823 9156 { 8824 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);8825 8826 TRACE("(hwnd=%x, key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);8827 8828 if (infoPtr->bLButtonDown != FALSE) 8829 { 8830 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);9157 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9158 9159 TRACE("(hwnd=%x, key=%hu, X=%hu, Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 9160 9161 if (infoPtr->bLButtonDown != FALSE) 9162 { 9163 LVHITTESTINFO lvHitTestInfo; 8831 9164 NMLISTVIEW nmlv; 8832 LVHITTESTINFO lvHitTestInfo;8833 INT ret;8834 9165 8835 9166 lvHitTestInfo.pt.x = wPosX; … … 8838 9169 /* send NM_CLICK notification */ 8839 9170 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); 8840 nmlv.hdr.hwndFrom = hwnd; 8841 nmlv.hdr.idFrom = nCtrlId; 8842 nmlv.hdr.code = NM_CLICK; 8843 ret = LISTVIEW_HitTestItem(hwnd, &lvHitTestInfo, TRUE); 8844 if (ret != -1) 9171 if (LISTVIEW_HitTestItem(hwnd, &lvHitTestInfo, TRUE) != -1) 8845 9172 { 8846 9173 nmlv.iItem = lvHitTestInfo.iItem; … … 8854 9181 nmlv.ptAction.x = wPosX; 8855 9182 nmlv.ptAction.y = wPosY; 8856 ListView_LVNotify(GetParent(hwnd), nCtrlId, &nmlv); 8857 9183 listview_notify(hwnd, NM_CLICK, &nmlv); 8858 9184 8859 9185 /* set left button flag */ … … 8862 9188 if(infoPtr->nEditLabelItem != -1) 8863 9189 { 8864 if(lvHitTestInfo.iItem == infoPtr->nEditLabelItem) 8865 { 8866 LISTVIEW_EditLabelA(hwnd, lvHitTestInfo.iItem); 8867 } 9190 if(lvHitTestInfo.iItem == infoPtr->nEditLabelItem && lvHitTestInfo.flags & LVHT_ONITEMLABEL) 9191 LISTVIEW_EditLabelT(hwnd, lvHitTestInfo.iItem, TRUE); 8868 9192 infoPtr->nEditLabelItem = -1; 8869 9193 } … … 8876 9200 * DESCRIPTION: 8877 9201 * Creates the listview control (called before WM_CREATE). 8878 * 8879 * PARAMETER(S): 8880 * [I] HWND : window handle 8881 * [I] WPARAM : unhandled 9202 * 9203 * PARAMETER(S): 9204 * [I] HWND : window handle 9205 * [I] WPARAM : unhandled 8882 9206 * [I] LPARAM : widow creation info 8883 * 9207 * 8884 9208 * RETURN: 8885 9209 * Zero … … 8889 9213 LISTVIEW_INFO *infoPtr; 8890 9214 8891 TRACE("(hwnd=%x, wParam=%x,lParam=%lx)\n", hwnd, wParam, lParam);9215 TRACE("(hwnd=%x, wParam=%x, lParam=%lx)\n", hwnd, wParam, lParam); 8892 9216 8893 9217 /* allocate memory for info structure */ … … 8897 9221 infoPtr = (LISTVIEW_INFO *)COMCTL32_Alloc(sizeof(LISTVIEW_INFO)); 8898 9222 #endif 8899 SetWindowLongA(hwnd, 0, (LONG)infoPtr); 8900 if (infoPtr == NULL) 9223 if (infoPtr == NULL) 8901 9224 { 8902 9225 ERR("could not allocate info memory!\n"); … … 8904 9227 } 8905 9228 8906 if ((LISTVIEW_INFO *)GetWindowLongA(hwnd, 0) != infoPtr) 9229 SetWindowLongW(hwnd, 0, (LONG)infoPtr); 9230 if ((LISTVIEW_INFO *)GetWindowLongW(hwnd, 0) != infoPtr) 8907 9231 { 8908 9232 ERR("pointer assignment error!\n"); … … 8910 9234 } 8911 9235 8912 return DefWindowProc A(hwnd, WM_NCCREATE, wParam, lParam);9236 return DefWindowProcW(hwnd, WM_NCCREATE, wParam, lParam); 8913 9237 } 8914 9238 … … 8916 9240 * DESCRIPTION: 8917 9241 * Destroys the listview control (called after WM_DESTROY). 8918 * 8919 * PARAMETER(S): 8920 * [I] HWND : window handle 8921 * 9242 * 9243 * PARAMETER(S): 9244 * [I] HWND : window handle 9245 * 8922 9246 * RETURN: 8923 9247 * Zero … … 8925 9249 static LRESULT LISTVIEW_NCDestroy(HWND hwnd) 8926 9250 { 8927 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);9251 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 8928 9252 8929 9253 TRACE("(hwnd=%x)\n", hwnd); … … 8951 9275 COMCTL32_Free(infoPtr); 8952 9276 8953 SetWindowLong A(hwnd, 0, 0);9277 SetWindowLongW(hwnd, 0, 0); 8954 9278 return 0; 8955 9279 } … … 8958 9282 * DESCRIPTION: 8959 9283 * Handles notifications from children. 8960 * 9284 * 8961 9285 * PARAMETER(S): 8962 9286 * [I] HWND : window handle 8963 9287 * [I] INT : control identifier 8964 9288 * [I] LPNMHDR : notification information 8965 * 9289 * 8966 9290 * RETURN: 8967 9291 * Zero … … 8969 9293 static LRESULT LISTVIEW_Notify(HWND hwnd, INT nCtrlId, LPNMHDR lpnmh) 8970 9294 { 8971 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 8972 8973 if (lpnmh->hwndFrom == infoPtr->hwndHeader) 9295 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9296 9297 TRACE("(hwnd=%x, nCtrlId=%d, lpnmh=%p)\n", hwnd, nCtrlId, lpnmh); 9298 9299 if (lpnmh->hwndFrom == infoPtr->hwndHeader) 8974 9300 { 8975 9301 /* handle notification from header control */ 8976 if (lpnmh->code == HDN_ENDTRACK A)9302 if (lpnmh->code == HDN_ENDTRACKW) 8977 9303 { 8978 9304 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); … … 8998 9324 } 8999 9325 #endif 9000 else if(lpnmh->code == HDN_ITEMCLICK A)9326 else if(lpnmh->code == HDN_ITEMCLICKW || lpnmh->code == HDN_ITEMCLICKA) 9001 9327 { 9002 9328 /* Handle sorting by Header Column */ 9003 9329 NMLISTVIEW nmlv; 9004 LPNMHEADERA pnmHeader = (LPNMHEADERA) lpnmh;9005 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID);9006 9330 9007 9331 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); 9008 nmlv.hdr.hwndFrom = hwnd;9009 nmlv.hdr.idFrom = lCtrlId;9010 nmlv.hdr.code = LVN_COLUMNCLICK;9011 9332 nmlv.iItem = -1; 9012 nmlv.iSubItem = pnmHeader->iItem; 9013 9014 ListView_LVNotify(GetParent(hwnd),lCtrlId, &nmlv); 9015 9333 nmlv.iSubItem = ((LPNMHEADERW)lpnmh)->iItem; 9334 listview_notify(hwnd, LVN_COLUMNCLICK, &nmlv); 9016 9335 } 9017 9336 else if(lpnmh->code == NM_RELEASEDCAPTURE) … … 9036 9355 * DESCRIPTION: 9037 9356 * Determines the type of structure to use. 9038 * 9357 * 9039 9358 * PARAMETER(S): 9040 9359 * [I] HWND : window handle of the sender 9041 * [I] HWND : listview window handle 9360 * [I] HWND : listview window handle 9042 9361 * [I] INT : command specifying the nature of the WM_NOTIFYFORMAT 9043 9362 * … … 9047 9366 static LRESULT LISTVIEW_NotifyFormat(HWND hwndFrom, HWND hwnd, INT nCommand) 9048 9367 { 9049 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 9050 9368 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9369 9370 TRACE("(hwndFrom=%x, hwnd=%x, nCommand=%d)\n", hwndFrom, hwnd, nCommand); 9371 9051 9372 if (nCommand == NF_REQUERY) 9052 { 9053 /* determine the type of structure to use */ 9054 infoPtr->notifyFormat = SendMessageA(hwndFrom, WM_NOTIFYFORMAT, 9373 infoPtr->notifyFormat = SendMessageW(hwndFrom, WM_NOTIFYFORMAT, 9055 9374 (WPARAM)hwnd, (LPARAM)NF_QUERY); 9056 if (infoPtr->notifyFormat == NFR_UNICODE)9057 {9058 FIXME("NO support for unicode structures\n");9059 }9060 }9061 9062 9375 return 0; 9063 9376 } … … 9066 9379 * DESCRIPTION: 9067 9380 * Paints/Repaints the listview control. 9068 * 9381 * 9069 9382 * PARAMETER(S): 9070 9383 * [I] HWND : window handle … … 9078 9391 PAINTSTRUCT ps; 9079 9392 9080 TRACE("(hwnd=%x,hdc=%x)\n", hwnd, hdc);9393 TRACE("(hwnd=%x, hdc=%x)\n", hwnd, hdc); 9081 9394 9082 9395 if (hdc == 0) … … 9097 9410 * DESCRIPTION: 9098 9411 * Processes double click messages (right mouse button). 9099 * 9412 * 9100 9413 * PARAMETER(S): 9101 9414 * [I] HWND : window handle … … 9107 9420 * Zero 9108 9421 */ 9109 static LRESULT LISTVIEW_RButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 9422 static LRESULT LISTVIEW_RButtonDblClk(HWND hwnd, WORD wKey, WORD wPosX, 9110 9423 WORD wPosY) 9111 9424 { 9112 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);9113 NMHDR nmh;9114 9115 9425 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 9116 9426 9117 /* send NM_RELEASEDCAPTURE notification */ 9118 nmh.hwndFrom = hwnd; 9119 nmh.idFrom = nCtrlId; 9120 nmh.code = NM_RELEASEDCAPTURE; 9121 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 9427 /* send NM_RELEASEDCAPTURE notification */ 9428 hdr_notify(hwnd, NM_RELEASEDCAPTURE); 9122 9429 9123 9430 /* send NM_RDBLCLK notification */ 9124 nmh.code = NM_RDBLCLK; 9125 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 9431 hdr_notify(hwnd, NM_RDBLCLK); 9126 9432 9127 9433 return 0; … … 9131 9437 * DESCRIPTION: 9132 9438 * Processes mouse down messages (right mouse button). 9133 * 9439 * 9134 9440 * PARAMETER(S): 9135 9441 * [I] HWND : window handle … … 9141 9447 * Zero 9142 9448 */ 9143 static LRESULT LISTVIEW_RButtonDown(HWND hwnd, WORD wKey, WORD wPosX, 9449 static LRESULT LISTVIEW_RButtonDown(HWND hwnd, WORD wKey, WORD wPosX, 9144 9450 WORD wPosY) 9145 9451 { 9146 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 9147 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 9452 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9148 9453 POINT ptPosition; 9149 NMHDR nmh;9150 9454 INT nItem; 9455 NMLISTVIEW nmlv; 9456 LVHITTESTINFO lvHitTestInfo; 9151 9457 9152 9458 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 9153 9459 9154 9460 /* send NM_RELEASEDCAPTURE notification */ 9155 nmh.hwndFrom = hwnd; 9156 nmh.idFrom = nCtrlId; 9157 nmh.code = NM_RELEASEDCAPTURE; 9158 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 9159 9461 hdr_notify(hwnd, NM_RELEASEDCAPTURE); 9462 9160 9463 /* make sure the listview control window has the focus */ 9161 9464 if (infoPtr->bFocus == FALSE) 9162 {9163 9465 SetFocus(hwnd); 9164 }9165 9466 9166 9467 /* set right button down flag */ … … 9176 9477 if (!((wKey & MK_SHIFT) || (wKey & MK_CONTROL)) && 9177 9478 !LISTVIEW_IsSelected(hwnd,nItem)) 9178 {9179 9479 LISTVIEW_SetSelection(hwnd, nItem); 9180 }9181 9480 } 9182 9481 else … … 9185 9484 } 9186 9485 9486 lvHitTestInfo.pt.x = wPosX; 9487 lvHitTestInfo.pt.y = wPosY; 9488 9489 /* Send NM_RClICK notification */ 9490 ZeroMemory(&nmlv, sizeof(nmlv)); 9491 if (LISTVIEW_HitTestItem(hwnd, &lvHitTestInfo, TRUE) != -1) 9492 { 9493 nmlv.iItem = lvHitTestInfo.iItem; 9494 nmlv.iSubItem = lvHitTestInfo.iSubItem; 9495 } 9496 else 9497 { 9498 nmlv.iItem = -1; 9499 nmlv.iSubItem = 0; 9500 } 9501 nmlv.ptAction.x = wPosX; 9502 nmlv.ptAction.y = wPosY; 9503 listview_notify(hwnd, NM_RCLICK, &nmlv); 9504 9187 9505 return 0; 9188 9506 } … … 9191 9509 * DESCRIPTION: 9192 9510 * Processes mouse up messages (right mouse button). 9193 * 9511 * 9194 9512 * PARAMETER(S): 9195 9513 * [I] HWND : window handle … … 9201 9519 * Zero 9202 9520 */ 9203 static LRESULT LISTVIEW_RButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 9521 static LRESULT LISTVIEW_RButtonUp(HWND hwnd, WORD wKey, WORD wPosX, 9204 9522 WORD wPosY) 9205 9523 { 9206 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 9207 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 9524 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9208 9525 9209 9526 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 9210 9527 9211 if (infoPtr->bRButtonDown != FALSE) 9212 { 9213 NMLISTVIEW nmlv; 9214 LVHITTESTINFO lvHitTestInfo; 9528 if (infoPtr->bRButtonDown) 9529 { 9215 9530 POINT pt; 9216 INT ret;9217 9218 lvHitTestInfo.pt.x = wPosX;9219 lvHitTestInfo.pt.y = wPosY;9220 9221 /* Send NM_RClICK notification */9222 ZeroMemory(&nmlv, sizeof(NMLISTVIEW));9223 nmlv.hdr.hwndFrom = hwnd;9224 nmlv.hdr.idFrom = nCtrlId;9225 nmlv.hdr.code = NM_RCLICK;9226 ret = LISTVIEW_HitTestItem(hwnd, &lvHitTestInfo, TRUE);9227 if (ret != -1)9228 {9229 nmlv.iItem = lvHitTestInfo.iItem;9230 nmlv.iSubItem = lvHitTestInfo.iSubItem;9231 }9232 else9233 {9234 nmlv.iItem = -1;9235 nmlv.iSubItem = 0;9236 }9237 nmlv.ptAction.x = wPosX;9238 nmlv.ptAction.y = wPosY;9239 ListView_LVNotify(GetParent(hwnd), nCtrlId, &nmlv);9240 9531 9241 9532 pt.x = wPosX; … … 9244 9535 /* set button flag */ 9245 9536 infoPtr->bRButtonDown = FALSE; 9246 9537 9247 9538 /* Change to screen coordinate for WM_CONTEXTMENU */ 9248 9539 ClientToScreen(hwnd, &pt); 9249 9540 9250 9541 /* Send a WM_CONTEXTMENU message in response to the RBUTTONUP */ 9251 SendMessage A( hwnd, WM_CONTEXTMENU, (WPARAM) hwnd, MAKELPARAM(pt.x, pt.y));9252 } 9253 9542 SendMessageW( hwnd, WM_CONTEXTMENU, (WPARAM) hwnd, MAKELPARAM(pt.x, pt.y)); 9543 } 9544 9254 9545 return 0; 9255 9546 } … … 9257 9548 /*** 9258 9549 * DESCRIPTION: 9259 * Sets the focus. 9260 * 9550 * Sets the focus. 9551 * 9261 9552 * PARAMETER(S): 9262 9553 * [I] HWND : window handle … … 9268 9559 static LRESULT LISTVIEW_SetFocus(HWND hwnd, HWND hwndLoseFocus) 9269 9560 { 9270 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 9271 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 9272 NMHDR nmh; 9561 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9273 9562 9274 9563 TRACE("(hwnd=%x, hwndLoseFocus=%x)\n", hwnd, hwndLoseFocus); 9275 9564 9276 9565 /* send NM_SETFOCUS notification */ 9277 nmh.hwndFrom = hwnd; 9278 nmh.idFrom = nCtrlId; 9279 nmh.code = NM_SETFOCUS; 9280 ListView_Notify(GetParent(hwnd), nCtrlId, &nmh); 9566 hdr_notify(hwnd, NM_SETFOCUS); 9281 9567 9282 9568 /* set window focus flag */ … … 9290 9576 /*** 9291 9577 * DESCRIPTION: 9292 * Sets the font. 9293 * 9578 * Sets the font. 9579 * 9294 9580 * PARAMETER(S): 9295 9581 * [I] HWND : window handle … … 9302 9588 static LRESULT LISTVIEW_SetFont(HWND hwnd, HFONT hFont, WORD fRedraw) 9303 9589 { 9304 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);9305 UINT uView = GetWindowLong A(hwnd, GWL_STYLE) & LVS_TYPEMASK;9590 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9591 UINT uView = GetWindowLongW(hwnd, GWL_STYLE) & LVS_TYPEMASK; 9306 9592 9307 9593 TRACE("(hwnd=%x,hfont=%x,redraw=%hu)\n", hwnd, hFont, fRedraw); 9308 9594 9309 if (hFont == 0) 9310 { 9311 infoPtr->hFont = infoPtr->hDefaultFont; 9312 } 9313 else 9314 { 9315 infoPtr->hFont = hFont; 9316 } 9595 infoPtr->hFont = hFont ? hFont : infoPtr->hDefaultFont; 9596 LISTVIEW_SaveTextMetrics(hwnd); 9317 9597 9318 9598 if (uView == LVS_REPORT) 9319 9599 { 9320 9600 /* set header font */ 9321 SendMessage A(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)hFont,9601 SendMessageW(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)hFont, 9322 9602 MAKELPARAM(fRedraw, 0)); 9323 9603 } … … 9330 9610 /* invalidate listview control client area */ 9331 9611 InvalidateRect(hwnd, NULL, TRUE); 9332 9612 9333 9613 if (fRedraw != FALSE) 9334 {9335 9614 UpdateWindow(hwnd); 9336 }9337 9615 9338 9616 return 0; … … 9341 9619 /*** 9342 9620 * DESCRIPTION: 9343 * Message handling for WM_SETREDRAW. 9621 * Message handling for WM_SETREDRAW. 9344 9622 * For the Listview, it invalidates the entire window (the doc specifies otherwise) 9345 * 9623 * 9346 9624 * PARAMETER(S): 9347 9625 * [I] HWND : window handle … … 9385 9663 * Resizes the listview control. This function processes WM_SIZE 9386 9664 * messages. At this time, the width and height are not used. 9387 * 9665 * 9388 9666 * PARAMETER(S): 9389 9667 * [I] HWND : window handle … … 9396 9674 static LRESULT LISTVIEW_Size(HWND hwnd, int Width, int Height) 9397 9675 { 9398 LONG lStyle = GetWindowLong A(hwnd, GWL_STYLE);9676 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 9399 9677 UINT uView = lStyle & LVS_TYPEMASK; 9400 9678 #ifdef __WIN32OS2__ 9401 9679 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 9402 9680 #endif 9403 TRACE("(hwnd=%x, width=%d, height=%d)\n",hwnd, Width, Height); 9404 9405 LISTVIEW_UpdateSize(hwnd); 9406 9407 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 9408 { 9409 if (lStyle & LVS_ALIGNLEFT) 9410 { 9411 LISTVIEW_AlignLeft(hwnd); 9412 } 9413 else 9414 { 9415 LISTVIEW_AlignTop(hwnd); 9416 } 9417 } 9418 9419 LISTVIEW_UpdateScroll(hwnd); 9681 TRACE("(hwnd=%x, width=%d, height=%d)\n", hwnd, Width, Height); 9682 9683 if (LISTVIEW_UpdateSize(hwnd)) 9684 { 9685 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 9686 { 9687 if (lStyle & LVS_ALIGNLEFT) 9688 LISTVIEW_AlignLeft(hwnd); 9689 else 9690 LISTVIEW_AlignTop(hwnd); 9691 } 9692 9693 LISTVIEW_UpdateScroll(hwnd); 9420 9694 9421 9695 #ifdef __WIN32OS2__ … … 9424 9698 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd); 9425 9699 #endif 9426 9427 /* invalidate client area + erase background */ 9428 InvalidateRect(hwnd, NULL, TRUE); 9700 9701 /* invalidate client area + erase background */ 9702 InvalidateRect(hwnd, NULL, TRUE); 9703 } 9429 9704 9430 9705 return 0; … … 9434 9709 * DESCRIPTION: 9435 9710 * Sets the size information. 9436 * 9437 * PARAMETER(S): 9438 * [I] HWND : window handle 9439 * 9440 * RETURN: 9441 * Zero 9442 */ 9443 static VOID LISTVIEW_UpdateSize(HWND hwnd) 9444 { 9445 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 9446 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 9711 * 9712 * PARAMETER(S): 9713 * [I] HWND : window handle 9714 * 9715 * RETURN: 9716 * Zero if no size change 9717 * 1 of size changed 9718 */ 9719 static BOOL LISTVIEW_UpdateSize(HWND hwnd) 9720 { 9721 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9722 LONG lStyle = GetWindowLongW(hwnd, GWL_STYLE); 9447 9723 UINT uView = lStyle & LVS_TYPEMASK; 9448 9724 RECT rcList; 9449 9725 RECT rcOld; 9726 9727 TRACE("(hwnd=%x)\n", hwnd); 9728 9450 9729 GetClientRect(hwnd, &rcList); 9730 CopyRect(&rcOld,&(infoPtr->rcList)); 9451 9731 infoPtr->rcList.left = 0; 9452 9732 infoPtr->rcList.right = max(rcList.right - rcList.left, 1); 9453 9733 infoPtr->rcList.top = 0; 9454 9734 infoPtr->rcList.bottom = max(rcList.bottom - rcList.top, 1); 9455 9735 9456 9736 if (uView == LVS_LIST) 9457 9737 { … … 9460 9740 INT nHScrollHeight = GetSystemMetrics(SM_CYHSCROLL); 9461 9741 if (infoPtr->rcList.bottom > nHScrollHeight) 9462 {9463 9742 infoPtr->rcList.bottom -= nHScrollHeight; 9464 }9465 9743 } 9466 9744 } … … 9477 9755 9478 9756 if (!(LVS_NOCOLUMNHEADER & lStyle)) 9479 {9480 9757 infoPtr->rcList.top = max(wp.cy, 0); 9481 9482 }9483 } 9484 9485 /*** 9486 * DESCRIPTION: 9487 * Processes WM_STYLECHANGED messages. 9488 * 9758 } 9759 return (!EqualRect(&rcOld,&(infoPtr->rcList))); 9760 } 9761 9762 /*** 9763 * DESCRIPTION: 9764 * Processes WM_STYLECHANGED messages. 9765 * 9489 9766 * PARAMETER(S): 9490 9767 * [I] HWND : window handle … … 9495 9772 * Zero 9496 9773 */ 9497 static INT LISTVIEW_StyleChanged(HWND hwnd, WPARAM wStyleType, 9774 static INT LISTVIEW_StyleChanged(HWND hwnd, WPARAM wStyleType, 9498 9775 LPSTYLESTRUCT lpss) 9499 9776 { 9500 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLong A(hwnd, 0);9777 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 9501 9778 UINT uNewView = lpss->styleNew & LVS_TYPEMASK; 9502 9779 UINT uOldView = lpss->styleOld & LVS_TYPEMASK; 9503 9780 RECT rcList = infoPtr->rcList; 9504 9781 9505 TRACE("(hwnd=%x, styletype=%x, stylestruct=%p)\n", 9782 TRACE("(hwnd=%x, styletype=%x, stylestruct=%p)\n", 9506 9783 hwnd, wStyleType, lpss); 9507 9784 … … 9509 9786 { 9510 9787 if (uOldView == LVS_REPORT) 9511 {9512 9788 ShowWindow(infoPtr->hwndHeader, SW_HIDE); 9513 } 9514 9515 if ((lpss->styleOld & WS_HSCROLL) != 0) 9516 { 9789 9790 if (((lpss->styleOld & WS_HSCROLL) != 0)&& 9791 ((lpss->styleNew & WS_HSCROLL) == 0)) 9517 9792 ShowScrollBar(hwnd, SB_HORZ, FALSE); 9518 } 9519 9520 if ((lpss->styleOld & WS_VSCROLL) != 0) 9521 { 9793 9794 if (((lpss->styleOld & WS_VSCROLL) != 0)&& 9795 ((lpss->styleNew & WS_VSCROLL) == 0)) 9522 9796 ShowScrollBar(hwnd, SB_VERT, FALSE); 9523 } 9524 9797 9525 9798 if (uNewView == LVS_ICON) 9526 9799 { … … 9530 9803 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd); 9531 9804 if (lpss->styleNew & LVS_ALIGNLEFT) 9532 {9533 9805 LISTVIEW_AlignLeft(hwnd); 9534 }9535 9806 else 9536 {9537 9807 LISTVIEW_AlignTop(hwnd); 9538 }9539 9808 } 9540 9809 else if (uNewView == LVS_REPORT) … … 9546 9815 hl.pwpos = ℘ 9547 9816 Header_Layout(infoPtr->hwndHeader, &hl); 9548 SetWindowPos(infoPtr->hwndHeader, hwnd, wp.x, wp.y, wp.cx, wp.cy, 9817 SetWindowPos(infoPtr->hwndHeader, hwnd, wp.x, wp.y, wp.cx, wp.cy, 9549 9818 wp.flags); 9550 9819 if (!(LVS_NOCOLUMNHEADER & lpss->styleNew)) 9551 9820 ShowWindow(infoPtr->hwndHeader, SW_SHOWNORMAL); 9552 9821 9553 9822 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); 9554 9823 infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); … … 9570 9839 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd); 9571 9840 if (lpss->styleNew & LVS_ALIGNLEFT) 9572 {9573 9841 LISTVIEW_AlignLeft(hwnd); 9574 }9575 9842 else 9576 {9577 9843 LISTVIEW_AlignTop(hwnd); 9578 } 9579 } 9580 9844 } 9581 9845 9582 9846 /* update the size of the client area */ … … 9585 9849 /* add scrollbars if needed */ 9586 9850 LISTVIEW_UpdateScroll(hwnd); 9587 9851 9588 9852 /* invalidate client area + erase background */ 9589 9853 InvalidateRect(hwnd, NULL, TRUE); … … 9593 9857 } 9594 9858 9595 /* If they change the view and we have an active edit control 9859 /* If they change the view and we have an active edit control 9596 9860 we will need to kill the control since the redraw will 9597 9861 misplace the edit control. … … 9601 9865 ((LVS_ICON|LVS_LIST|LVS_SMALLICON) & uOldView))) 9602 9866 { 9603 SendMessage A(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0);9867 SendMessageW(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0); 9604 9868 } 9605 9869 … … 9808 10072 lvItem.header.pszText = NULL; 9809 10073 lvItem.mustFree = FALSE; 9810 // if (LISTVIEW_GetItemA(hwnd,(LPLVITEMW)&lvItem,TRUE,TRUE)) 9811 if (LISTVIEW_GetItemA(hwnd,(LPLVITEMA)&lvItem,TRUE)) 9812 nLabelWidth = LISTVIEW_GetStringWidth(hwnd,0,lvItem.header.pszText,lvItem.unicode); 10074 if (LISTVIEW_GetItemT(hwnd,(LPLVITEMW)&lvItem,TRUE,TRUE)) 10075 nLabelWidth = ListView_GetStringWidthW(hwnd,lvItem.header.pszText); 9813 10076 if (lvItem.mustFree) COMCTL32_Free(lvItem.header.pszText); 9814 10077 … … 10009 10272 10010 10273 return FALSE; 10011 }10012 10013 static LRESULT LISTVIEW_SetIconSpacing(HWND hwnd,WPARAM wParam,LPARAM lParam)10014 {10015 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);10016 UINT dwStyle = GetWindowLongA(hwnd, GWL_STYLE);10017 UINT uView = dwStyle & LVS_TYPEMASK;10018 DWORD oldIS = MAKELONG(infoPtr->iconSpacing.cx,infoPtr->iconSpacing.cy);10019 INT cx = LOWORD(lParam),cy = HIWORD(lParam);10020 10021 if (cx == -1) cx = GetSystemMetrics(SM_CXICONSPACING);10022 if (cy == -1) cy = GetSystemMetrics(SM_CYICONSPACING);10023 if ((cx != infoPtr->iconSpacing.cx) || (cy != infoPtr->iconSpacing.cy))10024 {10025 infoPtr->iconSpacing.cx = cx;10026 infoPtr->iconSpacing.cy = cy;10027 if (((uView == LVS_ICON) || (uView == LVS_SMALLICON)) && (dwStyle & LVS_AUTOARRANGE))10028 {10029 LISTVIEW_Arrange(hwnd,LVA_DEFAULT);10030 }10031 }10032 10033 return oldIS;10034 10274 } 10035 10275 … … 10451 10691 TRACE("hwnd=%x uMsg=%x wParam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam); 10452 10692 #endif 10453 10454 if (!GetWindowLongA(hwnd, 0) && (uMsg != WM_NCCREATE)) 10455 return DefWindowProcA( hwnd, uMsg, wParam, lParam ); 10693 if (!GetWindowLongW(hwnd, 0) && (uMsg != WM_NCCREATE)) 10694 return DefWindowProcW( hwnd, uMsg, wParam, lParam ); 10456 10695 switch (uMsg) 10457 10696 { 10458 case LVM_APPROXIMATEVIEWRECT: 10459 return LISTVIEW_ApproximateViewRect(hwnd, (INT)wParam, 10697 case LVM_APPROXIMATEVIEWRECT: 10698 return LISTVIEW_ApproximateViewRect(hwnd, (INT)wParam, 10460 10699 LOWORD(lParam), HIWORD(lParam)); 10461 case LVM_ARRANGE: 10700 case LVM_ARRANGE: 10462 10701 return LISTVIEW_Arrange(hwnd, (INT)wParam); 10463 10702 … … 10467 10706 10468 10707 #endif 10708 10469 10709 /* case LVM_CREATEDRAGIMAGE: */ 10470 10710 … … 10479 10719 10480 10720 case LVM_EDITLABELW: 10721 return LISTVIEW_EditLabelT(hwnd, (INT)wParam, TRUE); 10722 10481 10723 case LVM_EDITLABELA: 10482 return LISTVIEW_EditLabel A(hwnd, (INT)wParam);10724 return LISTVIEW_EditLabelT(hwnd, (INT)wParam, FALSE); 10483 10725 10484 10726 case LVM_ENSUREVISIBLE: 10485 10727 return LISTVIEW_EnsureVisible(hwnd, (INT)wParam, (BOOL)lParam); 10486 10728 10729 case LVM_FINDITEMW: 10730 return LISTVIEW_FindItemW(hwnd, (INT)wParam, (LPLVFINDINFOW)lParam); 10731 10487 10732 case LVM_FINDITEMA: 10488 return LISTVIEW_FindItem (hwnd, (INT)wParam, (LPLVFINDINFO)lParam);10733 return LISTVIEW_FindItemA(hwnd, (INT)wParam, (LPLVFINDINFOA)lParam); 10489 10734 10490 10735 case LVM_GETBKCOLOR: … … 10498 10743 return LISTVIEW_GetBkImage(hwnd,wParam,lParam,TRUE); 10499 10744 #endif 10500 /* 10745 /* case LVM_GETBKIMAGE: */ 10501 10746 10502 10747 case LVM_GETCALLBACKMASK: … … 10504 10749 10505 10750 case LVM_GETCOLUMNA: 10506 return LISTVIEW_GetColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam); 10507 10508 /* case LVM_GETCOLUMNW: */ 10751 return LISTVIEW_GetColumnT(hwnd, (INT)wParam, (LPLVCOLUMNW)lParam, FALSE); 10752 10753 case LVM_GETCOLUMNW: 10754 return LISTVIEW_GetColumnT(hwnd, (INT)wParam, (LPLVCOLUMNW)lParam, TRUE); 10509 10755 10510 10756 case LVM_GETCOLUMNORDERARRAY: … … 10526 10772 return LISTVIEW_GetHeader(hwnd); 10527 10773 10528 /* case LVM_GETHOTCURSOR: */10529 10774 #ifdef __WIN32OS2__ 10530 10775 case LVM_GETHOTCURSOR: … … 10541 10786 return LISTVIEW_GetImageList(hwnd, (INT)wParam); 10542 10787 10543 /* case LVM_GETISEARCHSTRING: */10544 10545 10788 #ifdef __WIN32OS2__ 10546 10789 case LVM_GETISEARCHSTRINGA: … … 10552 10795 10553 10796 case LVM_GETITEMA: 10554 return LISTVIEW_GetItemA(hwnd, (LPLVITEMA)lParam, FALSE); 10555 10556 /* case LVM_GETITEMW: */ 10797 return LISTVIEW_GetItemT(hwnd, (LPLVITEMW)lParam, FALSE, FALSE); 10798 10799 case LVM_GETITEMW: 10800 return LISTVIEW_GetItemT(hwnd, (LPLVITEMW)lParam, FALSE, TRUE); 10557 10801 10558 10802 case LVM_GETITEMCOUNT: … … 10562 10806 return LISTVIEW_GetItemPosition(hwnd, (INT)wParam, (LPPOINT)lParam); 10563 10807 10564 case LVM_GETITEMRECT: 10808 case LVM_GETITEMRECT: 10565 10809 return LISTVIEW_GetItemRect(hwnd, (INT)wParam, (LPRECT)lParam); 10566 10810 10567 case LVM_GETITEMSPACING: 10811 case LVM_GETITEMSPACING: 10568 10812 return LISTVIEW_GetItemSpacing(hwnd, (BOOL)wParam); 10569 10813 10570 case LVM_GETITEMSTATE: 10814 case LVM_GETITEMSTATE: 10571 10815 return LISTVIEW_GetItemState(hwnd, (INT)wParam, (UINT)lParam); 10572 10816 10573 10817 case LVM_GETITEMTEXTA: 10574 LISTVIEW_GetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam);10575 break; 10576 10577 /* case LVM_GETITEMTEXTW: */ 10818 return LISTVIEW_GetItemTextT(hwnd, (INT)wParam, (LPLVITEMW)lParam, FALSE); 10819 10820 case LVM_GETITEMTEXTW: 10821 return LISTVIEW_GetItemTextT(hwnd, (INT)wParam, (LPLVITEMW)lParam, TRUE); 10578 10822 10579 10823 case LVM_GETNEXTITEM: 10580 10824 return LISTVIEW_GetNextItem(hwnd, (INT)wParam, LOWORD(lParam)); 10581 10582 /* case LVM_GETNUMBEROFWORKAREAS: */10583 10825 10584 10826 #ifdef __WIN32OS2__ … … 10593 10835 return LISTVIEW_GetSelectedCount(hwnd); 10594 10836 10595 case LVM_GETSELECTIONMARK: 10837 case LVM_GETSELECTIONMARK: 10596 10838 return LISTVIEW_GetSelectionMark(hwnd); 10597 10839 10598 10840 case LVM_GETSTRINGWIDTHA: 10599 return LISTVIEW_GetStringWidth A (hwnd, (LPCSTR)lParam);10600 10601 /* case LVM_GETSTRINGWIDTHW: */ 10602 /* case LVM_GETSUBITEMRECT: */ 10841 return LISTVIEW_GetStringWidthT(hwnd, (LPCWSTR)lParam, FALSE); 10842 10843 case LVM_GETSTRINGWIDTHW: 10844 return LISTVIEW_GetStringWidthT(hwnd, (LPCWSTR)lParam, TRUE); 10603 10845 10604 10846 #ifdef __WIN32OS2__ … … 10606 10848 return LISTVIEW_GetSubItemRect(hwnd,(INT)wParam,(LPRECT)lParam); 10607 10849 #endif 10608 10850 10609 10851 case LVM_GETTEXTBKCOLOR: 10610 10852 return LISTVIEW_GetTextBkColor(hwnd); … … 10613 10855 return LISTVIEW_GetTextColor(hwnd); 10614 10856 10615 /* case LVM_GETTOOLTIPS: */10616 10857 #ifdef __WIN32OS2__ 10617 10858 case LVM_GETTOOLTIPS: … … 10622 10863 return LISTVIEW_GetTopIndex(hwnd); 10623 10864 10624 /* case LVM_GETUNICODEFORMAT: */ 10865 /*case LVM_GETUNICODEFORMAT: 10866 FIXME("LVM_GETUNICODEFORMAT: unimplemented\n"); 10867 return FALSE;*/ 10625 10868 10626 10869 case LVM_GETVIEWRECT: 10627 10870 return LISTVIEW_GetViewRect(hwnd, (LPRECT)lParam); 10628 10871 10629 /* case LVM_GETWORKAREAS: */10630 10872 #ifdef __WIN32OS2__ 10631 10873 case LVM_GETWORKAREAS: … … 10637 10879 10638 10880 case LVM_INSERTCOLUMNA: 10639 return LISTVIEW_InsertColumn A(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam);10881 return LISTVIEW_InsertColumnT(hwnd, (INT)wParam, (LPLVCOLUMNW)lParam, FALSE); 10640 10882 10641 10883 case LVM_INSERTCOLUMNW: 10642 return LISTVIEW_InsertColumn W(hwnd, (INT)wParam, (LPLVCOLUMNW)lParam);10884 return LISTVIEW_InsertColumnT(hwnd, (INT)wParam, (LPLVCOLUMNW)lParam, TRUE); 10643 10885 10644 10886 case LVM_INSERTITEMA: 10645 return LISTVIEW_InsertItem A(hwnd, (LPLVITEMA)lParam);10887 return LISTVIEW_InsertItemT(hwnd, (LPLVITEMW)lParam, FALSE); 10646 10888 10647 10889 case LVM_INSERTITEMW: 10648 return LISTVIEW_InsertItem W(hwnd, (LPLVITEMW)lParam);10890 return LISTVIEW_InsertItemT(hwnd, (LPLVITEMW)lParam, TRUE); 10649 10891 10650 10892 case LVM_REDRAWITEMS: … … 10655 10897 return LISTVIEW_Scroll(hwnd, (INT)wParam, (INT)lParam); 10656 10898 #endif 10899 10657 10900 /* case LVM_SCROLL: */ 10658 10901 /* return LISTVIEW_Scroll(hwnd, (INT)wParam, (INT)lParam); */ … … 10661 10904 return LISTVIEW_SetBkColor(hwnd, (COLORREF)lParam); 10662 10905 10663 /* case LVM_SETBKIMAGE: */ 10906 /* case LVM_SETBKIMAGE: */ 10907 10664 10908 #ifdef __WIN32OS2__ 10665 10909 case LVM_SETBKIMAGEA: … … 10674 10918 10675 10919 case LVM_SETCOLUMNA: 10676 return LISTVIEW_SetColumn A(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam);10920 return LISTVIEW_SetColumnT(hwnd, (INT)wParam, (LPLVCOLUMNW)lParam, FALSE); 10677 10921 10678 10922 case LVM_SETCOLUMNW: 10679 FIXME("Unimplemented msg LVM_SETCOLUMNW\n"); 10680 return 0; 10923 return LISTVIEW_SetColumnT(hwnd, (INT)wParam, (LPLVCOLUMNW)lParam, TRUE); 10681 10924 10682 10925 case LVM_SETCOLUMNORDERARRAY: … … 10689 10932 return LISTVIEW_SetExtendedListViewStyle(hwnd, (DWORD)wParam, (DWORD)lParam); 10690 10933 10691 /* case LVM_SETHOTCURSOR: */10692 10934 #ifdef __WIN32OS2__ 10693 10935 case LVM_SETHOTCURSOR: … … 10695 10937 #endif 10696 10938 10939 /* case LVM_SETHOTCURSOR: */ 10940 10697 10941 case LVM_SETHOTITEM: 10698 10942 return LISTVIEW_SetHotItem(hwnd, (INT)wParam); … … 10700 10944 case LVM_SETHOVERTIME: 10701 10945 return LISTVIEW_SetHoverTime(hwnd, (DWORD)wParam); 10702 10703 /* case LVM_SETICONSPACING: */10704 10946 #ifdef __WIN32OS2__ 10705 10947 case LVM_SETICONSPACING: 10706 10948 return LISTVIEW_SetIconSpacing(hwnd,wParam,lParam); 10707 #endif 10708 10949 #else 10950 case LVM_SETICONSPACING: 10951 return LISTVIEW_SetIconSpacing(hwnd, (DWORD)lParam); 10952 #endif 10709 10953 case LVM_SETIMAGELIST: 10710 return LISTVIEW_SetImageList(hwnd, (INT)wParam, (HIMAGELIST)lParam);10954 return (LRESULT)LISTVIEW_SetImageList(hwnd, (INT)wParam, (HIMAGELIST)lParam); 10711 10955 10712 10956 case LVM_SETITEMA: 10713 return LISTVIEW_SetItemA(hwnd, (LPLVITEMA)lParam); 10714 10715 /* case LVM_SETITEMW: */ 10716 10717 case LVM_SETITEMCOUNT: 10957 return LISTVIEW_SetItemT(hwnd, (LPLVITEMW)lParam, FALSE); 10958 10959 case LVM_SETITEMW: 10960 return LISTVIEW_SetItemT(hwnd, (LPLVITEMW)lParam, TRUE); 10961 10962 case LVM_SETITEMCOUNT: 10718 10963 return LISTVIEW_SetItemCount(hwnd, (INT)wParam, (DWORD)lParam); 10719 10964 10720 10965 case LVM_SETITEMPOSITION: 10721 10966 return LISTVIEW_SetItemPosition(hwnd, (INT)wParam, (INT)LOWORD(lParam), … … 10724 10969 case LVM_SETITEMPOSITION32: 10725 10970 return LISTVIEW_SetItemPosition(hwnd, (INT)wParam, ((POINT*)lParam)->x, 10726 10971 ((POINT*)lParam)->y); 10727 10972 10728 10973 case LVM_SETITEMSTATE: 10729 return LISTVIEW_SetItemState(hwnd, (INT)wParam, (LPLVITEM A)lParam);10974 return LISTVIEW_SetItemState(hwnd, (INT)wParam, (LPLVITEMW)lParam); 10730 10975 10731 10976 case LVM_SETITEMTEXTA: 10732 return LISTVIEW_SetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam); 10733 10734 /* case LVM_SETITEMTEXTW: */ 10977 return LISTVIEW_SetItemTextT(hwnd, (INT)wParam, (LPLVITEMW)lParam, FALSE); 10978 10979 case LVM_SETITEMTEXTW: 10980 return LISTVIEW_SetItemTextT(hwnd, (INT)wParam, (LPLVITEMW)lParam, TRUE); 10735 10981 10736 10982 case LVM_SETSELECTIONMARK: … … 10750 10996 return LISTVIEW_SetWorkAreas(hwnd,wParam,lParam); 10751 10997 #endif 10752 /* case LVM_SETTOOLTIPS: */ 10753 /* case LVM_SETUNICODEFORMAT: */ 10754 /* case LVM_SETWORKAREAS: */ 10998 10999 /* case LVM_SETTOOLTIPS: */ 11000 /* case LVM_SETUNICODEFORMAT: */ 11001 /* case LVM_SETWORKAREAS: */ 10755 11002 10756 11003 case LVM_SORTITEMS: 10757 return LISTVIEW_SortItems(hwnd, wParam, lParam); 10758 10759 /* case LVM_SUBITEMHITTEST: */ 11004 return LISTVIEW_SortItems(hwnd, (PFNLVCOMPARE)lParam, (LPARAM)wParam); 11005 10760 11006 #ifdef __WIN32OS2__ 10761 11007 case LVM_SUBITEMHITTEST: … … 10763 11009 #endif 10764 11010 10765 case LVM_UPDATE: 11011 /* case LVM_SUBITEMHITTEST: */ 11012 11013 case LVM_UPDATE: 10766 11014 return LISTVIEW_Update(hwnd, (INT)wParam); 10767 11015 … … 10773 11021 10774 11022 case WM_CREATE: 10775 return LISTVIEW_Create(hwnd, wParam,lParam);10776 11023 return LISTVIEW_Create(hwnd, (LPCREATESTRUCTW)lParam); 11024 10777 11025 case WM_ERASEBKGND: 10778 11026 return LISTVIEW_EraseBackground(hwnd, wParam, lParam); … … 10785 11033 10786 11034 case WM_HSCROLL: 10787 return LISTVIEW_HScroll(hwnd, (INT)LOWORD(wParam), 11035 return LISTVIEW_HScroll(hwnd, (INT)LOWORD(wParam), 10788 11036 (INT)HIWORD(wParam), (HWND)lParam); 10789 11037 … … 10795 11043 10796 11044 case WM_LBUTTONDBLCLK: 10797 return LISTVIEW_LButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 11045 return LISTVIEW_LButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 10798 11046 HIWORD(lParam)); 10799 11047 10800 11048 case WM_LBUTTONDOWN: 10801 return LISTVIEW_LButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 11049 return LISTVIEW_LButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 10802 11050 HIWORD(lParam)); 10803 11051 case WM_LBUTTONUP: 10804 return LISTVIEW_LButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 11052 return LISTVIEW_LButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 10805 11053 HIWORD(lParam)); 10806 11054 case WM_MOUSEMOVE: … … 10822 11070 return LISTVIEW_NotifyFormat(hwnd, (HWND)wParam, (INT)lParam); 10823 11071 10824 case WM_PAINT: 10825 return LISTVIEW_Paint(hwnd, (HDC)wParam); 11072 case WM_PAINT: 11073 return LISTVIEW_Paint(hwnd, (HDC)wParam); 10826 11074 10827 11075 case WM_RBUTTONDBLCLK: 10828 return LISTVIEW_RButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 11076 return LISTVIEW_RButtonDblClk(hwnd, (WORD)wParam, LOWORD(lParam), 10829 11077 HIWORD(lParam)); 10830 11078 10831 11079 case WM_RBUTTONDOWN: 10832 return LISTVIEW_RButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 11080 return LISTVIEW_RButtonDown(hwnd, (WORD)wParam, LOWORD(lParam), 10833 11081 HIWORD(lParam)); 10834 11082 10835 11083 case WM_RBUTTONUP: 10836 return LISTVIEW_RButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 11084 return LISTVIEW_RButtonUp(hwnd, (WORD)wParam, LOWORD(lParam), 10837 11085 HIWORD(lParam)); 10838 11086 … … 10843 11091 return LISTVIEW_SetFont(hwnd, (HFONT)wParam, (WORD)lParam); 10844 11092 10845 case WM_SETREDRAW: 11093 case WM_SETREDRAW: 10846 11094 return LISTVIEW_SetRedraw(hwnd, (BOOL)wParam); 10847 11095 … … 10852 11100 return LISTVIEW_StyleChanged(hwnd, wParam, (LPSTYLESTRUCT)lParam); 10853 11101 10854 /* case WM_TIMER: */10855 11102 #ifdef __WIN32OS2__ 10856 11103 case WM_TIMER: … … 10858 11105 #endif 10859 11106 11107 /* case WM_TIMER: */ 11108 10860 11109 case WM_VSCROLL: 10861 return LISTVIEW_VScroll(hwnd, (INT)LOWORD(wParam), 11110 return LISTVIEW_VScroll(hwnd, (INT)LOWORD(wParam), 10862 11111 (INT)HIWORD(wParam), (HWND)lParam); 10863 11112 10864 11113 case WM_MOUSEWHEEL: 10865 11114 if (wParam & (MK_SHIFT | MK_CONTROL)) 10866 return DefWindowProc A( hwnd, uMsg, wParam, lParam );10867 return LISTVIEW_MouseWheel(hwnd, (short int)HIWORD(wParam));/* 10868 10869 /* 11115 return DefWindowProcW( hwnd, uMsg, wParam, lParam ); 11116 return LISTVIEW_MouseWheel(hwnd, (short int)HIWORD(wParam));/* case WM_WINDOWPOSCHANGED: */ 11117 11118 /* case WM_WININICHANGE: */ 10870 11119 10871 11120 default: 10872 11121 if (uMsg >= WM_USER) 10873 11122 { 10874 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, 11123 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, 10875 11124 lParam); 10876 11125 } 10877 10878 /* call default window procedure */10879 11126 #ifdef __WIN32OS2__ 10880 11127 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); … … 10890 11137 * DESCRIPTION: 10891 11138 * Registers the window class. 10892 * 11139 * 10893 11140 * PARAMETER(S): 10894 11141 * None … … 10899 11146 VOID LISTVIEW_Register(void) 10900 11147 { 10901 WNDCLASS AwndClass;10902 10903 ZeroMemory(&wndClass, sizeof(WNDCLASS A));11148 WNDCLASSW wndClass; 11149 11150 ZeroMemory(&wndClass, sizeof(WNDCLASSW)); 10904 11151 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; 10905 11152 wndClass.lpfnWndProc = (WNDPROC)LISTVIEW_WindowProc; 10906 11153 wndClass.cbClsExtra = 0; 10907 11154 wndClass.cbWndExtra = sizeof(LISTVIEW_INFO *); 10908 wndClass.hCursor = LoadCursor A(0, IDC_ARROWA);11155 wndClass.hCursor = LoadCursorW(0, IDC_ARROWW); 10909 11156 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 10910 wndClass.lpszClassName = WC_LISTVIEW A;10911 RegisterClass A(&wndClass);11157 wndClass.lpszClassName = WC_LISTVIEWW; 11158 RegisterClassW(&wndClass); 10912 11159 } 10913 11160 … … 10915 11162 * DESCRIPTION: 10916 11163 * Unregisters the window class. 10917 * 11164 * 10918 11165 * PARAMETER(S): 10919 11166 * None … … 10924 11171 VOID LISTVIEW_Unregister(void) 10925 11172 { 10926 UnregisterClass A(WC_LISTVIEWA, (HINSTANCE)NULL);11173 UnregisterClassW(WC_LISTVIEWW, (HINSTANCE)NULL); 10927 11174 } 10928 11175 … … 10930 11177 * DESCRIPTION: 10931 11178 * Handle any WM_COMMAND messages 10932 * 11179 * 10933 11180 * PARAMETER(S): 10934 11181 * … … 10939 11186 switch (HIWORD(wParam)) 10940 11187 { 10941 10942 10943 /* 10944 * Adjust the edit window size 10945 10946 charbuffer[1024];10947 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);10948 11188 case EN_UPDATE: 11189 { 11190 /* 11191 * Adjust the edit window size 11192 */ 11193 WCHAR buffer[1024]; 11194 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(hwnd, 0); 11195 HDC hdc = GetDC(infoPtr->hwndEdit); 10949 11196 HFONT hFont, hOldFont = 0; 10950 RECTrect;10951 SIZEsz;10952 intlen;10953 10954 len = GetWindowTextA(infoPtr->hwndEdit, buffer, 1023);10955 11197 RECT rect; 11198 SIZE sz; 11199 int len; 11200 11201 len = GetWindowTextW(infoPtr->hwndEdit, buffer, sizeof(buffer)/sizeof(buffer[0])); 11202 GetWindowRect(infoPtr->hwndEdit, &rect); 10956 11203 10957 11204 /* Select font to get the right dimension of the string */ 10958 hFont = SendMessage A(infoPtr->hwndEdit, WM_GETFONT, 0, 0);11205 hFont = SendMessageW(infoPtr->hwndEdit, WM_GETFONT, 0, 0); 10959 11206 if(hFont != 0) 10960 11207 { … … 10962 11209 } 10963 11210 10964 if (GetTextExtentPoint32A(hdc, buffer, strlen(buffer), &sz))10965 10966 TEXTMETRIC AtextMetric;11211 if (GetTextExtentPoint32W(hdc, buffer, lstrlenW(buffer), &sz)) 11212 { 11213 TEXTMETRICW textMetric; 10967 11214 10968 11215 /* Add Extra spacing for the next character */ 10969 GetTextMetrics A(hdc, &textMetric);11216 GetTextMetricsW(hdc, &textMetric); 10970 11217 sz.cx += (textMetric.tmMaxCharWidth * 2); 10971 11218 10972 SetWindowPos ( 10973 10974 HWND_TOP, 10975 0, 10976 10977 10978 10979 10980 11219 SetWindowPos ( 11220 infoPtr->hwndEdit, 11221 HWND_TOP, 11222 0, 11223 0, 11224 sz.cx, 11225 rect.bottom - rect.top, 11226 SWP_DRAWFRAME|SWP_NOMOVE); 11227 } 10981 11228 if(hFont != 0) 10982 {10983 11229 SelectObject(hdc, hOldFont); 10984 } 10985 10986 ReleaseDC(hwnd, hdc); 10987 10988 break; 10989 } 10990 10991 default: 10992 return SendMessageA (GetParent (hwnd), WM_COMMAND, wParam, lParam); 11230 11231 ReleaseDC(hwnd, hdc); 11232 11233 break; 11234 } 11235 11236 default: 11237 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, lParam); 10993 11238 } 10994 11239 … … 11005 11250 * RETURN: 11006 11251 */ 11007 LRESULT CALLBACK EditLblWndProc(HWND hwnd, UINT uMsg, 11008 WPARAM wParam, LPARAM lParam) 11009 { 11010 BOOL cancel = FALSE; 11011 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(GetParent(hwnd), 0); 11252 static LRESULT EditLblWndProcT(HWND hwnd, UINT uMsg, 11253 WPARAM wParam, LPARAM lParam, BOOL isW) 11254 { 11255 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(GetParent(hwnd), 0); 11012 11256 EDITLABEL_ITEM *einfo = infoPtr->pedititem; 11013 11257 static BOOL bIgnoreKillFocus = FALSE; 11258 BOOL cancel = FALSE; 11259 11260 TRACE("(hwnd=%x, uMsg=%x, wParam=%x, lParam=%lx, isW=%d)\n", 11261 hwnd, uMsg, wParam, lParam, isW); 11262 11014 11263 switch (uMsg) 11015 11264 { 11016 case WM_GETDLGCODE: 11017 return DLGC_WANTARROWS | DLGC_WANTALLKEYS; 11018 11019 case WM_KILLFOCUS: 11020 if(bIgnoreKillFocus) 11021 { 11022 return TRUE; 11023 } 11024 break; 11025 11026 case WM_DESTROY: 11027 { 11028 WNDPROC editProc = einfo->EditWndProc; 11029 SetWindowLongA(hwnd, GWL_WNDPROC, (LONG)editProc); 11030 COMCTL32_Free(einfo); 11031 infoPtr->pedititem = NULL; 11032 return CallWindowProcA(editProc, hwnd, uMsg, wParam, lParam); 11033 } 11034 11035 case WM_KEYDOWN: 11036 if (VK_ESCAPE == (INT)wParam) 11037 { 11038 cancel = TRUE; 11265 case WM_GETDLGCODE: 11266 return DLGC_WANTARROWS | DLGC_WANTALLKEYS; 11267 11268 case WM_KILLFOCUS: 11269 if(bIgnoreKillFocus) return TRUE; 11270 break; 11271 11272 case WM_DESTROY: 11273 { 11274 WNDPROC editProc = einfo->EditWndProc; 11275 SetWindowLongW(hwnd, GWL_WNDPROC, (LONG)editProc); 11276 COMCTL32_Free(einfo); 11277 infoPtr->pedititem = NULL; 11278 return CallWindowProcT(editProc, hwnd, uMsg, wParam, lParam, isW); 11279 } 11280 11281 case WM_KEYDOWN: 11282 if (VK_ESCAPE == (INT)wParam) 11283 { 11284 cancel = TRUE; 11039 11285 break; 11040 11041 } 11042 else if (VK_RETURN == (INT)wParam) 11043 break; 11044 11045 default: 11046 return CallWindowProcA(einfo->EditWndProc, hwnd, 11047 uMsg, wParam, lParam); 11286 } 11287 else if (VK_RETURN == (INT)wParam) 11288 break; 11289 11290 default: 11291 return CallWindowProcT(einfo->EditWndProc, hwnd, uMsg, wParam, lParam, isW); 11048 11292 } 11049 11293 11050 11294 if (einfo->EditLblCb) 11051 11295 { 11052 char *buffer= NULL;11053 11054 11055 if (!cancel) 11056 { 11057 int len = 1 + GetWindowTextLengthA(hwnd); 11058 11059 if (len > 1) 11060 { 11061 if (NULL != (buffer = (char *)COMCTL32_Alloc(len*sizeof(char)))) 11062 { 11063 GetWindowTextA(hwnd, buffer, len);11064 11065 11066 11296 LPWSTR buffer = NULL; 11297 11298 if (!cancel) 11299 { 11300 DWORD len = isW ? GetWindowTextLengthW(hwnd) : GetWindowTextLengthA(hwnd); 11301 11302 if (len) 11303 { 11304 if ( (buffer = COMCTL32_Alloc((len+1) * (isW ? sizeof(WCHAR) : sizeof(CHAR)))) ) 11305 { 11306 if (isW) GetWindowTextW(hwnd, buffer, len+1); 11307 else GetWindowTextA(hwnd, (CHAR*)buffer, len+1); 11308 } 11309 } 11310 } 11067 11311 /* Processing LVN_ENDLABELEDIT message could kill the focus */ 11068 11312 /* eg. Using a messagebox */ 11069 11313 bIgnoreKillFocus = TRUE; 11070 einfo->EditLblCb(GetParent(hwnd), buffer, einfo->param); 11071 11072 if (buffer) 11073 COMCTL32_Free(buffer); 11074 11075 einfo->EditLblCb = NULL; 11314 einfo->EditLblCb(GetParent(hwnd), buffer, einfo->param); 11315 11316 if (buffer) COMCTL32_Free(buffer); 11317 11318 einfo->EditLblCb = NULL; 11076 11319 bIgnoreKillFocus = FALSE; 11077 11320 } 11078 11321 11079 SendMessage A(hwnd, WM_CLOSE, 0, 0);11322 SendMessageW(hwnd, WM_CLOSE, 0, 0); 11080 11323 return TRUE; 11081 11324 } 11082 11325 11326 /*** 11327 * DESCRIPTION: 11328 * Subclassed edit control windproc function 11329 * 11330 * PARAMETER(S): 11331 * 11332 * RETURN: 11333 */ 11334 LRESULT CALLBACK EditLblWndProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 11335 { 11336 return EditLblWndProcT(hwnd, uMsg, wParam, lParam, TRUE); 11337 } 11338 11339 /*** 11340 * DESCRIPTION: 11341 * Subclassed edit control windproc function 11342 * 11343 * PARAMETER(S): 11344 * 11345 * RETURN: 11346 */ 11347 LRESULT CALLBACK EditLblWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 11348 { 11349 return EditLblWndProcT(hwnd, uMsg, wParam, lParam, FALSE); 11350 } 11083 11351 11084 11352 /*** … … 11090 11358 * RETURN: 11091 11359 */ 11092 HWND CreateEditLabel(LPCSTR text, DWORD style, INT x, INT y, 11093 INT width, INT height, HWND parent, HINSTANCE hinst, 11094 EditlblCallback EditLblCb, DWORD param) 11095 { 11360 HWND CreateEditLabelT(LPCWSTR text, DWORD style, INT x, INT y, 11361 INT width, INT height, HWND parent, HINSTANCE hinst, 11362 EditlblCallbackW EditLblCb, DWORD param, BOOL isW) 11363 { 11364 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongW(parent, 0); 11365 WCHAR editName[5] = { 'E', 'd', 'i', 't', '\0' }; 11096 11366 HWND hedit; 11097 11367 SIZE sz; 11098 11368 HDC hdc; 11099 11369 HDC hOldFont=0; 11100 TEXTMETRICA textMetric; 11101 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(parent, 0); 11102 11370 TEXTMETRICW textMetric; 11371 11372 TRACE("(text=%s, ..., isW=%d)\n", debugstr_t(text, isW), isW); 11373 11103 11374 if (NULL == (infoPtr->pedititem = COMCTL32_Alloc(sizeof(EDITLABEL_ITEM)))) 11104 11375 return 0; 11105 11376 11106 11377 style |= WS_CHILDWINDOW|WS_CLIPSIBLINGS|ES_LEFT|WS_BORDER; … … 11109 11380 /* Select the font to get appropriate metric dimensions */ 11110 11381 if(infoPtr->hFont != 0) 11111 {11112 11382 hOldFont = SelectObject(hdc, infoPtr->hFont); 11113 }11114 11383 11115 11384 /*Get String Lenght in pixels */ 11116 GetTextExtentPoint32 A(hdc, text, strlen(text), &sz);11385 GetTextExtentPoint32W(hdc, text, lstrlenW(text), &sz); 11117 11386 11118 11387 /*Add Extra spacing for the next character */ 11119 GetTextMetrics A(hdc, &textMetric);11388 GetTextMetricsW(hdc, &textMetric); 11120 11389 sz.cx += (textMetric.tmMaxCharWidth * 2); 11121 11390 11122 11391 if(infoPtr->hFont != 0) 11123 {11124 11392 SelectObject(hdc, hOldFont); 11125 }11126 11393 11127 11394 ReleaseDC(parent, hdc); 11128 if (!(hedit = CreateWindowA("Edit", text, style, x, y, sz.cx, height, 11129 parent, 0, hinst, 0))) 11130 { 11131 COMCTL32_Free(infoPtr->pedititem); 11132 return 0; 11395 if (isW) 11396 hedit = CreateWindowW(editName, text, style, x, y, sz.cx, height, parent, 0, hinst, 0); 11397 else 11398 hedit = CreateWindowA("Edit", (LPCSTR)text, style, x, y, sz.cx, height, parent, 0, hinst, 0); 11399 11400 if (!hedit) 11401 { 11402 COMCTL32_Free(infoPtr->pedititem); 11403 return 0; 11133 11404 } 11134 11405 11135 11406 infoPtr->pedititem->param = param; 11136 11407 infoPtr->pedititem->EditLblCb = EditLblCb; 11137 infoPtr->pedititem->EditWndProc = (WNDPROC)SetWindowLongA(hedit, 11138 GWL_WNDPROC, (LONG) EditLblWndProc); 11139 11140 SendMessageA(hedit, WM_SETFONT, infoPtr->hFont, FALSE); 11408 infoPtr->pedititem->EditWndProc = (WNDPROC) 11409 (isW ? SetWindowLongW(hedit, GWL_WNDPROC, (LONG)EditLblWndProcW) : 11410 SetWindowLongA(hedit, GWL_WNDPROC, (LONG)EditLblWndProcA) ); 11411 11412 SendMessageW(hedit, WM_SETFONT, infoPtr->hFont, FALSE); 11141 11413 11142 11414 return hedit; 11143 11415 } 11144 11416 11145
Note:
See TracChangeset
for help on using the changeset viewer.