Changeset 2858 for trunk/src/comctl32/treeview.c
- Timestamp:
- Feb 22, 2000, 6:11:41 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/treeview.c
r2835 r2858 1 /* $Id: treeview.c,v 1. 29 2000-02-20 18:29:58cbratschi Exp $ */1 /* $Id: treeview.c,v 1.30 2000-02-22 17:11:41 cbratschi Exp $ */ 2 2 /* Treeview control 3 3 * … … 47 47 #include "commctrl.h" 48 48 #include "comctl32.h" 49 #include "ccbase.h" 49 50 #include "treeview.h" 50 51 … … 2002 2003 INT cChildren; 2003 2004 HTREEITEM hti; 2004 BOOL root ;2005 BOOL root = FALSE; 2005 2006 2006 2007 /* Obtain the TVSORTBC struct */ … … 2690 2691 2691 2692 /* allocate memory for info structure */ 2692 infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO)); 2693 2694 SetWindowLongA( hwnd, 0, (DWORD)infoPtr); 2693 infoPtr = (TREEVIEW_INFO*)initControl(hwnd,sizeof(TREEVIEW_INFO)); 2695 2694 2696 2695 if (infoPtr == NULL) return 0; 2697 2698 if ((TREEVIEW_INFO*)GetWindowLongA(hwnd,0) != infoPtr) return 0;2699 2696 2700 2697 hdc = GetDC(hwnd); … … 2702 2699 /* set default settings */ 2703 2700 infoPtr->uInternalStatus = TV_CALCALL; 2704 if (IsWindowUnicode(hwnd)) infoPtr->uInternalStatus |= TV_UNICODE;2705 2701 infoPtr->uNumItems = 0; 2706 2702 infoPtr->clrBk = GetSysColor (COLOR_WINDOW); … … 2809 2805 DeleteObject(infoPtr->hBoldFont); 2810 2806 COMCTL32_Free(infoPtr->pszISearch); 2811 COMCTL32_Free (infoPtr);2807 doneControl(hwnd); 2812 2808 2813 2809 return 0; … … 2906 2902 TREEVIEW_ITEM *wineItem; 2907 2903 HWND parent = GetParent(hwnd); 2908 BOOL unicode = IsWindowUnicode(parent),rc;2909 2904 CHAR *oldText = NULL,*newText = NULL; 2905 BOOL rc; 2910 2906 2911 2907 ZeroMemory(&nmhdr,sizeof(NMTREEVIEWW)); … … 2923 2919 nmhdr.itemOld.stateMask = wineItem->stateMask; 2924 2920 nmhdr.itemOld.iImage = wineItem->iImage; 2925 if ( !unicode)2921 if (infoPtr->header.uNotifyFormat == NFR_ANSI) 2926 2922 { 2927 2923 if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else … … 2949 2945 nmhdr.itemNew.stateMask = wineItem->stateMask; 2950 2946 nmhdr.itemNew.iImage = wineItem->iImage; 2951 if ( !unicode)2947 if (infoPtr->header.uNotifyFormat == NFR_ANSI) 2952 2948 { 2953 2949 if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else … … 2970 2966 nmhdr.ptDrag.y = 0; 2971 2967 2972 if (unicode) 2973 rc = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)GetWindowLongW(hwnd,GWL_ID),(LPARAM)&nmhdr); 2974 else 2975 rc = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)GetWindowLongA(hwnd,GWL_ID),(LPARAM)&nmhdr); 2968 rc = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr); 2976 2969 2977 2970 if (oldText) COMCTL32_Free(oldText); … … 3010 3003 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, UINT code, UINT what) 3011 3004 { 3005 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3012 3006 NMTVDISPINFOW tvdi; 3013 3007 BOOL retval; 3014 3008 WCHAR *buf; 3015 3009 HWND parent = GetParent(hwnd); 3016 BOOL unicode = IsWindowUnicode(parent);3017 3010 3018 3011 tvdi.hdr.hwndFrom = hwnd; … … 3023 3016 tvdi.item.state = wineItem->state; 3024 3017 tvdi.item.lParam = wineItem->lParam; 3025 tvdi.item.pszText = COMCTL32_Alloc(128*( unicode? sizeof(WCHAR):sizeof(char)));3018 tvdi.item.pszText = COMCTL32_Alloc(128*((infoPtr->header.uNotifyFormat == NFR_UNICODE) ? sizeof(WCHAR):sizeof(char))); 3026 3019 tvdi.item.cchTextMax = 128; 3027 3020 buf = tvdi.item.pszText; 3028 3021 3029 if (unicode) 3030 retval = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 3031 else 3032 retval = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 3022 retval = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 3033 3023 3034 3024 /* Ignore posible changes */ … … 3038 3028 if (what & TVIF_TEXT) 3039 3029 { 3040 if ( unicode)3030 if (infoPtr->header.uNotifyFormat == NFR_UNICODE) 3041 3031 { 3042 3032 wineItem->pszText = tvdi.item.pszText; … … 3069 3059 3070 3060 if (what & TVIF_SELECTEDIMAGE) 3071 3061 wineItem->iSelectedImage = tvdi.item.iSelectedImage; 3072 3062 if (what & TVIF_IMAGE) 3073 3063 wineItem->iImage = tvdi.item.iImage; 3074 3064 if (what & TVIF_CHILDREN) 3075 3076 3077 return retval;3065 wineItem->cChildren = tvdi.item.cChildren; 3066 3067 return retval; 3078 3068 } 3079 3069 … … 3086 3076 LPNMCUSTOMDRAW nmcd; 3087 3077 3088 nmcd =& nmcdhdr.nmcd;3078 nmcd =& nmcdhdr.nmcd; 3089 3079 nmcd->hdr.hwndFrom = hwnd; 3090 3080 nmcd->hdr.idFrom = GetWindowLongA( hwnd, GWL_ID); … … 3452 3442 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 3453 3443 HWND parent = GetParent(hwnd); 3454 BOOL unicode = IsWindowUnicode(parent);3455 3444 BOOL bCommit; 3456 3445 WCHAR *textW = NULL; … … 3479 3468 //} 3480 3469 3481 if ( unicode) tvdi.item.pszText = textW; else3470 if (infoPtr->header.uNotifyFormat == NFR_UNICODE) tvdi.item.pszText = textW; else 3482 3471 { 3483 3472 INT len = iLength+1; … … 3495 3484 } 3496 3485 3497 if (unicode) 3498 bCommit=(BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 3499 else 3500 bCommit=(BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 3486 bCommit = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 3501 3487 3502 3488 if (!bCancel && bCommit) /* Apply the changes */ 3503 3489 { 3504 if ( !unicode)3490 if (infoPtr->header.uNotifyFormat == NFR_ANSI) 3505 3491 lstrcpynAtoW(textW,textA,iLength+1); 3506 3492 if (lstrcmpW(textW,editedItem->pszText) != 0) … … 3646 3632 NMTVGETINFOTIPW tvgit; 3647 3633 HWND parent = GetParent(hwnd); 3648 BOOL unicode = IsWindowUnicode(parent);3649 3634 3650 3635 tvgit.hdr.hwndFrom = hwnd; 3651 3636 tvgit.hdr.idFrom = GetWindowLongA(hwnd,GWL_ID); 3652 tvgit.hdr.code = unicode? TVN_GETINFOTIPW:TVN_GETINFOTIPA;3653 tvgit.pszText = COMCTL32_Alloc( unicode? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR));3637 tvgit.hdr.code = (infoPtr->header.uNotifyFormat == NFR_UNICODE) ? TVN_GETINFOTIPW:TVN_GETINFOTIPA; 3638 tvgit.pszText = COMCTL32_Alloc((infoPtr->header.uNotifyFormat == NFR_UNICODE) ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR)); 3654 3639 tvgit.cchTextMax = INFOTIPSIZE; 3655 3640 tvgit.hItem = item->hItem; 3656 3641 tvgit.lParam = item->lParam; 3657 3642 3658 if (unicode) 3643 SendMessageA(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit); 3644 if (infoPtr->header.uNotifyFormat == NFR_UNICODE) 3659 3645 { 3660 SendMessageW(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit);3661 3646 text = tvgit.pszText; 3662 3647 } else 3663 3648 { 3664 SendMessageA(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit);3665 3649 text = COMCTL32_Alloc(tvgit.cchTextMax*sizeof(WCHAR)); 3666 3650 lstrcpyAtoW(text,(LPSTR)tvgit.pszText); … … 4598 4582 } 4599 4583 4600 static LRESULT TREEVIEW_GetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam)4601 {4602 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);4603 4604 return infoPtr->uInternalStatus & TV_UNICODE;4605 }4606 4607 static LRESULT TREEVIEW_SetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam)4608 {4609 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);4610 BOOL oldFormat = infoPtr->uInternalStatus & TV_UNICODE;4611 4612 if (wParam)4613 infoPtr->uInternalStatus |= TV_UNICODE;4614 else4615 infoPtr->uInternalStatus &= ~TV_UNICODE;4616 4617 return oldFormat;4618 }4619 4620 4584 static LRESULT WINAPI 4621 4585 TREEVIEW_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) … … 4760 4724 case TVM_GETINSERTMARKCOLOR: 4761 4725 return TREEVIEW_GetInsertMarkColor (hwnd,wParam, lParam); 4762 4763 case TVM_GETUNICODEFORMAT:4764 return TREEVIEW_GetUnicodeFormat(hwnd,wParam,lParam);4765 4766 case TVM_SETUNICODEFORMAT:4767 return TREEVIEW_SetUnicodeFormat(hwnd,wParam,lParam);4768 4726 4769 4727 case WM_COMMAND: … … 4853 4811 // FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n", 4854 4812 // uMsg, wParam, lParam); 4855 return DefWindowProcA (hwnd, uMsg, wParam,lParam);4813 return defComCtl32ProcA(hwnd,uMsg,wParam,lParam); 4856 4814 } 4857 4815 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.