Changeset 8382 for trunk/src/comctl32
- Timestamp:
- May 8, 2002, 1:26:30 PM (23 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 4 added
- 3 deleted
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/CCBase.cpp
r3410 r8382 1 /* $Id: CCBase.cpp,v 1. 9 2000-04-16 18:52:38 cbratschiExp $ */1 /* $Id: CCBase.cpp,v 1.10 2002-05-08 11:24:58 sandervl Exp $ */ 2 2 /* 3 3 * COMCTL32 Base Functions and Macros for all Controls … … 7 7 * parts from WINE code 8 8 */ 9 #include <winuser.h> 9 10 #include <string.h> 10 11 #include <wcstr.h> 11 12 #include "winbase.h" 12 13 #include "comctl32.h" 14 #include <commctrl.h> 13 15 #include "ccbase.h" 14 16 -
trunk/src/comctl32/LICENSE.TXT
r6380 r8382 1 $Id: LICENSE.TXT,v 1. 2 2001-07-21 09:07:16sandervl Exp $2 @cThis is an additional Odin license agreement.3 @cIt supercedes the main Odin license, but is only valid in4 @cthe source directory in which it is present.1 $Id: LICENSE.TXT,v 1.3 2002-05-08 11:24:58 sandervl Exp $ 2 This is an additional Odin license agreement. 3 It supercedes the main Odin license, but is only valid in 4 the source directory in which it is present. 5 5 6 @c This file is processed by GNU's TeXinfo 7 @c If you modify it or move it to another location, make sure that 8 @c TeXinfo works (type `make' in directory documentation). 9 10 Copyright (c) 1993-2000 the Wine project authors (see the file AUTHORS 6 Copyright (c) 1993-2002 the Wine project authors (see the file AUTHORS 11 7 for a complete list) 12 8 13 Permission is hereby granted, free of charge, to any person obtaining a copy 14 of this software and associated documentation files (the "Software"), to deal 15 in the Software without restriction, including without limitation the rights 16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 copies of the Software, and to permit persons to whom the Software is 18 furnished to do so, subject to the following conditions: 9 Wine is free software; you can redistribute it and/or modify it under 10 the terms of the GNU Lesser General Public License as published by the 11 Free Software Foundation; either version 2.1 of the License, or (at 12 your option) any later version. 19 13 20 The above copyright notice and this permission notice shall be included in 21 all copies or substantial portions of the Software. 14 This program is distributed in the hope that it will be useful, but 15 WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 22 18 23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 27 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 A copy of the GNU Lesser General Public License is included in the 20 Wine distribution in the file COPYING.LIB. If you did not receive this 21 copy, write to the Free Software Foundation, Inc., 59 Temple Place, 22 Suite 330, Boston, MA 02111-1307 USA. -
trunk/src/comctl32/animate.c
r6709 r8382 5 5 * Copyright 1998, 1999 Eric Kohl 6 6 * 1999 Eric Pouech 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 7 21 * 8 22 * NOTES … … 20 34 #include "vfw.h" 21 35 #include "mmsystem.h" 22 #include "debugtools.h" 36 #include "wine/debug.h" 37 38 WINE_DEFAULT_DEBUG_CHANNEL(animate); 39 40 static struct { 41 HMODULE hModule; 23 42 #ifdef __WIN32OS2__ 24 #include "ccbase.h" 43 HIC (* WINAPI fnICOpen)(DWORD, DWORD, UINT); 44 LRESULT (* WINAPI fnICClose)(HIC); 45 LRESULT (* WINAPI fnICSendMessage)(HIC, UINT, DWORD, DWORD); 46 DWORD (* WINAPIV fnICDecompress)(HIC,DWORD,LPBITMAPINFOHEADER,LPVOID,LPBITMAPINFOHEADER,LPVOID); 47 #else 48 HIC (WINAPI *fnICOpen)(DWORD, DWORD, UINT); 49 LRESULT (WINAPI *fnICClose)(HIC); 50 LRESULT (WINAPI *fnICSendMessage)(HIC, UINT, DWORD, DWORD); 51 DWORD (WINAPIV *fnICDecompress)(HIC,DWORD,LPBITMAPINFOHEADER,LPVOID,LPBITMAPINFOHEADER,LPVOID); 25 52 #endif 26 27 DEFAULT_DEBUG_CHANNEL(animate); 53 } fnIC; 28 54 29 55 typedef struct 30 56 { 31 #ifdef __WIN32OS2__32 COMCTL32_HEADER header;33 #endif34 57 /* reference to input stream (file or resource) */ 35 58 HGLOBAL hRes; … … 71 94 } 72 95 73 #ifdef __WIN32OS2__74 static BOOL ANIMATE_LoadRes(ANIMATE_INFO *infoPtr,HINSTANCE hInst,LPWSTR lpName,BOOL unicode)75 #else76 96 static BOOL ANIMATE_LoadResA(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpName) 77 #endif78 97 { 79 98 HRSRC hrsrc; … … 81 100 LPVOID lpAvi; 82 101 83 #ifdef __WIN32OS2__84 if (unicode)85 hrsrc = FindResourceW(hInst,lpName,(LPWSTR)L"AVI");86 else87 hrsrc = FindResourceA(hInst,(LPCSTR)lpName,"AVI");88 #else89 102 hrsrc = FindResourceA(hInst, lpName, "AVI"); 90 #endif91 103 if (!hrsrc) 92 104 return FALSE; … … 114 126 115 127 116 #ifdef __WIN32OS2__117 static BOOL ANIMATE_LoadFile(ANIMATE_INFO *infoPtr,LPWSTR lpName,BOOL unicode)118 #else119 128 static BOOL ANIMATE_LoadFileA(ANIMATE_INFO *infoPtr, LPSTR lpName) 120 #endif 121 { 122 #ifdef __WIN32OS2__ 123 if (unicode) 124 infoPtr->hMMio = mmioOpenW(lpName,NULL,MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); 125 else 126 infoPtr->hMMio = mmioOpenA((LPSTR)lpName,NULL,MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); 127 #else 129 { 128 130 infoPtr->hMMio = mmioOpenA((LPSTR)lpName, NULL, 129 131 MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); 130 #endif 132 131 133 if (!infoPtr->hMMio) 132 134 return FALSE; … … 174 176 } 175 177 if (infoPtr->hic) { 176 ICClose(infoPtr->hic);178 fnIC.fnICClose(infoPtr->hic); 177 179 infoPtr->hic = 0; 178 180 } … … 348 350 349 351 if (infoPtr->hic && 350 ICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata,352 fnIC.fnICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata, 351 353 infoPtr->outbih, infoPtr->outdata) != ICERR_OK) { 352 354 LeaveCriticalSection(&infoPtr->cs); … … 636 638 /* check uncompressed AVI */ 637 639 if ((infoPtr->ash.fccHandler == mmioFOURCC('D', 'I', 'B', ' ')) || 638 (infoPtr->ash.fccHandler == mmioFOURCC('R', 'L', 'E', ' '))) 640 (infoPtr->ash.fccHandler == mmioFOURCC('R', 'L', 'E', ' ')) || 641 (infoPtr->ash.fccHandler == mmioFOURCC(0, 0, 0, 0))) 639 642 { 640 643 infoPtr->hic = 0; … … 643 646 644 647 /* try to get a decompressor for that type */ 645 infoPtr->hic = ICOpen(ICTYPE_VIDEO, infoPtr->ash.fccHandler, ICMODE_DECOMPRESS);648 infoPtr->hic = fnIC.fnICOpen(ICTYPE_VIDEO, infoPtr->ash.fccHandler, ICMODE_DECOMPRESS); 646 649 if (!infoPtr->hic) { 647 650 WARN("Can't load codec for the file\n"); … … 649 652 } 650 653 651 outSize = ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT,654 outSize = fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 652 655 (DWORD)infoPtr->inbih, 0L); 653 656 … … 658 661 } 659 662 660 if ( ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT,663 if (fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 661 664 (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) { 662 665 WARN("Can't get output BIH\n"); … … 670 673 } 671 674 672 if ( ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN,675 if (fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN, 673 676 (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) { 674 677 WARN("Can't begin decompression\n"); … … 679 682 } 680 683 681 #ifdef __WIN32OS2__682 static LRESULT ANIMATE_Open(HWND hWnd, WPARAM wParam, LPARAM lParam,BOOL unicode)683 #else684 684 static LRESULT ANIMATE_OpenA(HWND hWnd, WPARAM wParam, LPARAM lParam) 685 #endif686 685 { 687 686 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd); … … 689 688 690 689 ANIMATE_Free(infoPtr); 690 infoPtr->hWnd = hWnd; 691 691 692 692 if (!lParam) { … … 698 698 hInstance = GetWindowLongA(hWnd, GWL_HINSTANCE); 699 699 700 #ifdef __WIN32OS2__701 if (HIWORD(lParam)) {702 //TRACE("(\"%s\");\n", (LPSTR)lParam);703 704 if (!ANIMATE_LoadRes(infoPtr, hInstance, (LPWSTR)lParam,unicode)) {705 TRACE("No AVI resource found!\n");706 if (!ANIMATE_LoadFile(infoPtr, (LPWSTR)lParam,unicode)) {707 WARN("No AVI file found!\n");708 return FALSE;709 }710 }711 } else {712 //TRACE("(%u);\n", (WORD)LOWORD(lParam));713 714 if (!ANIMATE_LoadRes(infoPtr,hInstance,unicode ? MAKEINTRESOURCEW((INT)lParam):(LPWSTR)MAKEINTRESOURCEA((INT)lParam),unicode)) {715 WARN("No AVI resource found!\n");716 return FALSE;717 }718 }719 #else720 700 if (HIWORD(lParam)) { 721 701 TRACE("(\"%s\");\n", (LPSTR)lParam); … … 737 717 } 738 718 } 739 #endif 719 740 720 if (!ANIMATE_GetAviInfo(infoPtr)) { 741 721 WARN("Can't get AVI information\n"); … … 782 762 ANIMATE_INFO* infoPtr; 783 763 764 if (!fnIC.hModule) /* FIXME: not thread safe */ 765 { 766 /* since there's a circular dep between msvfw32 and comctl32, we could either: 767 * - fix the build chain to allow this circular dep 768 * - handle it by hand 769 * AJ wants the latter :-( 770 */ 771 fnIC.hModule = LoadLibraryA("msvfw32.dll"); 772 if (!fnIC.hModule) return FALSE; 773 774 fnIC.fnICOpen = (void*)GetProcAddress(fnIC.hModule, "ICOpen"); 775 fnIC.fnICClose = (void*)GetProcAddress(fnIC.hModule, "ICClose"); 776 fnIC.fnICSendMessage = (void*)GetProcAddress(fnIC.hModule, "ICSendMessage"); 777 fnIC.fnICDecompress = (void*)GetProcAddress(fnIC.hModule, "ICDecompress"); 778 } 779 784 780 /* allocate memory for info structure */ 785 #ifdef __WIN32OS2__786 infoPtr = (ANIMATE_INFO*)initControl(hWnd,sizeof(ANIMATE_INFO));787 #else788 781 infoPtr = (ANIMATE_INFO *)COMCTL32_Alloc(sizeof(ANIMATE_INFO)); 789 #endif790 782 if (!infoPtr) { 791 783 ERR("could not allocate info memory!\n"); … … 854 846 switch (uMsg) 855 847 { 856 #ifdef __WIN32OS2__857 case ACM_OPENA:858 return ANIMATE_Open(hWnd,wParam,lParam,FALSE);859 860 case ACM_OPENW:861 return ANIMATE_Open(hWnd,wParam,lParam,TRUE);862 #else863 848 case ACM_OPENA: 864 849 return ANIMATE_OpenA(hWnd, wParam, lParam); … … 866 851 /* case ACM_OPEN32W: FIXME!! */ 867 852 /* return ANIMATE_Open32W(hWnd, wParam, lParam); */ 868 #endif869 853 870 854 case ACM_PLAY: … … 944 928 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); 945 929 946 #ifdef __WIN32OS2__947 return defComCtl32ProcA (hWnd, uMsg, wParam, lParam);948 #else949 930 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 950 #endif951 931 } 952 932 return 0; 953 933 } 954 955 934 956 935 void ANIMATE_Register(void) -
trunk/src/comctl32/comboex.c
r7815 r8382 1 1 /* 2 * TODO <------------- 3 * 1. The following extended styles need to be implemented, use will 4 * result in a FIXME: 5 * CBES_EX_NOEDITIMAGEINDENT 2 * ComboBoxEx control 3 * 4 * Copyright 1998, 1999 Eric Kohl 5 * Copyright 2000, 2001, 2002 Guy Albertelli <galberte@neo.lrun.com> 6 * Copyright 2002 Dimitrie O. Paun 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 22 * FIXME: 23 * 1. Implement following extended styles: 6 24 * CBES_EX_PATHWORDBREAKPROC 7 25 * CBES_EX_NOSIZELIMIT 8 26 * CBES_EX_CASESENSITIVE 9 * 2. None of the following callback items are implemented. Therefor 10 * no CBEN_GETDISPINFO notifies are issued. Use in either CBEM_INSERTITEM 11 * or CBEM_SETITEM will result in a FIXME: 12 * LPSTR_TEXTCALLBACK 13 * I_IMAGECALLBACK 14 * I_INDENTCALLBACK 15 * 3. No use is made of the iOverlay image. 16 * 4. Notify CBEN_DRAGBEGIN is not implemented. 17 */ 18 19 20 /* 21 * ComboBoxEx control v2 (mod6) 22 * 23 * Copyright 1998, 1999 Eric Kohl 24 * 25 * NOTES 26 * This is just a dummy control. An author is needed! Any volunteers? 27 * I will only improve this control once in a while. 28 * Eric <ekohl@abo.rhein-zeitung.de> 29 * 30 31 * Changes Guy Albertelli <galberte@neo.lrun.com> 32 * v1 Implemented messages: CB_SETITEMHEIGHT, WM_WINDOWPOSCHANGING, 33 * WM_DRAWITEM, and WM_MEASUREITEM. Fixed WM_CREATE. Fixed height 34 * of window rect reported fixing rebar control. 35 * v2 36 * 1. Rewrite of WM_Create for own created EDIT control. Also try to 37 * generate message sequence similar to native DLL. 38 * 2. Handle case where CBEM_SETITEM is called to display data in EDIT 39 * Control. 40 * 3. Add override for WNDPROC for the EDIT control (reqed for VK_RETURN). 41 * 4. Dump input data for things using COMBOBOXEXITEM{A|W}. 42 * 5. Handle positioning EDIT control based on whether icon present. 43 * 6. Make InsertItemA use InsertItemW, and store all data in ..W form. 44 * 7. Implement CBEM_DELETEITEM, CBEM_GETITEM{A|W}, CB_SETCURSEL, 45 * CBEM_{GET|SET}UNICODEFORMAT. 46 * 8. Add override for WNDPROC for the COMBO control. 47 * 9. Support extended style CBES_EX_NOEDITIMAGE and warn others are not 48 * supported. 49 * 10. Implement CB_FINDSTRINGEXACT in both the Combo and ComboEx window 50 * procs to match the items. This eliminates dup entries in the listbox. 51 * 52 * mod 4 53 * 1. Implemented CBN_SELCHANGE, CBN_KILLFOCUS, and CBN_SELENDOK. 54 * 2. Fix putting text in CBEN_ENDEDIT notifies for CBN_DROPDOWN case. 55 * 3. Lock image selected status to focus state of edit control if 56 * edit control exists. Mimics native actions. 57 * 4. Implemented WM_SETFOCUS in EditWndProc to track status of 58 * focus for 3 above. 59 * 5. The LBN_SELCHANGE is just for documentation purposes. 60 * 61 * mod 5 62 * 1. Add support for CB_GETITEMDATA to a Comboex. Returns the LPARAM 63 * passed during insert of item. 64 * 2. Remember selected item and don't issue CB_SETCURSEL unless needed. 65 * 3. Add initial support for WM_NCCREATE to remove unwanted window styles 66 * (Currently just WS_VSCROLL and WS_HSCROLL, but probably should be 67 * more.) 68 * 4. Improve some traces. 69 * 5. Add support for CB_SETITEMDATA sets LPARAM value from item. 70 * 71 * mod 6 72 * 1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do 73 * WM_NOTIFY correctly based on results. 74 * 2. Fix memory leaks of text strings in COMBOEX_WM_DELETEITEM. 75 * 3. Add routines to handle special cases of NMCBEENDEDIT and NMCOMBOXEX 76 * so translation to ANSI is done correctly. 77 * 4. Fix some issues with COMBOEX_DrawItem. 78 * 79 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe), 80 * WinRAR, and IE 4.0. 27 * 2. Notify CBEN_DRAGBEGIN is not implemented. 81 28 * 82 29 */ … … 85 32 #include "winbase.h" 86 33 #include "commctrl.h" 87 #include " debugtools.h"34 #include "wine/debug.h" 88 35 #include "wine/unicode.h" 89 36 90 DEFAULT_DEBUG_CHANNEL(comboex); 91 /* 92 * The following is necessary for the test done in COMBOEX_DrawItem 93 * to determine whether to dump out the DRAWITEM structure or not. 94 */ 95 DECLARE_DEBUG_CHANNEL(message); 37 WINE_DEFAULT_DEBUG_CHANNEL(comboex); 96 38 97 39 /* Item structure */ … … 101 43 UINT mask; 102 44 LPWSTR pszText; 45 LPWSTR pszTemp; 103 46 int cchTextMax; 104 47 int iImage; … … 117 60 HWND hwndEdit; 118 61 WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */ 119 WNDPROC prevComboWndProc; 62 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */ 120 63 DWORD dwExtStyle; 121 64 INT selected; /* index of selected item */ 122 65 DWORD flags; /* WINE internal flags */ 123 HFONT hDefaultFont;66 HFONT defaultFont; 124 67 HFONT font; 125 68 INT nb_items; /* Number of items */ 126 BOOL bUnicode;/* TRUE if this window is Unicode */127 BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */69 BOOL unicode; /* TRUE if this window is Unicode */ 70 BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */ 128 71 CBE_ITEMDATA *edit; /* item data for edit item */ 129 72 CBE_ITEMDATA *items; /* Array of items */ … … 131 74 132 75 /* internal flags in the COMBOEX_INFO structure */ 133 #define WCBE_ACTEDIT 76 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e. 134 77 * CBEN_BEGINEDIT issued 135 78 * but CBEN_ENDEDIT{A|W} 136 79 * not yet issued. */ 137 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */ 138 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */ 139 140 141 #define ID_CB_EDIT 1001 80 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */ 81 #define WCBE_EDITHASCHANGED (WCBE_ACTEDIT | WCBE_EDITCHG) 82 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */ 83 84 85 #define ID_CB_EDIT 1001 142 86 143 87 … … 152 96 * only version 4.0 applications will have ODS_COMBOBOXEDIT set. 153 97 */ 154 #define ODS_COMBOEXLBOX 98 #define ODS_COMBOEXLBOX 0x4000 155 99 156 100 157 101 158 102 /* Height in pixels of control over the amount of the selected font */ 159 #define CBE_EXTRA 103 #define CBE_EXTRA 3 160 104 161 105 /* Indent amount per MS documentation */ 162 #define CBE_INDENT 106 #define CBE_INDENT 10 163 107 164 108 /* Offset in pixels from left side for start of image or text */ 165 #define CBE_STARTOFFSET 109 #define CBE_STARTOFFSET 6 166 110 167 111 /* Offset between image and text */ 168 #define CBE_SEP 4 169 170 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0)) 112 #define CBE_SEP 4 113 114 #define COMBOEX_SUBCLASS_PROP "CCComboEx32SubclassInfo" 115 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongW (hwnd, 0)) 171 116 172 117 173 118 /* Things common to the entire DLL */ 174 static ATOM ComboExInfo;175 119 static LRESULT WINAPI 176 120 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 177 121 static LRESULT WINAPI 178 122 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 179 180 static void 181 COMBOEX_DumpItem (CBE_ITEMDATA *item) 182 { 183 if (TRACE_ON(comboex)){ 184 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n", 185 item, item->mask, item->pszText, item->cchTextMax, 186 item->iImage); 187 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 188 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam); 189 if ((item->mask & CBEIF_TEXT) && item->pszText) 190 TRACE("item %p - pszText=%s\n", 191 item, debugstr_w((const WCHAR *)item->pszText)); 192 } 193 } 194 195 196 static void 197 COMBOEX_DumpInput (COMBOBOXEXITEMA *input, BOOL true_for_w) 198 { 199 if (TRACE_ON(comboex)){ 200 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n", 201 input->mask, input->iItem, input->pszText, input->cchTextMax, 202 input->iImage); 203 if ((input->mask & CBEIF_TEXT) && input->pszText) { 204 if (true_for_w) 205 TRACE("input - pszText=<%s>\n", 206 debugstr_w((const WCHAR *)input->pszText)); 207 else 208 TRACE("input - pszText=<%s>\n", 209 debugstr_a((const char *)input->pszText)); 210 } 211 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 212 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam); 213 } 214 } 215 216 217 inline static LRESULT 218 COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 219 { 220 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 221 222 if (infoPtr->hwndCombo) 223 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam); 224 225 return 0; 226 } 227 228 229 static INT 230 COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr) 231 { 232 123 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr); 124 125 inline static BOOL is_textW(LPCWSTR str) 126 { 127 return str && str != LPSTR_TEXTCALLBACKW; 128 } 129 130 inline static BOOL is_textA(LPCSTR str) 131 { 132 return str && str != LPSTR_TEXTCALLBACKA; 133 } 134 135 inline static LPCSTR debugstr_txt(LPCWSTR str) 136 { 137 if (str == LPSTR_TEXTCALLBACKW) return "(callback)"; 138 return debugstr_w(str); 139 } 140 141 static void COMBOEX_DumpItem (CBE_ITEMDATA *item) 142 { 143 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n", 144 item, item->mask, item->pszText, item->cchTextMax, item->iImage); 145 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 146 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam); 147 if (item->mask & CBEIF_TEXT) 148 TRACE("item %p - pszText=%s\n", item, debugstr_txt(item->pszText)); 149 } 150 151 152 static void COMBOEX_DumpInput (COMBOBOXEXITEMW *input) 153 { 154 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n", 155 input->mask, input->iItem, input->pszText, input->cchTextMax, 156 input->iImage); 157 if (input->mask & CBEIF_TEXT) 158 TRACE("input - pszText=<%s>\n", debugstr_txt(input->pszText)); 159 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 160 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam); 161 } 162 163 164 inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index) 165 { 166 return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA, 167 (WPARAM)index, 0); 168 } 169 170 171 static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr) 172 { 233 173 hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf); 234 174 hdr->hwndFrom = infoPtr->hwndSelf; … … 246 186 COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT code, NMCOMBOBOXEXW *hdr) 247 187 { 248 249 188 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ 250 251 hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf);252 hdr->hdr.hwndFrom = infoPtr->hwndSelf;253 hdr->hdr.code = code;254 189 if (infoPtr->NtfUnicode) 255 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 256 (LPARAM)hdr); 190 return COMBOEX_Notify (infoPtr, code, &hdr->hdr); 257 191 else { 258 LPWSTR str, ostr = NULL; 192 LPWSTR wstr = hdr->ceItem.pszText; 193 LPSTR astr = 0; 259 194 INT ret, len = 0; 260 195 261 if (hdr->ceItem.mask & CBEIF_TEXT) { 262 ostr = hdr->ceItem.pszText; 263 str = ostr; 264 if (!str) str = (LPWSTR)L""; 265 len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL); 196 if ((hdr->ceItem.mask & CBEIF_TEXT) && is_textW(wstr)) { 197 len = WideCharToMultiByte (CP_ACP, 0, wstr, -1, 0, 0, NULL, NULL); 266 198 if (len > 0) { 267 hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR)); 268 WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText, 269 len, NULL, NULL); 199 astr = (LPSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR)); 200 if (!astr) return 0; 201 WideCharToMultiByte (CP_ACP, 0, wstr, -1, astr, len, 0, 0); 202 hdr->ceItem.pszText = (LPWSTR)astr; 270 203 } 271 204 } 272 205 273 ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 274 (LPARAM)hdr); 275 if (hdr->ceItem.mask & CBEIF_TEXT) { 276 if (len > 0) 277 COMCTL32_Free (hdr->ceItem.pszText); 278 hdr->ceItem.pszText = ostr; 279 } 206 if (code == CBEN_ENDEDITW) code = CBEN_ENDEDITA; 207 else if (code == CBEN_GETDISPINFOW) code = CBEN_GETDISPINFOA; 208 else if (code == CBEN_DRAGBEGINW) code = CBEN_DRAGBEGINA; 209 210 ret = COMBOEX_Notify (infoPtr, code, (NMHDR *)hdr); 211 212 if (astr && hdr->ceItem.pszText == (LPWSTR)astr) 213 hdr->ceItem.pszText = wstr; 214 215 if (astr) COMCTL32_Free(astr); 216 280 217 return ret; 281 218 } … … 283 220 284 221 285 static INT 286 COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *hdr, LPWSTR itemText) 287 { 288 222 static INT COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *neew, LPCWSTR wstr) 223 { 289 224 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ 290 291 hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf); 292 hdr->hdr.hwndFrom = infoPtr->hwndSelf; 293 hdr->hdr.code = (infoPtr->NtfUnicode) ? CBEN_ENDEDITW : CBEN_ENDEDITA; 294 if (infoPtr->NtfUnicode) 295 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 296 (LPARAM)hdr); 297 else { 298 NMCBEENDEDITA ansi; 299 300 memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR)); 301 ansi.fChanged = hdr->fChanged; 302 ansi.iNewSelection = hdr->iNewSelection; 303 WideCharToMultiByte (CP_ACP, 0, itemText, -1, 304 (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL); 305 ansi.iWhy = hdr->iWhy; 306 return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 307 (LPARAM)&ansi); 308 } 309 } 310 311 312 static void 313 COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size) 225 if (infoPtr->NtfUnicode) { 226 lstrcpynW(neew->szText, wstr, CBEMAXSTRLEN); 227 return COMBOEX_Notify (infoPtr, CBEN_ENDEDITW, &neew->hdr); 228 } else { 229 NMCBEENDEDITA neea; 230 231 memcpy (&neea.hdr, &neew->hdr, sizeof(NMHDR)); 232 neea.fChanged = neew->fChanged; 233 neea.iNewSelection = neew->iNewSelection; 234 WideCharToMultiByte (CP_ACP, 0, wstr, -1, neea.szText, CBEMAXSTRLEN, 0, 0); 235 neea.iWhy = neew->iWhy; 236 237 return COMBOEX_Notify (infoPtr, CBEN_ENDEDITA, &neea.hdr); 238 } 239 } 240 241 242 static void COMBOEX_FreeText (CBE_ITEMDATA *item) 243 { 244 if (is_textW(item->pszText)) COMCTL32_Free(item->pszText); 245 item->pszText = 0; 246 if (item->pszTemp) COMCTL32_Free(item->pszTemp); 247 item->pszTemp = 0; 248 } 249 250 251 static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) 252 { 253 NMCOMBOBOXEXW nmce; 254 LPWSTR text, buf; 255 INT len; 256 257 if (item->pszText != LPSTR_TEXTCALLBACKW) 258 return item->pszText; 259 260 ZeroMemory(&nmce, sizeof(nmce)); 261 nmce.ceItem.mask = CBEIF_TEXT; 262 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); 263 264 if (is_textW(nmce.ceItem.pszText)) { 265 len = MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, NULL, 0); 266 buf = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 267 if (buf) 268 MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, buf, len); 269 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) { 270 COMBOEX_FreeText(item); 271 item->pszText = buf; 272 } else { 273 if (item->pszTemp) COMCTL32_Free(item->pszTemp); 274 item->pszTemp = buf; 275 } 276 text = buf; 277 } else 278 text = nmce.ceItem.pszText; 279 280 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) 281 item->pszText = text; 282 return text; 283 } 284 285 286 static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size) 314 287 { 315 288 HFONT nfont, ofont; … … 326 299 327 300 328 static void 329 COMBOEX_CopyItem (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit) 301 static void COMBOEX_CopyItem (CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit) 330 302 { 331 303 if (cit->mask & CBEIF_TEXT) { 332 cit->pszText = item->pszText; 333 cit->cchTextMax = item->cchTextMax; 304 /* 305 * when given a text buffer actually use that buffer 306 */ 307 if (cit->pszText) { 308 if (is_textW(item->pszText)) 309 lstrcpynW(cit->pszText, item->pszText, cit->cchTextMax); 310 else 311 cit->pszText[0] = 0; 312 } else { 313 cit->pszText = item->pszText; 314 cit->cchTextMax = item->cchTextMax; 315 } 334 316 } 335 317 if (cit->mask & CBEIF_IMAGE) … … 343 325 if (cit->mask & CBEIF_LPARAM) 344 326 cit->lParam = item->lParam; 345 346 } 347 348 349 static void 350 COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr) 327 } 328 329 330 static void COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr) 351 331 { 352 332 SIZE mysize; 353 IMAGEINFO iinfo; 354 INT x, y, w, h, xoff = 0; 333 INT x, y, w, h, xioff; 355 334 RECT rect; 356 335 357 336 if (!infoPtr->hwndEdit) return; 358 iinfo.rcImage.left = iinfo.rcImage.right = 0; 359 if (infoPtr->himl) { 337 338 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) { 339 IMAGEINFO iinfo; 340 iinfo.rcImage.left = iinfo.rcImage.right = 0; 360 341 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); 361 xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; 362 } 342 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; 343 } else xioff = 0; 344 363 345 GetClientRect (infoPtr->hwndCombo, &rect); 364 346 InflateRect (&rect, -2, -2); … … 368 350 COMBOEX_GetComboFontSize (infoPtr, &mysize); 369 351 TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy); 370 x = xoff + CBE_STARTOFFSET + 1; 371 y = CBE_EXTRA + 1; 352 x = xioff + CBE_STARTOFFSET + 1; 372 353 w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1; 373 354 h = mysize.cy + 1; 355 y = rect.bottom - h - 1; 374 356 375 357 TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n", 376 rect.left, rect.top, rect.right, rect.bottom, 377 x, y, x + w, y + h); 378 SetWindowPos(infoPtr->hwndEdit, HWND_TOP, 379 x, y, 380 w, h, 358 rect.left, rect.top, rect.right, rect.bottom, x, y, x + w, y + h); 359 SetWindowPos(infoPtr->hwndEdit, HWND_TOP, x, y, w, h, 381 360 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); 382 361 } 383 362 384 363 385 static void 386 COMBOEX_ReSize (HWND hwnd, COMBOEX_INFO *infoPtr) 364 static void COMBOEX_ReSize (COMBOEX_INFO *infoPtr) 387 365 { 388 366 SIZE mysize; … … 397 375 TRACE("upgraded height due to image: height=%d\n", cy); 398 376 } 399 SendMessageW ( hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM)cy);377 SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy); 400 378 if (infoPtr->hwndCombo) 401 379 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, … … 404 382 405 383 406 static void 407 COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) 384 static void COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) 408 385 { 409 386 if (!infoPtr->hwndEdit) return; … … 413 390 /* EM_SETSEL32 (0,-1) */ 414 391 if (item->mask & CBEIF_TEXT) { 415 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM) item->pszText);392 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)COMBOEX_GetText(infoPtr, item)); 416 393 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0); 417 394 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1); … … 420 397 421 398 422 static CBE_ITEMDATA * 423 COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index) 399 static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index) 424 400 { 425 401 CBE_ITEMDATA *item; … … 439 415 } 440 416 if (!item || (i != index)) { 441 FIXME("COMBOBOXEX item structures broken. Please report!\n");417 ERR("COMBOBOXEX item structures broken. Please report!\n"); 442 418 return 0; 443 419 } … … 446 422 447 423 448 static void 449 COMBOEX_WarnCallBack (CBE_ITEMDATA *item) 450 { 451 if (item->pszText == LPSTR_TEXTCALLBACKW) 452 FIXME("Callback not implemented yet for pszText\n"); 453 if (item->iImage == I_IMAGECALLBACK) 454 FIXME("Callback not implemented yet for iImage\n"); 455 if (item->iSelectedImage == I_IMAGECALLBACK) 456 FIXME("Callback not implemented yet for iSelectedImage\n"); 457 if (item->iOverlay == I_IMAGECALLBACK) 458 FIXME("Callback not implemented yet for iOverlay\n"); 459 if (item->iIndent == I_INDENTCALLBACK) 460 FIXME("Callback not implemented yet for iIndent\n"); 461 } 462 424 static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr) 425 { 426 return infoPtr->hwndEdit; 427 } 428 463 429 464 430 /* *** CBEM_xxx message support *** */ 465 431 466 432 467 static LRESULT 468 COMBOEX_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 469 { 470 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 471 INT index = (INT) wParam; 433 static INT COMBOEX_DeleteItem (COMBOEX_INFO *infoPtr, INT index) 434 { 472 435 CBE_ITEMDATA *item; 473 436 474 TRACE("( 0x%08x 0x%08lx)\n", wParam, lParam);437 TRACE("(index=%d)\n", index); 475 438 476 439 /* if item number requested does not exist then return failure */ 477 if ((index > infoPtr->nb_items) || (index < 0)) { 478 ERR("attempt to delete item that does not exist\n"); 479 return CB_ERR; 480 } 481 482 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 483 ERR("attempt to delete item that was not found!\n"); 484 return CB_ERR; 485 } 440 if ((index > infoPtr->nb_items) || (index < 0)) return CB_ERR; 441 if (!(item = COMBOEX_FindItem(infoPtr, index))) return CB_ERR; 486 442 487 443 /* doing this will result in WM_DELETEITEM being issued */ … … 492 448 493 449 494 inline static LRESULT 495 COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam) 496 { 497 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 498 499 TRACE("\n"); 500 501 return (LRESULT)infoPtr->hwndCombo; 502 } 503 504 505 inline static LRESULT 506 COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam) 507 { 508 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 509 510 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN) 511 return 0; 512 513 TRACE("-- 0x%x\n", infoPtr->hwndEdit); 514 515 return (LRESULT)infoPtr->hwndEdit; 516 } 517 518 519 inline static LRESULT 520 COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam) 521 { 522 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 523 524 TRACE("-- 0x%08lx\n", infoPtr->dwExtStyle); 525 526 return (LRESULT)infoPtr->dwExtStyle; 527 } 528 529 530 inline static LRESULT 531 COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) 532 { 533 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 534 535 TRACE("-- %p\n", infoPtr->himl); 536 537 return (LRESULT)infoPtr->himl; 538 } 539 540 541 static LRESULT 542 COMBOEX_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) 543 { 544 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 545 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam; 546 INT index; 450 static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) 451 { 452 INT index = cit->iItem; 547 453 CBE_ITEMDATA *item; 548 454 549 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam); 550 551 /* get real index of item to insert */ 552 index = cit->iItem; 455 TRACE("(...)\n"); 553 456 554 457 /* if item number requested does not exist then return failure */ 555 if ((index > infoPtr->nb_items) || (index < -1)) { 556 ERR("attempt to get item that does not exist\n"); 557 return 0; 558 } 458 if ((index > infoPtr->nb_items) || (index < -1)) return FALSE; 559 459 560 460 /* if the item is the edit control and there is no edit control, skip */ 561 if ((index == -1) && 562 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)) 563 return 0; 564 565 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 566 ERR("attempt to get item that was not found!\n"); 567 return 0; 568 } 569 570 COMBOEX_CopyItem (infoPtr, item, cit); 461 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE; 462 463 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE; 464 465 COMBOEX_CopyItem (item, cit); 571 466 572 467 return TRUE; … … 574 469 575 470 576 inline static LRESULT 577 COMBOEX_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 578 { 579 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam; 471 static BOOL COMBOEX_GetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) 472 { 580 473 COMBOBOXEXITEMW tmpcit; 581 INT len; 582 583 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam); 474 475 TRACE("(...)\n"); 584 476 585 477 tmpcit.mask = cit->mask; 586 478 tmpcit.iItem = cit->iItem; 587 COMBOEX_GetItemW (hwnd, wParam, (LPARAM) &tmpcit);588 589 len = WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 0, 0, NULL, NULL); 590 if ( len > 0)591 479 tmpcit.pszText = 0; 480 if(!COMBOEX_GetItemW (infoPtr, &tmpcit)) return FALSE; 481 482 if (is_textW(tmpcit.pszText) && cit->pszText) 483 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 592 484 cit->pszText, cit->cchTextMax, NULL, NULL); 485 else if (cit->pszText) cit->pszText[0] = 0; 486 else cit->pszText = (LPSTR)tmpcit.pszText; 593 487 594 488 cit->iImage = tmpcit.iImage; … … 602 496 603 497 604 inline static LRESULT 605 COMBOEX_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) 606 { 607 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 608 609 TRACE("%s hwnd=0x%x\n", 610 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd); 611 612 return infoPtr->bUnicode; 613 } 614 615 616 inline static LRESULT 617 COMBOEX_HasEditChanged (HWND hwnd, WPARAM wParam, LPARAM lParam) 618 { 619 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 620 621 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN) 622 return FALSE; 623 if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) == 624 (WCBE_ACTEDIT | WCBE_EDITCHG)) 625 return TRUE; 626 return FALSE; 627 } 628 629 630 static LRESULT 631 COMBOEX_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) 632 { 633 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 634 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam; 498 inline static BOOL COMBOEX_HasEditChanged (COMBOEX_INFO *infoPtr) 499 { 500 return COMBOEX_HasEdit(infoPtr) && 501 (infoPtr->flags & WCBE_EDITHASCHANGED) == WCBE_EDITHASCHANGED; 502 } 503 504 505 static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) 506 { 635 507 INT index; 636 508 CBE_ITEMDATA *item; … … 639 511 TRACE("\n"); 640 512 641 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);513 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit); 642 514 643 515 /* get real index of item to insert */ … … 646 518 if (index > infoPtr->nb_items) index = infoPtr->nb_items; 647 519 648 /* get space and chain it in */ 649 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA)); 650 item->next = NULL; 651 item->pszText = NULL; 652 520 /* get zero-filled space and chain it in */ 521 if(!(item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof(*item)))) return -1; 522 653 523 /* locate position to insert new item in */ 654 524 if (index == infoPtr->nb_items) { … … 666 536 } 667 537 if (!moving) { 668 FIXME("COMBOBOXEX item structures broken. Please report!\n");538 ERR("COMBOBOXEX item structures broken. Please report!\n"); 669 539 COMCTL32_Free(item); 670 540 return -1; … … 675 545 676 546 /* fill in our hidden item structure */ 677 item->mask 547 item->mask = cit->mask; 678 548 if (item->mask & CBEIF_TEXT) { 679 LPWSTR str; 680 INT len; 681 682 str = cit->pszText; 683 if (!str) str = (LPWSTR) L""; 684 len = strlenW (str); 549 INT len = 0; 550 551 if (is_textW(cit->pszText)) len = strlenW (cit->pszText); 685 552 if (len > 0) { 686 553 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 687 strcpyW (item->pszText, str); 688 } 689 else 690 item->pszText = NULL; 691 item->cchTextMax = cit->cchTextMax; 554 if (!item->pszText) { 555 COMCTL32_Free(item); 556 return -1; 557 } 558 strcpyW (item->pszText, cit->pszText); 559 } 560 else if (cit->pszText == LPSTR_TEXTCALLBACKW) 561 item->pszText = LPSTR_TEXTCALLBACKW; 562 item->cchTextMax = cit->cchTextMax; 692 563 } 693 564 if (item->mask & CBEIF_IMAGE) 694 item->iImage= cit->iImage;565 item->iImage = cit->iImage; 695 566 if (item->mask & CBEIF_SELECTEDIMAGE) 696 item->iSelectedImage = cit->iSelectedImage;567 item->iSelectedImage = cit->iSelectedImage; 697 568 if (item->mask & CBEIF_OVERLAY) 698 item->iOverlay= cit->iOverlay;569 item->iOverlay = cit->iOverlay; 699 570 if (item->mask & CBEIF_INDENT) 700 item->iIndent= cit->iIndent;571 item->iIndent = cit->iIndent; 701 572 if (item->mask & CBEIF_LPARAM) 702 item->lParam= cit->lParam;573 item->lParam = cit->lParam; 703 574 infoPtr->nb_items++; 704 575 705 COMBOEX_WarnCallBack (item); 706 707 COMBOEX_DumpItem (item); 576 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); 708 577 709 578 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, 710 579 (WPARAM)cit->iItem, (LPARAM)item); 711 580 712 COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem); 581 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem)); 582 COMBOEX_CopyItem (item, &nmcit.ceItem); 713 583 COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit); 714 584 … … 718 588 719 589 720 static LRESULT 721 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 722 { 723 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam; 724 COMBOBOXEXITEMW citW; 725 LRESULT ret; 590 static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) 591 { 592 COMBOBOXEXITEMW citW; 593 LPWSTR wstr = NULL; 594 INT ret; 726 595 727 596 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA)); 728 if (cit->mask & CBEIF_TEXT) { 729 LPSTR str; 730 INT len; 731 732 str = cit->pszText; 733 if (!str) str=""; 734 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0); 735 if (len > 0) { 736 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 737 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len); 738 } 739 } 740 ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);; 741 742 if (cit->mask & CBEIF_TEXT) 743 COMCTL32_Free(citW.pszText); 597 if (cit->mask & CBEIF_TEXT && is_textA(cit->pszText)) { 598 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0); 599 wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 600 if (!wstr) return -1; 601 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len); 602 citW.pszText = wstr; 603 } 604 ret = COMBOEX_InsertItemW(infoPtr, &citW);; 605 606 if (wstr) COMCTL32_Free(wstr); 607 744 608 return ret; 745 609 } 746 610 747 611 748 static LRESULT 749 COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam) 750 { 751 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 612 static DWORD 613 COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style) 614 { 752 615 DWORD dwTemp; 753 616 754 TRACE("( 0x%08x 0x%08lx)\n", wParam, lParam);617 TRACE("(mask=x%08lx, style=0x%08lx)\n", mask, style); 755 618 756 619 dwTemp = infoPtr->dwExtStyle; 757 620 758 if (lParam & (CBES_EX_NOEDITIMAGEINDENT | 759 CBES_EX_PATHWORDBREAKPROC | 621 if (style & (CBES_EX_PATHWORDBREAKPROC | 760 622 CBES_EX_NOSIZELIMIT | 761 623 CBES_EX_CASESENSITIVE)) 762 FIXME("Extended style not implemented %08lx\n", lParam); 763 764 if ((DWORD)wParam) { 765 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam; 766 } 624 FIXME("Extended style not implemented %08lx\n", style); 625 626 if (mask) 627 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~mask) | style; 767 628 else 768 infoPtr->dwExtStyle = (DWORD)lParam; 769 770 /* 771 * native does this for CBES_EX_NOEDITIMAGE state change 772 */ 773 if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^ 774 (dwTemp & CBES_EX_NOEDITIMAGE)) { 629 infoPtr->dwExtStyle = style; 630 631 /* test if the control's appearance has changed */ 632 mask = CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT; 633 if ((infoPtr->dwExtStyle & mask) != (dwTemp & mask)) { 775 634 /* if state of EX_NOEDITIMAGE changes, invalidate all */ 776 635 TRACE("EX_NOEDITIMAGE state changed to %ld\n", 777 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);778 InvalidateRect ( hwnd, NULL, TRUE);636 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE); 637 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE); 779 638 COMBOEX_AdjustEditPos (infoPtr); 780 639 if (infoPtr->hwndEdit) … … 782 641 } 783 642 784 return (LRESULT)dwTemp; 785 } 786 787 788 inline static LRESULT 789 COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) 790 { 791 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 792 HIMAGELIST himlTemp; 793 794 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam); 795 796 himlTemp = infoPtr->himl; 797 infoPtr->himl = (HIMAGELIST)lParam; 798 799 COMBOEX_ReSize (hwnd, infoPtr); 643 return dwTemp; 644 } 645 646 647 static HIMAGELIST COMBOEX_SetImageList (COMBOEX_INFO *infoPtr, HIMAGELIST himl) 648 { 649 HIMAGELIST himlTemp = infoPtr->himl; 650 651 TRACE("(...)\n"); 652 653 infoPtr->himl = himl; 654 655 COMBOEX_ReSize (infoPtr); 800 656 InvalidateRect (infoPtr->hwndCombo, NULL, TRUE); 801 657 802 658 /* reposition the Edit control based on whether icon exists */ 803 659 COMBOEX_AdjustEditPos (infoPtr); 804 return (LRESULT)himlTemp; 805 } 806 807 static LRESULT 808 COMBOEX_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) 809 { 810 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 811 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam; 812 INT index; 660 return himlTemp; 661 } 662 663 static BOOL COMBOEX_SetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) 664 { 665 INT index = cit->iItem; 813 666 CBE_ITEMDATA *item; 814 667 815 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE); 816 817 /* get real index of item to insert */ 818 index = cit->iItem; 668 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit); 819 669 820 670 /* if item number requested does not exist then return failure */ 821 if ((index > infoPtr->nb_items) || (index < -1)) { 822 ERR("attempt to set item that does not exist yet!\n"); 823 return 0; 824 } 671 if ((index > infoPtr->nb_items) || (index < -1)) return FALSE; 825 672 826 673 /* if the item is the edit control and there is no edit control, skip */ 827 if ((index == -1) && 828 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)) 829 return 0; 830 831 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 832 ERR("attempt to set item that was not found!\n"); 833 return 0; 834 } 674 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE; 675 676 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE; 835 677 836 678 /* add/change stuff to the internal item structure */ 837 679 item->mask |= cit->mask; 838 680 if (cit->mask & CBEIF_TEXT) { 839 LPWSTR str; 840 INT len; 841 WCHAR emptystr[1] = {0}; 842 843 str = cit->pszText; 844 if (!str) str=emptystr; 845 len = strlenW(str); 681 INT len = 0; 682 683 COMBOEX_FreeText(item); 684 if (is_textW(cit->pszText)) len = strlenW(cit->pszText); 846 685 if (len > 0) { 847 686 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 848 strcpyW(item->pszText,str); 849 } 850 item->cchTextMax = cit->cchTextMax; 687 if (!item->pszText) return FALSE; 688 strcpyW(item->pszText, cit->pszText); 689 } else if (cit->pszText == LPSTR_TEXTCALLBACKW) 690 item->pszText = LPSTR_TEXTCALLBACKW; 691 item->cchTextMax = cit->cchTextMax; 851 692 } 852 693 if (cit->mask & CBEIF_IMAGE) 853 item->iImage= cit->iImage;694 item->iImage = cit->iImage; 854 695 if (cit->mask & CBEIF_SELECTEDIMAGE) 855 item->iSelectedImage = cit->iSelectedImage;696 item->iSelectedImage = cit->iSelectedImage; 856 697 if (cit->mask & CBEIF_OVERLAY) 857 item->iOverlay= cit->iOverlay;698 item->iOverlay = cit->iOverlay; 858 699 if (cit->mask & CBEIF_INDENT) 859 item->iIndent= cit->iIndent;700 item->iIndent = cit->iIndent; 860 701 if (cit->mask & CBEIF_LPARAM) 861 cit->lParam = cit->lParam; 862 863 COMBOEX_WarnCallBack (item); 864 865 COMBOEX_DumpItem (item); 702 cit->lParam = cit->lParam; 703 704 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); 866 705 867 706 /* if original request was to update edit control, do some fast foot work */ … … 873 712 } 874 713 875 static LRESULT 876 COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 877 { 878 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam; 879 COMBOBOXEXITEMW citW; 880 LRESULT ret; 881 882 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA)); 883 if (cit->mask & CBEIF_TEXT) { 884 LPSTR str; 885 INT len; 886 887 str = cit->pszText; 888 if (!str) str=""; 889 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0); 890 if (len > 0) { 891 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 892 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len); 893 } 894 } 895 ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);; 896 897 if (cit->mask & CBEIF_TEXT) 898 COMCTL32_Free(citW.pszText); 714 static BOOL COMBOEX_SetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) 715 { 716 COMBOBOXEXITEMW citW; 717 LPWSTR wstr = NULL; 718 BOOL ret; 719 720 memcpy(&citW, cit, sizeof(COMBOBOXEXITEMA)); 721 if ((cit->mask & CBEIF_TEXT) && is_textA(cit->pszText)) { 722 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0); 723 wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 724 if (!wstr) return FALSE; 725 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len); 726 citW.pszText = wstr; 727 } 728 ret = COMBOEX_SetItemW(infoPtr, &citW);; 729 730 if (wstr) COMCTL32_Free(wstr); 731 899 732 return ret; 900 733 } 901 734 902 735 903 inline static LRESULT 904 COMBOEX_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) 905 { 906 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 907 BOOL bTemp = infoPtr->bUnicode; 908 909 TRACE("to %s hwnd=0x%04x, was %s\n", 910 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd, 911 (bTemp) ? "TRUE" : "FALSE"); 912 913 infoPtr->bUnicode = (BOOL)wParam; 736 static BOOL COMBOEX_SetUnicodeFormat (COMBOEX_INFO *infoPtr, BOOL value) 737 { 738 BOOL bTemp = infoPtr->unicode; 739 740 TRACE("to %s, was %s\n", value ? "TRUE":"FALSE", bTemp ? "TRUE":"FALSE"); 741 742 infoPtr->unicode = value; 914 743 915 744 return bTemp; … … 917 746 918 747 919 920 748 /* *** CB_xxx message support *** */ 921 749 922 923 static LRESULT 924 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 750 static INT 751 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCSTR str) 925 752 { 926 753 INT i, count; 927 754 CBE_ITEMDATA *item; 928 755 LPWSTR desired = NULL; 929 INT start = (INT) wParam; 930 931 i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0); 756 757 i = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0); 932 758 if (i > 0) { 933 759 desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR)); 934 MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i); 935 } 936 937 count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0 , 0); 760 if (!desired) return CB_ERR; 761 MultiByteToWideChar (CP_ACP, 0, str, -1, desired, i); 762 } 763 764 count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0); 938 765 939 766 /* now search from after starting loc and wrapping back to start */ 940 767 for(i=start+1; i<count; i++) { 941 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 942 CB_GETITEMDATA, (WPARAM)i, 0); 943 TRACE("desired=%s, item=%s\n", 944 debugstr_w(desired), debugstr_w(item->pszText)); 945 if (lstrcmpiW(item->pszText, desired) == 0) { 768 item = get_item_data(infoPtr, i); 769 if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) { 946 770 COMCTL32_Free (desired); 947 771 return i; … … 949 773 } 950 774 for(i=0; i<=start; i++) { 951 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 952 CB_GETITEMDATA, (WPARAM)i, 0); 953 TRACE("desired=%s, item=%s\n", 954 debugstr_w(desired), debugstr_w(item->pszText)); 955 if (lstrcmpiW(item->pszText, desired) == 0) { 775 item = get_item_data(infoPtr, i); 776 if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) { 956 777 COMCTL32_Free (desired); 957 778 return i; … … 963 784 964 785 965 static LRESULT 966 COMBOEX_GetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam) 967 { 968 INT index = wParam; 969 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 786 static DWORD COMBOEX_GetItemData (COMBOEX_INFO *infoPtr, INT index) 787 { 970 788 CBE_ITEMDATA *item1, *item2; 971 LRESULT lret = 0; 972 973 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 974 wParam, lParam); 789 DWORD ret = 0; 790 791 item1 = get_item_data(infoPtr, index); 975 792 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { 976 793 item2 = COMBOEX_FindItem (infoPtr, index); … … 979 796 return CB_ERR; 980 797 } 981 if (item1->mask & CBEIF_LPARAM) 982 lret = (LRESULT) item1->lParam; 983 TRACE("returning 0x%08lx\n", lret); 984 return lret; 985 } 986 lret = (LRESULT)item1; 987 TRACE("non-valid result from combo, returning 0x%08lx\n", lret); 988 return lret; 989 } 990 991 992 static LRESULT 993 COMBOEX_SetCursel (HWND hwnd, WPARAM wParam, LPARAM lParam) 994 { 995 INT index = wParam; 996 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 798 if (item1->mask & CBEIF_LPARAM) ret = item1->lParam; 799 TRACE("returning 0x%08lx\n", ret); 800 } else { 801 ret = (DWORD)item1; 802 TRACE("non-valid result from combo, returning 0x%08lx\n", ret); 803 } 804 return ret; 805 } 806 807 808 static INT COMBOEX_SetCursel (COMBOEX_INFO *infoPtr, INT index) 809 { 997 810 CBE_ITEMDATA *item; 998 LRESULT lret; 999 1000 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 1001 /* FIXME: need to clear selection */ 1002 return CB_ERR; 1003 } 1004 1005 TRACE("selecting item %d text=%s\n", index, (item->pszText) ? 1006 debugstr_w(item->pszText) : "<null>"); 811 INT sel; 812 813 if (!(item = COMBOEX_FindItem(infoPtr, index))) 814 return SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0); 815 816 TRACE("selecting item %d text=%s\n", index, debugstr_txt(item->pszText)); 1007 817 infoPtr->selected = index; 1008 818 1009 lret = SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, wParam, lParam);819 sel = (INT)SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0); 1010 820 COMBOEX_SetEditText (infoPtr, item); 1011 return lret; 1012 } 1013 1014 1015 static LRESULT 1016 COMBOEX_SetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam) 1017 { 1018 INT index = wParam; 1019 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 821 return sel; 822 } 823 824 825 static DWORD COMBOEX_SetItemData (COMBOEX_INFO *infoPtr, INT index, DWORD data) 826 { 1020 827 CBE_ITEMDATA *item1, *item2; 1021 828 1022 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 1023 wParam, lParam); 829 item1 = get_item_data(infoPtr, index); 1024 830 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { 1025 831 item2 = COMBOEX_FindItem (infoPtr, index); … … 1029 835 } 1030 836 item1->mask |= CBEIF_LPARAM; 1031 item1->lParam = lParam;1032 TRACE("setting lparam to 0x%08lx\n", lParam);837 item1->lParam = data; 838 TRACE("setting lparam to 0x%08lx\n", data); 1033 839 return 0; 1034 840 } … … 1038 844 1039 845 1040 static LRESULT 1041 COMBOEX_SetItemHeight (HWND hwnd, WPARAM wParam, LPARAM lParam) 1042 { 1043 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 846 static INT COMBOEX_SetItemHeight (COMBOEX_INFO *infoPtr, INT index, UINT height) 847 { 1044 848 RECT cb_wrect, cbx_wrect, cbx_crect; 1045 LRESULT ret = 0;1046 UINT height;1047 849 1048 850 /* First, lets forward the message to the normal combo control 1049 851 just like Windows. */ 1050 if (infoPtr->hwndCombo) 1051 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam); 852 if (infoPtr->hwndCombo) 853 if (SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, 854 index, height) == CB_ERR) return CB_ERR; 1052 855 1053 856 GetWindowRect (infoPtr->hwndCombo, &cb_wrect); 1054 GetWindowRect ( hwnd, &cbx_wrect);1055 GetClientRect ( hwnd, &cbx_crect);857 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect); 858 GetClientRect (infoPtr->hwndSelf, &cbx_crect); 1056 859 /* the height of comboex as height of the combo + comboex border */ 1057 860 height = cb_wrect.bottom-cb_wrect.top … … 1064 867 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom, 1065 868 cbx_wrect.right-cbx_wrect.left, height); 1066 SetWindowPos (hwnd, HWND_TOP, 0, 0, 1067 cbx_wrect.right-cbx_wrect.left, 1068 height, 869 SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0, 870 cbx_wrect.right-cbx_wrect.left, height, 1069 871 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); 1070 872 1071 return ret;873 return 0; 1072 874 } 1073 875 … … 1076 878 1077 879 1078 static LRESULT 1079 COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) 1080 { 1081 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam; 880 static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs) 881 { 882 WCHAR COMBOBOX[] = { 'C', 'o', 'm', 'b', 'o', 'B', 'o', 'x', 0 }; 883 WCHAR EDIT[] = { 'E', 'D', 'I', 'T', 0 }; 884 WCHAR NIL[] = { 0 }; 1082 885 COMBOEX_INFO *infoPtr; 1083 886 DWORD dwComboStyle; 1084 LOGFONTA mylogfont; 1085 CBE_ITEMDATA *item; 887 LOGFONTW mylogfont; 1086 888 RECT wnrc1, clrc1, cmbwrc; 1087 LONG test;1088 889 INT i; 1089 890 1090 891 /* allocate memory for info structure */ 1091 892 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO)); 1092 if (infoPtr == NULL) { 1093 ERR("could not allocate info memory!\n"); 1094 return 0; 1095 } 893 if (!infoPtr) return -1; 1096 894 1097 895 /* initialize info structure */ 1098 1099 infoPtr->items = NULL; 1100 infoPtr->nb_items = 0; 896 /* note that infoPtr is allocated zero-filled */ 897 1101 898 infoPtr->hwndSelf = hwnd; 1102 899 infoPtr->selected = -1; 1103 900 1104 infoPtr->bUnicode = IsWindowUnicode (hwnd); 1105 1106 i = SendMessageA(GetParent (hwnd), 1107 WM_NOTIFYFORMAT, hwnd, NF_QUERY); 1108 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { 1109 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", 1110 i); 901 infoPtr->unicode = IsWindowUnicode (hwnd); 902 903 i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, hwnd, NF_QUERY); 904 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) { 905 WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i); 1111 906 i = NFR_ANSI; 1112 907 } 1113 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;1114 1115 SetWindowLong A(hwnd, 0, (DWORD)infoPtr);908 infoPtr->NtfUnicode = (i == NFR_UNICODE); 909 910 SetWindowLongW (hwnd, 0, (DWORD)infoPtr); 1116 911 1117 912 /* create combo box */ 1118 dwComboStyle = GetWindowLong A(hwnd, GWL_STYLE) &913 dwComboStyle = GetWindowLongW (hwnd, GWL_STYLE) & 1119 914 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD); 1120 915 … … 1136 931 /* (allow space for the icons). */ 1137 932 1138 infoPtr->hwndCombo = CreateWindow A ("ComboBox", "",933 infoPtr->hwndCombo = CreateWindowW (COMBOBOX, NIL, 1139 934 /* following line added to match native */ 1140 935 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | … … 1143 938 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle, 1144 939 cs->y, cs->x, cs->cx, cs->cy, hwnd, 1145 (HMENU) GetWindowLong A(hwnd, GWL_ID),1146 GetWindowLong A(hwnd, GWL_HINSTANCE), NULL);940 (HMENU) GetWindowLongW (hwnd, GWL_ID), 941 GetWindowLongW (hwnd, GWL_HINSTANCE), NULL); 1147 942 1148 943 /* … … 1158 953 * data structure. 1159 954 */ 1160 test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo); 1161 if (!test || ((COMBOEX_INFO *)test != infoPtr)) { 1162 SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr); 1163 } 1164 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo, 955 SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd); 956 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo, 1165 957 GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc); 1166 958 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); … … 1172 964 */ 1173 965 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) { 1174 infoPtr->hwndEdit = CreateWindowEx A (0, "EDIT", "",966 infoPtr->hwndEdit = CreateWindowExW (0, EDIT, NIL, 1175 967 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL, 1176 968 0, 0, 0, 0, /* will set later */ 1177 969 infoPtr->hwndCombo, 1178 (HMENU) GetWindowLong A(hwnd, GWL_ID),1179 GetWindowLong A(hwnd, GWL_HINSTANCE),970 (HMENU) GetWindowLongW (hwnd, GWL_ID), 971 GetWindowLongW (hwnd, GWL_HINSTANCE), 1180 972 NULL); 1181 973 … … 1191 983 * data structure. 1192 984 */ 1193 test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo); 1194 if (!test || ((COMBOEX_INFO *)test != infoPtr)) { 1195 SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr); 1196 } 1197 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit, 985 SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd); 986 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit, 1198 987 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc); 1199 988 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); 1200 }1201 else {1202 infoPtr->hwndEdit = 0;1203 infoPtr->font = 0;1204 989 } 1205 990 … … 1209 994 */ 1210 995 if (!infoPtr->font) { 1211 SystemParametersInfo A(SPI_GETICONTITLELOGFONT, sizeof(mylogfont),996 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), 1212 997 &mylogfont, 0); 1213 infoPtr->font = infoPtr-> hDefaultFont = CreateFontIndirectA(&mylogfont);998 infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont); 1214 999 } 1215 1000 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0); … … 1219 1004 } 1220 1005 1221 COMBOEX_ReSize ( hwnd,infoPtr);1006 COMBOEX_ReSize (infoPtr); 1222 1007 1223 1008 /* Above is fairly certain, below is much less certain. */ … … 1245 1030 /* 1246 1031 * Create an item structure to represent the data in the 1247 * EDIT control. 1032 * EDIT control. It is allocated zero-filled. 1248 1033 */ 1249 i tem= (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));1250 i tem->next = NULL;1251 item->pszText = NULL;1252 item->mask = 0;1253 infoPtr->edit = item;1034 infoPtr->edit = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA)); 1035 if (!infoPtr->edit) { 1036 COMBOEX_Destroy(infoPtr); 1037 return -1; 1038 } 1254 1039 1255 1040 return 0; … … 1257 1042 1258 1043 1259 inline static LRESULT 1260 COMBOEX_Command (HWND hwnd, WPARAM wParam, LPARAM lParam) 1044 static LRESULT COMBOEX_Command (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 1261 1045 { 1262 1046 LRESULT lret; 1263 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);1264 1047 INT command = HIWORD(wParam); 1265 1048 CBE_ITEMDATA *item = 0; … … 1268 1051 NMCBEENDEDITW cbeend; 1269 1052 DWORD oldflags; 1053 HWND parent = GetParent (infoPtr->hwndSelf); 1270 1054 1271 1055 TRACE("for command %d\n", command); … … 1274 1058 { 1275 1059 case CBN_DROPDOWN: 1276 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1277 (LPARAM)hwnd); 1060 SetFocus (infoPtr->hwndCombo); 1061 ShowWindow (infoPtr->hwndEdit, SW_HIDE); 1062 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1063 1064 case CBN_CLOSEUP: 1065 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1278 1066 /* 1279 1067 * from native trace of first dropdown after typing in URL in IE4 … … 1289 1077 * the rest is supposition 1290 1078 */ 1079 ShowWindow (infoPtr->hwndEdit, SW_SHOW); 1080 InvalidateRect (infoPtr->hwndCombo, 0, TRUE); 1081 InvalidateRect (infoPtr->hwndEdit, 0, TRUE); 1291 1082 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); 1292 1083 if (cursel == -1) { … … 1295 1086 n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0); 1296 1087 for (cursel = 0; cursel < n; cursel++){ 1297 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 1298 CB_GETITEMDATA, 1299 cursel, 0); 1088 item = get_item_data(infoPtr, cursel); 1300 1089 if ((INT)item == CB_ERR) break; 1301 if ( lstrcmpiW(item->pszText, wintext) == 0) break;1090 if (!lstrcmpiW(COMBOEX_GetText(infoPtr, item), wintext)) break; 1302 1091 } 1303 1092 if ((cursel == n) || ((INT)item == CB_ERR)) { … … 1310 1099 } 1311 1100 else { 1312 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 1313 CB_GETITEMDATA, 1314 cursel, 0); 1101 item = get_item_data(infoPtr, cursel); 1315 1102 if ((INT)item == CB_ERR) { 1316 1103 TRACE("failed to find match??? item=%p cursel=%d\n", … … 1332 1119 cbeend.iWhy = CBENF_DROPDOWN; 1333 1120 1334 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) { 1335 /* abort the change */ 1336 TRACE("Notify requested abort of change\n"); 1337 return 0; 1338 } 1121 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, COMBOEX_GetText(infoPtr, item))) return 0; 1339 1122 } 1340 1123 … … 1343 1126 if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) { 1344 1127 infoPtr->selected = cursel; 1345 SendMessageW ( hwnd, CB_SETCURSEL, cursel, 0);1128 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, cursel, 0); 1346 1129 SetFocus(infoPtr->hwndCombo); 1347 1130 } … … 1369 1152 infoPtr->selected = oldItem; 1370 1153 COMBOEX_SetEditText (infoPtr, item); 1371 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1372 (LPARAM)hwnd); 1154 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1373 1155 1374 1156 case CBN_SELENDOK: … … 1377 1159 * issuing the message. IE4 depends on this. 1378 1160 */ 1379 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1380 (LPARAM)hwnd); 1161 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1381 1162 1382 1163 case CBN_KILLFOCUS: … … 1392 1173 * return 0 1393 1174 */ 1394 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1395 (LPARAM)hwnd); 1175 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1396 1176 if (infoPtr->flags & WCBE_ACTEDIT) { 1397 1177 GetWindowTextW (infoPtr->hwndEdit, wintext, 260); … … 1402 1182 1403 1183 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); 1404 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) { 1405 /* abort the change */ 1406 TRACE("Notify requested abort of change\n"); 1407 return 0; 1408 } 1184 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) return 0; 1409 1185 } 1410 1186 /* possible CB_GETCURSEL */ … … 1412 1188 return 0; 1413 1189 1414 case CBN_CLOSEUP:1415 1190 default: 1416 1191 /* … … 1420 1195 * after passing the command to the parent of the ComboEx. 1421 1196 */ 1422 lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1423 (LPARAM)hwnd); 1197 lret = SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); 1424 1198 if (infoPtr->hwndEdit) 1425 1199 SetFocus(infoPtr->hwndEdit); … … 1430 1204 1431 1205 1432 inline static LRESULT 1433 COMBOEX_WM_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 1434 { 1435 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1436 DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)lParam; 1206 static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis) 1207 { 1437 1208 CBE_ITEMDATA *item, *olditem; 1209 NMCOMBOBOXEXW nmcit; 1438 1210 INT i; 1439 NMCOMBOBOXEXW nmcit;1440 1211 1441 1212 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n", … … 1460 1231 } 1461 1232 if (!item->next || (i != dis->itemID)) { 1462 FIXME("COMBOBOXEX item structures broken. Please report!\n");1233 ERR("COMBOBOXEX item structures broken. Please report!\n"); 1463 1234 return FALSE; 1464 1235 } … … 1468 1239 infoPtr->nb_items--; 1469 1240 1470 COMBOEX_CopyItem (infoPtr, olditem, &nmcit.ceItem); 1241 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem)); 1242 COMBOEX_CopyItem (olditem, &nmcit.ceItem); 1471 1243 COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit); 1472 1244 1473 if (olditem->pszText) 1474 COMCTL32_Free(olditem->pszText); 1245 COMBOEX_FreeText(olditem); 1475 1246 COMCTL32_Free(olditem); 1476 1247 1477 1248 return TRUE; 1478 1479 } 1480 1481 1482 inline static LRESULT 1483 COMBOEX_DrawItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 1484 { 1485 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1486 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam; 1249 } 1250 1251 1252 static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT *dis) 1253 { 1254 WCHAR nil[] = { 0 }; 1487 1255 CBE_ITEMDATA *item = 0; 1488 1256 SIZE txtsize; 1489 1257 RECT rect; 1490 LPWSTR str; 1491 int drawimage, drawstate; 1258 LPCWSTR str = nil; 1492 1259 UINT xbase, x, y; 1493 UINT xioff = 0; /* size and spacer of image if any */1494 IMAGEINFO iinfo;1495 1260 INT len; 1496 COLORREF nbkc, ntxc; 1261 COLORREF nbkc, ntxc, bkc, txc; 1262 int drawimage, drawstate, xioff; 1497 1263 1498 1264 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0; 1499 1265 1500 /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */ 1501 if (!TRACE_ON(message)) { 1502 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n", 1503 dis->CtlType, dis->CtlID); 1504 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n", 1505 dis->itemID, dis->itemAction, dis->itemState); 1506 TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n", 1507 dis->hwndItem, dis->hDC, dis->rcItem.left, 1508 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom, 1509 dis->itemData); 1510 } 1266 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n", 1267 dis->CtlType, dis->CtlID); 1268 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n", 1269 dis->itemID, dis->itemAction, dis->itemState); 1270 TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n", 1271 dis->hwndItem, dis->hDC, dis->rcItem.left, 1272 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom, 1273 dis->itemData); 1511 1274 1512 1275 /* MSDN says: */ … … 1536 1299 { 1537 1300 RECT exrc, cbrc, edrc; 1538 GetWindowRect ( hwnd, &exrc);1301 GetWindowRect (infoPtr->hwndSelf, &exrc); 1539 1302 GetWindowRect (infoPtr->hwndCombo, &cbrc); 1540 1303 edrc.left=edrc.top=edrc.right=edrc.bottom=-1; … … 1558 1321 /* If draw item is -1 (edit control) setup the item pointer */ 1559 1322 if (dis->itemID == 0xffffffff) { 1560 CHAR str[260];1561 INT wlen, alen;1562 1563 1323 item = infoPtr->edit; 1564 1324 1565 1325 if (infoPtr->hwndEdit) { 1326 INT len; 1566 1327 1567 1328 /* free previous text of edit item */ 1568 if (item->pszText) { 1569 COMCTL32_Free(item->pszText); 1570 item->pszText = 0; 1571 item->mask &= ~CBEIF_TEXT; 1329 COMBOEX_FreeText(item); 1330 item->mask &= ~CBEIF_TEXT; 1331 if( (len = GetWindowTextLengthW(infoPtr->hwndEdit)) ) { 1332 item->mask |= CBEIF_TEXT; 1333 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 1334 if (item->pszText) 1335 GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1); 1336 1337 TRACE("edit control hwndEdit=%0x, text len=%d str=%s\n", 1338 infoPtr->hwndEdit, len, debugstr_txt(item->pszText)); 1572 1339 } 1573 alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str); 1574 TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n", 1575 infoPtr->hwndEdit, alen, str); 1576 if (alen > 0) { 1577 item->mask |= CBEIF_TEXT; 1578 wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0); 1579 if (wlen > 0) { 1580 item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR)); 1581 MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen); 1582 } 1583 } 1584 } 1585 } 1340 } 1341 } 1342 1586 1343 1587 1344 /* if the item pointer is not set, then get the data and locate it */ 1588 1345 if (!item) { 1589 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 1590 CB_GETITEMDATA, (WPARAM)dis->itemID, 0); 1591 if (item == (CBE_ITEMDATA *)CB_ERR) 1592 { 1593 FIXME("invalid item for id %d \n",dis->itemID); 1594 return 0; 1346 item = get_item_data(infoPtr, dis->itemID); 1347 if (item == (CBE_ITEMDATA *)CB_ERR) { 1348 ERR("invalid item for id %d \n", dis->itemID); 1349 return 0; 1350 } 1351 } 1352 1353 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); 1354 1355 xbase = CBE_STARTOFFSET; 1356 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) { 1357 INT indent = item->iIndent; 1358 if (indent == I_INDENTCALLBACK) { 1359 NMCOMBOBOXEXW nmce; 1360 ZeroMemory(&nmce, sizeof(nmce)); 1361 nmce.ceItem.mask = CBEIF_INDENT; 1362 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); 1363 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) 1364 item->iIndent = nmce.ceItem.iIndent; 1365 indent = nmce.ceItem.iIndent; 1366 } 1367 xbase += (indent * CBE_INDENT); 1368 } 1369 1370 drawimage = -2; 1371 drawstate = ILD_NORMAL; 1372 if (item->mask & CBEIF_IMAGE) 1373 drawimage = item->iImage; 1374 if (dis->itemState & ODS_COMBOEXLBOX) { 1375 /* drawing listbox entry */ 1376 if (dis->itemState & ODS_SELECTED) { 1377 if (item->mask & CBEIF_SELECTEDIMAGE) 1378 drawimage = item->iSelectedImage; 1379 drawstate = ILD_SELECTED; 1380 } 1381 } else { 1382 /* drawing combo/edit entry */ 1383 if (IsWindowVisible(infoPtr->hwndEdit)) { 1384 /* if we have an edit control, the slave the 1385 * selection state to the Edit focus state 1386 */ 1387 if (infoPtr->flags & WCBE_EDITFOCUSED) { 1388 if (item->mask & CBEIF_SELECTEDIMAGE) 1389 drawimage = item->iSelectedImage; 1390 drawstate = ILD_SELECTED; 1595 1391 } 1596 } 1597 1598 COMBOEX_DumpItem (item); 1599 1600 xbase = CBE_STARTOFFSET; 1601 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) 1602 xbase += (item->iIndent * CBE_INDENT); 1603 if (item->mask & CBEIF_IMAGE) { 1604 ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo); 1605 xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP); 1606 } 1607 1608 switch (dis->itemAction) { 1609 case ODA_FOCUS: 1610 if (dis->itemState & ODS_SELECTED /*1*/) { 1611 if ((item->mask & CBEIF_TEXT) && item->pszText) { 1612 RECT rect2; 1613 1614 len = strlenW (item->pszText); 1615 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize); 1616 rect.left = xbase + xioff - 1; 1617 rect.right = rect.left + txtsize.cx + 2; 1618 rect.top = dis->rcItem.top; 1619 rect.bottom = dis->rcItem.bottom; 1620 GetClipBox (dis->hDC, &rect2); 1621 TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n", 1622 dis->itemID, rect.left, rect.top, 1623 rect.right, rect.bottom); 1624 TRACE(" clip=(%d,%d)-(%d,%d)\n", 1625 rect2.left, rect2.top, 1626 rect2.right, rect2.bottom); 1627 1628 DrawFocusRect(dis->hDC, &rect); 1392 } else { 1393 /* if we don't have an edit control, use 1394 * the requested state. 1395 */ 1396 if (dis->itemState & ODS_SELECTED) { 1397 if (item->mask & CBEIF_SELECTEDIMAGE) 1398 drawimage = item->iSelectedImage; 1399 drawstate = ILD_SELECTED; 1629 1400 } 1630 else { 1631 FIXME("ODA_FOCUS and ODS_SELECTED but no text\n"); 1632 } 1633 } 1634 else { 1635 FIXME("ODA_FOCUS but not ODS_SELECTED\n"); 1636 } 1637 break; 1638 case ODA_SELECT: 1639 case ODA_DRAWENTIRE: 1640 drawimage = -1; 1641 drawstate = ILD_NORMAL; 1642 if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) { 1643 if (item->mask & CBEIF_IMAGE) 1644 drawimage = item->iImage; 1645 if (dis->itemState & ODS_COMBOEXLBOX) { 1646 /* drawing listbox entry */ 1647 if (dis->itemState & ODS_SELECTED) { 1648 if (item->mask & CBEIF_SELECTEDIMAGE) 1649 drawimage = item->iSelectedImage; 1650 drawstate = ILD_SELECTED; 1651 } 1652 } 1653 else { 1654 /* drawing combo/edit entry */ 1655 if (infoPtr->hwndEdit) { 1656 /* if we have an edit control, the slave the 1657 * selection state to the Edit focus state 1658 */ 1659 if (infoPtr->flags & WCBE_EDITFOCUSED) { 1660 if (item->mask & CBEIF_SELECTEDIMAGE) 1661 drawimage = item->iSelectedImage; 1662 drawstate = ILD_SELECTED; 1663 } 1664 } 1665 else { 1666 /* if we don't have an edit control, use 1667 * the requested state. 1668 */ 1669 if (dis->itemState & ODS_SELECTED) { 1670 if (item->mask & CBEIF_SELECTEDIMAGE) 1671 drawimage = item->iSelectedImage; 1672 drawstate = ILD_SELECTED; 1673 } 1674 } 1675 } 1676 } 1677 if (drawimage != -1) { 1678 TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED); 1679 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, 1680 xbase, dis->rcItem.top, drawstate); 1681 } 1682 1683 /* setup pointer to text to be drawn */ 1684 if ((item->mask & CBEIF_TEXT) && item->pszText) 1685 str = item->pszText; 1686 else 1687 str = (LPWSTR) L""; 1401 } 1402 } 1403 1404 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) { 1405 IMAGEINFO iinfo; 1406 iinfo.rcImage.left = iinfo.rcImage.right = 0; 1407 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); 1408 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; 1409 } else xioff = 0; 1410 1411 /* setup pointer to text to be drawn */ 1412 str = COMBOEX_GetText(infoPtr, item); 1413 if (!str) str = nil; 1414 1415 len = strlenW (str); 1416 GetTextExtentPoint32W (dis->hDC, str, len, &txtsize); 1417 1418 if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) { 1419 int overlay = item->iOverlay; 1420 1421 if (drawimage == I_IMAGECALLBACK) { 1422 NMCOMBOBOXEXW nmce; 1423 ZeroMemory(&nmce, sizeof(nmce)); 1424 nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE; 1425 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); 1426 if (drawstate == ILD_NORMAL) { 1427 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage; 1428 drawimage = nmce.ceItem.iImage; 1429 } else if (drawstate == ILD_SELECTED) { 1430 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iSelectedImage = nmce.ceItem.iSelectedImage; 1431 drawimage = nmce.ceItem.iSelectedImage; 1432 } else ERR("Bad draw state = %d\n", drawstate); 1433 } 1434 1435 if (overlay == I_IMAGECALLBACK) { 1436 NMCOMBOBOXEXW nmce; 1437 ZeroMemory(&nmce, sizeof(nmce)); 1438 nmce.ceItem.mask = CBEIF_OVERLAY; 1439 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); 1440 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) 1441 item->iOverlay = nmce.ceItem.iOverlay; 1442 overlay = nmce.ceItem.iOverlay; 1443 } 1444 1445 if (drawimage >= 0 && 1446 !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) { 1447 if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1); 1448 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top, 1449 drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0)); 1450 } 1688 1451 1689 1452 /* now draw the text */ 1690 len = lstrlenW (str); 1691 GetTextExtentPointW (dis->hDC, str, len, &txtsize); 1692 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ? 1693 COLOR_HIGHLIGHT : COLOR_WINDOW); 1694 SetBkColor (dis->hDC, nbkc); 1695 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ? 1696 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT); 1697 SetTextColor (dis->hDC, ntxc); 1698 x = xbase + xioff; 1699 y = dis->rcItem.top + 1700 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2; 1701 rect.left = x; 1702 rect.right = x + txtsize.cx; 1703 rect.top = dis->rcItem.top + 1; 1704 rect.bottom = dis->rcItem.bottom - 1; 1705 TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n", 1706 dis->itemID, rect.left, rect.top, rect.right, rect.bottom); 1707 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED, 1708 &rect, str, len, 0); 1709 if (dis->itemState & ODS_FOCUS) { 1710 rect.top -= 1; 1711 rect.bottom += 1; 1712 rect.left -= 1; 1713 rect.right += 1; 1714 TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n", 1715 dis->itemID, rect.left, rect.top, rect.right, rect.bottom); 1716 DrawFocusRect (dis->hDC, &rect); 1717 } 1718 break; 1719 default: 1720 FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n", 1721 hwnd, wParam, lParam, dis->itemAction); 1453 if (!IsWindowVisible (infoPtr->hwndEdit)) { 1454 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ? 1455 COLOR_HIGHLIGHT : COLOR_WINDOW); 1456 bkc = SetBkColor (dis->hDC, nbkc); 1457 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ? 1458 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT); 1459 txc = SetTextColor (dis->hDC, ntxc); 1460 x = xbase + xioff; 1461 y = dis->rcItem.top + 1462 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2; 1463 rect.left = x; 1464 rect.right = x + txtsize.cx; 1465 rect.top = dis->rcItem.top + 1; 1466 rect.bottom = dis->rcItem.bottom - 1; 1467 TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n", 1468 dis->itemID, rect.left, rect.top, rect.right, rect.bottom); 1469 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED, 1470 &rect, str, len, 0); 1471 SetBkColor (dis->hDC, bkc); 1472 SetTextColor (dis->hDC, txc); 1473 } 1474 } 1475 1476 if (dis->itemAction & ODA_FOCUS) { 1477 rect.left = xbase + xioff - 1; 1478 rect.right = rect.left + txtsize.cx + 2; 1479 rect.top = dis->rcItem.top; 1480 rect.bottom = dis->rcItem.bottom; 1481 DrawFocusRect(dis->hDC, &rect); 1722 1482 } 1723 1483 … … 1726 1486 1727 1487 1728 static LRESULT 1729 COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) 1730 { 1731 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1732 1488 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr) 1489 { 1733 1490 if (infoPtr->hwndCombo) 1734 1491 DestroyWindow (infoPtr->hwndCombo); … … 1740 1497 1741 1498 if (infoPtr->items) { 1742 CBE_ITEMDATA *this, *next; 1743 1744 this = infoPtr->items; 1745 while (this) { 1746 next = (CBE_ITEMDATA *)this->next; 1747 if ((this->mask & CBEIF_TEXT) && this->pszText) 1748 COMCTL32_Free (this->pszText); 1749 COMCTL32_Free (this); 1750 this = next; 1751 } 1752 } 1753 1754 if (infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont); 1499 CBE_ITEMDATA *item, *next; 1500 1501 item = infoPtr->items; 1502 while (item) { 1503 next = (CBE_ITEMDATA *)item->next; 1504 COMBOEX_FreeText (item); 1505 COMCTL32_Free (item); 1506 item = next; 1507 } 1508 infoPtr->items = 0; 1509 } 1510 1511 if (infoPtr->defaultFont) 1512 DeleteObject (infoPtr->defaultFont); 1755 1513 1756 1514 /* free comboex info data */ 1757 1515 COMCTL32_Free (infoPtr); 1758 SetWindowLong A (hwnd, 0, 0);1516 SetWindowLongW (infoPtr->hwndSelf, 0, 0); 1759 1517 return 0; 1760 1518 } 1761 1519 1762 1520 1763 static LRESULT 1764 COMBOEX_MeasureItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 1765 { 1766 /*COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);*/ 1767 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam; 1521 static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO *infoPtr, MEASUREITEMSTRUCT *mis) 1522 { 1523 SIZE mysize; 1768 1524 HDC hdc; 1769 SIZE mysize;1770 1525 1771 1526 hdc = GetDC (0); … … 1775 1530 1776 1531 TRACE("adjusted height hwnd=%08x, height=%d\n", 1777 hwnd, mis->itemHeight);1532 infoPtr->hwndSelf, mis->itemHeight); 1778 1533 1779 1534 return 0; … … 1781 1536 1782 1537 1783 static LRESULT 1784 COMBOEX_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) 1538 static LRESULT COMBOEX_NCCreate (HWND hwnd) 1785 1539 { 1786 1540 /* WARNING: The COMBOEX_INFO structure is not yet created */ 1787 1541 DWORD oldstyle, newstyle; 1788 1542 1789 oldstyle = (DWORD)GetWindowLong A(hwnd, GWL_STYLE);1543 oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE); 1790 1544 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL); 1791 1545 if (newstyle != oldstyle) { 1792 1546 TRACE("req style %08lx, reseting style %08lx\n", 1793 1547 oldstyle, newstyle); 1794 SetWindowLong A(hwnd, GWL_STYLE, newstyle);1548 SetWindowLongW (hwnd, GWL_STYLE, newstyle); 1795 1549 } 1796 1550 return 1; … … 1798 1552 1799 1553 1800 static LRESULT 1801 COMBOEX_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) 1802 { 1803 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1804 INT i; 1805 1554 static LRESULT COMBOEX_NotifyFormat (COMBOEX_INFO *infoPtr, LPARAM lParam) 1555 { 1806 1556 if (lParam == NF_REQUERY) { 1807 i = SendMessageA(GetParent (hwnd),1557 INT i = SendMessageW(GetParent (infoPtr->hwndSelf), 1808 1558 WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY); 1809 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {1810 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",1811 i);1812 i = NFR_ANSI;1813 }1814 1559 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; 1815 return (LRESULT)i; 1816 } 1817 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI); 1818 } 1819 1820 1821 static LRESULT 1822 COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) 1823 { 1824 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1825 RECT rect; 1826 1827 GetWindowRect (hwnd, &rect); 1828 TRACE("my rect (%d,%d)-(%d,%d)\n", 1829 rect.left, rect.top, rect.right, rect.bottom); 1830 1831 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left, 1832 rect.bottom - rect.top, TRUE); 1560 } 1561 return infoPtr->NtfUnicode ? NFR_UNICODE : NFR_ANSI; 1562 } 1563 1564 1565 static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height) 1566 { 1567 TRACE("(width=%d, height=%d)\n", width, height); 1568 1569 MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE); 1833 1570 1834 1571 COMBOEX_AdjustEditPos (infoPtr); … … 1838 1575 1839 1576 1840 static LRESULT 1841 COMBOEX_WindowPosChanging (HWND hwnd, WPARAM wParam, LPARAM lParam) 1842 { 1843 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 1577 static LRESULT COMBOEX_WindowPosChanging (COMBOEX_INFO *infoPtr, WINDOWPOS *wp) 1578 { 1844 1579 RECT cbx_wrect, cbx_crect, cb_wrect; 1845 1580 UINT width, height; 1846 WINDOWPOS *wp = (WINDOWPOS *)lParam; 1847 1848 GetWindowRect (hwnd, &cbx_wrect); 1849 GetClientRect (hwnd, &cbx_crect); 1581 1582 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect); 1583 GetClientRect (infoPtr->hwndSelf, &cbx_crect); 1850 1584 GetWindowRect (infoPtr->hwndCombo, &cb_wrect); 1851 1585 … … 1888 1622 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 1889 1623 { 1890 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo); 1624 HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); 1625 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); 1891 1626 NMCBEENDEDITW cbeend; 1892 1627 WCHAR edit_text[260]; 1893 COLORREF nbkc,obkc;1628 COLORREF obkc; 1894 1629 HDC hDC; 1895 1630 RECT rect; … … 1904 1639 { 1905 1640 1906 1641 case WM_CHAR: 1907 1642 /* handle (ignore) the return character */ 1908 1643 if (wParam == VK_RETURN) return 0; 1909 1644 /* all other characters pass into the real Edit */ 1910 return CallWindowProc A(infoPtr->prevEditWndProc,1645 return CallWindowProcW (infoPtr->prevEditWndProc, 1911 1646 hwnd, uMsg, wParam, lParam); 1912 1647 1913 1648 case WM_ERASEBKGND: 1914 1649 /* 1915 1650 * The following was determined by traces of the native 1916 1651 */ 1917 1652 hDC = (HDC) wParam; 1918 nbkc = GetSysColor (COLOR_WINDOW); 1919 obkc = SetBkColor (hDC, nbkc); 1653 obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW)); 1920 1654 GetClientRect (hwnd, &rect); 1921 1655 TRACE("erasing (%d,%d)-(%d,%d)\n", … … 1923 1657 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); 1924 1658 SetBkColor (hDC, obkc); 1925 return CallWindowProc A(infoPtr->prevEditWndProc,1659 return CallWindowProcW (infoPtr->prevEditWndProc, 1926 1660 hwnd, uMsg, wParam, lParam); 1927 1661 1928 1929 INT oldItem, selected ;1662 case WM_KEYDOWN: { 1663 INT oldItem, selected, step = 1; 1930 1664 CBE_ITEMDATA *item; 1931 1665 … … 1960 1694 cbeend.iWhy = CBENF_ESCAPE; 1961 1695 1962 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) { 1963 /* abort the change */ 1964 TRACE("Notify requested abort of change\n"); 1965 return 0; 1966 } 1967 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0); 1696 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0; 1697 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); 1968 1698 InvalidateRect (infoPtr->hwndCombo, 0, 0); 1969 1699 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) { … … 2010 1740 item = COMBOEX_FindItem (infoPtr, selected); 2011 1741 TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n", 2012 selected, debugstr_ w(item->pszText));1742 selected, debugstr_txt(item->pszText)); 2013 1743 TRACE("handling VK_RETURN, edittext=%s\n", 2014 1744 debugstr_w(edit_text)); 2015 if (lstrcmpiW ( item->pszText, edit_text)) {1745 if (lstrcmpiW (COMBOEX_GetText(infoPtr, item), edit_text)) { 2016 1746 /* strings not equal -- indicate edit has changed */ 2017 1747 selected = -1; … … 2040 1770 break; 2041 1771 1772 case VK_UP: 1773 step = -1; 1774 case VK_DOWN: 1775 /* by default, step is 1 */ 1776 oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0); 1777 if (oldItem >= 0 && oldItem + step >= 0) 1778 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0); 1779 return 0; 2042 1780 default: 2043 return CallWindowProc A(infoPtr->prevEditWndProc,1781 return CallWindowProcW (infoPtr->prevEditWndProc, 2044 1782 hwnd, uMsg, wParam, lParam); 2045 1783 } … … 2047 1785 } 2048 1786 2049 1787 case WM_SETFOCUS: 2050 1788 /* remember the focus to set state of icon */ 2051 lret = CallWindowProc A(infoPtr->prevEditWndProc,1789 lret = CallWindowProcW (infoPtr->prevEditWndProc, 2052 1790 hwnd, uMsg, wParam, lParam); 2053 1791 infoPtr->flags |= WCBE_EDITFOCUSED; 2054 1792 return lret; 2055 1793 2056 1794 case WM_KILLFOCUS: 2057 1795 /* 2058 1796 * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS … … 2072 1810 /* fall through */ 2073 1811 2074 2075 return CallWindowProc A(infoPtr->prevEditWndProc,1812 default: 1813 return CallWindowProcW (infoPtr->prevEditWndProc, 2076 1814 hwnd, uMsg, wParam, lParam); 2077 1815 } … … 2083 1821 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 2084 1822 { 2085 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo); 1823 HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); 1824 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); 2086 1825 NMCBEENDEDITW cbeend; 2087 1826 NMMOUSE nmmse; 2088 COLORREF nbkc,obkc;1827 COLORREF obkc; 2089 1828 HDC hDC; 2090 1829 HWND focusedhwnd; … … 2101 1840 2102 1841 case CB_FINDSTRINGEXACT: 2103 return COMBOEX_FindStringExact (infoPtr, wParam,lParam);1842 return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam); 2104 1843 2105 1844 case WM_DRAWITEM: … … 2110 1849 */ 2111 1850 ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX; 2112 return CallWindowProc A(infoPtr->prevComboWndProc,1851 return CallWindowProcW (infoPtr->prevComboWndProc, 2113 1852 hwnd, uMsg, wParam, lParam); 2114 1853 … … 2118 1857 */ 2119 1858 hDC = (HDC) wParam; 2120 nbkc = GetSysColor (COLOR_WINDOW); 2121 obkc = SetBkColor (hDC, nbkc); 1859 obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW)); 2122 1860 GetClientRect (hwnd, &rect); 2123 1861 TRACE("erasing (%d,%d)-(%d,%d)\n", … … 2125 1863 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); 2126 1864 SetBkColor (hDC, obkc); 2127 return CallWindowProc A(infoPtr->prevComboWndProc,1865 return CallWindowProcW (infoPtr->prevComboWndProc, 2128 1866 hwnd, uMsg, wParam, lParam); 2129 1867 … … 2140 1878 nmmse.dwHitInfo = lParam; 2141 1879 COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse); 2142 return CallWindowProc A(infoPtr->prevComboWndProc,1880 return CallWindowProcW (infoPtr->prevComboWndProc, 2143 1881 hwnd, uMsg, wParam, lParam); 2144 1882 … … 2174 1912 2175 1913 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); 2176 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) { 2177 /* abort the change */ 2178 TRACE("Notify requested abort of change\n"); 2179 return 0; 2180 } 1914 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0; 2181 1915 } 2182 1916 /* possible CB_GETCURSEL */ … … 2219 1953 */ 2220 1954 WCHAR edit_text[260]; 2221 WCHAR *lastwrk;2222 INT selected , cnt;1955 LPCWSTR lastwrk; 1956 INT selected; 2223 1957 CBE_ITEMDATA *item; 2224 1958 … … 2231 1965 if (selected == -1) { 2232 1966 lastwrk = infoPtr->edit->pszText; 2233 cnt = lstrlenW (lastwrk);2234 if (cnt >= 259) cnt = 259;2235 1967 } 2236 1968 else { 2237 1969 item = COMBOEX_FindItem (infoPtr, selected); 2238 cnt = lstrlenW (item->pszText); 2239 lastwrk = item->pszText; 2240 if (cnt >= 259) cnt = 259; 1970 lastwrk = COMBOEX_GetText(infoPtr, item); 2241 1971 } 2242 1972 2243 1973 TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n", 2244 selected, debugstr_w(lastwrk));1974 selected, debugstr_w(lastwrk)); 2245 1975 TRACE("handling EN_CHANGE, edittext=%s\n", 2246 1976 debugstr_w(edit_text)); 2247 1977 2248 1978 /* lstrcmpiW is between lastworkingURL and GetWindowText */ 2249 2250 1979 if (lstrcmpiW (lastwrk, edit_text)) { 2251 1980 /* strings not equal -- indicate edit has changed */ … … 2295 2024 }/* fall through */ 2296 2025 default: 2297 return CallWindowProc A(infoPtr->prevComboWndProc,2026 return CallWindowProcW (infoPtr->prevComboWndProc, 2298 2027 hwnd, uMsg, wParam, lParam); 2299 2028 } … … 2309 2038 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam); 2310 2039 2311 if (! COMBOEX_GetInfoPtr (hwnd)) {2040 if (!infoPtr) { 2312 2041 if (uMsg == WM_CREATE) 2313 return COMBOEX_Create (hwnd, wParam,lParam);2042 return COMBOEX_Create (hwnd, (LPCREATESTRUCTA)lParam); 2314 2043 if (uMsg == WM_NCCREATE) 2315 COMBOEX_NCCreate (hwnd , wParam, lParam);2316 return DefWindowProc A(hwnd, uMsg, wParam, lParam);2044 COMBOEX_NCCreate (hwnd); 2045 return DefWindowProcW (hwnd, uMsg, wParam, lParam); 2317 2046 } 2318 2047 2319 2048 switch (uMsg) 2320 2049 { 2321 case CBEM_DELETEITEM: /* maps to CB_DELETESTRING */2322 return COMBOEX_DeleteItem ( hwnd, wParam, lParam);2050 case CBEM_DELETEITEM: 2051 return COMBOEX_DeleteItem (infoPtr, wParam); 2323 2052 2324 2053 case CBEM_GETCOMBOCONTROL: 2325 return COMBOEX_GetComboControl (hwnd, wParam, lParam);2054 return infoPtr->hwndCombo; 2326 2055 2327 2056 case CBEM_GETEDITCONTROL: 2328 return COMBOEX_GetEditControl (hwnd, wParam, lParam);2057 return infoPtr->hwndEdit; 2329 2058 2330 2059 case CBEM_GETEXTENDEDSTYLE: 2331 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);2060 return infoPtr->dwExtStyle; 2332 2061 2333 2062 case CBEM_GETIMAGELIST: 2334 return COMBOEX_GetImageList (hwnd, wParam, lParam);2063 return (LRESULT)infoPtr->himl; 2335 2064 2336 2065 case CBEM_GETITEMA: 2337 return COMBOEX_GetItemA (hwnd, wParam,lParam);2066 return (LRESULT)COMBOEX_GetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); 2338 2067 2339 2068 case CBEM_GETITEMW: 2340 return COMBOEX_GetItemW (hwnd, wParam,lParam);2069 return (LRESULT)COMBOEX_GetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); 2341 2070 2342 2071 case CBEM_GETUNICODEFORMAT: 2343 return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);2072 return infoPtr->unicode; 2344 2073 2345 2074 case CBEM_HASEDITCHANGED: 2346 return COMBOEX_HasEditChanged ( hwnd, wParam, lParam);2075 return COMBOEX_HasEditChanged (infoPtr); 2347 2076 2348 2077 case CBEM_INSERTITEMA: 2349 return COMBOEX_InsertItemA ( hwnd, wParam,lParam);2078 return COMBOEX_InsertItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); 2350 2079 2351 2080 case CBEM_INSERTITEMW: 2352 return COMBOEX_InsertItemW ( hwnd, wParam,lParam);2353 2354 case CBEM_SETEXSTYLE: /* FIXME: obsoleted, should be the same as: */2081 return COMBOEX_InsertItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); 2082 2083 case CBEM_SETEXSTYLE: 2355 2084 case CBEM_SETEXTENDEDSTYLE: 2356 return COMBOEX_SetExtendedStyle ( hwnd, wParam,lParam);2085 return COMBOEX_SetExtendedStyle (infoPtr, (DWORD)wParam, (DWORD)lParam); 2357 2086 2358 2087 case CBEM_SETIMAGELIST: 2359 return COMBOEX_SetImageList (hwnd, wParam,lParam);2088 return (LRESULT)COMBOEX_SetImageList (infoPtr, (HIMAGELIST)lParam); 2360 2089 2361 2090 case CBEM_SETITEMA: 2362 return COMBOEX_SetItemA ( hwnd, wParam,lParam);2091 return COMBOEX_SetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); 2363 2092 2364 2093 case CBEM_SETITEMW: 2365 return COMBOEX_SetItemW ( hwnd, wParam,lParam);2094 return COMBOEX_SetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); 2366 2095 2367 2096 case CBEM_SETUNICODEFORMAT: 2368 return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam); 2369 2097 return COMBOEX_SetUnicodeFormat (infoPtr, wParam); 2098 2099 /*case CBEM_SETWINDOWTHEME: 2100 FIXME("CBEM_SETWINDOWTHEME: stub\n");*/ 2370 2101 2371 2102 /* Combo messages we are not sure if we need to process or just forward */ … … 2382 2113 FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n", 2383 2114 uMsg, wParam, lParam); 2384 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);2385 2115 2386 2116 /* Combo messages OK to just forward to the regular COMBO */ … … 2391 2121 case CB_SETEXTENDEDUI: 2392 2122 case CB_SHOWDROPDOWN: 2393 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);2123 return SendMessageW (infoPtr->hwndCombo, uMsg, wParam, lParam); 2394 2124 2395 2125 /* Combo messages we need to process specially */ 2396 2126 case CB_FINDSTRINGEXACT: 2397 return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd), 2398 wParam, lParam); 2127 return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam); 2399 2128 2400 2129 case CB_GETITEMDATA: 2401 return COMBOEX_GetItemData ( hwnd, wParam, lParam);2130 return COMBOEX_GetItemData (infoPtr, (INT)wParam); 2402 2131 2403 2132 case CB_SETCURSEL: 2404 return COMBOEX_SetCursel ( hwnd, wParam, lParam);2133 return COMBOEX_SetCursel (infoPtr, (INT)wParam); 2405 2134 2406 2135 case CB_SETITEMDATA: 2407 return COMBOEX_SetItemData ( hwnd, wParam,lParam);2136 return COMBOEX_SetItemData (infoPtr, (INT)wParam, (DWORD)lParam); 2408 2137 2409 2138 case CB_SETITEMHEIGHT: 2410 return COMBOEX_SetItemHeight ( hwnd, wParam,lParam);2139 return COMBOEX_SetItemHeight (infoPtr, (INT)wParam, (UINT)lParam); 2411 2140 2412 2141 … … 2414 2143 /* Window messages passed to parent */ 2415 2144 case WM_COMMAND: 2416 return COMBOEX_Command ( hwnd, wParam, lParam);2145 return COMBOEX_Command (infoPtr, wParam, lParam); 2417 2146 2418 2147 case WM_NOTIFY: 2419 2148 if (infoPtr->NtfUnicode) 2420 return SendMessageW (GetParent (hwnd), 2421 uMsg, wParam, lParam); 2149 return SendMessageW (GetParent (hwnd), uMsg, wParam, lParam); 2422 2150 else 2423 return SendMessageA (GetParent (hwnd), 2424 uMsg, wParam, lParam); 2151 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); 2425 2152 2426 2153 2427 2154 /* Window messages we need to process */ 2428 2155 case WM_DELETEITEM: 2429 return COMBOEX_WM_DeleteItem ( hwnd, wParam,lParam);2156 return COMBOEX_WM_DeleteItem (infoPtr, (DELETEITEMSTRUCT *)lParam); 2430 2157 2431 2158 case WM_DRAWITEM: 2432 return COMBOEX_DrawItem ( hwnd, wParam,lParam);2159 return COMBOEX_DrawItem (infoPtr, (DRAWITEMSTRUCT *)lParam); 2433 2160 2434 2161 case WM_DESTROY: 2435 return COMBOEX_Destroy ( hwnd, wParam, lParam);2162 return COMBOEX_Destroy (infoPtr); 2436 2163 2437 2164 case WM_MEASUREITEM: 2438 return COMBOEX_MeasureItem ( hwnd, wParam,lParam);2165 return COMBOEX_MeasureItem (infoPtr, (MEASUREITEMSTRUCT *)lParam); 2439 2166 2440 2167 case WM_NOTIFYFORMAT: 2441 return COMBOEX_NotifyFormat ( hwnd, wParam, lParam);2168 return COMBOEX_NotifyFormat (infoPtr, lParam); 2442 2169 2443 2170 case WM_SIZE: 2444 return COMBOEX_Size ( hwnd, wParam, lParam);2171 return COMBOEX_Size (infoPtr, LOWORD(lParam), HIWORD(lParam)); 2445 2172 2446 2173 case WM_WINDOWPOSCHANGING: 2447 return COMBOEX_WindowPosChanging ( hwnd, wParam,lParam);2174 return COMBOEX_WindowPosChanging (infoPtr, (WINDOWPOS *)lParam); 2448 2175 2449 2176 default: 2450 2177 if (uMsg >= WM_USER) 2451 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 2452 uMsg, wParam, lParam); 2453 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 2178 ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam); 2179 return DefWindowProcW (hwnd, uMsg, wParam, lParam); 2454 2180 } 2455 2181 return 0; … … 2457 2183 2458 2184 2459 VOID 2460 COMBOEX_Register (void) 2461 { 2462 WNDCLASSA wndClass; 2463 2464 ZeroMemory (&wndClass, sizeof(WNDCLASSA)); 2185 void COMBOEX_Register (void) 2186 { 2187 WNDCLASSW wndClass; 2188 2189 ZeroMemory (&wndClass, sizeof(WNDCLASSW)); 2465 2190 wndClass.style = CS_GLOBALCLASS; 2466 2191 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc; 2467 2192 wndClass.cbClsExtra = 0; 2468 2193 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *); 2469 wndClass.hCursor = LoadCursor A (0, IDC_ARROWA);2194 wndClass.hCursor = LoadCursorW (0, IDC_ARROWW); 2470 2195 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 2471 wndClass.lpszClassName = WC_COMBOBOXEX A;2196 wndClass.lpszClassName = WC_COMBOBOXEXW; 2472 2197 2473 RegisterClassA (&wndClass); 2474 2475 ComboExInfo = GlobalAddAtomA("CC32SubclassInfo"); 2476 } 2477 2478 2479 VOID 2480 COMBOEX_Unregister (void) 2481 { 2482 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL); 2483 } 2484 2198 RegisterClassW (&wndClass); 2199 } 2200 2201 2202 void COMBOEX_Unregister (void) 2203 { 2204 UnregisterClassW (WC_COMBOBOXEXW, (HINSTANCE)NULL); 2205 } 2206 -
trunk/src/comctl32/comctl32.def
r7815 r8382 1 ; $Id: comctl32.def,v 1.2 5 2002-02-06 17:23:18sandervl Exp $1 ; $Id: comctl32.def,v 1.26 2002-05-08 11:24:59 sandervl Exp $ 2 2 LIBRARY COMCTL32 INITINSTANCE 3 3 DESCRIPTION 'Odin32 System DLL - ComCtl32 - Common Controls Library' … … 15 15 DPA_SaveStream = _DPA_SaveStream@16 @10 16 16 DPA_Merge = _DPA_Merge@24 @11 17 CreatePropertySheetPage = _CreatePropertySheetPageA@4 @1217 ;;12 stub Cctl1632_ThunkData32 18 18 MakeDragList = _MakeDragList@4 @13 19 19 LBItemFromPt = _LBItemFromPt@16 @14 … … 107 107 CreateMRUListLazyA = _CreateMRUListLazyA@16 @157 108 108 109 ;;163 stub CreatePage 110 ;;164 stub CreateProxyPage 111 109 112 AddMRUData = _AddMRUData@12 @167 110 113 FindMRUData = _FindMRUData@16 @169 -
trunk/src/comctl32/comctl32.h
r7815 r8382 1 /* $Id: comctl32.h,v 1.21 2002-02-06 17:23:18 sandervl Exp $ */2 /* 3 * Win32 common controls implementation1 /****************************************************************************** 2 * 3 * Common definitions (resource ids and global variables) 4 4 * 5 * Copyright (C) 1999 Achim Hasenmueller 5 * Copyright 1999 Thuy Nguyen 6 * Copyright 1999 Eric Kohl 6 7 * 7 * Based on the work of the WINE group (www.winehq.com) 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 8 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 9 17 * 10 * Project Odin Software License can be found in LICENSE.TXT 11 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 12 21 */ 13 22 14 /* Status: Corel WINE 20000807 */ 15 16 #ifndef _H_COMCTL32 17 #define _H_COMCTL32 18 19 #include "winbase.h" 20 #include "wingdi.h" 21 #include "winuser.h" 22 #include <win/commctrl.h> 23 #include "unicode.h" 24 25 #define _OS2WIN_H 26 #define NO_ULONG 27 #include <misc.h> 28 29 #ifndef __cplusplus 30 #undef inline 31 #define inline 32 #endif 33 34 extern HBRUSH COMCTL32_hPattern55AABrush; 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /* registers window classes inside this DLL */ 41 void CDECL RegisterCOMCTL32WindowClasses(unsigned long hinstDLL); 42 void CDECL UnregisterCOMCTL32WindowClasses(void); 43 #ifdef __cplusplus 44 } 45 #endif 46 47 // string functions from kernel32 48 LPWSTR WIN32API HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str ); 49 LPSTR WIN32API HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str ); 50 51 52 /************************************************************************** 53 * UNDOCUMENTED functions 54 */ 55 56 /* private heap memory functions */ 57 58 LPVOID WINAPI COMCTL32_Alloc (DWORD); 59 LPVOID WINAPI COMCTL32_ReAlloc (LPVOID, DWORD); 60 BOOL WINAPI COMCTL32_Free (LPVOID); 61 DWORD WINAPI COMCTL32_GetSize (LPVOID); 62 23 #ifndef __WINE_COMCTL32_H 24 #define __WINE_COMCTL32_H 63 25 64 26 extern HMODULE COMCTL32_hModule; 27 extern HBRUSH COMCTL32_hPattern55AABrush; 65 28 66 29 /* Property sheet / Wizard */ … … 75 38 #define IDC_SUNKEN_LINE 12326 76 39 77 #define IDS_CLOSE 416040 #define IDS_CLOSE 4160 78 41 79 42 /* Toolbar customization dialog */ … … 98 61 #define IDB_HIST_LARGE 131 99 62 100 //direction bitmaps101 #define IDB_DIRECTION_ALL 132102 #define IDB_DIRECTION_NS 133103 #define IDB_DIRECTION WE 134104 105 //Header filter bitmap106 #define IDB_HEADER_FILTER 140107 108 //cursors109 #define IDC_COMCTL32_ERROR 20480110 #define IDC_COMCTL32_INFORMATION 20481111 #define IDC_COMCTL32_EXCLAMATION 20482112 113 #define IDC_COMCTL32_DRAGRECT 102114 #define IDC_COMCTL32_ARROW1 104115 #define IDC_COMCTL32_ARROW2 105116 #define IDC_COMCTL32_DRAGHLINE 106117 #define IDC_COMCTL32_SPLITHLINE 107118 #define IDC_COMCTL32_HAND 108119 #define IDC_COMCTL32_DIRECTION_NS 109120 #define IDC_COMCTL32_DIRECTION_WE 110121 #define IDC_COMCTL32_DIRECTION_ALL 111122 #define IDC_COMCTL32_DIRECTION_N 112123 #define IDC_COMCTL32_DIRECTION_S 113124 #define IDC_COMCTL32_DIRECTION_E 114125 #define IDC_COMCTL32_DIRECTION_W 115126 #define IDC_COMCTL32_DIRECTION_NE 116127 #define IDC_COMCTL32_DIRECTION_NW 117128 #define IDC_COMCTL32_DIRECTION_SE 118129 #define IDC_COMCTL32_DIRECTION_SW 119130 131 #define IDC_COMCTL32_SPLITVLINE 135132 #define IDC_COMCTL32_ENTER 150133 63 134 64 /* Month calendar month menu popup */ 135 65 #define IDD_MCMONTHMENU 300 136 66 137 #define IDM_JAN 138 #define IDM_FEB 139 #define IDM_MAR 140 #define IDM_APR 141 #define IDM_MAY 142 #define IDM_JUN 143 #define IDM_JUL 144 #define IDM_AUG 145 #define IDM_SEP 146 #define IDM_OCT 147 #define IDM_NOV 148 #define IDM_DEC 67 #define IDM_JAN 301 68 #define IDM_FEB 302 69 #define IDM_MAR 303 70 #define IDM_APR 304 71 #define IDM_MAY 305 72 #define IDM_JUN 306 73 #define IDM_JUL 307 74 #define IDM_AUG 308 75 #define IDM_SEP 309 76 #define IDM_OCT 310 77 #define IDM_NOV 311 78 #define IDM_DEC 312 149 79 150 80 #define IDM_TODAY 4163 … … 160 90 #define IDC_DIVIDEROPEN 107 161 91 92 #ifdef __WIN32OS2__ 93 /* Header filter bitmap */ 94 #define IDB_HEADER_FILTER 140 95 96 #define IDC_COMCTL32_DRAGHLINE 106 97 #define IDC_COMCTL32_SPLITHLINE 107 98 99 #endif 162 100 163 101 /* DragList icon */ 164 102 #define IDI_DRAGARROW 150 103 104 typedef struct 105 { 106 COLORREF clrBtnHighlight; /* COLOR_BTNHIGHLIGHT */ 107 COLORREF clrBtnShadow; /* COLOR_BTNSHADOW */ 108 COLORREF clrBtnText; /* COLOR_BTNTEXT */ 109 COLORREF clrBtnFace; /* COLOR_BTNFACE */ 110 COLORREF clrHighlight; /* COLOR_HIGHLIGHT */ 111 COLORREF clrHighlightText; /* COLOR_HIGHLIGHTTEXT */ 112 COLORREF clr3dHilight; /* COLOR_3DHILIGHT */ 113 COLORREF clr3dShadow; /* COLOR_3DSHADOW */ 114 COLORREF clr3dDkShadow; /* COLOR_3DDKSHADOW */ 115 COLORREF clr3dFace; /* COLOR_3DFACE */ 116 COLORREF clrWindow; /* COLOR_WINDOW */ 117 COLORREF clrWindowText; /* COLOR_WINDOWTEXT */ 118 COLORREF clrGrayText; /* COLOR_GREYTEXT */ 119 COLORREF clrActiveCaption; /* COLOR_ACTIVECAPTION */ 120 COLORREF clrInfoBk; /* COLOR_INFOBK */ 121 COLORREF clrInfoText; /* COLOR_INFOTEXT */ 122 } COMCTL32_SysColor; 123 124 extern COMCTL32_SysColor comctl32_color; 125 126 /* Internal function */ 127 HWND COMCTL32_CreateToolTip (HWND); 128 VOID COMCTL32_RefreshSysColors(void); 129 INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen); 130 BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc); 165 131 166 132 #define COMCTL32_VERSION_MINOR 0 … … 168 134 #define WINE_FILEVERSIONSTR "5.00" 169 135 170 # define UINT_PTR DWORD171 136 #ifdef __WIN32OS2__ 137 #define swprintf wsprintfW 172 138 #ifdef __cplusplus 173 139 extern "C" { … … 216 182 217 183 218 INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen);219 BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc);220 221 184 #ifdef __cplusplus 222 185 } 223 186 #endif 187 #endif 224 188 225 #endif /* _H_COMCTL32*/189 #endif /* __WINE_COMCTL32_H */ -
trunk/src/comctl32/comctl32dbg.def
r7921 r8382 1 ; $Id: comctl32dbg.def,v 1. 1 2002-02-15 15:39:29 sandervl Exp $1 ; $Id: comctl32dbg.def,v 1.2 2002-05-08 11:24:59 sandervl Exp $ 2 2 LIBRARY COMCTL32 INITINSTANCE 3 3 DESCRIPTION 'Odin32 System DLL - ComCtl32 - Common Controls Library' … … 15 15 DPA_SaveStream = _DbgDPA_SaveStream@16 @10 16 16 DPA_Merge = _DbgDPA_Merge@24 @11 17 CreatePropertySheetPage = _DbgCreatePropertySheetPageA@4 @1217 ;;12 stub Cctl1632_ThunkData32 18 18 MakeDragList = _DbgMakeDragList@4 @13 19 19 LBItemFromPt = _DbgLBItemFromPt@16 @14 -
trunk/src/comctl32/comctl32undoc.c
r7815 r8382 5 5 * 1998 Juergen Schmied <j.schmied@metronet.de> 6 6 * 2000 Eric Kohl for CodeWeavers 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 7 21 * 8 22 * NOTES … … 34 48 #include "comctl32.h" 35 49 36 #include " debugtools.h"37 38 DEFAULT_DEBUG_CHANNEL(commctrl);50 #include "wine/debug.h" 51 52 WINE_DEFAULT_DEBUG_CHANNEL(commctrl); 39 53 40 54 … … 206 220 INT nCount; 207 221 LPVOID *pWork1, *pWork2; 208 INT nResult ;222 INT nResult, i; 209 223 INT nIndex; 210 224 … … 224 238 return FALSE; 225 239 226 if ( dwFlags & DPAM_SORT) {240 if (!(dwFlags & DPAM_NOSORT)) { 227 241 TRACE("sorting dpa's!\n"); 228 242 if (hdpa1->nItemCount > 0) … … 251 265 do 252 266 { 253 if (nIndex < 0) break; 267 if (nIndex < 0) { 268 if ((nCount >= 0) && (dwFlags & DPAM_INSERT)) { 269 /* Now insert the remaining new items into DPA 1 */ 270 TRACE("%d items to be inserted at start of DPA 1\n", 271 nCount+1); 272 for (i=nCount; i>=0; i--) { 273 PVOID ptr; 274 275 ptr = (pfnMerge)(3, *pWork2, NULL, lParam); 276 if (!ptr) 277 return FALSE; 278 DPA_InsertPtr (hdpa1, 0, ptr); 279 pWork2--; 280 } 281 } 282 break; 283 } 254 284 nResult = (pfnCompare)(*pWork1, *pWork2, lParam); 255 285 TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n", … … 270 300 pWork1--; 271 301 } 272 else if (nResult <0)302 else if (nResult > 0) 273 303 { 274 if (!(dwFlags & 8)) 304 /* item in DPA 1 missing from DPA 2 */ 305 if (dwFlags & DPAM_DELETE) 275 306 { 307 /* Now delete the extra item in DPA1 */ 276 308 PVOID ptr; 277 309 … … 285 317 else 286 318 { 287 if (!(dwFlags & 4)) 319 /* new item in DPA 2 */ 320 if (dwFlags & DPAM_INSERT) 288 321 { 322 /* Now insert the new item in DPA 1 */ 289 323 PVOID ptr; 290 324 … … 292 326 if (!ptr) 293 327 return FALSE; 294 DPA_InsertPtr (hdpa1, nIndex , ptr);328 DPA_InsertPtr (hdpa1, nIndex+1, ptr); 295 329 } 296 330 nCount--; … … 2800 2834 return TRUE; 2801 2835 } 2802 -
trunk/src/comctl32/commctrl.c
r7815 r8382 5 5 * Copyright 1998,2000 Eric Kohl 6 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 7 20 */ 8 21 … … 17 30 #include "shlwapi.h" 18 31 #include "comctl32.h" 19 #include " debugtools.h"20 21 DEFAULT_DEBUG_CHANNEL(commctrl);32 #include "wine/debug.h" 33 34 WINE_DEFAULT_DEBUG_CHANNEL(commctrl); 22 35 23 36 extern void ANIMATE_Register(void); … … 68 81 LANGID COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL); 69 82 HBRUSH COMCTL32_hPattern55AABrush = (HANDLE)NULL; 83 COMCTL32_SysColor comctl32_color; 70 84 71 85 static HBITMAP COMCTL32_hPattern55AABitmap = (HANDLE)NULL; … … 111 125 COMCTL32_hPattern55AABitmap = CreateBitmap (8, 8, 1, 1, wPattern55AA); 112 126 COMCTL32_hPattern55AABrush = CreatePatternBrush (COMCTL32_hPattern55AABitmap); 127 128 /* Get all the colors at DLL load */ 129 COMCTL32_RefreshSysColors(); 113 130 114 131 /* register all Win95 common control classes */ … … 396 413 */ 397 414 398 VOID WINAPI 399 DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style) 415 void WINAPI DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style) 400 416 { 401 417 RECT r = *lprc; … … 403 419 404 420 if (style & SBT_POPOUT) 405 border = BDR_RAISEDOUTER;421 border = BDR_RAISEDOUTER; 406 422 else if (style & SBT_NOBORDERS) 407 border = 0;408 409 DrawEdge (hdc, &r, border, BF_RECT|BF_ADJUST |BF_MIDDLE);423 border = 0; 424 425 DrawEdge (hdc, &r, border, BF_RECT|BF_ADJUST); 410 426 411 427 /* now draw text */ 412 428 if (text) { 413 int oldbkmode = SetBkMode (hdc, TRANSPARENT); 414 r.left += 3; 415 DrawTextW (hdc, text, lstrlenW(text), 416 &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE); 417 if (oldbkmode != TRANSPARENT) 429 int oldbkmode = SetBkMode (hdc, TRANSPARENT); 430 UINT align = DT_LEFT; 431 if (*text == L'\t') { 432 text++; 433 align = DT_CENTER; 434 if (*text == L'\t') { 435 text++; 436 align = DT_RIGHT; 437 } 438 } 439 r.left += 3; 440 if (style & SBT_RTLREADING) 441 FIXME("Usupported RTL style!"); 442 DrawTextW (hdc, text, -1, &r, align|DT_VCENTER|DT_SINGLELINE); 418 443 SetBkMode(hdc, oldbkmode); 419 444 } … … 437 462 */ 438 463 439 VOID WINAPI 440 DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style) 464 void WINAPI DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style) 441 465 { 442 466 INT len; … … 1015 1039 return hwndToolTip; 1016 1040 } 1041 1042 1043 /*********************************************************************** 1044 * COMCTL32_RefreshSysColors [NOT AN API] 1045 * 1046 * Invoked on any control recognizing a WM_SYSCOLORCHANGE message to 1047 * refresh the color values in the color structure 1048 * 1049 * PARAMS 1050 * none 1051 * 1052 * RETURNS 1053 * none 1054 */ 1055 VOID 1056 COMCTL32_RefreshSysColors(void) 1057 { 1058 comctl32_color.clrBtnHighlight = GetSysColor (COLOR_BTNHIGHLIGHT); 1059 comctl32_color.clrBtnShadow = GetSysColor (COLOR_BTNSHADOW); 1060 comctl32_color.clrBtnText = GetSysColor (COLOR_BTNTEXT); 1061 comctl32_color.clrBtnFace = GetSysColor (COLOR_BTNFACE); 1062 comctl32_color.clrHighlight = GetSysColor (COLOR_HIGHLIGHT); 1063 comctl32_color.clrHighlightText = GetSysColor (COLOR_HIGHLIGHTTEXT); 1064 comctl32_color.clr3dHilight = GetSysColor (COLOR_3DHILIGHT); 1065 comctl32_color.clr3dShadow = GetSysColor (COLOR_3DSHADOW); 1066 comctl32_color.clr3dDkShadow = GetSysColor (COLOR_3DDKSHADOW); 1067 comctl32_color.clr3dFace = GetSysColor (COLOR_3DFACE); 1068 comctl32_color.clrWindow = GetSysColor (COLOR_WINDOW); 1069 comctl32_color.clrWindowText = GetSysColor (COLOR_WINDOWTEXT); 1070 comctl32_color.clrGrayText = GetSysColor (COLOR_GRAYTEXT); 1071 comctl32_color.clrActiveCaption = GetSysColor (COLOR_ACTIVECAPTION); 1072 comctl32_color.clrInfoBk = GetSysColor (COLOR_INFOBK); 1073 comctl32_color.clrInfoText = GetSysColor (COLOR_INFOTEXT); 1074 } -
trunk/src/comctl32/dbgwrap.cpp
r7921 r8382 50 50 DEBUGWRAP20(FlatSB_SetScrollRange) 51 51 DEBUGWRAP12(FlatSB_ShowScrollBar) 52 NODEF_DEBUGWRAP0(GetMUILanguage)52 DEBUGWRAP0(GetMUILanguage) 53 53 DEBUGWRAP12(ImageList_Add) 54 54 DEBUGWRAP8(ImageList_AddIcon) … … 95 95 NODEF_DEBUGWRAP8(ImageList_Write) 96 96 DEBUGWRAP4(InitCommonControlsEx) 97 NODEF_DEBUGWRAP4(InitMUILanguage)97 DEBUGWRAP4(InitMUILanguage) 98 98 DEBUGWRAP4(InitializeFlatSB) 99 99 DEBUGWRAP4(PropertySheetA) -
trunk/src/comctl32/flatsb.c
r6709 r8382 4 4 * Copyright 1998, 1999 Eric Kohl 5 5 * Copyright 1998 Alex Priem 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 20 * 7 21 * NOTES … … 16 30 */ 17 31 32 #include <string.h> 18 33 #include "winbase.h" 19 34 #include "winerror.h" 20 35 #include "commctrl.h" 21 #include "debugtools.h" 22 23 #ifdef __WIN32OS2__ 24 #include "ccbase.h" 25 #endif 26 27 DEFAULT_DEBUG_CHANNEL(commctrl); 36 #include "wine/debug.h" 37 38 WINE_DEFAULT_DEBUG_CHANNEL(commctrl); 28 39 29 40 typedef struct 30 41 { 31 #ifdef __WIN32OS2__32 COMCTL32_HEADER header;33 #endif34 42 DWORD dwDummy; /* just to keep the compiler happy ;-) */ 35 43 } FLATSB_INFO, *LPFLATSB_INFO; … … 39 47 40 48 /*********************************************************************** 41 * InitializeFlatSB 49 * InitializeFlatSB (COMCTL32.86) 42 50 * 43 51 * returns nonzero if successful, zero otherwise … … 52 60 53 61 /*********************************************************************** 54 * UninitializeFlatSB 62 * UninitializeFlatSB (COMCTL32.90) 55 63 * 56 64 * returns: … … 68 76 69 77 /*********************************************************************** 70 * FlatSB_GetScrollProp 78 * FlatSB_GetScrollProp (COMCTL32.32) 71 79 * 72 80 * Returns nonzero if successful, or zero otherwise. If index is WSB_PROP_HSTYLE, … … 84 92 85 93 /*********************************************************************** 86 * FlatSB_SetScrollProp 94 * FlatSB_SetScrollProp (COMCTL32.36) 87 95 */ 88 96 BOOL WINAPI … … 111 119 112 120 /*********************************************************************** 113 * FlatSB_EnableScrollBar 121 * FlatSB_EnableScrollBar (COMCTL32.29) 114 122 */ 115 123 BOOL WINAPI … … 120 128 121 129 /*********************************************************************** 122 * FlatSB_ShowScrollBar 130 * FlatSB_ShowScrollBar (COMCTL32.38) 123 131 */ 124 132 BOOL WINAPI … … 129 137 130 138 /*********************************************************************** 131 * FlatSB_GetScrollRange 139 * FlatSB_GetScrollRange (COMCTL32.33) 132 140 */ 133 141 BOOL WINAPI … … 138 146 139 147 /*********************************************************************** 140 * FlatSB_GetScrollInfo 148 * FlatSB_GetScrollInfo (COMCTL32.30) 141 149 */ 142 150 BOOL WINAPI … … 147 155 148 156 /*********************************************************************** 149 * FlatSB_GetScrollPos 157 * FlatSB_GetScrollPos (COMCTL32.31) 150 158 */ 151 159 INT WINAPI … … 156 164 157 165 /*********************************************************************** 158 * FlatSB_SetScrollPos 166 * FlatSB_SetScrollPos (COMCTL32.35) 159 167 */ 160 168 INT WINAPI … … 165 173 166 174 /*********************************************************************** 167 * FlatSB_SetScrollInfo 175 * FlatSB_SetScrollInfo (COMCTL32.34) 168 176 */ 169 177 INT WINAPI … … 174 182 175 183 /*********************************************************************** 176 * FlatSB_SetScrollRange 184 * FlatSB_SetScrollRange (COMCTL32.37) 177 185 */ 178 186 INT WINAPI … … 187 195 { 188 196 TRACE("[%04x] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam); 189 #ifdef __WIN32OS2__190 initControl(hwnd,sizeof(FLATSB_INFO));191 #endif192 193 197 return 0; 194 198 } … … 199 203 { 200 204 TRACE("[%04x] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam); 201 #ifdef __WIN32OS2__202 /* free pager info data */203 doneControl(hwnd);204 #endif205 205 return 0; 206 206 } … … 210 210 FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 211 211 { 212 if (!FlatSB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)) 213 return DefWindowProcA( hwnd, uMsg, wParam, lParam ); 214 212 215 switch (uMsg) 213 216 { … … 222 225 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 223 226 uMsg, wParam, lParam); 224 #ifdef __WIN32OS2__225 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);226 #else227 227 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 228 #endif229 228 } 230 229 return 0; -
trunk/src/comctl32/imagelist.c
r7815 r8382 6 6 * 2001 Michael Stefaniuc 7 7 * 2001 Charles Loep for CodeWeavers 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License as published by the Free Software Foundation; either 12 * version 2.1 of the License, or (at your option) any later version. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 8 22 * 9 23 * TODO: … … 22 36 * partially implemented, the functions mentioned above will be 23 37 * limited in functionality too. 38 * 39 * - Hotspot handling still not correct. The Hotspot passed to BeginDrag 40 * is the offset of the image position relative to the actual mouse pointer 41 * position. However the Hotspot passed to SetDragCursorImage is the 42 * offset of the mouse messages sent to the application... 24 43 */ 25 44 … … 32 51 #include "commctrl.h" 33 52 #include "imagelist.h" 34 #include " debugtools.h"35 36 DEFAULT_DEBUG_CHANNEL(imagelist);53 #include "wine/debug.h" 54 55 WINE_DEFAULT_DEBUG_CHANNEL(imagelist); 37 56 38 57 … … 54 73 /* saved background */ 55 74 HBITMAP hbmBg; 75 BOOL bHSPending; 56 76 } INTERNALDRAG; 57 77 58 static INTERNALDRAG InternalDrag = { 0, 0, 0, 0, 0, 0, FALSE, 0 };78 static INTERNALDRAG InternalDrag = { 0, 0, 0, 0, 0, 0, FALSE, 0, FALSE }; 59 79 60 80 … … 748 768 749 769 InternalDrag.himl->cCurImage = 1; 770 InternalDrag.bHSPending = TRUE; 750 771 751 772 return TRUE; … … 1072 1093 ImageList_DragLeave (HWND hwndLock) 1073 1094 { 1074 if (hwndLock) 1095 /* As we don't save drag info in the window this can lead to problems if 1096 an app does not supply the same window as DragEnter */ 1097 /* if (hwndLock) 1075 1098 InternalDrag.hwnd = hwndLock; 1076 1099 else 1077 InternalDrag.hwnd = GetDesktopWindow (); 1100 InternalDrag.hwnd = GetDesktopWindow (); */ 1101 if(!hwndLock) 1102 hwndLock = GetDesktopWindow(); 1103 if(InternalDrag.hwnd != hwndLock) 1104 FIXME("DragLeave hWnd != DragEnter hWnd\n"); 1078 1105 1079 1106 ImageList_DragShowNolock (FALSE); … … 1490 1517 DeleteObject(InternalDrag.hbmBg); 1491 1518 InternalDrag.hbmBg = 0; 1519 InternalDrag.bHSPending = FALSE; 1492 1520 1493 1521 return TRUE; … … 2601 2629 * hotspot) to the origin of the second image. 2602 2630 * See M$DN for details */ 2603 dx = InternalDrag.dxHotspot - dxHotspot; 2604 dy = InternalDrag.dyHotspot - dyHotspot; 2631 if(InternalDrag.bHSPending) { 2632 dx = 0; 2633 dy = 0; 2634 InternalDrag.bHSPending = FALSE; 2635 } else { 2636 dx = InternalDrag.dxHotspot - dxHotspot; 2637 dy = InternalDrag.dyHotspot - dyHotspot; 2638 } 2605 2639 himlTemp = ImageList_Merge (InternalDrag.himl, 0, himlDrag, iDrag, dx, dy); 2606 2640 … … 2621 2655 /* update the InternalDragOffset, if the origin of the 2622 2656 * DragImage was changed by ImageList_Merge. */ 2623 if (dx > InternalDrag.dxHotspot) { 2624 InternalDrag.dxHotspot = dx; 2625 } 2626 if (dy > InternalDrag.dyHotspot) { 2627 InternalDrag.dyHotspot = dy; 2628 } 2657 if (dx <= 0) 2658 InternalDrag.dxHotspot = dxHotspot; 2659 if (dy <= 0) 2660 InternalDrag.dyHotspot = dyHotspot; 2629 2661 2630 2662 if (visible) { … … 2934 2966 2935 2967 if(bitCount == 1) { 2936 //Hack. 2968 /* Hack. */ 2937 2969 LPBITMAPINFO inf = (LPBITMAPINFO)bmih; 2938 2970 inf->bmiColors[0].rgbRed = inf->bmiColors[0].rgbGreen = inf->bmiColors[0].rgbBlue = 0; -
trunk/src/comctl32/ipaddress.c
r7815 r8382 2 2 * IP Address control 3 3 * 4 * Copyright 1999 Chris Morgan<cmorgan@wpi.edu> and 5 * James Abbatiello<abbeyj@wpi.edu> 4 * Copyright 2002 Dimitrie O. Paun 5 * Copyright 1999 Chris Morgan<cmorgan@wpi.edu> 6 * Copyright 1999 James Abbatiello<abbeyj@wpi.edu> 6 7 * Copyright 1998, 1999 Eric Kohl 7 8 * Copyright 1998 Alex Priem <alexp@sci.kun.nl> 8 9 * 9 * NOTES 10 * 11 * TODO: 12 * -Edit control doesn't support the ES_CENTER style which prevents 13 * this ipaddress control from having centered text look like the 14 * windows ipaddress control 15 * -Check all notifications/behavior. 16 * -Optimization: 17 * -include lpipsi in IPADDRESS_INFO. 18 * -CurrentFocus: field that has focus at moment of processing. 19 * -connect Rect32 rcClient. 20 * -check ipaddress.cpp for missing features. 21 * -refresh: draw '.' instead of setpixel. 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 23 * 22 24 */ 23 25 … … 27 29 #include <string.h> 28 30 31 #include "ntddk.h" 29 32 #include "winbase.h" 30 33 #include "commctrl.h" 31 #include "debugtools.h" 32 33 DEFAULT_DEBUG_CHANNEL(ipaddress); 34 #include "wine/debug.h" 35 #ifdef __WIN32OS2__ 36 #include "comctl32.h" 37 #endif 38 39 WINE_DEFAULT_DEBUG_CHANNEL(ipaddress); 34 40 35 41 typedef struct 36 42 { 37 BYTE LowerLimit[4]; 38 BYTE UpperLimit[4]; 39 40 RECT rcClient; 41 INT uFocus; 43 HWND EditHwnd; 44 INT LowerLimit; 45 INT UpperLimit; 46 WNDPROC OrigProc; 47 } IPPART_INFO; 48 49 typedef struct 50 { 51 HWND Self; 52 IPPART_INFO Part[4]; 42 53 } IPADDRESS_INFO; 43 54 44 typedef struct 45 { 46 WNDPROC wpOrigProc[4]; 47 HWND hwndIP[4]; 48 IPADDRESS_INFO *infoPtr; 49 HWND hwnd; 50 UINT uRefCount; 51 } IP_SUBCLASS_INFO, *LPIP_SUBCLASS_INFO; 52 53 #define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO *)GetWindowLongA (hwnd, 0)) 54 55 static BOOL 56 IPADDRESS_SendNotify (HWND hwnd, UINT command); 57 static BOOL 58 IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue); 59 60 /* property name of tooltip window handle */ 55 #define POS_DEFAULT 0 56 #define POS_LEFT 1 57 #define POS_RIGHT 2 58 #define POS_SELALL 3 59 61 60 #define IP_SUBCLASS_PROP "CCIP32SubclassInfo" 61 #define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO *)GetWindowLongW (hwnd, 0)) 62 62 63 63 … … 65 65 IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 66 66 67 68 static VOID 69 IPADDRESS_Refresh (HWND hwnd, HDC hdc) 70 { 71 RECT rcClient; 72 HBRUSH hbr; 73 COLORREF clr=GetSysColor (COLOR_3DDKSHADOW); 74 int i,x,fieldsize; 75 76 GetClientRect (hwnd, &rcClient); 77 hbr = CreateSolidBrush (RGB(255,255,255)); 78 DrawEdge (hdc, &rcClient, EDGE_SUNKEN, BF_RECT | BF_ADJUST); 79 FillRect (hdc, &rcClient, hbr); 80 DeleteObject (hbr); 81 82 x=rcClient.left; 83 fieldsize=(rcClient.right-rcClient.left) / 4; 84 85 for (i=0; i<3; i++) { /* Should draw text "." here */ 86 x+=fieldsize; 87 SetPixel (hdc, x, 13, clr); 88 SetPixel (hdc, x, 14, clr); 89 SetPixel (hdc, x+1, 13, clr); 90 SetPixel (hdc, x+1, 14, clr); 91 } 92 } 93 94 95 static LRESULT 96 IPADDRESS_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) 97 { 98 IPADDRESS_INFO *infoPtr; 99 RECT rcClient, edit; 100 int i,fieldsize; 101 LPIP_SUBCLASS_INFO lpipsi; 67 static LRESULT IPADDRESS_Notify (IPADDRESS_INFO *infoPtr, UINT command) 68 { 69 HWND hwnd = infoPtr->Self; 70 71 TRACE("(command=%x)\n", command); 72 73 return SendMessageW (GetParent (hwnd), WM_COMMAND, 74 MAKEWPARAM (GetWindowLongW (hwnd, GWL_ID), command), (LPARAM)hwnd); 75 } 76 77 static INT IPADDRESS_IPNotify (IPADDRESS_INFO *infoPtr, INT field, INT value) 78 { 79 NMIPADDRESS nmip; 80 81 TRACE("(field=%x, value=%d)\n", field, value); 82 83 nmip.hdr.hwndFrom = infoPtr->Self; 84 nmip.hdr.idFrom = GetWindowLongW (infoPtr->Self, GWL_ID); 85 nmip.hdr.code = IPN_FIELDCHANGED; 86 87 nmip.iField = field; 88 nmip.iValue = value; 89 90 SendMessageW (GetParent (infoPtr->Self), WM_NOTIFY, 91 (WPARAM)nmip.hdr.idFrom, (LPARAM)&nmip); 92 93 TRACE("<-- %d\n", nmip.iValue); 94 95 return nmip.iValue; 96 } 97 98 99 static int IPADDRESS_GetPartIndex(IPADDRESS_INFO *infoPtr, HWND hwnd) 100 { 101 int i; 102 103 TRACE("(hwnd=%x)\n", hwnd); 104 105 for (i = 0; i < 4; i++) 106 if (infoPtr->Part[i].EditHwnd == hwnd) return i; 107 108 ERR("We subclassed the wrong window! (hwnd=%x)\n", hwnd); 109 return -1; 110 } 111 112 113 static LRESULT IPADDRESS_Draw (IPADDRESS_INFO *infoPtr, HDC hdc) 114 { 115 RECT rect, rcPart; 116 POINT pt; 117 int i; 118 119 TRACE("\n"); 120 121 GetClientRect (infoPtr->Self, &rect); 122 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); 123 124 for (i = 0; i < 3; i++) { 125 GetWindowRect (infoPtr->Part[i].EditHwnd, &rcPart); 126 pt.x = rcPart.right; 127 ScreenToClient(infoPtr->Self, &pt); 128 rect.left = pt.x; 129 GetWindowRect (infoPtr->Part[i+1].EditHwnd, &rcPart); 130 pt.x = rcPart.left; 131 ScreenToClient(infoPtr->Self, &pt); 132 rect.right = pt.x; 133 DrawTextA(hdc, ".", 1, &rect, DT_SINGLELINE | DT_CENTER | DT_BOTTOM); 134 } 135 136 return 0; 137 } 138 139 140 static LRESULT IPADDRESS_Create (HWND hwnd) 141 { 142 IPADDRESS_INFO *infoPtr; 143 RECT rcClient, edit; 144 int i, fieldsize; 145 WCHAR EDIT[] = { 'E', 'd', 'i', 't', 0 }; 146 147 TRACE("\n"); 148 149 SetWindowLongW (hwnd, GWL_STYLE, 150 GetWindowLongW(hwnd, GWL_STYLE) & ~WS_BORDER); 151 152 infoPtr = (IPADDRESS_INFO *)COMCTL32_Alloc (sizeof(IPADDRESS_INFO)); 153 if (!infoPtr) return -1; 154 SetWindowLongW (hwnd, 0, (DWORD)infoPtr); 155 156 GetClientRect (hwnd, &rcClient); 157 158 fieldsize = (rcClient.right - rcClient.left) / 4; 159 160 edit.top = rcClient.top + 2; 161 edit.bottom = rcClient.bottom - 2; 162 163 infoPtr->Self = hwnd; 164 165 for (i = 0; i < 4; i++) { 166 IPPART_INFO* part = &infoPtr->Part[i]; 102 167 103 104 infoPtr = (IPADDRESS_INFO *)COMCTL32_Alloc (sizeof(IPADDRESS_INFO)); 105 SetWindowLongA (hwnd, 0, (DWORD)infoPtr); 106 107 GetClientRect (hwnd, &rcClient); 108 109 fieldsize=(rcClient.right-rcClient.left) /4; 110 111 edit.top =rcClient.top+2; 112 edit.bottom=rcClient.bottom-2; 113 114 lpipsi=(LPIP_SUBCLASS_INFO) GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP); 115 if (lpipsi == NULL) { 116 lpipsi = (LPIP_SUBCLASS_INFO) COMCTL32_Alloc (sizeof(IP_SUBCLASS_INFO)); 117 lpipsi->hwnd = hwnd; 118 lpipsi->uRefCount++; 119 SetPropA ((HWND)hwnd, IP_SUBCLASS_PROP, (HANDLE)lpipsi); 120 /* infoPtr->lpipsi= lpipsi; */ 121 } else 122 WARN("IP-create called twice\n"); 168 part->LowerLimit = 0; 169 part->UpperLimit = 255; 170 edit.left = rcClient.left + i*fieldsize + 6; 171 edit.right = rcClient.left + (i+1)*fieldsize - 2; 172 part->EditHwnd = 173 CreateWindowW (EDIT, NULL, WS_CHILD | WS_VISIBLE | ES_CENTER, 174 edit.left, edit.top, edit.right - edit.left, 175 edit.bottom - edit.top, hwnd, (HMENU) 1, 176 GetWindowLongW (hwnd, GWL_HINSTANCE), NULL); 177 SetPropA(part->EditHwnd, IP_SUBCLASS_PROP, hwnd); 178 part->OrigProc = (WNDPROC) 179 SetWindowLongW (part->EditHwnd, GWL_WNDPROC, 180 (LONG)IPADDRESS_SubclassProc); 181 } 182 183 return 0; 184 } 185 186 187 static LRESULT IPADDRESS_Destroy (IPADDRESS_INFO *infoPtr) 188 { 189 int i; 190 191 TRACE("\n"); 192 193 for (i = 0; i < 4; i++) { 194 IPPART_INFO* part = &infoPtr->Part[i]; 195 SetWindowLongW (part->EditHwnd, GWL_WNDPROC, (LONG)part->OrigProc); 196 } 197 198 SetWindowLongW (infoPtr->Self, 0, 0); 199 COMCTL32_Free (infoPtr); 200 return 0; 201 } 202 203 204 static LRESULT IPADDRESS_Paint (IPADDRESS_INFO *infoPtr, HDC hdc) 205 { 206 PAINTSTRUCT ps; 207 208 TRACE("\n"); 209 210 if (hdc) return IPADDRESS_Draw (infoPtr, hdc); 211 212 hdc = BeginPaint (infoPtr->Self, &ps); 213 IPADDRESS_Draw (infoPtr, hdc); 214 EndPaint (infoPtr->Self, &ps); 215 return 0; 216 } 217 218 219 static BOOL IPADDRESS_IsBlank (IPADDRESS_INFO *infoPtr) 220 { 221 int i; 222 223 TRACE("\n"); 224 225 for (i = 0; i < 4; i++) 226 if (GetWindowTextLengthW (infoPtr->Part[i].EditHwnd)) return FALSE; 227 228 return TRUE; 229 } 230 231 232 static int IPADDRESS_GetAddress (IPADDRESS_INFO *infoPtr, LPDWORD ip_address) 233 { 234 WCHAR field[5]; 235 int i, invalid = 0; 236 DWORD ip_addr = 0; 237 238 TRACE("\n"); 239 240 for (i = 0; i < 4; i++) { 241 ip_addr *= 256; 242 if (GetWindowTextW (infoPtr->Part[i].EditHwnd, field, 4)) 243 ip_addr += wcstol(field, 0, 10); 244 else 245 invalid++; 246 } 247 *ip_address = ip_addr; 248 249 return 4 - invalid; 250 } 251 252 253 static BOOL IPADDRESS_SetRange (IPADDRESS_INFO *infoPtr, int index, WORD range) 254 { 255 TRACE("\n"); 256 257 if ( (index < 0) || (index > 3) ) return FALSE; 258 259 infoPtr->Part[index].LowerLimit = range & 0xFF; 260 infoPtr->Part[index].UpperLimit = (range >> 8) & 0xFF; 261 262 return TRUE; 263 } 264 265 266 static void IPADDRESS_ClearAddress (IPADDRESS_INFO *infoPtr) 267 { 268 WCHAR nil[1] = { 0 }; 269 int i; 270 271 TRACE("\n"); 272 273 for (i = 0; i < 4; i++) 274 SetWindowTextW (infoPtr->Part[i].EditHwnd, nil); 275 } 276 277 278 static LRESULT IPADDRESS_SetAddress (IPADDRESS_INFO *infoPtr, DWORD ip_address) 279 { 280 WCHAR buf[20], fmt[] = { '%', 'd', 0 }; 281 int i; 282 283 TRACE("\n"); 284 285 for (i = 3; i >= 0; i--) { 286 IPPART_INFO* part = &infoPtr->Part[i]; 287 int value = ip_address & 0xff; 288 if ( (value >= part->LowerLimit) && (value <= part->UpperLimit) ) { 289 swprintf (buf, fmt, value); 290 SetWindowTextW (part->EditHwnd, buf); 291 IPADDRESS_Notify (infoPtr, EN_CHANGE); 292 } 293 ip_address >>= 8; 294 } 295 296 return TRUE; 297 } 298 299 300 static void IPADDRESS_SetFocusToField (IPADDRESS_INFO *infoPtr, INT index) 301 { 302 TRACE("(index=%d)\n", index); 303 304 if (index > 3) { 305 for (index = 0; index < 4; index++) 306 if (!GetWindowTextLengthW(infoPtr->Part[index].EditHwnd)) break; 307 } 308 if (index < 9 || index > 3) index = 0; 123 309 124 for (i=0; i<=3; i++) 125 { 126 infoPtr->LowerLimit[i]=0; 127 infoPtr->UpperLimit[i]=255; 128 edit.left=rcClient.left+i*fieldsize+6; 129 edit.right=rcClient.left+(i+1)*fieldsize-2; 130 lpipsi->hwndIP[i]= CreateWindowA ("edit", NULL, 131 WS_CHILD | WS_VISIBLE | ES_CENTER, 132 edit.left, edit.top, edit.right-edit.left, edit.bottom-edit.top, 133 hwnd, (HMENU) 1, GetWindowLongA (hwnd, GWL_HINSTANCE), NULL); 134 lpipsi->wpOrigProc[i]= (WNDPROC) 135 SetWindowLongA (lpipsi->hwndIP[i],GWL_WNDPROC, (LONG) 136 IPADDRESS_SubclassProc); 137 SetPropA ((HWND)lpipsi->hwndIP[i], IP_SUBCLASS_PROP, (HANDLE)lpipsi); 138 } 139 140 lpipsi->infoPtr= infoPtr; 141 142 return 0; 143 } 144 145 146 static LRESULT 147 IPADDRESS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) 148 { 149 int i; 150 IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); 151 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 152 GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP); 153 154 for (i=0; i<=3; i++) { 155 SetWindowLongA ((HWND)lpipsi->hwndIP[i], GWL_WNDPROC, 156 (LONG)lpipsi->wpOrigProc[i]); 157 } 158 159 COMCTL32_Free (infoPtr); 160 SetWindowLongA (hwnd, 0, 0); 161 return 0; 162 } 163 164 165 static LRESULT 166 IPADDRESS_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 167 { 168 HDC hdc; 169 170 TRACE("\n"); 171 hdc = GetDC (hwnd); 172 IPADDRESS_Refresh (hwnd, hdc); 173 ReleaseDC (hwnd, hdc); 174 175 IPADDRESS_SendIPAddressNotify (hwnd, 0, 0); /* FIXME: should use -1 */ 176 IPADDRESS_SendNotify (hwnd, EN_KILLFOCUS); 177 InvalidateRect (hwnd, NULL, TRUE); 178 179 return 0; 180 } 181 182 183 static LRESULT 184 IPADDRESS_Paint (HWND hwnd, WPARAM wParam) 185 { 186 HDC hdc; 187 PAINTSTRUCT ps; 188 189 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; 190 IPADDRESS_Refresh (hwnd, hdc); 191 if(!wParam) 192 EndPaint (hwnd, &ps); 193 return 0; 194 } 195 196 197 static LRESULT 198 IPADDRESS_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 199 { 200 HDC hdc; 201 202 TRACE("\n"); 203 204 hdc = GetDC (hwnd); 205 IPADDRESS_Refresh (hwnd, hdc); 206 ReleaseDC (hwnd, hdc); 207 208 return 0; 209 } 210 211 212 static LRESULT 213 IPADDRESS_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) 214 { 215 /* IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); */ 216 TRACE("\n"); 217 return 0; 218 } 219 220 221 static BOOL 222 IPADDRESS_SendNotify (HWND hwnd, UINT command) 223 { 224 TRACE("%x\n",command); 225 return (BOOL)SendMessageA (GetParent (hwnd), WM_COMMAND, 226 MAKEWPARAM (GetWindowLongA (hwnd, GWL_ID),command), (LPARAM)hwnd); 227 } 228 229 230 static BOOL 231 IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue) 232 { 233 NMIPADDRESS nmip; 234 235 TRACE("%x %x\n",field,newValue); 236 nmip.hdr.hwndFrom = hwnd; 237 nmip.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 238 nmip.hdr.code = IPN_FIELDCHANGED; 239 240 nmip.iField=field; 241 nmip.iValue=newValue; 242 243 return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY, 244 (WPARAM)nmip.hdr.idFrom, (LPARAM)&nmip); 245 } 246 247 248 static LRESULT 249 IPADDRESS_ClearAddress (HWND hwnd, WPARAM wParam, LPARAM lParam) 250 { 251 int i; 252 HDC hdc; 253 char buf[1]; 254 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 255 GetPropA ((HWND)hwnd,IP_SUBCLASS_PROP); 256 257 TRACE("\n"); 258 259 buf[0]=0; 260 for (i=0; i<=3; i++) 261 SetWindowTextA (lpipsi->hwndIP[i],buf); 310 SetFocus (infoPtr->Part[index].EditHwnd); 311 } 312 313 314 static BOOL IPADDRESS_ConstrainField (IPADDRESS_INFO *infoPtr, int currentfield) 315 { 316 IPPART_INFO *part = &infoPtr->Part[currentfield]; 317 WCHAR field[10], fmt[] = { '%', 'd', 0 }; 318 int curValue, newValue; 319 320 TRACE("(currentfield=%d)\n", currentfield); 321 322 if (currentfield < 0 || currentfield > 3) return FALSE; 323 324 if (!GetWindowTextW (part->EditHwnd, field, 4)) return FALSE; 325 326 curValue = wcstol(field, 0, 10); 327 TRACE(" curValue=%d\n", curValue); 328 329 newValue = IPADDRESS_IPNotify(infoPtr, currentfield, curValue); 330 TRACE(" newValue=%d\n", newValue); 331 332 if (newValue < part->LowerLimit) newValue = part->LowerLimit; 333 if (newValue > part->UpperLimit) newValue = part->UpperLimit; 334 335 if (newValue == curValue) return FALSE; 336 337 swprintf (field, fmt, newValue); 338 TRACE(" field='%s'\n", debugstr_w(field)); 339 return SetWindowTextW (part->EditHwnd, field); 340 } 341 342 343 static BOOL IPADDRESS_GotoNextField (IPADDRESS_INFO *infoPtr, int cur, int sel) 344 { 345 TRACE("\n"); 346 347 if(cur >= -1 && cur < 4) { 348 IPADDRESS_ConstrainField(infoPtr, cur); 262 349 263 hdc = GetDC (hwnd); 264 IPADDRESS_Refresh (hwnd, hdc); 265 ReleaseDC (hwnd, hdc); 266 267 return 0; 268 } 269 270 271 static LRESULT 272 IPADDRESS_IsBlank (HWND hwnd, WPARAM wParam, LPARAM lParam) 273 { 274 int i; 275 char buf[20]; 276 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 277 GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP); 278 279 TRACE("\n"); 280 281 for (i=0; i<=3; i++) { 282 GetWindowTextA (lpipsi->hwndIP[i],buf,5); 283 if (buf[0]) 284 return 0; 285 } 286 287 return 1; 288 } 289 290 291 static LRESULT 292 IPADDRESS_GetAddress (HWND hwnd, WPARAM wParam, LPARAM lParam) 293 { 294 char field[20]; 295 int i,valid,fieldvalue; 296 DWORD ip_addr; 297 IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); 298 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 299 GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP); 300 301 TRACE("\n"); 302 303 valid=0; 304 ip_addr=0; 305 for (i=0; i<=3; i++) { 306 GetWindowTextA (lpipsi->hwndIP[i],field,4); 307 ip_addr*=256; 308 if (field[0]) { 309 field[3]=0; 310 fieldvalue=atoi(field); 311 if (fieldvalue<infoPtr->LowerLimit[i]) 312 fieldvalue=infoPtr->LowerLimit[i]; 313 if (fieldvalue>infoPtr->UpperLimit[i]) 314 fieldvalue=infoPtr->UpperLimit[i]; 315 ip_addr+=fieldvalue; 316 valid++; 317 } 318 } 319 320 *(LPDWORD) lParam=ip_addr; 321 322 return valid; 323 } 324 325 326 static LRESULT 327 IPADDRESS_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam) 328 { 329 IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); 330 INT index; 331 332 TRACE("\n"); 333 334 index=(INT) wParam; 335 if ((index<0) || (index>3)) return 0; 336 337 infoPtr->LowerLimit[index]=lParam & 0xff; 338 infoPtr->UpperLimit[index]=(lParam >>8) & 0xff; 339 return 1; 340 } 341 342 343 static LRESULT 344 IPADDRESS_SetAddress (HWND hwnd, WPARAM wParam, LPARAM lParam) 345 { 346 IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); 347 HDC hdc; 348 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) 349 GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP); 350 int i,value; 351 DWORD ip_address; 352 char buf[20]; 353 354 TRACE("\n"); 355 ip_address=(DWORD) lParam; 356 357 for (i=3; i>=0; i--) { 358 value=ip_address & 0xff; 359 if ((value>=infoPtr->LowerLimit[i]) && (value<=infoPtr->UpperLimit[i])) 360 { 361 sprintf (buf,"%d",value); 362 SetWindowTextA (lpipsi->hwndIP[i],buf); 363 IPADDRESS_SendNotify (hwnd, EN_CHANGE); 364 } 365 ip_address= ip_address >> 8; 366 } 367 368 hdc = GetDC (hwnd); /* & send notifications */ 369 IPADDRESS_Refresh (hwnd, hdc); 370 ReleaseDC (hwnd, hdc); 371 372 return TRUE; 373 } 374 375 376 static LRESULT 377 IPADDRESS_SetFocusToField (HWND hwnd, WPARAM wParam, LPARAM lParam) 378 { 379 /* IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); */ 380 LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO) GetPropA ((HWND)hwnd, 381 IP_SUBCLASS_PROP); 382 INT index; 383 384 index=(INT) wParam; 385 TRACE(" %d\n", index); 386 if ((index<0) || (index>3)) return 0; 387 388 SetFocus (lpipsi->hwndIP[index]); 389 390 return 1; 391 } 392 393 394 static LRESULT 395 IPADDRESS_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 396 { 397 TRACE("\n"); 398 399 SetFocus (hwnd); 400 IPADDRESS_SendNotify (hwnd, EN_SETFOCUS); 401 IPADDRESS_SetFocusToField (hwnd, 0, 0); 402 403 return TRUE; 404 } 405 406 407 static INT 408 IPADDRESS_CheckField (LPIP_SUBCLASS_INFO lpipsi, int currentfield) 409 { 410 int newField,fieldvalue; 411 char field[20]; 412 IPADDRESS_INFO *infoPtr=lpipsi->infoPtr; 413 414 if(currentfield >= 0 && currentfield < 4) 415 { 416 TRACE("\n"); 417 GetWindowTextA (lpipsi->hwndIP[currentfield],field,4); 418 if (field[0]) 419 { 420 field[3]=0; 421 newField=-1; 422 fieldvalue=atoi(field); 423 424 if (fieldvalue < infoPtr->LowerLimit[currentfield]) 425 newField=infoPtr->LowerLimit[currentfield]; 426 427 if (fieldvalue > infoPtr->UpperLimit[currentfield]) 428 newField=infoPtr->UpperLimit[currentfield]; 429 430 if (newField >= 0) 431 { 432 sprintf (field,"%d",newField); 433 SetWindowTextA (lpipsi->hwndIP[currentfield], field); 434 return TRUE; 435 } 436 } 437 } 438 return FALSE; 439 } 440 441 442 static INT 443 IPADDRESS_GotoNextField (LPIP_SUBCLASS_INFO lpipsi, int currentfield) 444 { 445 if(currentfield >= -1 && currentfield < 4) 446 { 447 IPADDRESS_CheckField(lpipsi, currentfield); /* check the fields value */ 448 449 if(currentfield < 3) 450 { 451 SetFocus (lpipsi->hwndIP[currentfield+1]); 452 return TRUE; 453 } 454 } 455 return FALSE; 456 } 457 458 459 /* period: move and select the text in the next field to the right if */ 460 /* the current field is not empty(l!=0), we are not in the */ 461 /* left most position, and nothing is selected(startsel==endsel) */ 462 463 /* spacebar: same behavior as period */ 464 465 /* alpha characters: completely ignored */ 466 467 /* digits: accepted when field text length < 2 ignored otherwise. */ 468 /* when 3 numbers have been entered into the field the value */ 469 /* of the field is checked, if the field value exceeds the */ 470 /* maximum value and is changed the field remains the current */ 471 /* field, otherwise focus moves to the field to the right */ 472 473 /* tab: change focus from the current ipaddress control to the next */ 474 /* control in the tab order */ 475 476 /* right arrow: move to the field on the right to the left most */ 477 /* position in that field if no text is selected, */ 478 /* we are in the right most position in the field, */ 479 /* we are not in the right most field */ 480 481 /* left arrow: move to the field on the left to the right most */ 482 /* position in that field if no text is selected, */ 483 /* we are in the left most position in the current field */ 484 /* and we are not in the left most field */ 485 486 /* backspace: delete the character to the left of the cursor position, */ 487 /* if none are present move to the field on the left if */ 488 /* we are not in the left most field and delete the right */ 489 /* most digit in that field while keeping the cursor */ 490 /* on the right side of the field */ 491 492 350 if(cur < 3) { 351 IPPART_INFO *next = &infoPtr->Part[cur + 1]; 352 int start = 0, end = 0; 353 SetFocus (next->EditHwnd); 354 if (sel != POS_DEFAULT) { 355 if (sel == POS_RIGHT) 356 start = end = GetWindowTextLengthW(next->EditHwnd); 357 else if (sel == POS_SELALL) 358 end = -1; 359 SendMessageW(next->EditHwnd, EM_SETSEL, start, end); 360 } 361 return TRUE; 362 } 363 364 } 365 return FALSE; 366 } 367 368 369 /* 370 * period: move and select the text in the next field to the right if 371 * the current field is not empty(l!=0), we are not in the 372 * left most position, and nothing is selected(startsel==endsel) 373 * 374 * spacebar: same behavior as period 375 * 376 * alpha characters: completely ignored 377 * 378 * digits: accepted when field text length < 2 ignored otherwise. 379 * when 3 numbers have been entered into the field the value 380 * of the field is checked, if the field value exceeds the 381 * maximum value and is changed the field remains the current 382 * field, otherwise focus moves to the field to the right 383 * 384 * tab: change focus from the current ipaddress control to the next 385 * control in the tab order 386 * 387 * right arrow: move to the field on the right to the left most 388 * position in that field if no text is selected, 389 * we are in the right most position in the field, 390 * we are not in the right most field 391 * 392 * left arrow: move to the field on the left to the right most 393 * position in that field if no text is selected, 394 * we are in the left most position in the current field 395 * and we are not in the left most field 396 * 397 * backspace: delete the character to the left of the cursor position, 398 * if none are present move to the field on the left if 399 * we are not in the left most field and delete the right 400 * most digit in that field while keeping the cursor 401 * on the right side of the field 402 */ 493 403 LRESULT CALLBACK 494 404 IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 495 405 { 496 IPADDRESS_INFO *infoPtr; 497 LPIP_SUBCLASS_INFO lpipsi = (LPIP_SUBCLASS_INFO) GetPropA 498 ((HWND)hwnd,IP_SUBCLASS_PROP); 499 CHAR c = (CHAR)wParam; 500 INT i, l, index, startsel, endsel; 501 502 infoPtr = lpipsi->infoPtr; 503 index=0; /* FIXME */ 504 for (i=0; i<=3; i++) 505 if (lpipsi->hwndIP[i]==hwnd) index=i; 506 507 switch (uMsg) { 508 case WM_CHAR: 509 if(isdigit(c)) /* process all digits */ 510 { 511 int return_val; 512 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 513 l = GetWindowTextLengthA (lpipsi->hwndIP[index]); 514 if(l==2 && startsel==endsel) /* field is full after this key is processed */ 515 { 516 /* process the digit press before we check the field */ 517 return_val = CallWindowProcA (lpipsi->wpOrigProc[index], hwnd, uMsg, wParam, lParam); 406 HWND Self = (HWND)GetPropA (hwnd, IP_SUBCLASS_PROP); 407 IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (Self); 408 CHAR c = (CHAR)wParam; 409 INT index, len = 0, startsel, endsel; 410 IPPART_INFO *part; 411 412 TRACE("(hwnd=0x%x msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam); 413 414 if ( (index = IPADDRESS_GetPartIndex(infoPtr, hwnd)) < 0) return 0; 415 part = &infoPtr->Part[index]; 416 417 if (uMsg == WM_CHAR || uMsg == WM_KEYDOWN) { 418 len = GetWindowTextLengthW (hwnd); 419 SendMessageW(hwnd, EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 420 } 421 switch (uMsg) { 422 case WM_CHAR: 423 if(isdigit(c)) { 424 if(len == 2 && startsel==endsel && endsel==len) { 425 /* process the digit press before we check the field */ 426 int return_val = CallWindowProcW (part->OrigProc, hwnd, uMsg, wParam, lParam); 518 427 519 /* if the field value was changed stay at the current field */ 520 if(!IPADDRESS_CheckField(lpipsi, index)) 521 IPADDRESS_GotoNextField (lpipsi,index); 522 523 return return_val; 524 } 525 526 if(l > 2) /* field is full, stop key messages */ 527 { 528 lParam = 0; 529 wParam = 0; 530 } 531 break; 532 } 533 534 if(c == '.') /* VK_PERIOD */ 535 { 536 l = GetWindowTextLengthA(lpipsi->hwndIP[index]); 537 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 538 if(l != 0 && startsel==endsel && startsel != 0) 539 { 540 IPADDRESS_GotoNextField(lpipsi, index); 541 SendMessageA(lpipsi->hwndIP[index+1], EM_SETSEL, (WPARAM)0, (LPARAM)3); 542 } 543 } 428 /* if the field value was changed stay at the current field */ 429 if(!IPADDRESS_ConstrainField(infoPtr, index)) 430 IPADDRESS_GotoNextField (infoPtr, index, POS_DEFAULT); 431 432 return return_val; 433 } else if (len == 3 && startsel==endsel && endsel==len) 434 IPADDRESS_GotoNextField (infoPtr, index, POS_SELALL); 435 else if (len < 3) break; 436 } else if(c == '.' || c == ' ') { 437 if(len && startsel==endsel && startsel != 0) { 438 IPADDRESS_GotoNextField(infoPtr, index, POS_SELALL); 439 } 440 } else if (c == VK_BACK) break; 441 return 0; 544 442 545 /* stop all other characters */ 546 wParam = 0; 547 lParam = 0; 548 break; 549 550 case WM_KEYDOWN: 551 if(c == VK_SPACE) 552 { 553 l = GetWindowTextLengthA(lpipsi->hwndIP[index]); 554 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 555 if(l != 0 && startsel==endsel && startsel != 0) 556 { 557 IPADDRESS_GotoNextField(lpipsi, index); 558 SendMessageA(lpipsi->hwndIP[index+1], EM_SETSEL, (WPARAM)0, (LPARAM)3); 559 } 560 } 561 562 if(c == VK_RIGHT) 563 { 564 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 565 l = GetWindowTextLengthA (lpipsi->hwndIP[index]); 566 567 if(startsel==endsel && startsel==l) 568 { 569 IPADDRESS_GotoNextField(lpipsi, index); 570 SendMessageA(lpipsi->hwndIP[index+1], EM_SETSEL, (WPARAM)0,(LPARAM)0); 571 } 572 } 573 574 if(c == VK_LEFT) 575 { 576 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 577 if(startsel==0 && startsel==endsel && index > 0) 578 { 579 IPADDRESS_GotoNextField(lpipsi, index - 2); 580 l = GetWindowTextLengthA(lpipsi->hwndIP[index-1]); 581 SendMessageA(lpipsi->hwndIP[index-1], EM_SETSEL, (WPARAM)l,(LPARAM)l); 582 } 583 } 584 585 if(c == VK_BACK) /* VK_BACKSPACE */ 586 { 587 CHAR buf[4]; 588 589 SendMessageA(lpipsi->hwndIP[index], EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel); 590 l = GetWindowTextLengthA (lpipsi->hwndIP[index]); 591 if(startsel==endsel && startsel==0 && index > 0) 592 { 593 l = GetWindowTextLengthA(lpipsi->hwndIP[index-1]); 594 if(l!=0) 595 { 596 GetWindowTextA (lpipsi->hwndIP[index-1],buf,4); 597 buf[l-1] = '\0'; 598 SetWindowTextA(lpipsi->hwndIP[index-1], buf); 599 SendMessageA(lpipsi->hwndIP[index-1], EM_SETSEL, (WPARAM)l,(LPARAM)l); 600 } 601 IPADDRESS_GotoNextField(lpipsi, index - 2); 602 } 603 } 604 break; 605 606 default: 607 break; 608 } 609 return CallWindowProcA (lpipsi->wpOrigProc[index], hwnd, uMsg, wParam, lParam); 443 case WM_KEYDOWN: 444 switch(c) { 445 case VK_RIGHT: 446 if(startsel==endsel && startsel==len) { 447 IPADDRESS_GotoNextField(infoPtr, index, POS_LEFT); 448 return 0; 449 } 450 break; 451 case VK_LEFT: 452 if(startsel==0 && startsel==endsel && index > 0) { 453 IPADDRESS_GotoNextField(infoPtr, index - 2, POS_RIGHT); 454 return 0; 455 } 456 break; 457 case VK_BACK: 458 if(startsel==endsel && startsel==0 && index > 0) { 459 IPPART_INFO *prev = &infoPtr->Part[index-1]; 460 WCHAR val[10]; 461 462 if(GetWindowTextW(prev->EditHwnd, val, 5)) { 463 val[lstrlenW(val) - 1] = 0; 464 SetWindowTextW(prev->EditHwnd, val); 465 } 466 467 IPADDRESS_GotoNextField(infoPtr, index - 2, POS_RIGHT); 468 return 0; 469 } 470 break; 471 } 472 break; 473 case WM_KILLFOCUS: 474 if (IPADDRESS_GetPartIndex(infoPtr, (HWND)wParam) < 0) 475 IPADDRESS_Notify(infoPtr, EN_KILLFOCUS); 476 break; 477 case WM_SETFOCUS: 478 if (IPADDRESS_GetPartIndex(infoPtr, (HWND)wParam) < 0) 479 IPADDRESS_Notify(infoPtr, EN_SETFOCUS); 480 break; 481 } 482 return CallWindowProcW (part->OrigProc, hwnd, uMsg, wParam, lParam); 610 483 } 611 484 … … 614 487 IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 615 488 { 616 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam); 617 if (!IPADDRESS_GetInfoPtr (hwnd) && (uMsg != WM_CREATE)) 618 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 619 switch (uMsg) 620 { 621 case IPM_CLEARADDRESS: 622 return IPADDRESS_ClearAddress (hwnd, wParam, lParam); 623 624 case IPM_SETADDRESS: 625 return IPADDRESS_SetAddress (hwnd, wParam, lParam); 626 627 case IPM_GETADDRESS: 628 return IPADDRESS_GetAddress (hwnd, wParam, lParam); 629 630 case IPM_SETRANGE: 631 return IPADDRESS_SetRange (hwnd, wParam, lParam); 632 633 case IPM_SETFOCUS: 634 return IPADDRESS_SetFocusToField (hwnd, wParam, lParam); 635 636 case IPM_ISBLANK: 637 return IPADDRESS_IsBlank (hwnd, wParam, lParam); 638 639 case WM_CREATE: 640 return IPADDRESS_Create (hwnd, wParam, lParam); 641 642 case WM_DESTROY: 643 return IPADDRESS_Destroy (hwnd, wParam, lParam); 644 645 case WM_GETDLGCODE: 646 return DLGC_WANTARROWS | DLGC_WANTCHARS; 647 648 case WM_KILLFOCUS: 649 return IPADDRESS_KillFocus (hwnd, wParam, lParam); 650 651 case WM_LBUTTONDOWN: 652 return IPADDRESS_LButtonDown (hwnd, wParam, lParam); 653 654 case WM_PAINT: 655 return IPADDRESS_Paint (hwnd, wParam); 656 657 case WM_SETFOCUS: 658 return IPADDRESS_SetFocus (hwnd, wParam, lParam); 659 660 case WM_SIZE: 661 return IPADDRESS_Size (hwnd, wParam, lParam); 662 663 default: 664 if (uMsg >= WM_USER) 665 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 666 uMsg, wParam, lParam); 667 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 489 IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); 490 491 TRACE("(hwnd=0x%x msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam); 492 493 if (!infoPtr && (uMsg != WM_CREATE)) 494 return DefWindowProcW (hwnd, uMsg, wParam, lParam); 495 496 switch (uMsg) 497 { 498 case WM_CREATE: 499 return IPADDRESS_Create (hwnd); 500 501 case WM_DESTROY: 502 return IPADDRESS_Destroy (infoPtr); 503 504 case WM_PAINT: 505 return IPADDRESS_Paint (infoPtr, (HDC)wParam); 506 507 case WM_COMMAND: 508 switch(wParam >> 16) { 509 case EN_CHANGE: 510 IPADDRESS_Notify(infoPtr, EN_CHANGE); 511 break; 512 case EN_KILLFOCUS: 513 IPADDRESS_ConstrainField(infoPtr, IPADDRESS_GetPartIndex(infoPtr, (HWND)lParam)); 514 break; 515 } 516 break; 517 518 case IPM_CLEARADDRESS: 519 IPADDRESS_ClearAddress (infoPtr); 520 break; 521 522 case IPM_SETADDRESS: 523 return IPADDRESS_SetAddress (infoPtr, (DWORD)lParam); 524 525 case IPM_GETADDRESS: 526 return IPADDRESS_GetAddress (infoPtr, (LPDWORD)lParam); 527 528 case IPM_SETRANGE: 529 return IPADDRESS_SetRange (infoPtr, (int)wParam, (WORD)lParam); 530 531 case IPM_SETFOCUS: 532 IPADDRESS_SetFocusToField (infoPtr, (int)wParam); 533 break; 534 535 case IPM_ISBLANK: 536 return IPADDRESS_IsBlank (infoPtr); 537 538 default: 539 if (uMsg >= WM_USER) 540 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); 541 return DefWindowProcW (hwnd, uMsg, wParam, lParam); 668 542 } 669 543 return 0; … … 673 547 void IPADDRESS_Register (void) 674 548 { 675 WNDCLASSAwndClass;676 677 ZeroMemory (&wndClass, sizeof(WNDCLASSA));678 wndClass.style = CS_GLOBALCLASS;679 wndClass.lpfnWndProc = (WNDPROC)IPADDRESS_WindowProc;680 wndClass.cbClsExtra = 0;681 wndClass.cbWndExtra = sizeof(IPADDRESS_INFO *);682 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);683 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);684 wndClass.lpszClassName = WC_IPADDRESSA;549 WNDCLASSW wndClass; 550 551 ZeroMemory (&wndClass, sizeof(WNDCLASSW)); 552 wndClass.style = CS_GLOBALCLASS; 553 wndClass.lpfnWndProc = (WNDPROC)IPADDRESS_WindowProc; 554 wndClass.cbClsExtra = 0; 555 wndClass.cbWndExtra = sizeof(IPADDRESS_INFO *); 556 wndClass.hCursor = LoadCursorW (0, IDC_IBEAMW); 557 wndClass.hbrBackground = GetStockObject(WHITE_BRUSH); 558 wndClass.lpszClassName = WC_IPADDRESSW; 685 559 686 RegisterClassA(&wndClass);687 } 688 689 690 VOIDIPADDRESS_Unregister (void)691 { 692 UnregisterClassA (WC_IPADDRESSA, (HINSTANCE)NULL);693 } 560 RegisterClassW (&wndClass); 561 } 562 563 564 void IPADDRESS_Unregister (void) 565 { 566 UnregisterClassW (WC_IPADDRESSW, (HINSTANCE)NULL); 567 } -
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 -
trunk/src/comctl32/pager.c
r6705 r8382 3 3 * 4 4 * Copyright 1998, 1999 Eric Kohl 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 5 19 * 6 20 * NOTES … … 18 32 #include "winbase.h" 19 33 #include "commctrl.h" 20 #include "debugtools.h" 21 22 DEFAULT_DEBUG_CHANNEL(pager); 23 24 #ifdef __WIN32OS2__ 25 #include "ccbase.h" 26 #undef inline 27 #define inline 28 #endif 34 #include "wine/debug.h" 35 36 WINE_DEFAULT_DEBUG_CHANNEL(pager); 29 37 30 38 typedef struct 31 39 { 32 #ifdef __WIN32OS2__33 COMCTL32_HEADER header;34 #endif35 40 HWND hwndChild; /* handle of the contained wnd */ 36 41 BOOL bNoResize; /* set when created with CCS_NORESIZE */ … … 594 599 } 595 600 601 /****************************************************************** 602 * For the PGM_RECALCSIZE message (but not the other uses in * 603 * this module), the native control does only the following: * 604 * * 605 * if (some condition) * 606 * PostMessageA(hwnd, EM_FMTLINES, 0, 0); * 607 * return DefWindowProcA(hwnd, PGM_RECALCSIZE, 0, 0); * 608 * * 609 * When we figure out what the "some condition" is we will * 610 * implement that for the message processing. * 611 ******************************************************************/ 612 596 613 static LRESULT 597 614 PAGER_RecalcSize(HWND hwnd) … … 630 647 TRACE("[%04x] %06lx\n", hwnd, infoPtr->clrBk); 631 648 632 PAGER_RecalcSize(hwnd); 633 SendMessageA(hwnd, WM_NCPAINT, (WPARAM)0, (LPARAM)0); 649 /* the native control seems to do things this way */ 650 SetWindowPos(hwnd, 0,0,0,0,0, 651 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | 652 SWP_NOZORDER | SWP_NOACTIVATE); 653 654 RedrawWindow(hwnd, 0, 0, RDW_ERASE | RDW_INVALIDATE); 634 655 635 656 return (LRESULT)clrTemp; … … 757 778 758 779 static LRESULT 780 PAGER_FmtLines(HWND hwnd) 781 { 782 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 783 784 /* initiate NCCalcSize to resize client wnd and get size */ 785 SetWindowPos(hwnd, 0, 0,0,0,0, 786 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | 787 SWP_NOZORDER | SWP_NOACTIVATE); 788 789 SetWindowPos(infoPtr->hwndChild, 0, 790 0,0,infoPtr->nWidth,infoPtr->nHeight, 791 0); 792 793 return DefWindowProcA (hwnd, EM_FMTLINES, 0, 0); 794 } 795 796 static LRESULT 759 797 PAGER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) 760 798 { … … 763 801 764 802 /* allocate memory for info structure */ 765 #ifdef __WIN32OS2__766 infoPtr =(PAGER_INFO*)initControl(hwnd,sizeof(PAGER_INFO));767 #else768 803 infoPtr = (PAGER_INFO *)COMCTL32_Alloc (sizeof(PAGER_INFO)); 769 #endif770 804 SetWindowLongA (hwnd, 0, (DWORD)infoPtr); 771 805 … … 820 854 RECT rcChildw, rcmyw, wnrc, lbrc, rbrc; 821 855 POINT cursor; 856 BOOL resizeClient = FALSE; 857 BOOL repaintBtns = FALSE; 858 INT scrollRange; 822 859 823 860 /* … … 830 867 DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam); 831 868 869 TRACE("orig rect=(%d,%d)-(%d,%d)\n", 870 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); 871 832 872 if (PAGER_IsHorizontal(hwnd)) 833 873 { … … 838 878 GetCursorPos (&cursor); 839 879 GetWindowRect (hwnd, &rcmyw); 880 881 /* Reset buttons and hide any grey ones */ 882 scrollRange = infoPtr->nWidth - (rcmyw.right - rcmyw.left); 883 884 TRACE("nPos=%d, scrollrange=%d, nWidth=%d, myw=(%d,%d)-(%d,%d)\n", 885 infoPtr->nPos, scrollRange, infoPtr->nWidth, 886 rcmyw.left, rcmyw.top, rcmyw.right, rcmyw.bottom); 887 PAGER_GrayAndRestoreBtns(infoPtr, scrollRange, &resizeClient, &repaintBtns); 888 PAGER_HideGrayBtns(infoPtr, &resizeClient); 889 840 890 if (PtInRect (&rcmyw, cursor)) { 841 891 GetWindowRect (hwnd, &wnrc); … … 852 902 RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE); 853 903 } 854 if (infoPtr->TLbtnState ) /* != PGF_INVISIBLE */904 if (infoPtr->TLbtnState && (lpRect->left + infoPtr->nButtonSize < lpRect->right)) 855 905 lpRect->left += infoPtr->nButtonSize; 856 if (infoPtr->BRbtnState )906 if (infoPtr->BRbtnState && (lpRect->right - infoPtr->nButtonSize > lpRect->left)) 857 907 lpRect->right -= infoPtr->nButtonSize; 858 908 } … … 875 925 GetCursorPos (&cursor); 876 926 GetWindowRect (hwnd, &rcmyw); 927 928 /* Reset buttons and hide any grey ones */ 929 scrollRange = infoPtr->nHeight - (rcmyw.bottom - rcmyw.top); 930 931 TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d)\n", 932 infoPtr->nPos, scrollRange, infoPtr->nHeight, 933 rcmyw.left, rcmyw.top, 934 rcmyw.right, rcmyw.bottom); 935 PAGER_GrayAndRestoreBtns(infoPtr, scrollRange, &resizeClient, &repaintBtns); 936 PAGER_HideGrayBtns(infoPtr, &resizeClient); 937 877 938 if (PtInRect (&rcmyw, cursor)) { 878 939 … … 900 961 RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE); 901 962 } 902 if (infoPtr->TLbtnState )963 if (infoPtr->TLbtnState && (lpRect->top + infoPtr->nButtonSize < lpRect->bottom)) 903 964 lpRect->top += infoPtr->nButtonSize; 904 if (infoPtr->BRbtnState )965 if (infoPtr->BRbtnState && (lpRect->bottom - infoPtr->nButtonSize > lpRect->top)) 905 966 lpRect->bottom -= infoPtr->nButtonSize; 906 967 /* ???? */ … … 909 970 } 910 971 911 TRACE("[%04x] client rect set to %dx%d at (%d,%d) \n", hwnd,912 lpRect->right-lpRect->left,913 lpRect->bottom-lpRect->top,914 lpRect->left, lpRect->top);972 TRACE("[%04x] client rect set to %dx%d at (%d,%d) BtnState[%d,%d]\n", 973 hwnd, lpRect->right-lpRect->left, lpRect->bottom-lpRect->top, 974 lpRect->left, lpRect->top, 975 infoPtr->TLbtnState, infoPtr->BRbtnState); 915 976 916 977 return 0; … … 1248 1309 switch (uMsg) 1249 1310 { 1311 case EM_FMTLINES: 1312 return PAGER_FmtLines(hwnd); 1313 1250 1314 case PGM_FORWARDMOUSE: 1251 1315 return PAGER_ForwardMouse (hwnd, wParam); … … 1356 1420 1357 1421 default: 1358 #ifdef __WIN32OS2__1359 return defComCtl32ProcA(hwnd, uMsg, wParam, lParam);1360 #else1361 1422 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 1362 #endif1363 1423 } 1364 1424 -
trunk/src/comctl32/rebar.c
r7815 r8382 21 21 22 22 /* 23 * Rebar control rev 8 b23 * Rebar control rev 8e 24 24 * 25 25 * Copyright 1998, 1999 Eric Kohl 26 * 27 * This library is free software; you can redistribute it and/or 28 * modify it under the terms of the GNU Lesser General Public 29 * License as published by the Free Software Foundation; either 30 * version 2.1 of the License, or (at your option) any later version. 31 * 32 * This library is distributed in the hope that it will be useful, 33 * but WITHOUT ANY WARRANTY; without even the implied warranty of 34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35 * Lesser General Public License for more details. 36 * 37 * You should have received a copy of the GNU Lesser General Public 38 * License along with this library; if not, write to the Free Software 39 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 40 * 27 41 * NOTES … … 94 108 * rev 8c 95 109 * 19. Fix problem in _Layout when all lengths are 0. 110 * 20. If CLR_NONE specified, we will use default BtnFace color when drawing. 111 * 21. Fix test in REBAR_Layout. 112 * rev 8d 113 * 22. Add support for WM_WINDOWPOSCHANGED to save new origin of window. 114 * 23. Correct RBN_CHILDSIZE rect value for CCS_VERT rebar. 115 * 24. Do UpdateWindow only if doing redraws. 116 * rev 8e 117 * 25. Adjust setting of offChild.cx based on RBBS_CHILDEDGE. 96 118 * 97 119 * … … 126 148 #include "commctrl.h" 127 149 /* #include "spy.h" */ 128 #include " debugtools.h"129 130 DEFAULT_DEBUG_CHANNEL(rebar);150 #include "wine/debug.h" 151 152 WINE_DEFAULT_DEBUG_CHANNEL(rebar); 131 153 132 154 typedef struct … … 225 247 INT ihitBand; /* band number of band whose gripper was grabbed */ 226 248 INT ihitoffset; /* offset of hotspot from gripper.left */ 249 POINT origin; /* left/upper corner of client */ 227 250 228 251 REBAR_ROW *rows; /* pointer to row indexes */ … … 1198 1221 width += infoPtr->calcSize.cx; 1199 1222 height += infoPtr->calcSize.cy; 1200 } 1201 1202 TRACE("hwnd %04x, style=%08lx, setting at (%d,%d) for (%d,%d)\n", 1223 x = infoPtr->origin.x; 1224 y = infoPtr->origin.y; 1225 } 1226 1227 TRACE("hwnd %08x, style=%08lx, setting at (%d,%d) for (%d,%d)\n", 1203 1228 infoPtr->hwndSelf, infoPtr->dwStyle, 1204 1229 x, y, width, height); … … 1234 1259 rbcz.rcChild = lpBand->rcChild; 1235 1260 rbcz.rcBand = lpBand->rcBand; 1236 rbcz.rcBand.left += lpBand->cxHeader; 1261 if (infoPtr->dwStyle & CCS_VERT) 1262 rbcz.rcBand.top += lpBand->cxHeader; 1263 else 1264 rbcz.rcBand.left += lpBand->cxHeader; 1237 1265 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE); 1238 1266 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) { … … 1303 1331 ERR("EndDeferWindowPos returned NULL\n"); 1304 1332 1305 UpdateWindow (infoPtr->hwndSelf); 1333 if (infoPtr->DoRedraw) 1334 UpdateWindow (infoPtr->hwndSelf); 1306 1335 1307 1336 if (infoPtr->fStatus & NTF_HGHTCHG) { … … 1406 1435 if ((lpBand->fMask & RBBIM_CHILD) && 1407 1436 !(lpBand->fStyle & RBBS_FIXEDSIZE)) { 1408 lpBand->offChild.cx = 4; /* ??? */1437 lpBand->offChild.cx = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 4 : 0); 1409 1438 } 1410 1439 lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0); … … 1732 1761 lpBand = &infoPtr->bands[iband]; 1733 1762 if(HIDDENBAND(lpBand)) continue; 1734 if ( !(lpBand->fMask & RBBS_VARIABLEHEIGHT)) continue;1763 if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue; 1735 1764 if (((INT)lpBand->cyMaxChild < 1) || 1736 1765 ((INT)lpBand->cyIntegral < 1)) { … … 2141 2170 new = RGB(0,128,0); 2142 2171 #endif 2143 old = SetBkColor (hdc, new); 2144 } 2172 } 2173 else { 2174 /* In the absence of documentation for Rebar vs. CLR_NONE, 2175 * we will use the default BtnFace color. Note documentation 2176 * exists for Listview and Imagelist. 2177 */ 2178 new = infoPtr->clrBtnFace; 2179 #if GLATESTING 2180 /* testing only - make background green to see it */ 2181 new = RGB(0,128,0); 2182 #endif 2183 } 2184 old = SetBkColor (hdc, new); 2145 2185 2146 2186 rect = lpBand->rcBand; … … 3741 3781 POINTS ptsmove; 3742 3782 3743 /* Validate entry as hit on Gripper has occur ed */3783 /* Validate entry as hit on Gripper has occurred */ 3744 3784 if (GetCapture() != infoPtr->hwndSelf) return 0; 3745 3785 if (infoPtr->ihitBand == -1) return 0; … … 4197 4237 4198 4238 4239 static LRESULT 4240 REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 4241 { 4242 WINDOWPOS *lpwp = (WINDOWPOS *)lParam; 4243 LRESULT ret; 4244 RECT rc; 4245 4246 /* Save the new origin of this window - used by _ForceResize */ 4247 infoPtr->origin.x = lpwp->x; 4248 infoPtr->origin.y = lpwp->y; 4249 ret = DefWindowProcA(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED, 4250 wParam, lParam); 4251 GetWindowRect(infoPtr->hwndSelf, &rc); 4252 TRACE("hwnd %08x new pos (%d,%d)-(%d,%d)\n", 4253 infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom); 4254 return ret; 4255 } 4256 4257 4199 4258 static LRESULT WINAPI 4200 4259 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) … … 4409 4468 /* case WM_VKEYTOITEM: supported according to ControlSpy */ 4410 4469 /* case WM_WININICHANGE: */ 4470 4471 case WM_WINDOWPOSCHANGED: 4472 return REBAR_WindowPosChanged (infoPtr, wParam, lParam); 4411 4473 4412 4474 default: -
trunk/src/comctl32/rsrc.orc
r3972 r8382 1 /* $Id: rsrc.orc,v 1. 6 2000-08-09 15:57:55 cbratschiExp $ */1 /* $Id: rsrc.orc,v 1.7 2002-05-08 11:25:02 sandervl Exp $ */ 2 2 /* 3 3 * Top level resource file for Common Controls … … 16 16 * being duplicated for each language. 17 17 */ 18 #include " cctl_xx.orc"18 #include "resources\cctl_xx.orc" 19 19 20 20 /* … … 26 26 */ 27 27 28 #include " cctl_Ca.orc"29 #include " cctl_Cs.orc"30 #include " cctl_Da.orc"31 #include " cctl_De.orc"32 #include " cctl_En.orc"33 #include " cctl_Eo.orc"34 #include " cctl_Es.orc"35 #include " cctl_Fi.orc"36 #include " cctl_Fr.orc"37 #include " cctl_Hu.orc"38 #include " cctl_It.orc"39 #include " cctl_Ko.orc"40 #include " cctl_Nl.orc"41 #include " cctl_No.orc"42 #include " cctl_Pl.orc"43 #include " cctl_Pt.orc"44 #include " cctl_Ru.orc"45 #include " cctl_Sv.orc"46 #include " cctl_Wa.orc"28 #include "resources\cctl_Ca.orc" 29 #include "resources\cctl_Cs.orc" 30 #include "resources\cctl_Da.orc" 31 #include "resources\cctl_De.orc" 32 #include "resources\cctl_En.orc" 33 #include "resources\cctl_Eo.orc" 34 #include "resources\cctl_Es.orc" 35 #include "resources\cctl_Fi.orc" 36 #include "resources\cctl_Fr.orc" 37 #include "resources\cctl_Hu.orc" 38 #include "resources\cctl_It.orc" 39 #include "resources\cctl_Ko.orc" 40 #include "resources\cctl_Nl.orc" 41 #include "resources\cctl_No.orc" 42 #include "resources\cctl_Pl.orc" 43 #include "resources\cctl_Pt.orc" 44 #include "resources\cctl_Ru.orc" 45 #include "resources\cctl_Sv.orc" 46 #include "resources\cctl_Wa.orc" -
trunk/src/comctl32/tab.c
r7815 r8382 5 5 * Copyright 1999 Alex Priem <alexp@sci.kun.nl> 6 6 * Copyright 1999 Francis Beaudet 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 7 21 * 8 22 * TODO: … … 19 33 #include "commctrl.h" 20 34 #include "comctl32.h" 21 #include " debugtools.h"35 #include "wine/debug.h" 22 36 #include <math.h> 23 37 24 DEFAULT_DEBUG_CHANNEL(tab);38 WINE_DEFAULT_DEBUG_CHANNEL(tab); 25 39 26 40 typedef struct -
trunk/src/comctl32/toolbar.c
r7815 r8382 4 4 * Copyright 1998,1999 Eric Kohl 5 5 * Copyright 2000 Eric Kohl for CodeWeavers 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 20 * 7 21 * Differences between MSDN and actual native control operation: … … 56 70 #include "imagelist.h" 57 71 #include "comctl32.h" 58 #include " debugtools.h"59 60 DEFAULT_DEBUG_CHANNEL(toolbar);72 #include "wine/debug.h" 73 74 WINE_DEFAULT_DEBUG_CHANNEL(toolbar); 61 75 62 76 typedef struct … … 73 87 RECT rect; 74 88 } TBUTTON_INFO; 89 90 typedef struct 91 { 92 UINT nButtons; 93 HINSTANCE hInst; 94 UINT nID; 95 } TBITMAP_INFO; 75 96 76 97 typedef struct … … 91 112 INT nNumBitmaps; /* number of bitmaps */ 92 113 INT nNumStrings; /* number of strings */ 114 INT nNumBitmapInfos; 93 115 BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */ 94 116 BOOL bCaptured; /* mouse captured? */ … … 96 118 INT nOldHit; 97 119 INT nHotItem; /* index of the "hot" item */ 120 DWORD dwBaseCustDraw; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */ 121 DWORD dwItemCustDraw; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */ 122 DWORD dwItemCDFlag; /* TBCDRF_ flags from last ITEMPREPAINT */ 123 SIZE szPadding; /* padding values around button */ 98 124 HFONT hDefaultFont; 99 125 HFONT hFont; /* text font */ … … 115 141 116 142 COLORREF clrInsertMark; /* insert mark color */ 143 COLORREF clrBtnHighlight; /* color for Flat Separator */ 144 COLORREF clrBtnShadow; /* color for Flag Separator */ 117 145 RECT rcBound; /* bounding rectangle */ 118 146 INT iVersion; … … 120 148 TBUTTON_INFO *buttons; /* pointer to button array */ 121 149 LPWSTR *strings; /* pointer to string array */ 150 TBITMAP_INFO *bitmaps; 122 151 } TOOLBAR_INFO, *PTOOLBAR_INFO; 123 152 … … 147 176 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE) 148 177 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE) 178 179 /* Used to find undocumented extended styles */ 180 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \ 181 TBSTYLE_EX_UNDOC1 | \ 182 TBSTYLE_EX_MIXEDBUTTONS | \ 183 TBSTYLE_EX_HIDECLIPPEDBUTTONS) 184 185 static LRESULT 186 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam); 149 187 150 188 … … 302 340 303 341 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 342 if (btnPtr->iBitmap == I_IMAGENONE) return FALSE; 304 343 ERR("index %d is not valid, max %d\n", 305 344 btnPtr->iBitmap, infoPtr->nNumBitmaps); … … 308 347 309 348 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) { 310 if (index == -1) return FALSE; 349 if ((index == I_IMAGECALLBACK) || 350 (index == I_IMAGENONE)) return FALSE; 311 351 ERR("TBN_GETDISPINFO returned invalid index %d\n", 312 352 index); … … 335 375 336 376 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 377 if (btnPtr->iBitmap == I_IMAGENONE) return FALSE; 337 378 ERR("index %d is not valid, max %d\n", 338 379 btnPtr->iBitmap, infoPtr->nNumBitmaps); … … 341 382 342 383 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) { 343 if (index == -1) return FALSE; 384 if ((index == I_IMAGECALLBACK) || 385 (index == I_IMAGENONE)) return FALSE; 344 386 ERR("TBN_GETDISPINFO returned invalid index %d\n", 345 387 index); … … 351 393 352 394 static void 353 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc) 354 { 355 INT x = (lpRect->left + lpRect->right) / 2 - 1; 356 INT yBottom = lpRect->bottom - 3; 357 INT yTop = lpRect->top + 1; 358 359 SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW)); 360 MoveToEx (hdc, x, yBottom, NULL); 361 LineTo (hdc, x, yTop); 362 x++; 363 SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT)); 364 MoveToEx (hdc, x, yBottom, NULL); 365 LineTo (hdc, x, yTop); 395 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc, TOOLBAR_INFO *infoPtr) 396 { 397 RECT myrect; 398 COLORREF oldcolor, newcolor; 399 400 myrect.left = (lpRect->left + lpRect->right) / 2 - 1; 401 myrect.right = myrect.left + 1; 402 myrect.top = lpRect->top + 2; 403 myrect.bottom = lpRect->bottom - 2; 404 405 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ? 406 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow; 407 oldcolor = SetBkColor (hdc, newcolor); 408 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); 409 410 myrect.left = myrect.right; 411 myrect.right = myrect.left + 1; 412 413 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ? 414 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight; 415 SetBkColor (hdc, newcolor); 416 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); 417 418 SetBkColor (hdc, oldcolor); 366 419 } 367 420 … … 379 432 */ 380 433 static void 381 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr )434 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr, TOOLBAR_INFO *infoPtr) 382 435 { 383 436 RECT myrect; … … 394 447 myrect.left, myrect.top, myrect.right, myrect.bottom); 395 448 396 newcolor = GetSysColor (COLOR_BTNSHADOW); 449 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ? 450 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow; 397 451 oldcolor = SetBkColor (hdc, newcolor); 398 452 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); … … 401 455 myrect.bottom = myrect.top + 1; 402 456 403 newcolor = GetSysColor (COLOR_BTNHIGHLIGHT); 457 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ? 458 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight; 404 459 SetBkColor (hdc, newcolor); 405 460 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); … … 432 487 static void 433 488 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 434 HDC hdc, INT nState, DWORD dwStyle) 435 { 436 RECT rcText = btnPtr->rect; 437 HFONT hOldFont; 438 COLORREF clrOld; 489 HDC hdc, INT nState, DWORD dwStyle, 490 RECT *rcText, LPWSTR lpText, NMTBCUSTOMDRAW *tbcd) 491 { 492 HFONT hOldFont = 0; 493 COLORREF clrOld = 0; 494 495 /* draw text */ 496 if (lpText) { 497 TRACE("string rect=(%d,%d)-(%d,%d)\n", 498 rcText->left, rcText->top, rcText->right, rcText->bottom); 499 500 hOldFont = SelectObject (hdc, infoPtr->hFont); 501 if (!(nState & TBSTATE_ENABLED)) { 502 clrOld = SetTextColor (hdc, tbcd->clrBtnHighlight); 503 OffsetRect (rcText, 1, 1); 504 DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags); 505 SetTextColor (hdc, comctl32_color.clr3dShadow); 506 OffsetRect (rcText, -1, -1); 507 } 508 else if (nState & TBSTATE_INDETERMINATE) { 509 clrOld = SetTextColor (hdc, comctl32_color.clr3dShadow); 510 } 511 else if (btnPtr->bHot && (infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )) { 512 clrOld = SetTextColor (hdc, tbcd->clrTextHighlight); 513 } 514 else { 515 clrOld = SetTextColor (hdc, tbcd->clrText); 516 } 517 518 DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags); 519 SetTextColor (hdc, clrOld); 520 SelectObject (hdc, hOldFont); 521 } 522 } 523 524 525 static void 526 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect) 527 { 528 HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush); 529 INT cx = lpRect->right - lpRect->left; 530 INT cy = lpRect->bottom - lpRect->top; 531 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089); 532 SelectObject (hdc, hbr); 533 } 534 535 536 static void 537 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 538 HDC hdc, INT x, INT y) 539 { 540 /* FIXME: this function is a hack since it uses image list 541 internals directly */ 542 543 HIMAGELIST himl = infoPtr->himlDef; 544 HBITMAP hbmMask; 545 HDC hdcImageList; 546 HDC hdcMask; 547 548 if (!himl) 549 return; 550 551 /* create new dc's */ 552 hdcImageList = CreateCompatibleDC (0); 553 hdcMask = CreateCompatibleDC (0); 554 555 /* create new bitmap */ 556 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL); 557 SelectObject (hdcMask, hbmMask); 558 559 /* copy the mask bitmap */ 560 SelectObject (hdcImageList, himl->hbmMask); 561 SetBkColor (hdcImageList, RGB(255, 255, 255)); 562 SetTextColor (hdcImageList, RGB(0, 0, 0)); 563 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy, 564 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY); 565 566 /* draw the new mask */ 567 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT)); 568 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy, 569 hdcMask, 0, 0, 0xB8074A); 570 571 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW)); 572 BitBlt (hdc, x, y, himl->cx, himl->cy, 573 hdcMask, 0, 0, 0xB8074A); 574 575 DeleteObject (hbmMask); 576 DeleteDC (hdcMask); 577 DeleteDC (hdcImageList); 578 } 579 580 581 static UINT 582 TOOLBAR_TranslateState(TBUTTON_INFO *btnPtr) 583 { 584 UINT retstate = 0; 585 586 retstate |= (btnPtr->fsState & TBSTATE_CHECKED) ? CDIS_CHECKED : 0; 587 retstate |= (btnPtr->fsState & TBSTATE_PRESSED) ? CDIS_SELECTED : 0; 588 retstate |= (btnPtr->fsState & TBSTATE_ENABLED) ? 0 : CDIS_DISABLED; 589 retstate |= (btnPtr->fsState & TBSTATE_MARKED ) ? CDIS_MARKED : 0; 590 retstate |= (btnPtr->bHot ) ? CDIS_HOT : 0; 591 retstate |= (btnPtr->fsState & TBSTATE_INDETERMINATE) ? CDIS_INDETERMINATE : 0; 592 /* FIXME: don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */ 593 /* don't test TBSTATE_HIDDEN */ 594 return retstate; 595 } 596 597 598 static void 599 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) 600 { 601 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 602 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 603 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && 604 (btnPtr->fsStyle & TBSTYLE_DROPDOWN); 605 RECT rc, rcArrow, rcBitmap, rcText, rcFill; 439 606 LPWSTR lpText = NULL; 440 HIMAGELIST himl = infoPtr->himlDef; 441 442 TRACE ("iString: %x\n", btnPtr->iString); 607 NMTBCUSTOMDRAW tbcd; 608 DWORD ntfret; 609 INT offset; 610 611 if (btnPtr->fsState & TBSTATE_HIDDEN) 612 return; 613 614 rc = btnPtr->rect; 615 CopyRect (&rcFill, &rc); 616 CopyRect (&rcArrow, &rc); 617 CopyRect(&rcBitmap, &rc); 618 CopyRect(&rcText, &rc); 443 619 444 620 /* get a pointer to the text */ 445 621 lpText = TOOLBAR_GetText(infoPtr, btnPtr); 446 622 623 if (hasDropDownArrow) 624 { 625 if (dwStyle & TBSTYLE_FLAT) 626 rc.right = max(rc.left, rc.right - DDARROW_WIDTH); 627 else 628 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2); 629 rcArrow.left = rc.right; 630 } 631 632 /* Center the bitmap horizontally and vertically */ 633 if (dwStyle & TBSTYLE_LIST) 634 rcBitmap.left += 3; 635 else 636 rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2; 637 638 if(lpText) 639 rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */ 640 else 641 rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2; 642 643 TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n", 644 btnPtr->iBitmap, rcBitmap.left, rcBitmap.top, 645 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight); 646 TRACE ("iString: %x\n", btnPtr->iString); 447 647 TRACE ("Stringtext: %s\n", debugstr_w(lpText)); 448 648 … … 452 652 InflateRect (&rcText, -3, -3); 453 653 454 if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 654 if (infoPtr->himlDef && 655 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 455 656 /* The following test looked like this before 456 657 * I changed it. IE4 "Links" toolbar would not … … 477 678 } 478 679 479 if ( nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))680 if (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED)) 480 681 OffsetRect (&rcText, 1, 1); 481 482 TRACE("string rect=(%d,%d)-(%d,%d)\n", 483 rcText.left, rcText.top, rcText.right, rcText.bottom); 484 485 hOldFont = SelectObject (hdc, infoPtr->hFont); 486 if (!(nState & TBSTATE_ENABLED)) { 487 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT)); 488 OffsetRect (&rcText, 1, 1); 489 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 490 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 491 OffsetRect (&rcText, -1, -1); 492 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 493 } 494 else if (nState & TBSTATE_INDETERMINATE) { 495 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 496 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 497 } 498 else { 499 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); 500 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 501 } 502 503 SetTextColor (hdc, clrOld); 504 SelectObject (hdc, hOldFont); 505 } 506 } 507 508 509 static void 510 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect) 511 { 512 HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush); 513 INT cx = lpRect->right - lpRect->left; 514 INT cy = lpRect->bottom - lpRect->top; 515 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089); 516 SelectObject (hdc, hbr); 517 } 518 519 520 static void 521 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 522 HDC hdc, INT x, INT y) 523 { 524 /* FIXME: this function is a hack since it uses image list 525 internals directly */ 526 527 HIMAGELIST himl = infoPtr->himlDef; 528 HBITMAP hbmMask; 529 HDC hdcImageList; 530 HDC hdcMask; 531 532 if (!himl) 533 return; 534 535 /* create new dc's */ 536 hdcImageList = CreateCompatibleDC (0); 537 hdcMask = CreateCompatibleDC (0); 538 539 /* create new bitmap */ 540 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL); 541 SelectObject (hdcMask, hbmMask); 542 543 /* copy the mask bitmap */ 544 SelectObject (hdcImageList, himl->hbmMask); 545 SetBkColor (hdcImageList, RGB(255, 255, 255)); 546 SetTextColor (hdcImageList, RGB(0, 0, 0)); 547 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy, 548 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY); 549 550 /* draw the new mask */ 551 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT)); 552 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy, 553 hdcMask, 0, 0, 0xB8074A); 554 555 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW)); 556 BitBlt (hdc, x, y, himl->cx, himl->cy, 557 hdcMask, 0, 0, 0xB8074A); 558 559 DeleteObject (hbmMask); 560 DeleteDC (hdcMask); 561 DeleteDC (hdcImageList); 562 } 563 564 565 static void 566 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) 567 { 568 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 569 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 570 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && 571 (btnPtr->fsStyle & TBSTYLE_DROPDOWN); 572 RECT rc, rcArrow, rcBitmap; 573 574 if (btnPtr->fsState & TBSTATE_HIDDEN) 575 return; 576 577 rc = btnPtr->rect; 578 CopyRect (&rcArrow, &rc); 579 CopyRect(&rcBitmap, &rc); 682 } 683 684 /* Initialize fields in all cases, because we use these later */ 685 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW)); 686 tbcd.clrText = comctl32_color.clrBtnText; 687 tbcd.clrTextHighlight = comctl32_color.clrHighlightText; 688 tbcd.clrBtnFace = comctl32_color.clrBtnFace; 689 tbcd.clrBtnHighlight = comctl32_color.clrBtnHighlight; 690 tbcd.clrMark = comctl32_color.clrHighlight; 691 tbcd.clrHighlightHotTrack = 0; 692 tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; 693 tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; 694 /* MSDN says that this is the text rectangle. */ 695 /* But (why always a but) tracing of v5.7 of native shows */ 696 /* that this is really a *relative* rectangle based on the */ 697 /* the nmcd.rc. Also the left and top are always 0 ignoring*/ 698 /* any bitmap that might be present. */ 699 tbcd.rcText.left = 0; 700 tbcd.rcText.top = 0; 701 tbcd.rcText.right = rcText.right - rc.left; 702 tbcd.rcText.bottom = rcText.bottom - rc.top; 703 704 /* FIXME: what should these be set to ????? */ 705 tbcd.hbrMonoDither = 0; 706 tbcd.hbrLines = 0; 707 tbcd.hpenLines = 0; 708 709 /* Issue Item Prepaint notify */ 710 infoPtr->dwItemCustDraw = 0; 711 infoPtr->dwItemCDFlag = 0; 712 if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYITEMDRAW) 713 { 714 tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT; 715 tbcd.nmcd.hdc = hdc; 716 tbcd.nmcd.rc = rc; 717 tbcd.nmcd.dwItemSpec = btnPtr->idCommand; 718 tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr); 719 tbcd.nmcd.lItemlParam = btnPtr->dwData; 720 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); 721 infoPtr->dwItemCustDraw = ntfret & 0xffff; 722 infoPtr->dwItemCDFlag = ntfret & 0xffff0000; 723 if (infoPtr->dwItemCustDraw & CDRF_SKIPDEFAULT) 724 return; 725 /* save the only part of the rect that the user can change */ 726 rcText.right = tbcd.rcText.right + rc.left; 727 rcText.bottom = tbcd.rcText.bottom + rc.top; 728 } 580 729 581 730 if (!infoPtr->bBtnTranspnt) 582 FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE)); 583 584 if (hasDropDownArrow) 585 { 586 if (dwStyle & TBSTYLE_FLAT) 587 rc.right = max(rc.left, rc.right - DDARROW_WIDTH); 588 else 589 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2); 590 rcArrow.left = rc.right; 591 } 592 593 /* Center the bitmap horizontally and vertically */ 594 if (dwStyle & TBSTYLE_LIST) 595 rcBitmap.left += 3; 596 else 597 rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2; 598 599 if(TOOLBAR_HasText(infoPtr, btnPtr)) 600 rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */ 601 else 602 rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2; 603 604 TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n", 605 btnPtr->iBitmap, rcBitmap.left, rcBitmap.top, 606 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight); 731 FillRect( hdc, &rcFill, GetSysColorBrush(COLOR_BTNFACE)); 607 732 608 733 /* separator */ … … 615 740 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) { 616 741 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) 617 TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr );742 TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr, infoPtr); 618 743 else 619 TOOLBAR_DrawFlatSeparator (&rc, hdc); 620 } 621 return; 744 TOOLBAR_DrawFlatSeparator (&rc, hdc, infoPtr); 745 } 746 else if (btnPtr->fsStyle != TBSTYLE_SEP) { 747 FIXME("Draw some kind of separator: fsStyle=%x\n", 748 btnPtr->fsStyle); 749 } 750 goto FINALNOTIFY; 622 751 } 623 752 624 753 /* disabled */ 625 754 if (!(btnPtr->fsState & TBSTATE_ENABLED)) { 626 if (!(dwStyle & TBSTYLE_FLAT) )755 if (!(dwStyle & TBSTYLE_FLAT) && !(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES)) 627 756 { 628 757 DrawEdge (hdc, &rc, EDGE_RAISED, … … 644 773 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top); 645 774 646 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle );647 return;775 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd); 776 goto FINALNOTIFY; 648 777 } 649 778 650 779 /* pressed TBSTYLE_BUTTON */ 651 780 if (btnPtr->fsState & TBSTATE_PRESSED) { 652 if (dwStyle & TBSTYLE_FLAT) 781 offset = (infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) ? 0 : 1; 782 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES)) 653 783 { 654 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST); 655 if (hasDropDownArrow) 656 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST); 657 } 658 else 659 { 660 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 661 if (hasDropDownArrow) 662 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 784 if (dwStyle & TBSTYLE_FLAT) 785 { 786 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST); 787 if (hasDropDownArrow) 788 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST); 789 } 790 else 791 { 792 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 793 if (hasDropDownArrow) 794 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 795 } 663 796 } 664 797 … … 667 800 668 801 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef, 669 hdc, rcBitmap.left+ 1, rcBitmap.top+1,802 hdc, rcBitmap.left+offset, rcBitmap.top+offset, 670 803 ILD_NORMAL); 671 804 672 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle );673 return;805 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd); 806 goto FINALNOTIFY; 674 807 } 675 808 … … 677 810 if ((btnPtr->fsStyle & TBSTYLE_CHECK) && 678 811 (btnPtr->fsState & TBSTATE_CHECKED)) { 679 if (dwStyle & TBSTYLE_FLAT) 680 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, 681 BF_RECT | BF_ADJUST); 682 else 683 DrawEdge (hdc, &rc, EDGE_SUNKEN, 684 BF_RECT | BF_MIDDLE | BF_ADJUST); 812 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES)) 813 { 814 if (dwStyle & TBSTYLE_FLAT) 815 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, 816 BF_RECT | BF_ADJUST); 817 else 818 DrawEdge (hdc, &rc, EDGE_SUNKEN, 819 BF_RECT | BF_MIDDLE | BF_ADJUST); 820 } 685 821 686 822 TOOLBAR_DrawPattern (hdc, &rc); … … 690 826 ILD_NORMAL); 691 827 692 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle );693 return;828 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd); 829 goto FINALNOTIFY; 694 830 } 695 831 696 832 /* indeterminate */ 697 833 if (btnPtr->fsState & TBSTATE_INDETERMINATE) { 698 DrawEdge (hdc, &rc, EDGE_RAISED, 699 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 834 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES)) 835 DrawEdge (hdc, &rc, EDGE_RAISED, 836 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 700 837 701 838 TOOLBAR_DrawPattern (hdc, &rc); 702 839 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top); 703 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle );704 return;840 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd); 841 goto FINALNOTIFY; 705 842 } 706 843 … … 710 847 if (btnPtr->bHot) 711 848 { 712 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT); 713 if (hasDropDownArrow) 714 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT); 849 if ( infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK ) 850 { 851 COLORREF oldclr; 852 853 oldclr = SetBkColor(hdc, tbcd.clrHighlightHotTrack); 854 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0); 855 if (hasDropDownArrow) 856 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0); 857 SetBkColor(hdc, oldclr); 858 } 859 else 860 { 861 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES)) 862 { 863 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT); 864 if (hasDropDownArrow) 865 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT); 866 } 867 } 715 868 } 716 869 #if 1 … … 746 899 else 747 900 { 748 DrawEdge (hdc, &rc, EDGE_RAISED, 749 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 901 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES)) 902 DrawEdge (hdc, &rc, EDGE_RAISED, 903 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 750 904 751 905 if (hasDropDownArrow) 752 906 { 753 DrawEdge (hdc, &rcArrow, EDGE_RAISED, 754 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 907 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES)) 908 DrawEdge (hdc, &rcArrow, EDGE_RAISED, 909 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 755 910 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME); 756 911 } … … 758 913 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef, 759 914 hdc, rcBitmap.left, rcBitmap.top, 760 ILD_NORMAL); 761 } 762 763 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 915 ILD_NORMAL);} 916 917 918 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd); 919 920 FINALNOTIFY: 921 if (infoPtr->dwItemCustDraw & CDRF_NOTIFYPOSTPAINT) 922 { 923 tbcd.nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT; 924 tbcd.nmcd.hdc = hdc; 925 tbcd.nmcd.rc = rc; 926 tbcd.nmcd.dwItemSpec = btnPtr->idCommand; 927 tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr); 928 tbcd.nmcd.lItemlParam = btnPtr->dwData; 929 tbcd.rcText = rcText; 930 tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; 931 tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; 932 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); 933 } 934 764 935 } 765 936 … … 772 943 INT i, oldBKmode = 0; 773 944 RECT rcTemp; 945 NMTBCUSTOMDRAW tbcd; 946 DWORD ntfret; 774 947 775 948 /* if imagelist belongs to the app, it can be changed … … 779 952 780 953 TOOLBAR_DumpToolbar (infoPtr, __LINE__); 954 955 /* Send initial notify */ 956 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW)); 957 tbcd.nmcd.dwDrawStage = CDDS_PREPAINT; 958 tbcd.nmcd.hdc = hdc; 959 tbcd.nmcd.rc = ps->rcPaint; 960 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); 961 infoPtr->dwBaseCustDraw = ntfret & 0xffff; 781 962 782 963 if (infoPtr->bBtnTranspnt) … … 793 974 if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT)) 794 975 SetBkMode (hdc, oldBKmode); 976 977 if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTPAINT) 978 { 979 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW)); 980 tbcd.nmcd.dwDrawStage = CDDS_POSTPAINT; 981 tbcd.nmcd.hdc = hdc; 982 tbcd.nmcd.rc = ps->rcPaint; 983 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); 984 } 795 985 } 796 986 … … 820 1010 LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr); 821 1011 822 /* first get size of all the text */ 823 GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize); 824 825 /* feed above size into the rectangle for DrawText */ 826 myrect.left = myrect.top = 0; 827 myrect.right = lpSize->cx; 828 myrect.bottom = lpSize->cy; 829 830 /* Use DrawText to get true size as drawn (less pesky "&") */ 831 DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE | 832 DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ? 1012 if(lpText != NULL) { 1013 /* first get size of all the text */ 1014 GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize); 1015 1016 /* feed above size into the rectangle for DrawText */ 1017 myrect.left = myrect.top = 0; 1018 myrect.right = lpSize->cx; 1019 myrect.bottom = lpSize->cy; 1020 1021 /* Use DrawText to get true size as drawn (less pesky "&") */ 1022 DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE | 1023 DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ? 833 1024 DT_NOPREFIX : 0)); 834 1025 835 /* feed back to caller */ 836 lpSize->cx = myrect.right; 837 lpSize->cy = myrect.bottom; 1026 /* feed back to caller */ 1027 lpSize->cx = myrect.right; 1028 lpSize->cy = myrect.bottom; 1029 } 838 1030 } 839 1031 … … 891 1083 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE 892 1084 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items. 1085 * 1086 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow 1087 * vertical toolbar lists. 893 1088 */ 894 1089 … … 905 1100 /* no layout is necessary. Applications may use this style */ 906 1101 /* to perform their own layout on the toolbar. */ 907 if( !(dwStyle & TBSTYLE_WRAPABLE) )908 return;1102 if( !(dwStyle & TBSTYLE_WRAPABLE) && 1103 !(infoPtr->dwExStyle & TBSTYLE_EX_UNDOC1) ) return; 909 1104 910 1105 btnPtr = infoPtr->buttons; … … 972 1167 /* go to the next until it reaches a non separator. */ 973 1168 /* Wrap the last separator if it is before a button. */ 974 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) || 975 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 1169 while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) && 1170 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) || 1171 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 976 1172 i < infoPtr->nNumButtons ) 977 1173 { … … 1081 1277 TOOLBAR_CalcStrings (hwnd, &sizeString); 1082 1278 1279 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++) 1280 { 1281 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap)) 1282 usesBitmaps = TRUE; 1283 } 1083 1284 if (dwStyle & TBSTYLE_LIST) 1084 1285 { 1085 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)1086 {1087 if (infoPtr->buttons[i].iBitmap >= 0)1088 usesBitmaps = TRUE;1089 }1090 1286 infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight : 1091 0, sizeString.cy) + 6;1287 0, sizeString.cy) + infoPtr->szPadding.cy; 1092 1288 infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth : 1093 1289 0) + sizeString.cx + 6; … … 1098 1294 } 1099 1295 else { 1100 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)1101 {1102 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))1103 usesBitmaps = TRUE;1104 }1105 1106 1296 if (sizeString.cy > 0) 1107 1297 { … … 1252 1442 btnPtr->nRow = nRows + nSepRows; 1253 1443 1254 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d\n", 1255 i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow); 1444 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n", 1445 i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow, 1446 x, y, x+cx, y+cy); 1256 1447 1257 1448 if( bWrap ) … … 1275 1466 } 1276 1467 x = infoPtr->nIndent; 1468 1469 /* Increment row number unless this is the last button */ 1470 /* and it has Wrap set. */ 1471 if (i != infoPtr->nNumButtons-1) 1277 1472 nRows++; 1278 1473 } … … 1283 1478 /* infoPtr->nRows is the number of rows on the toolbar */ 1284 1479 infoPtr->nRows = nRows + nSepRows + 1; 1480 1481 #if 0 1482 /******************************************************************** 1483 * The following while interesting, does not match the values * 1484 * created above for the button rectangles, nor the rcBound rect. * 1485 * We will comment it out and remove it later. * 1486 * * 1487 * The problem showed up as heights in the pager control that was * 1488 * wrong. * 1489 ********************************************************************/ 1285 1490 1286 1491 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */ … … 1290 1495 nSepRows * (infoPtr->nBitmapHeight + 1) + 1291 1496 BOTTOM_BORDER; 1497 #endif 1498 1499 infoPtr->nHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top; 1500 1292 1501 TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth); 1293 1502 } … … 1333 1542 if (CommandIsIndex) { 1334 1543 TRACE("command is really index command=%d\n", idCommand); 1544 if (idCommand >= infoPtr->nNumButtons) return -1; 1335 1545 return idCommand; 1336 1546 } … … 1791 2001 1792 2002 /* set colors and select objects */ 1793 oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));2003 oldBk = SetBkColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlight:comctl32_color.clrWindow); 1794 2004 if (btnInfo->bVirtual) 1795 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));2005 oldText = SetTextColor (lpdis->hDC, comctl32_color.clrGrayText); 1796 2006 else 1797 oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));2007 oldText = SetTextColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlightText:comctl32_color.clrWindowText); 1798 2008 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1799 2009 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); … … 2000 2210 } 2001 2211 2212 TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos); 2213 2214 if (infoPtr->nNumBitmapInfos == 0) 2215 { 2216 infoPtr->bitmaps = COMCTL32_Alloc(sizeof(TBITMAP_INFO)); 2217 } 2218 else 2219 { 2220 TBITMAP_INFO *oldBitmaps = infoPtr->bitmaps; 2221 infoPtr->bitmaps = COMCTL32_Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO)); 2222 memcpy(&infoPtr->bitmaps[0], &oldBitmaps[0], infoPtr->nNumBitmapInfos); 2223 } 2224 2225 infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nButtons = nButtons; 2226 infoPtr->bitmaps[infoPtr->nNumBitmapInfos].hInst = lpAddBmp->hInst; 2227 infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nID = lpAddBmp->nID; 2228 2229 infoPtr->nNumBitmapInfos++; 2230 TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos); 2231 2002 2232 if (nIndex != -1) 2003 2233 { … … 2824 3054 2825 3055 2826 /* << TOOLBAR_GetColorScheme >> */2827 2828 2829 3056 static LRESULT 2830 3057 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) … … 2932 3159 2933 3160 /* << TOOLBAR_GetObject >> */ 2934 /* << TOOLBAR_GetPadding >> */ 3161 3162 3163 static LRESULT 3164 TOOLBAR_GetPadding (HWND hwnd) 3165 { 3166 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3167 DWORD oldPad; 3168 3169 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy); 3170 return (LRESULT) oldPad; 3171 } 2935 3172 2936 3173 … … 3215 3452 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE); 3216 3453 3217 if (nIndex < 0) 3218 return FALSE; 3219 3220 TRACE("inserting button index=%d\n", nIndex); 3221 if (nIndex > infoPtr->nNumButtons) { 3454 if (nIndex == -1) { 3455 /* EPP: this seems to be an undocumented call (from my IE4) 3456 * I assume in that case that: 3457 * - lpTbb->iString is a string pointer (not a string index in strings[] table 3458 * - index of insertion is at the end of existing buttons 3459 * I only see this happen with nIndex == -1, but it could have a special 3460 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion). 3461 */ 3222 3462 nIndex = infoPtr->nNumButtons; 3223 TRACE("adjust index=%d\n", nIndex); 3224 } 3225 3226 oldButtons = infoPtr->buttons; 3227 infoPtr->nNumButtons++; 3228 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons); 3229 /* pre insert copy */ 3230 if (nIndex > 0) { 3231 memcpy (&infoPtr->buttons[0], &oldButtons[0], 3232 nIndex * sizeof(TBUTTON_INFO)); 3233 } 3234 3463 3464 } else if (nIndex < 0) 3465 return FALSE; 3235 3466 3236 3467 /* If the string passed is not an index, assume address of string … … 3248 3479 lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr); 3249 3480 COMCTL32_Free(ptr); 3481 } 3482 3483 TRACE("inserting button index=%d\n", nIndex); 3484 if (nIndex > infoPtr->nNumButtons) { 3485 nIndex = infoPtr->nNumButtons; 3486 TRACE("adjust index=%d\n", nIndex); 3487 } 3488 3489 oldButtons = infoPtr->buttons; 3490 infoPtr->nNumButtons++; 3491 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons); 3492 /* pre insert copy */ 3493 if (nIndex > 0) { 3494 memcpy (&infoPtr->buttons[0], &oldButtons[0], 3495 nIndex * sizeof(TBUTTON_INFO)); 3250 3496 } 3251 3497 … … 3285 3531 COMCTL32_Free (oldButtons); 3286 3532 3533 TOOLBAR_CalcToolbar (hwnd); 3534 3287 3535 InvalidateRect (hwnd, NULL, TRUE); 3288 3536 … … 3407 3655 3408 3656 3409 /* << TOOLBAR_ReplaceBitmap >> */ 3410 3657 static LRESULT 3658 TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) 3659 { 3660 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3661 LPTBREPLACEBITMAP lpReplace = (LPTBREPLACEBITMAP) lParam; 3662 HBITMAP hBitmap; 3663 int i = 0, nOldButtons = 0, pos = 0; 3664 3665 TRACE("hInstOld %x nIDOld %x hInstNew %x nIDNew %x nButtons %x\n", 3666 lpReplace->hInstOld, lpReplace->nIDOld, lpReplace->hInstNew, lpReplace->nIDNew, 3667 lpReplace->nButtons); 3668 3669 if (lpReplace->hInstOld == -1) 3670 { 3671 FIXME("changing standard bitmaps not implemented\n"); 3672 return FALSE; 3673 } 3674 else if (lpReplace->hInstOld != 0) 3675 { 3676 FIXME("resources not in the current module not implemented\n"); 3677 return FALSE; 3678 } 3679 else 3680 { 3681 hBitmap = (HBITMAP) lpReplace->nIDNew; 3682 } 3683 3684 TRACE("To be replaced hInstOld %x nIDOld %x\n", lpReplace->hInstOld, lpReplace->nIDOld); 3685 for (i = 0; i < infoPtr->nNumBitmapInfos; i++) { 3686 TBITMAP_INFO *tbi = &infoPtr->bitmaps[i]; 3687 TRACE("tbimapinfo %d hInstOld %x nIDOld %x\n", i, tbi->hInst, tbi->nID); 3688 if (tbi->hInst == lpReplace->hInstOld && tbi->nID == lpReplace->nIDOld) 3689 { 3690 TRACE("Found: nButtons %d hInst %x nID %x\n", tbi->nButtons, tbi->hInst, tbi->nID); 3691 nOldButtons = tbi->nButtons; 3692 tbi->nButtons = lpReplace->nButtons; 3693 tbi->hInst = lpReplace->hInstNew; 3694 tbi->nID = lpReplace->nIDNew; 3695 TRACE("tbimapinfo changed %d hInstOld %x nIDOld %x\n", i, tbi->hInst, tbi->nID); 3696 break; 3697 } 3698 pos += tbi->nButtons; 3699 } 3700 3701 if (nOldButtons == 0) 3702 { 3703 WARN("No hinst/bitmap found! hInst %x nID %x\n", lpReplace->hInstOld, lpReplace->nIDOld); 3704 return FALSE; 3705 } 3706 3707 infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldButtons + lpReplace->nButtons; 3708 3709 /* ImageList_Replace(infoPtr->himlDef, pos, hBitmap, NULL); */ 3710 3711 3712 for (i = pos + nOldButtons - 1; i >= pos; i--) { 3713 ImageList_Remove(infoPtr->himlDef, i); 3714 } 3715 3716 ImageList_AddMasked(infoPtr->himlDef, hBitmap, CLR_DEFAULT); 3717 3718 InvalidateRect(hwnd, NULL, FALSE); 3719 3720 return TRUE; 3721 } 3411 3722 3412 3723 static LRESULT … … 3599 3910 { 3600 3911 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3601 3602 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 3912 INT cx = LOWORD(lParam), cy = HIWORD(lParam); 3913 3914 if ((cx < 0) || (cy < 0)) 3603 3915 { 3604 ERR("invalid parameter \n");3916 ERR("invalid parameter 0x%08lx\n", (DWORD)lParam); 3605 3917 return FALSE; 3606 3918 } … … 3612 3924 * Further testing shows that we must actually perform the change too. 3613 3925 */ 3614 infoPtr->nButtonWidth = (INT)LOWORD(lParam); 3615 infoPtr->nButtonHeight = (INT)HIWORD(lParam); 3926 /* 3927 * The documentation also does not mention that if 0 is supplied for 3928 * either size, the system changes it to the default of 24 wide and 3929 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02 3930 */ 3931 infoPtr->nButtonWidth = (cx) ? cx : 24; 3932 infoPtr->nButtonHeight = (cy) ? cy : 22; 3616 3933 return TRUE; 3617 3934 } … … 3681 3998 3682 3999 3683 /* << TOOLBAR_SetColorScheme >> */3684 3685 3686 4000 static LRESULT 3687 4001 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) … … 3718 4032 } 3719 4033 3720 3721 4034 static LRESULT 3722 4035 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam) … … 3727 4040 dwTemp = infoPtr->dwExStyle; 3728 4041 infoPtr->dwExStyle = (DWORD)lParam; 4042 4043 if (infoPtr->dwExStyle & (TBSTYLE_EX_MIXEDBUTTONS | 4044 TBSTYLE_EX_HIDECLIPPEDBUTTONS)) { 4045 FIXME("Extended style not implemented %s %s\n", 4046 (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ? 4047 "TBSTYLE_EX_MIXEDBUTTONS" : "", 4048 (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) ? 4049 "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : ""); 4050 } 4051 4052 if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL) 4053 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n", 4054 (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)); 3729 4055 3730 4056 return (LRESULT)dwTemp; … … 3869 4195 3870 4196 3871 /* << TOOLBAR_SetPadding >> */ 4197 static LRESULT 4198 TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam) 4199 { 4200 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 4201 DWORD oldPad; 4202 4203 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy); 4204 infoPtr->szPadding.cx = LOWORD((DWORD)lParam); 4205 infoPtr->szPadding.cy = HIWORD((DWORD)lParam); 4206 FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n", 4207 infoPtr->szPadding.cx, infoPtr->szPadding.cy); 4208 return (LRESULT) oldPad; 4209 } 3872 4210 3873 4211 … … 4015 4353 4016 4354 static LRESULT 4355 TOOLBAR_GetColorScheme (HWND hwnd, LPCOLORSCHEME lParam) 4356 { 4357 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 4358 4359 lParam->clrBtnHighlight = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ? 4360 comctl32_color.clrBtnHighlight : 4361 infoPtr->clrBtnHighlight; 4362 lParam->clrBtnShadow = (infoPtr->clrBtnShadow == CLR_DEFAULT) ? 4363 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow; 4364 return 1; 4365 } 4366 4367 4368 static LRESULT 4369 TOOLBAR_SetColorScheme (HWND hwnd, LPCOLORSCHEME lParam) 4370 { 4371 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 4372 4373 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n", 4374 lParam->clrBtnHighlight, lParam->clrBtnShadow, 4375 infoPtr->clrBtnHighlight, infoPtr->clrBtnShadow); 4376 4377 infoPtr->clrBtnHighlight = lParam->clrBtnHighlight; 4378 infoPtr->clrBtnShadow = lParam->clrBtnShadow; 4379 InvalidateRect(hwnd, 0, 0); 4380 return 0; 4381 } 4382 4383 4384 static LRESULT 4017 4385 TOOLBAR_SetVersion (HWND hwnd, INT iVersion) 4018 4386 { … … 4023 4391 4024 4392 return iOldVersion; 4393 } 4394 4395 4396 /*********************************************************************/ 4397 /* */ 4398 /* This is undocumented and appears to be a "Super" TB_SETHOTITEM */ 4399 /* without the restriction of TBSTYLE_FLAT. This implementation is */ 4400 /* based on relay traces of the native control and IE 5.5 */ 4401 /* */ 4402 /*********************************************************************/ 4403 static LRESULT 4404 TOOLBAR_Unkwn45E (HWND hwnd, WPARAM wParam, LPARAM lParam) 4405 { 4406 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd); 4407 INT nOldHotItem = infoPtr->nHotItem; 4408 TBUTTON_INFO *btnPtr; 4409 INT no_hi = 0; 4410 NMTBHOTITEM nmhotitem; 4411 4412 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons) 4413 wParam = -2; 4414 4415 infoPtr->nHotItem = (INT)wParam; 4416 if (nOldHotItem != infoPtr->nHotItem) { 4417 nmhotitem.dwFlags = (DWORD)lParam; 4418 if ( !(nmhotitem.dwFlags & HICF_ENTERING) ) 4419 nmhotitem.idOld = (nOldHotItem >= 0) ? 4420 infoPtr->buttons[nOldHotItem].idCommand : 0; 4421 if ( !(nmhotitem.dwFlags & HICF_LEAVING) ) 4422 nmhotitem.idNew = (infoPtr->nHotItem >= 0) ? 4423 infoPtr->buttons[infoPtr->nHotItem].idCommand : 0; 4424 no_hi = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE); 4425 } 4426 if ((INT)wParam >=0) { 4427 btnPtr = &infoPtr->buttons[(INT)wParam]; 4428 btnPtr->bHot = (no_hi) ? FALSE : TRUE; 4429 InvalidateRect (hwnd, &btnPtr->rect, 4430 TOOLBAR_HasText(infoPtr, btnPtr)); 4431 } 4432 if (nOldHotItem>=0) { 4433 btnPtr = &infoPtr->buttons[nOldHotItem]; 4434 btnPtr->bHot = FALSE; 4435 InvalidateRect (hwnd, &btnPtr->rect, 4436 TOOLBAR_HasText(infoPtr, btnPtr)); 4437 } 4438 GetFocus(); 4439 TRACE("old item=%d, new item=%d, flags=%08lx, notify=%d\n", 4440 nOldHotItem, infoPtr->nHotItem, (DWORD)lParam, no_hi); 4441 4442 if (nOldHotItem < 0) 4443 return -1; 4444 4445 return (LRESULT)nOldHotItem; 4446 } 4447 4448 4449 static LRESULT 4450 TOOLBAR_Unkwn463 (HWND hwnd, WPARAM wParam, LPARAM lParam) 4451 { 4452 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 4453 LPSIZE lpsize = (LPSIZE)lParam; 4454 4455 if (lpsize == NULL) 4456 return FALSE; 4457 4458 /* 4459 * Testing shows the following: 4460 * wParam = 0 adjust cx value 4461 * = 1 set cy value to max size. 4462 * lParam pointer to SIZE structure 4463 * 4464 */ 4465 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n", 4466 wParam, lParam, lpsize->cx, lpsize->cy); 4467 4468 switch(wParam) { 4469 case 0: 4470 if (lpsize->cx == -1) { 4471 /* **** this is wrong, native measures each button and sets it */ 4472 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left; 4473 } 4474 else if(HIWORD(lpsize->cx)) { 4475 RECT rc; 4476 HWND hwndParent = GetParent(hwnd); 4477 4478 InvalidateRect(hwnd, 0, 1); 4479 GetWindowRect(hwnd, &rc); 4480 MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2); 4481 TRACE("mapped to (%d,%d)-(%d,%d)\n", 4482 rc.left, rc.top, rc.right, rc.bottom); 4483 lpsize->cx = max(rc.right-rc.left, 4484 infoPtr->rcBound.right - infoPtr->rcBound.left); 4485 } 4486 else { 4487 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left; 4488 } 4489 break; 4490 case 1: 4491 lpsize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top; 4492 /* lpsize->cy = infoPtr->nHeight; */ 4493 break; 4494 default: 4495 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n", 4496 wParam); 4497 return 0; 4498 } 4499 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n", 4500 lpsize->cx, lpsize->cy); 4501 return 1; 4025 4502 } 4026 4503 … … 4058 4535 infoPtr->bAnchor = FALSE; /* no anchor highlighting */ 4059 4536 infoPtr->iVersion = 0; 4060 infoPtr->bNtfUnicode = FALSE;4061 4537 infoPtr->hwndSelf = hwnd; 4062 4538 infoPtr->bDoRedraw = TRUE; 4539 infoPtr->clrBtnHighlight = CLR_DEFAULT; 4540 infoPtr->clrBtnShadow = CLR_DEFAULT; 4541 infoPtr->szPadding.cx = 7; 4542 infoPtr->szPadding.cy = 6; 4543 TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY); 4063 4544 4064 4545 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); … … 4137 4618 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 4138 4619 NMTBCUSTOMDRAW tbcd; 4139 INT ret = FALSE, ntfret; 4620 INT ret = FALSE; 4621 DWORD ntfret; 4140 4622 4141 4623 if (dwStyle & TBSTYLE_CUSTOMERASE) { … … 4144 4626 tbcd.nmcd.hdc = (HDC)wParam; 4145 4627 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); 4628 infoPtr->dwBaseCustDraw = ntfret & 0xffff; 4629 4146 4630 /* FIXME: in general the return flags *can* be or'ed together */ 4147 switch ( ntfret)4631 switch (infoPtr->dwBaseCustDraw) 4148 4632 { 4149 4633 case CDRF_DODEFAULT: … … 4152 4636 return TRUE; 4153 4637 default: 4154 FIXME("[%04x] response % d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",4638 FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n", 4155 4639 hwnd, ntfret); 4156 4640 } … … 4176 4660 ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam); 4177 4661 4178 if (dwStyle & TBSTYLE_CUSTOMERASE) { 4662 if ((dwStyle & TBSTYLE_CUSTOMERASE) && 4663 (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTERASE)) { 4179 4664 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW)); 4180 4665 tbcd.nmcd.dwDrawStage = CDDS_POSTERASE; 4181 4666 tbcd.nmcd.hdc = (HDC)wParam; 4182 4667 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); 4183 switch (ntfret) 4668 infoPtr->dwBaseCustDraw = ntfret & 0xffff; 4669 switch (infoPtr->dwBaseCustDraw) 4184 4670 { 4185 4671 case CDRF_DODEFAULT: … … 4188 4674 return TRUE; 4189 4675 default: 4190 FIXME("[%04x] response % d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",4676 FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n", 4191 4677 hwnd, ntfret); 4192 4678 } … … 4345 4831 infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE; 4346 4832 4347 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {4348 4833 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 4349 4834 btnPtr->fsState &= ~TBSTATE_PRESSED; 4350 4835 4351 if (nHit == infoPtr->nButtonDown) { 4352 if (btnPtr->fsStyle & TBSTYLE_CHECK) { 4836 if (btnPtr->fsStyle & TBSTYLE_CHECK) { 4353 4837 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 4354 4838 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, 4355 infoPtr->nButtonDown);4356 if (nOldIndex == infoPtr->nButtonDown)4839 nHit); 4840 if (nOldIndex == nHit) 4357 4841 bSendMessage = FALSE; 4358 if ((nOldIndex != infoPtr->nButtonDown) &&4842 if ((nOldIndex != nHit) && 4359 4843 (nOldIndex != -1)) 4360 4844 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; … … 4367 4851 btnPtr->fsState |= TBSTATE_CHECKED; 4368 4852 } 4369 } 4370 } 4371 else 4372 bSendMessage = FALSE; 4853 } 4373 4854 4374 4855 if (nOldIndex != -1) … … 4383 4864 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged) 4384 4865 */ 4385 ReleaseCapture (); 4866 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) 4867 ReleaseCapture (); 4386 4868 4387 4869 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */ … … 4404 4886 TBN_ENDDRAG); 4405 4887 4406 if (bSendMessage) 4407 SendMessageA (infoPtr->hwndNotify, WM_COMMAND, 4408 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd); 4888 SendMessageA (infoPtr->hwndNotify, WM_COMMAND, 4889 MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd); 4409 4890 4410 4891 /* !!! Undocumented - toolbar at 4.71 level and above sends … … 4416 4897 TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr, 4417 4898 NM_CLICK); 4418 }4419 4420 4899 return 0; 4421 4900 } … … 4488 4967 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) 4489 4968 { 4490 TBUTTON_INFO *btnPtr , *oldBtnPtr;4969 TBUTTON_INFO *btnPtr = NULL, *oldBtnPtr = NULL; 4491 4970 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 4492 4971 POINT pt; 4493 4972 INT nHit; 4494 4973 TRACKMOUSEEVENT trackinfo; 4974 NMTBHOTITEM nmhotitem; 4495 4975 4496 4976 /* fill in the TRACKMOUSEEVENT struct */ … … 4530 5010 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 4531 5011 oldBtnPtr->bHot = FALSE; 4532 4533 InvalidateRect (hwnd, &oldBtnPtr->rect, 4534 TOOLBAR_HasText(infoPtr, oldBtnPtr)); 4535 } 5012 } 4536 5013 4537 5014 /* It's not a separator or in nowhere. It's a hot button. */ … … 4546 5023 { 4547 5024 btnPtr->bHot = TRUE; 4548 InvalidateRect(hwnd, &btnPtr->rect,4549 TOOLBAR_HasText(infoPtr, btnPtr));4550 5025 } 4551 4552 } 4553 4554 if (infoPtr->bCaptured) { 5026 } 5027 5028 nmhotitem.dwFlags = HICF_MOUSE; 5029 if (oldBtnPtr) 5030 nmhotitem.idOld = oldBtnPtr->idCommand; 5031 else 5032 nmhotitem.dwFlags |= HICF_ENTERING; 5033 if (btnPtr) 5034 nmhotitem.idNew = btnPtr->idCommand; 5035 else 5036 nmhotitem.dwFlags |= HICF_LEAVING; 5037 TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE); 5038 5039 /* now invalidate the old and new buttons so they will be painted */ 5040 if (oldBtnPtr) 5041 InvalidateRect (hwnd, &oldBtnPtr->rect, 5042 TOOLBAR_HasText(infoPtr, oldBtnPtr)); 5043 if (btnPtr && (btnPtr->fsState & TBSTATE_ENABLED)) 5044 InvalidateRect(hwnd, &btnPtr->rect, 5045 TOOLBAR_HasText(infoPtr, btnPtr)); 5046 5047 if (infoPtr->bCaptured) { 4555 5048 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 4556 5049 if (infoPtr->nOldHit == infoPtr->nButtonDown) { … … 4705 5198 4706 5199 if (lppgc->dwFlag == PGF_CALCWIDTH) { 4707 lppgc->iWidth = infoPtr-> nWidth;5200 lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left; 4708 5201 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n", 4709 infoPtr->nWidth);5202 lppgc->iWidth); 4710 5203 } 4711 5204 else { 4712 lppgc->iHeight = infoPtr-> nHeight;5205 lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top; 4713 5206 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n", 4714 infoPtr->nHeight);5207 lppgc->iHeight); 4715 5208 } 4716 5209 return 0; … … 4721 5214 4722 5215 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) { 4723 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam); 5216 if (infoPtr->bNtfUnicode) 5217 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, 5218 wParam, lParam); 5219 else 5220 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 5221 wParam, lParam); 4724 5222 4725 5223 #if 0 … … 4740 5238 4741 5239 return 0; 5240 } 5241 5242 5243 static LRESULT 5244 TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam) 5245 { 5246 /* remove this routine when Toolbar is improved to pass infoPtr 5247 * around instead of hwnd. 5248 */ 5249 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd); 5250 return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam); 5251 } 5252 5253 5254 static LRESULT 5255 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 5256 { 5257 INT i; 5258 5259 if (lParam == NF_REQUERY) { 5260 i = SendMessageA(GetParent(infoPtr->hwndSelf), 5261 WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY); 5262 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { 5263 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", 5264 i); 5265 i = NFR_ANSI; 5266 } 5267 infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0; 5268 return (LRESULT)i; 5269 } 5270 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI); 4742 5271 } 4743 5272 … … 4908 5437 4909 5438 5439 static LRESULT 5440 TOOLBAR_SysColorChange (HWND hwnd) 5441 { 5442 COMCTL32_RefreshSysColors(); 5443 5444 return 0; 5445 } 5446 5447 4910 5448 4911 5449 static LRESULT WINAPI … … 4989 5527 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam); 4990 5528 4991 /* case TB_GETCOLORSCHEME: */ /* 4.71 */4992 4993 5529 case TB_GETDISABLEDIMAGELIST: 4994 5530 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam); … … 5016 5552 5017 5553 /* case TB_GETOBJECT: */ /* 4.71 */ 5018 /* case TB_GETPADDING: */ /* 4.71 */ 5554 5555 case TB_GETPADDING: 5556 return TOOLBAR_GetPadding (hwnd); 5019 5557 5020 5558 case TB_GETRECT: … … 5038 5576 case TB_GETUNICODEFORMAT: 5039 5577 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam); 5040 5041 case CCM_GETVERSION:5042 return TOOLBAR_GetVersion (hwnd);5043 5578 5044 5579 case TB_HIDEBUTTON: … … 5089 5624 return TOOLBAR_PressButton (hwnd, wParam, lParam); 5090 5625 5091 /* case TB_REPLACEBITMAP: */ 5626 case TB_REPLACEBITMAP: 5627 return TOOLBAR_ReplaceBitmap (hwnd, wParam, lParam); 5092 5628 5093 5629 case TB_SAVERESTOREA: … … 5118 5654 return TOOLBAR_SetCmdId (hwnd, wParam, lParam); 5119 5655 5120 /* case TB_SETCOLORSCHEME: */ /* 4.71 */5121 5122 5656 case TB_SETDISABLEDIMAGELIST: 5123 5657 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam); … … 5149 5683 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam); 5150 5684 5151 /* case TB_SETPADDING: */ /* 4.71 */ 5685 case TB_SETPADDING: 5686 return TOOLBAR_SetPadding (hwnd, wParam, lParam); 5152 5687 5153 5688 case TB_SETPARENT: … … 5169 5704 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam); 5170 5705 5706 case TB_UNKWN45E: 5707 return TOOLBAR_Unkwn45E (hwnd, wParam, lParam); 5708 5709 case TB_UNKWN463: 5710 return TOOLBAR_Unkwn463 (hwnd, wParam, lParam); 5711 5712 5713 /* Common Control Messages */ 5714 5715 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */ 5716 case CCM_GETCOLORSCHEME: 5717 return TOOLBAR_GetColorScheme (hwnd, (LPCOLORSCHEME)lParam); 5718 5719 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */ 5720 case CCM_SETCOLORSCHEME: 5721 return TOOLBAR_SetColorScheme (hwnd, (LPCOLORSCHEME)lParam); 5722 5723 case CCM_GETVERSION: 5724 return TOOLBAR_GetVersion (hwnd); 5725 5171 5726 case CCM_SETVERSION: 5172 5727 return TOOLBAR_SetVersion (hwnd, (INT)wParam); … … 5223 5778 return TOOLBAR_Notify (hwnd, wParam, lParam); 5224 5779 5225 /* case WM_NOTIFYFORMAT: */ 5780 case WM_NOTIFYFORMAT: 5781 TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam); 5226 5782 5227 5783 case WM_PAINT: … … 5237 5793 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam); 5238 5794 5239 /* case WM_SYSCOLORCHANGE: */ 5795 case WM_SYSCOLORCHANGE: 5796 return TOOLBAR_SysColorChange (hwnd); 5240 5797 5241 5798 /* case WM_WININICHANGE: */ … … 5254 5811 } 5255 5812 5813 /* We see this in Outlook Express 5.x and just does DefWindowProc */ 5814 case PGM_FORWARDMOUSE: 5815 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 5816 5256 5817 default: 5257 5818 if (uMsg >= WM_USER) -
trunk/src/comctl32/tooltips.cpp
r7616 r8382 27 27 #include "ccbase.h" 28 28 #include "comctl32.h" 29 #ifdef __WIN32OS2__ 30 #include <dbglog.h> 31 #endif 29 32 30 33 #define ID_TIMERSHOW 1 /* show delay timer */
Note:
See TracChangeset
for help on using the changeset viewer.