- Timestamp:
- Nov 19, 1999, 5:07:29 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/listview.c
r1730 r1774 8 8 * 9 9 * NOTES 10 * Listview control implementation. 10 * Listview control implementation. 11 11 * 12 12 * TODO: … … 19 19 * 20 20 * Data structure: 21 * LISTVIEW_SetItemCount : empty stub 22 * 21 * LISTVIEW_SetItemCount : empty stub 22 * 23 23 * Unicode: 24 24 * LISTVIEW_SetItemW : no unicode support … … 32 32 * LISTVIEW_GetHotCursor : not implemented 33 33 * LISTVIEW_GetHoverTime : not implemented 34 * LISTVIEW_GetISearchString : not implemented 34 * LISTVIEW_GetISearchString : not implemented 35 35 * LISTVIEW_GetBkImage : not implemented 36 36 * LISTVIEW_GetColumnOrderArray : not implemented … … 38 38 * LISTVIEW_Arrange : empty stub 39 39 * LISTVIEW_ApproximateViewRect : incomplete 40 * LISTVIEW_Scroll : not implemented 40 * LISTVIEW_Scroll : not implemented 41 41 * LISTVIEW_RedrawItems : empty stub 42 42 * LISTVIEW_Update : not completed … … 82 82 83 83 /* Increment size of the horizontal scroll bar */ 84 #define REPORT_HSCROLL_INC_SIZE 1084 #define LISTVIEW_SCROLL_DIV_SIZE 10 85 85 86 86 /* … … 95 95 #define GETITEMCOUNT(infoPtr) ((infoPtr)->hdpaItems->nItemCount) 96 96 97 /* Some definitions for inline edit control */98 typedef BOOL (*EditlblCallback)(HWND, LPSTR, DWORD);99 97 100 98 HWND CreateEditLabel(LPCSTR text, DWORD style, INT x, INT y, … … 102 100 EditlblCallback EditLblCb, DWORD param); 103 101 104 typedef struct tagEDITLABEL_ITEM105 {106 WNDPROC EditWndProc;107 DWORD param;108 EditlblCallback EditLblCb;109 } EDITLABEL_ITEM;110 111 102 /* 112 103 * forward declarations … … 127 118 static INT LISTVIEW_GetLabelWidth(HWND, INT); 128 119 static LRESULT LISTVIEW_GetOrigin(HWND, LPPOINT); 120 static INT LISTVIEW_CalculateWidth(HWND hwnd, INT nItem); 129 121 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItem(HDPA, INT); 130 122 static LRESULT LISTVIEW_GetViewRect(HWND, LPRECT); … … 158 150 * hwnd [I] handle to a window 159 151 * nNewScrollPos [I] Scroll Pos to Set 160 * nOldScrollPos [I] Previous Scroll Pos161 152 * 162 153 * RETURNS … … 165 156 * NOTES 166 157 */ 167 static VOID LISTVIEW_UpdateHeaderSize(HWND hwnd, INT nNewScrollPos , INT nOldScrollPos)158 static VOID LISTVIEW_UpdateHeaderSize(HWND hwnd, INT nNewScrollPos) 168 159 { 169 160 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 170 INT nDiff = nOldScrollPos-nNewScrollPos;171 161 RECT winRect; 172 162 POINT point[2]; … … 179 169 180 170 MapWindowPoints(HWND_DESKTOP, hwnd, point, 2); 181 point[0].x += (nDiff * REPORT_HSCROLL_INC_SIZE);182 point[1].x -= point[0].x;171 point[0].x = -(nNewScrollPos * LISTVIEW_SCROLL_DIV_SIZE); 172 point[1].x += (nNewScrollPos * LISTVIEW_SCROLL_DIV_SIZE); 183 173 184 174 SetWindowPos(infoPtr->hwndHeader,0, … … 212 202 if (uView == LVS_LIST) 213 203 { 204 /* update horizontal scrollbar */ 205 214 206 INT nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd); 215 INT nCountPerPage = LISTVIEW_GetCountPerRow(hwnd) * nCountPerColumn; 207 INT nCountPerRow = LISTVIEW_GetCountPerRow(hwnd); 208 INT nCountPerPage = nCountPerRow * nCountPerColumn; 209 INT nNumOfItems = GETITEMCOUNT(infoPtr); 210 216 211 if (nCountPerPage < GETITEMCOUNT(infoPtr)) 217 212 { 218 /* calculate new scrollbar range */ 219 if((GETITEMCOUNT(infoPtr) % nCountPerPage) == 0) 220 { 221 scrollInfo.nMax = GETITEMCOUNT(infoPtr) / nCountPerPage * LISTVIEW_GetCountPerRow(hwnd)-1; 222 } 223 else 224 { 225 scrollInfo.nMax = (GETITEMCOUNT(infoPtr) / nCountPerPage)* LISTVIEW_GetCountPerRow(hwnd); 226 } 227 213 scrollInfo.nMax = nNumOfItems / nCountPerColumn; 214 if((nNumOfItems % nCountPerColumn) == 0) 215 { 216 scrollInfo.nMax--; 217 } 228 218 scrollInfo.nPos = ListView_GetTopIndex(hwnd) / nCountPerColumn; 229 scrollInfo.nPage = LISTVIEW_GetCountPerRow(hwnd);219 scrollInfo.nPage = nCountPerRow; 230 220 scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; 231 221 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); … … 242 232 else if (uView == LVS_REPORT) 243 233 { 244 RECT clientRect;245 234 /* update vertical scrollbar */ 246 235 scrollInfo.nMin = 0; … … 252 241 253 242 /* update horizontal scrollbar */ 254 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd);255 GetClientRect(hwnd, &clientRect);256 257 243 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE) 258 244 { … … 261 247 scrollInfo.nMin = 0; 262 248 scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE ; 263 scrollInfo.nPage = (clientRect.right - clientRect.left) / REPORT_HSCROLL_INC_SIZE; 264 scrollInfo.nMax = infoPtr->nItemWidth; 265 266 /* Check to see if we need the scroll bar */ 267 if(scrollInfo.nMax < 0) 268 { 269 scrollInfo.nMax = 0; 270 } 271 else 272 { 273 /* Even up the max */ 274 scrollInfo.nMax -= (scrollInfo.nMax % REPORT_HSCROLL_INC_SIZE); 275 scrollInfo.nMax = (scrollInfo.nMax / REPORT_HSCROLL_INC_SIZE)-1; 276 } 277 /* Set the scroll pos to the max if the current scroll pos is greater */ 278 if((scrollInfo.nPos+scrollInfo.nPage) > scrollInfo.nMax 279 && scrollInfo.nMax > scrollInfo.nPage) 280 { 281 UINT nOldScrollPos = scrollInfo.nPos; 282 scrollInfo.nPos = scrollInfo.nMax; 283 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 284 GetScrollInfo(hwnd, SB_HORZ, &scrollInfo); 285 LISTVIEW_UpdateHeaderSize(hwnd, scrollInfo.nPos, nOldScrollPos); 286 } 287 else 288 { 289 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 290 } 249 scrollInfo.nPage = nListWidth / LISTVIEW_SCROLL_DIV_SIZE; 250 scrollInfo.nMax = max(infoPtr->nItemWidth / LISTVIEW_SCROLL_DIV_SIZE, 0)-1; 251 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 252 253 /* Update the Header Control */ 254 scrollInfo.fMask = SIF_POS; 255 GetScrollInfo(hwnd, SB_HORZ, &scrollInfo); 256 LISTVIEW_UpdateHeaderSize(hwnd, scrollInfo.nPos); 257 291 258 } 292 259 else … … 301 268 if (nViewWidth > nListWidth) 302 269 { 303 INT nHiddenWidth;304 INT nScrollPosWidth = nListWidth / 10;305 306 if (nScrollPosWidth == 0)307 {308 nScrollPosWidth = 1;309 nHiddenWidth = nViewWidth - nListWidth;310 }311 else312 {313 nHiddenWidth = nViewWidth - nScrollPosWidth * 10;314 }315 316 270 scrollInfo.fMask = SIF_POS; 317 271 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE) … … 319 273 scrollInfo.nPos = 0; 320 274 } 321 322 if (nHiddenWidth % nScrollPosWidth == 0) 323 { 324 scrollInfo.nMax = nHiddenWidth / nScrollPosWidth; 325 } 326 else 327 { 328 scrollInfo.nMax = nHiddenWidth / nScrollPosWidth + 1; 329 } 330 275 scrollInfo.nMax = max(nViewWidth / LISTVIEW_SCROLL_DIV_SIZE, 0)-1; 331 276 scrollInfo.nMin = 0; 332 scrollInfo.nPage = 10;277 scrollInfo.nPage = nListWidth / LISTVIEW_SCROLL_DIV_SIZE; 333 278 scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; 334 279 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); … … 344 289 if (nViewHeight > nListHeight) 345 290 { 346 INT nHiddenHeight;347 INT nScrollPosHeight = nListHeight / 10;348 349 if (nScrollPosHeight == 0)350 {351 nScrollPosHeight = 1;352 nHiddenHeight = nViewHeight - nListHeight;353 }354 else355 {356 nHiddenHeight = nViewHeight - nScrollPosHeight * 10;357 }358 359 291 scrollInfo.fMask = SIF_POS; 360 292 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) == FALSE) … … 362 294 scrollInfo.nPos = 0; 363 295 } 364 365 if (nHiddenHeight % nScrollPosHeight == 0) 366 { 367 scrollInfo.nMax = nHiddenHeight / nScrollPosHeight; 368 } 369 else 370 { 371 scrollInfo.nMax = nHiddenHeight / nScrollPosHeight + 1; 372 } 373 296 scrollInfo.nMax = max(nViewHeight / LISTVIEW_SCROLL_DIV_SIZE,0)-1; 374 297 scrollInfo.nMin = 0; 375 scrollInfo.nPage = 10;298 scrollInfo.nPage = nListHeight / LISTVIEW_SCROLL_DIV_SIZE; 376 299 scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; 377 300 SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE); … … 662 585 * DESCRIPTION: 663 586 * Calculates the width of an item. 664 * 587 * 665 588 * PARAMETER(S): 666 589 * [I] HWND : window handle … … 701 624 { 702 625 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 703 { 626 { 704 627 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, i); 705 628 nItemWidth = max(nItemWidth, nLabelWidth); 706 629 } 707 630 708 631 /* default label size */ 709 632 if (GETITEMCOUNT(infoPtr) == 0) … … 721 644 /* add padding */ 722 645 nItemWidth += WIDTH_PADDING; 723 646 724 647 if (infoPtr->himlSmall != NULL) 725 648 { … … 734 657 } 735 658 } 736 659 660 return nItemWidth; 661 } 662 663 /*** 664 * DESCRIPTION: 665 * Calculates the width of a specific item. 666 * 667 * PARAMETER(S): 668 * [I] HWND : window handle 669 * [I] LPSTR : string 670 * 671 * RETURN: 672 * Returns the width of an item width a specified string. 673 */ 674 static INT LISTVIEW_CalculateWidth(HWND hwnd, INT nItem) 675 { 676 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 677 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 678 INT nHeaderItemCount; 679 RECT rcHeaderItem; 680 INT nItemWidth = 0; 681 INT i; 682 683 // TRACE("(hwnd=%x)\n", hwnd); 684 685 if (uView == LVS_ICON) 686 { 687 nItemWidth = infoPtr->iconSpacing.cx; 688 } 689 else if (uView == LVS_REPORT) 690 { 691 /* calculate width of header */ 692 nHeaderItemCount = Header_GetItemCount(infoPtr->hwndHeader); 693 for (i = 0; i < nHeaderItemCount; i++) 694 { 695 if (Header_GetItemRect(infoPtr->hwndHeader, i, &rcHeaderItem) != 0) 696 { 697 nItemWidth += (rcHeaderItem.right - rcHeaderItem.left); 698 } 699 } 700 } 701 else 702 { 703 /* get width of string */ 704 nItemWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 705 706 /* default label size */ 707 if (GETITEMCOUNT(infoPtr) == 0) 708 { 709 nItemWidth = DEFAULT_COLUMN_WIDTH; 710 } 711 else 712 { 713 if (nItemWidth == 0) 714 { 715 nItemWidth = DEFAULT_LABEL_WIDTH; 716 } 717 else 718 { 719 /* add padding */ 720 nItemWidth += WIDTH_PADDING; 721 722 if (infoPtr->himlSmall != NULL) 723 { 724 nItemWidth += infoPtr->iconSize.cx; 725 } 726 727 if (infoPtr->himlState != NULL) 728 { 729 nItemWidth += infoPtr->iconSize.cx; 730 } 731 } 732 } 733 } 734 737 735 return nItemWidth; 738 736 } … … 1862 1860 1863 1861 /* Don't bother painting item being edited */ 1864 if (infoPtr-> lpeditItem&& lvItem.state & LVIS_FOCUSED)1862 if (infoPtr->hwndEdit && lvItem.state & LVIS_FOCUSED) 1865 1863 return; 1866 1864 … … 2054 2052 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 2055 2053 { 2056 rcItem.left -= (scrollInfo.nPos * REPORT_HSCROLL_INC_SIZE);2057 rcItem.right -= (scrollInfo.nPos * REPORT_HSCROLL_INC_SIZE);2054 rcItem.left -= (scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE); 2055 rcItem.right -= (scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE); 2058 2056 } 2059 2057 … … 2691 2689 } 2692 2690 2691 /* If this item had focus change focus to next or previous item */ 2692 if (GETITEMCOUNT(infoPtr) > 0) 2693 { 2694 int sItem = nItem < GETITEMCOUNT(infoPtr) ? nItem : nItem - 1; 2695 if (infoPtr->nFocusedItem == nItem) 2696 LISTVIEW_SetItemFocus(hwnd, sItem); 2697 } 2698 else 2699 infoPtr->nFocusedItem = -1; 2700 2693 2701 LISTVIEW_UpdateScroll(hwnd); 2694 2702 … … 2762 2770 ListView_Notify(GetParent(hwnd), nCtrlId, &dispInfo); 2763 2771 infoPtr->hwndEdit = 0; 2764 infoPtr->lpeditItem = NULL;2765 2772 2766 2773 return TRUE; … … 2793 2800 if (~GetWindowLongA(hwnd, GWL_STYLE) & LVS_EDITLABELS) 2794 2801 return FALSE; 2802 2803 LISTVIEW_SetSelection(hwnd, nItem); 2804 LISTVIEW_SetItemFocus(hwnd, nItem); 2795 2805 2796 2806 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA)); … … 2827 2837 2828 2838 infoPtr->hwndEdit = hedit; 2829 infoPtr->lpeditItem = lpItem;2830 2839 SetFocus(hedit); 2831 2840 SendMessageA(hedit, EM_SETSEL, 0, -1); … … 2879 2888 else if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 2880 2889 { 2881 nScrollPosWidth = max(1, nListWidth / 10);2890 nScrollPosWidth = max(1, nListWidth / LISTVIEW_SCROLL_DIV_SIZE); 2882 2891 rcItem.left += infoPtr->rcList.left; 2883 2892 } … … 2908 2917 { 2909 2918 rcItem.right -= infoPtr->rcList.right; 2910 nScrollPosWidth = max(1, nListWidth / 10);2919 nScrollPosWidth = max(1, nListWidth / LISTVIEW_SCROLL_DIV_SIZE); 2911 2920 } 2912 2921 … … 2936 2945 else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 2937 2946 { 2938 nScrollPosHeight = max(1, nListHeight / 10);2947 nScrollPosHeight = max(1, nListHeight / LISTVIEW_SCROLL_DIV_SIZE); 2939 2948 rcItem.top += infoPtr->rcList.top; 2940 2949 } … … 2964 2973 else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 2965 2974 { 2966 nScrollPosHeight = max(1, nListHeight / 10);2975 nScrollPosHeight = max(1, nListHeight / LISTVIEW_SCROLL_DIV_SIZE); 2967 2976 rcItem.bottom -= infoPtr->rcList.bottom; 2968 2977 } … … 4404 4413 * DESCRIPTION: 4405 4414 * Retrieves the origin coordinates when in icon or small icon display mode. 4406 * 4415 * 4407 4416 * PARAMETER(S): 4408 4417 * [I] HWND : window handle 4409 4418 * [O] LPPOINT : coordinate information 4410 * 4419 * 4411 4420 * RETURN: 4412 4421 * SUCCESS : TRUE … … 4415 4424 static LRESULT LISTVIEW_GetOrigin(HWND hwnd, LPPOINT lpptOrigin) 4416 4425 { 4417 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);4418 4426 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 4419 4427 UINT uView = lStyle & LVS_TYPEMASK; 4420 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;4421 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;4422 4428 BOOL bResult = FALSE; 4423 4429 4424 4430 // TRACE("(hwnd=%x, lpptOrigin=%p)\n", hwnd, lpptOrigin); 4425 4431 … … 4434 4440 { 4435 4441 scrollInfo.fMask = SIF_POS; 4436 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 4437 { 4438 lpptOrigin->x = -scrollInfo.nPos * max(nListWidth / 10, 1);4442 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 4443 { 4444 lpptOrigin->x = -scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 4439 4445 } 4440 4446 } … … 4445 4451 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE) 4446 4452 { 4447 lpptOrigin->y = -scrollInfo.nPos * max(nListHeight / 10, 1);4448 } 4449 } 4450 4453 lpptOrigin->y = -scrollInfo.nPos * LISTVIEW_SCROLL_DIV_SIZE; 4454 } 4455 } 4456 4451 4457 bResult = TRUE; 4452 4458 } 4453 4459 4454 4460 return bResult; 4455 4461 } … … 4804 4810 * DESCRIPTION: 4805 4811 * Inserts a new item in the listview control. 4806 * 4812 * 4807 4813 * PARAMETER(S): 4808 4814 * [I] HWND : window handle … … 4822 4828 INT nItem = -1; 4823 4829 HDPA hdpaSubItems; 4830 INT nItemWidth = 0; 4824 4831 LISTVIEW_ITEM *lpItem = NULL; 4825 4832 … … 4844 4851 if (nItem != -1) 4845 4852 { 4846 nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem, 4853 nItem = DPA_InsertPtr(infoPtr->hdpaItems, lpLVItem->iItem, 4847 4854 hdpaSubItems); 4848 4855 if (nItem != -1) … … 4854 4861 { 4855 4862 LISTVIEW_SetItemFocus(hwnd, nItem); 4856 } 4863 } 4857 4864 } 4858 4865 4859 4866 /* send LVN_INSERTITEM notification */ 4860 4867 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); … … 4865 4872 nmlv.lParam = lpItem->lParam;; 4866 4873 ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv); 4874 4875 if ((uView == LVS_SMALLICON) || (uView == LVS_LIST)) 4876 { 4877 nItemWidth = LISTVIEW_CalculateWidth(hwnd, lpLVItem->iItem); 4878 if (nItemWidth > infoPtr->nItemWidth) 4879 { 4880 infoPtr->nItemWidth = nItemWidth; 4881 } 4882 } 4867 4883 4868 4884 /* align items (set position of each item) */ … … 4878 4894 } 4879 4895 } 4880 4896 4881 4897 LISTVIEW_UpdateScroll(hwnd); 4882 4898 /* refresh client area */ … … 4895 4911 COMCTL32_Free(lpItem); 4896 4912 } 4897 4913 4898 4914 return nItem; 4899 4915 } … … 5312 5328 { 5313 5329 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0); 5314 FIXME("(%d %08lx)empty stub!\n", nItems, dwFlags);5330 // FIXME("(%d %08lx)empty stub!\n", nItems, dwFlags); 5315 5331 if (nItems == 0) 5316 5332 return LISTVIEW_DeleteAllItems (hwnd); … … 5318 5334 { 5319 5335 /* append items */ 5320 FIXME("append items\n");5336 // FIXME("append items\n"); 5321 5337 } 5322 5338 else if (nItems < GETITEMCOUNT(infoPtr)) 5323 5339 { 5324 5340 /* remove items */ 5325 FIXME("remove items\n");5341 // FIXME("remove items\n"); 5326 5342 } 5327 5343 return TRUE; … … 5700 5716 ZeroMemory(&infoPtr->rcList, sizeof(RECT)); 5701 5717 infoPtr->hwndEdit = 0; 5702 infoPtr-> lpeditItem = NULL;5718 infoPtr->pedititem = NULL; 5703 5719 5704 5720 /* get default font (icon title) */ … … 5972 5988 scrollInfo.fMask = SIF_POS; 5973 5989 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 5974 scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;5975 GetScrollInfo(hwnd, SB_HORZ, &scrollInfo);5976 5990 if(uView == LVS_REPORT) 5977 5991 { 5978 LISTVIEW_UpdateHeaderSize(hwnd, scrollInfo.nPos, nOldScrollPos); 5992 scrollInfo.fMask = SIF_POS; 5993 GetScrollInfo(hwnd, SB_HORZ, &scrollInfo); 5994 LISTVIEW_UpdateHeaderSize(hwnd, scrollInfo.nPos); 5979 5995 } 5980 5996 InvalidateRect(hwnd, NULL, TRUE); … … 6399 6415 * no need to disturb it) 6400 6416 */ 6417 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); 6401 6418 LISTVIEW_UpdateScroll(hwnd); 6402 6419 InvalidateRect(hwnd, NULL, TRUE); … … 7340 7357 { 7341 7358 BOOL cancel = TRUE; 7342 EDITLABEL_ITEM *einfo =7343 (EDITLABEL_ITEM *) GetWindowLongA(hwnd, GWL_USERDATA);7359 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(GetParent(hwnd), 0); 7360 EDITLABEL_ITEM *einfo = infoPtr->pedititem; 7344 7361 7345 7362 switch (uMsg) 7346 7363 { 7364 case WM_GETDLGCODE: 7365 return DLGC_WANTARROWS | DLGC_WANTALLKEYS; 7366 7347 7367 case WM_KILLFOCUS: 7348 7368 break; 7369 7370 case WM_DESTROY: 7371 { 7372 WNDPROC editProc = einfo->EditWndProc; 7373 SetWindowLongA(hwnd, GWL_WNDPROC, (LONG)editProc); 7374 COMCTL32_Free(einfo); 7375 infoPtr->pedititem = NULL; 7376 return CallWindowProcA(editProc, hwnd, uMsg, wParam, lParam); 7377 } 7349 7378 7350 7379 case WM_CHAR: … … 7362 7391 } 7363 7392 7364 SetWindowLongA(hwnd, GWL_WNDPROC, (LONG)einfo->EditWndProc);7365 7393 if (einfo->EditLblCb) 7366 7394 { … … 7384 7412 if (buffer) 7385 7413 COMCTL32_Free(buffer); 7386 } 7387 7388 COMCTL32_Free(einfo); 7389 PostMessageA(hwnd, WM_CLOSE, 0, 0); 7414 7415 einfo->EditLblCb = NULL; 7416 } 7417 7418 SendMessageA(hwnd, WM_CLOSE, 0, 0); 7390 7419 return TRUE; 7391 7420 } … … 7405 7434 { 7406 7435 HWND hedit; 7407 EDITLABEL_ITEM *einfo; 7408 7409 if (NULL == (einfo = COMCTL32_Alloc(sizeof(EDITLABEL_ITEM)))) 7436 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(parent, 0); 7437 if (NULL == (infoPtr->pedititem = COMCTL32_Alloc(sizeof(EDITLABEL_ITEM)))) 7410 7438 return 0; 7411 7439 … … 7414 7442 parent, 0, hinst, 0))) 7415 7443 { 7416 COMCTL32_Free( einfo);7444 COMCTL32_Free(infoPtr->pedititem); 7417 7445 return 0; 7418 7446 } 7419 7447 7420 einfo->param = param;7421 einfo->EditLblCb = EditLblCb;7422 einfo->EditWndProc = (WNDPROC)SetWindowLongA(hedit,7448 infoPtr->pedititem->param = param; 7449 infoPtr->pedititem->EditLblCb = EditLblCb; 7450 infoPtr->pedititem->EditWndProc = (WNDPROC)SetWindowLongA(hedit, 7423 7451 GWL_WNDPROC, (LONG) EditLblWndProc); 7424 7452 7425 SetWindowLongA(hedit, GWL_USERDATA, (LONG)einfo);7426 7427 7453 return hedit; 7428 7454 }
Note:
See TracChangeset
for help on using the changeset viewer.