From d5d98f8ef5077717c723ef1467c98d275a7dedd3 Mon Sep 17 00:00:00 2001 From: xj qian <qianxj15@sina.com> Date: 星期四, 04 七月 2024 14:26:28 +0800 Subject: [PATCH] add listbox --- jrj/xframe/xcontrol/xlistbox.hpp | 525 +++++++++++++++++++++++++++ jrj/xframe/xcontrol/xlistview.hpp | 533 ++++++++++++++++++++++++++++ jrj/project/business/SO3.list.cpp | 4 jrj/ext-jrj/ext-jrj.vcxproj | 30 + 4 files changed, 1,086 insertions(+), 6 deletions(-) diff --git a/jrj/ext-jrj/ext-jrj.vcxproj b/jrj/ext-jrj/ext-jrj.vcxproj index f69ebbd..f9aeb6a 100644 --- a/jrj/ext-jrj/ext-jrj.vcxproj +++ b/jrj/ext-jrj/ext-jrj.vcxproj @@ -121,6 +121,7 @@ <PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <AdditionalIncludeDirectories>..\xframe;..\xframe\system;..\project</AdditionalIncludeDirectories> + <InlineFunctionExpansion>Disabled</InlineFunctionExpansion> </ClCompile> <Link> <SubSystem>Windows</SubSystem> @@ -139,7 +140,7 @@ <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>NDEBUG;EXTJRJ_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PreprocessorDefinitions>NDEBUG;EXTJRJ_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_XWIN;%(PreprocessorDefinitions)</PreprocessorDefinitions> <ConformanceMode>true</ConformanceMode> <PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> @@ -230,6 +231,10 @@ <ClInclude Include="..\xframe\xcontrol\xflowchart.hpp" /> <ClInclude Include="..\xframe\xcontrol\xhtml.hpp" /> <ClInclude Include="..\xframe\xcontrol\xlayersheet.hpp" /> + <ClInclude Include="..\xframe\xcontrol\xlistbox.hpp"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> + </ClInclude> + <ClInclude Include="..\xframe\xcontrol\xlistview.hpp" /> <ClInclude Include="..\xframe\xcontrol\xreport.hpp" /> <ClInclude Include="..\xframe\xcontrol\xshtml.hpp" /> <ClInclude Include="..\xframe\xcontrol\xtreeview.hpp" /> @@ -259,23 +264,26 @@ </ClCompile> <ClCompile Include="..\project\business\GDN\GDNSourcePaperCard.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\GDN\GDNSourcePriceMaint.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\GDN\select.item.po.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\GDN\SelectItem.New.GDN.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\HR\AdministrativeDepartment.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\HR\AdministrativeDepartmentFolder.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\HR\BlankExcelTemplate.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> @@ -289,13 +297,14 @@ </ClCompile> <ClCompile Include="..\project\business\HR\ManpowerFileWindow.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\PO\business4.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\PO\Maint.PaperCard.PO.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\PO\Maint.PurcherItem.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> @@ -312,9 +321,11 @@ </ClCompile> <ClCompile Include="..\project\business\Public\message.business.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Public\message.supplier.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\quote.enquiry.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> @@ -346,6 +357,7 @@ </ClCompile> <ClCompile Include="..\project\business\SO\Product.FetchNo.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\SO\Product.Select.SO.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> @@ -363,33 +375,43 @@ </ClCompile> <ClCompile Include="..\project\business\Supplier\asklist.Owner.Supplier.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Supplier\Inspection.Supplie.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Supplier\list.Owner.Supplier.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Supplier\maint.Document.Supplier.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Supplier\maint.Document.SupplierEx.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Supplier\maint.Document.SupplierSD.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Supplier\maint.Owner.Supplier.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Supplier\maintex.Owner.Supplier.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Supplier\paymen.Supplie.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\business\Supplier\SupplierSource.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\project\printview\Maint.Template.PrintEx.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> diff --git a/jrj/project/business/SO3.list.cpp b/jrj/project/business/SO3.list.cpp index c75d8cc..8f92f1c 100644 --- a/jrj/project/business/SO3.list.cpp +++ b/jrj/project/business/SO3.list.cpp @@ -143,8 +143,8 @@ dw_list.SetItemString(row, L"ApplyStatus", arg.GetArgString(L"state")); if (arg.GetArgString(L"billstatus") != L"") { - string billstatus = arg.GetArgString(L"billstatus"); - string statusName = GetBillStatusName(billstatus); + xstring billstatus = arg.GetArgString(L"billstatus"); + xstring statusName = GetBillStatusName(billstatus); dw_list.SetItemString(row, L"ApprovalStatus", billstatus); dw_list.SetItemDisplayString(row, L"ApprovalStatus", statusName); } diff --git a/jrj/xframe/xcontrol/xlistbox.hpp b/jrj/xframe/xcontrol/xlistbox.hpp new file mode 100644 index 0000000..bbadab4 --- /dev/null +++ b/jrj/xframe/xcontrol/xlistbox.hpp @@ -0,0 +1,525 @@ +#pragma once + +#include "wobject/xcontrol.hpp" +#include "win32/win.hpp" + +class xlistbox : public xcontrol +{ + static int GetCount(HWND hWnd)//杩斿洖鍒楄〃椤规�婚」鏁� + { + int LB_GETCOUNT = 0x018B; + return SendMessage(hWnd, LB_GETCOUNT, 0, 0); + } + + static int AddItem(HWND hWnd, string str)//杩藉姞涓�涓垪琛ㄩ」锛屽鏋滄寚瀹氫簡LBS_SORT椋庢牸锛屽皢閲嶆帓搴忥紝鍚﹀垯杩藉姞鍒版渶鍚� + { + int LB_ADDSTRING = 0x0180; + return SendMessage(hWnd, LB_ADDSTRING, 0, (LPARAM)str); + } + + static int AddItem(HWND hWnd, string str, int p)//杩藉姞涓�涓垪琛ㄩ」锛屽鏋滄寚瀹氫簡LBS_SORT椋庢牸锛屽皢閲嶆帓搴忥紝鍚﹀垯杩藉姞鍒版渶鍚� + { + int LB_ADDSTRING = 0x0180; + int nIndex = SendMessage(hWnd, LB_ADDSTRING, 0, (LPARAM)str); + int LB_SETITEMDATA = 0x019A; + SendMessage(hWnd, LB_SETITEMDATA, nIndex, p); + return nIndex; + } + static int InsertItem(HWND hWnd, int nIndex, string str)//鎸囧畾浣嶇疆鎻掑叆锛寃Param=-1娣诲姞鍒版湯灏俱�傚鏋滄寚瀹氫簡LBS_SORT椋庢牸锛屽垯涓嶄細閲嶆帓搴忥紝鎵�浠BS_SORT椋庢牸涓嬩笉鐢ㄣ�� + { + int LB_INSERTSTRING = 0x0181; + return SendMessage(hWnd, LB_INSERTSTRING, nIndex, (LPARAM)str); + } + + static int DeleteItem(HWND hWnd, int nIndex) //鍒犻櫎鎸囧畾鐨勫垪琛ㄩ」锛宭Param is not used + { + int LB_DELETESTRING = 0x0182; + return SendMessage(hWnd, LB_DELETESTRING, nIndex, 0); + } + + static int FindString(HWND hWnd, int nIndex, string str)//浠庢寚瀹氬紑濮嬭〃椤瑰簭鍙峰紑濮嬫煡鎵炬寚瀹氶」锛屽拷鐣ュぇ灏忓啓锛寃Param=-1浠庣涓�椤规壘 + { + int LB_ERR = -1; + int LB_FINDSTRING = 0x018F; + int lResult = SendMessage(hWnd, LB_FINDSTRING, nIndex, (LPARAM)str); + return lResult; + } + + static int FindStringExact(HWND hWnd, int nIndex, string str)//鏁翠釜瀛楃涓插尮閰� + { + int LB_ERR = -1; + int LB_FINDSTRINGEXACT = 0x01A2; + int lResult = SendMessage(hWnd, LB_FINDSTRINGEXACT, nIndex, (LPARAM)str); + return lResult; + } + + static int GetAnchorIndex(HWND hWnd)//杩斿洖榧犳爣鏈�鍚庨�変腑鐨勯」鐨勭储寮� + { + int LB_GETANCHORINDEX = 0x019D; + return SendMessage(hWnd, LB_GETANCHORINDEX, 0, 0); + } + + static int GetCaretIndex(HWND hWnd)//杩斿洖鍏锋湁鐭╁舰鐒︾偣鐨勯」鐨勭储寮� + { + int LB_GETCARETINDEX = 0x019F; + return SendMessage(hWnd, LB_GETCARETINDEX, 0, 0); + } + + static int GetCurSel(HWND hWnd)//鍗曢�夛紝杩斿洖褰撳墠琚�変腑椤圭储寮� + { + int LB_GETCURSEL = 0x0188; + return SendMessage(hWnd, LB_GETCURSEL, 0, 0); + } + + static int GetHorizon(HWND hWnd)//杩斿洖鍒楄〃妗嗗彲婊氬姩鐨勫搴︼紙鍍忕礌锛� + { + int LB_GETHORIZONTALEXTENT = 0x0193; + return SendMessage(hWnd, LB_GETHORIZONTALEXTENT, 0, 0); + } + + static int GetItemData(HWND hWnd, int nIndex)//杩斿洖鎸囧畾鍒楄〃椤圭殑闄勫姞鏁版嵁锛涗笉鏄疞BS_HASSTRINGS椋庢牸鐨勶紝鍐呭鏉ヨ嚜浜嶭B_ADDSTRING鎴朙B_INSERTSTRING娑堟伅鐨刲Param鍙傛暟锛屽惁鍒欏唴瀹规潵鑷簬LB_SETITEMDATA娑堟伅鐨刲Param + { + int LB_GETITEMDATA = 0x0199; + return SendMessage(hWnd, LB_GETITEMDATA, nIndex, 0); + } + static int SetItemData(HWND hWnd, int nIndex, string str)//杩斿洖鎸囧畾鍒楄〃椤圭殑闄勫姞鏁版嵁锛涗笉鏄疞BS_HASSTRINGS椋庢牸鐨勶紝鍐呭鏉ヨ嚜浜嶭B_ADDSTRING鎴朙B_INSERTSTRING娑堟伅鐨刲Param鍙傛暟锛屽惁鍒欏唴瀹规潵鑷簬LB_SETITEMDATA娑堟伅鐨刲Param + { + int LB_SETITEMDATA = 0x019A; + return SendMessage(hWnd, LB_SETITEMDATA, nIndex, (LPARAM)str); + } + + static int GetItemHeight(HWND hWnd, int nIndex)//杩斿洖鍒楄〃椤逛腑鏌愪竴椤圭殑楂樺害锛堝儚绱狅級锛涚敤浜嶭BS_OWNERDRAWVARIABLE椋庢牸鐨勶紝wParam鎸囧畾鐨勫弬鏁� + { + int LB_GETITEMHEIGHT = 0x01A1; + return SendMessage(hWnd, LB_GETITEMHEIGHT, nIndex, 0); + } + /*static Rect GetItemRect(HWND hWnd,int nIndex)//鑾峰緱鍒楄〃椤圭殑瀹㈡埛鍖篟ECT + { + int LB_GETITEMRECT = 0x0198; + xrect rect; + return SendMessage(hWnd,LB_GETITEMRECT,nIndex,rect); + }*/ + static int GetSel(HWND hWnd, int nIndex)//杩斿洖鎸囧畾鍒楄〃椤圭殑鐘舵�侊紝濡傛灉鏌ヨ鐨勫垪琛ㄩ」琚�夋嫨浜嗚繑鍥炰竴涓鍊硷紝鍚﹀垯杩斿洖0 + { + int LB_GETSEL = 0x0187; + return SendMessage(hWnd, LB_GETSEL, nIndex, 0); + } + static int GetSelCount(HWND hWnd)//杩斿洖閫夋嫨椤圭殑鏁扮洰锛屼粎鐢ㄤ簬澶氶噸閫夋嫨鍒楄〃妗� + { + int LB_GETSELCOUNT = 0x0190; + return SendMessage(hWnd, LB_GETSELCOUNT, 0, 0); + } + static int GetSelItems(HWND hWnd)//鑾峰彇閫変腑椤圭殑鏁扮洰鍜屼綅缃紝浠呯敤浜庡閲嶉�夋嫨鍒楄〃妗嗐�倃Param璇存槑鏁扮粍缂撳啿鍖虹殑澶у皬,lParam鎸囧悜涓�涓暣鍨嬫暟缁勭紦鍐插尯 + { + int LB_GETSELITEMS = 0x0191; + int nMax = GetSelCount(hWnd); + int nItems; + return SendMessage(hWnd, LB_GETSELITEMS, nMax, nItems); + } + + static string GetText(HWND hWnd, int nIndex) //杩斿洖鏂囨湰 + { + int LB_GETTEXT = 0x0189; + int LB_GETTEXTLEN = 0x018A; + int nLen = SendMessage(hWnd, LB_GETTEXTLEN, nIndex, 0); + string str = new wchar_t[nLen + 1]; + SendMessage(hWnd, LB_GETTEXT, nIndex, (LPARAM)str); + return str; + } + static int GetTextLen(HWND hWnd, int nIndex) //杩斿洖褰撳墠閫変腑椤规枃鏈暱搴� + { + int LB_GETTEXTLEN = 0x018A; + return SendMessage(hWnd, LB_GETTEXTLEN, nIndex, 0); + } + static int GetTopIndex(HWND hWnd) //绗竴涓彲瑙侀」鐨勭储寮� + { + int LB_GETTOPINDEX = 0x018E; + return SendMessage(hWnd, LB_GETTOPINDEX, 0, 0); + } + static int ResetCount(HWND hWnd)//娓呴櫎鎵�浠ュ垪琛ㄩ」 + { + int LB_RESETCONTENT = 0x0184; + return SendMessage(hWnd, LB_RESETCONTENT, 0, 0); + } + static int SelectString(HWND hWnd, int nIndex, string str) //閫変腑浠巒Index寮�濮嬬涓�涓猻tr锛岃繑鍥為�変腑鐨処ndex锛屽彧鐢ㄥ湪鍗曢�夊垪琛ㄦ涓� + { + int LB_SELECTSTRING = 0x018C; + return SendMessage(hWnd, LB_SELECTSTRING, nIndex, (LPARAM)str); + } + + static int SelItemRangeEx(HWND hWnd, int sIndex, int eIndex)//浠呯敤浜庡閲嶉�夋嫨锛屼粠璧风偣-缁堢偣 + { + int LB_SELITEMRANGEEX = 0x0183; + return SendMessage(hWnd, LB_SELITEMRANGEEX, sIndex, eIndex); + } + static int SetAnchorIndex(HWND hWnd, int nIndex)//璁剧疆榧犳爣鏈�鍚庨�変腑鐨勮〃椤规垚鎸囧畾琛ㄩ」 + { + int LB_SETANCHORINDEX = 0x019C; + return SendMessage(hWnd, LB_SETANCHORINDEX, nIndex, 0); + } + /*static int SetCarerIndex(HWND hWnd,int nIndex,bool lParam)//璁剧疆閿洏杈撳叆鐒︾偣鍒版寚瀹氳〃椤� + { + int LB_SETCARETINDEX = 0x019E; + return SendMessage(hWnd,LB_SETCARETINDEX,nIndex,lParam); + }*/ + static int SetColumnWidth(HWND hWnd, int nWidth)//璁剧疆澶氬垪鍒楄〃妗嗗搴︼紝style涓哄鍒楀垪琛ㄦ鏃舵湁鏁� + { + int LB_SETCOLUMNWIDTH = 0x0195; + SendMessage(hWnd, LB_SETCOLUMNWIDTH, nWidth, 0); + return 1; + } + static int SetCount(HWND hWnd, int nCnt)//璁剧疆琛ㄩ」鏁扮洰 + { + int LB_SETCOUNT = 0x01A7; + SendMessage(hWnd, LB_SETCOUNT, nCnt, 0); + return 1; + } + static int SetCurSel(HWND hWnd, int nIndex)//璁剧疆鎸囧畾鍒楄〃椤逛负褰撳墠閫夋嫨椤� + { + int LB_SETCURSEL = 0x0186; + return SendMessage(hWnd, LB_SETCURSEL, nIndex, 0);//鍙敤鍦ㄥ崟閫夊垪琛ㄦ涓�俷Index = -1涓哄叏涓嶉�� + } + /*static int SetSel(HWND hWnd, bool lbSel,int nIndex)//浣挎寚瀹氱殑鍒楄〃椤归�変腑鎴栦笉閫夛紝鐢ㄤ簬澶氶�変腑 + { + int LB_SETSEL = 0x0185; + return SendMessage(hWnd,LB_SETSEL,lbSel,nIndex);//鐢ㄥ湪澶氶�変腑锛寃Parm琛ㄧず鏄惁閫夛紝lParam涓�-1锛岄�夋嫨鎵�鏈� + } + + static bool SetTopIndex(HWND hWnd,int nIndex)//灏嗘寚瀹氱殑鍒楄〃椤硅缃负绗竴涓彲瑙侀」 + { + int LB_SETTOPINDEX = 0x0197; + return SendMessage(hWnd,LB_SETTOPINDEX,nIndex,0); + }*/ + + int GetCount()//杩斿洖鍒楄〃椤规�婚」鏁� + { + return GetCount(GetHWND()); + } + + int AddItem(string str)//杩藉姞涓�涓垪琛ㄩ」锛屽鏋滄寚瀹氫簡LBS_SORT椋庢牸锛屽皢閲嶆帓搴忥紝鍚﹀垯杩藉姞鍒版渶鍚� + { + return AddItem(GetHWND(), str); + } + + int AddItem(string str, int p)//杩藉姞涓�涓垪琛ㄩ」锛屽鏋滄寚瀹氫簡LBS_SORT椋庢牸锛屽皢閲嶆帓搴忥紝鍚﹀垯杩藉姞鍒版渶鍚� + { + return AddItem(GetHWND(), str, p); + } + + int InsertItem(int nIndex, string str)//鎸囧畾浣嶇疆鎻掑叆锛寃Param=-1娣诲姞鍒版湯灏俱�傚鏋滄寚瀹氫簡LBS_SORT椋庢牸锛屽垯涓嶄細閲嶆帓搴忥紝鎵�浠BS_SORT椋庢牸涓嬩笉鐢ㄣ�� + { + return InsertItem(GetHWND(), nIndex, str); + } + + int DeleteItem(int nIndex) //鍒犻櫎鎸囧畾鐨勫垪琛ㄩ」锛宭Param is not used + { + return DeleteItem(GetHWND(), nIndex); + } + + int FindString(int nIndex, string str)//浠庢寚瀹氬紑濮嬭〃椤瑰簭鍙峰紑濮嬫煡鎵炬寚瀹氶」锛屽拷鐣ュぇ灏忓啓锛寃Param=-1浠庣涓�椤规壘 + { + return FindString(GetHWND(), nIndex, str); + } + + int FindStringExact(int nIndex, string str)//鏁翠釜瀛楃涓插尮閰� + { + return FindStringExact(GetHWND(), nIndex, str); + } + + int GetAnchorIndex()//杩斿洖榧犳爣鏈�鍚庨�変腑鐨勯」鐨勭储寮� + { + return GetAnchorIndex(GetHWND()); + } + + int GetCaretIndex()//杩斿洖鍏锋湁鐭╁舰鐒︾偣鐨勯」鐨勭储寮� + { + return GetCaretIndex(GetHWND()); + } + + int GetCurSel()//鍗曢�夛紝杩斿洖褰撳墠琚�変腑椤圭储寮� + { + return GetCurSel(GetHWND()); + } + + int GetHorizon()//杩斿洖鍒楄〃妗嗗彲婊氬姩鐨勫搴︼紙鍍忕礌锛� + { + return GetHorizon(GetHWND()); + } + + int GetItemData(int nIndex)//杩斿洖鎸囧畾鍒楄〃椤圭殑闄勫姞鏁版嵁锛涗笉鏄疞BS_HASSTRINGS椋庢牸鐨勶紝鍐呭鏉ヨ嚜浜嶭B_ADDSTRING鎴朙B_INSERTSTRING娑堟伅鐨刲Param鍙傛暟锛屽惁鍒欏唴瀹规潵鑷簬LB_SETITEMDATA娑堟伅鐨刲Param + { + return GetItemData(GetHWND(),nIndex); + } + + int SetItemData(int nIndex, int str)//杩斿洖鎸囧畾鍒楄〃椤圭殑闄勫姞鏁版嵁锛涗笉鏄疞BS_HASSTRINGS椋庢牸鐨勶紝鍐呭鏉ヨ嚜浜嶭B_ADDSTRING鎴朙B_INSERTSTRING娑堟伅鐨刲Param鍙傛暟锛屽惁鍒欏唴瀹规潵鑷簬LB_SETITEMDATA娑堟伅鐨刲Param + { + return SetItemData(GetHWND(), nIndex, str); + } + + int GetItemHeight(int nIndex)//杩斿洖鍒楄〃椤逛腑鏌愪竴椤圭殑楂樺害锛堝儚绱狅級锛涚敤浜嶭BS_OWNERDRAWVARIABLE椋庢牸鐨勶紝wParam鎸囧畾鐨勫弬鏁� + { + return GetItemHeight(GetHWND(), nIndex); + } + + /*Rect GetItemRect(int nIndex)//鑾峰緱鍒楄〃椤圭殑瀹㈡埛鍖篟ECT + { + GetItemRect(GetID(),nIndex); + }*/ + + int GetSel(int nIndex)//杩斿洖鎸囧畾鍒楄〃椤圭殑鐘舵�侊紝濡傛灉鏌ヨ鐨勫垪琛ㄩ」琚�夋嫨浜嗚繑鍥炰竴涓鍊硷紝鍚﹀垯杩斿洖0 + { + return GetSel(GetHWND(), nIndex); + } + + int GetSelCount()//杩斿洖閫夋嫨椤圭殑鏁扮洰锛屼粎鐢ㄤ簬澶氶噸閫夋嫨鍒楄〃妗� + { + return GetSelCount(GetHWND()); + } + + int GetSelItems()//鑾峰彇閫変腑椤圭殑鏁扮洰鍜屼綅缃紝浠呯敤浜庡閲嶉�夋嫨鍒楄〃妗嗐�倃Param璇存槑鏁扮粍缂撳啿鍖虹殑澶у皬,lParam鎸囧悜涓�涓暣鍨嬫暟缁勭紦鍐插尯 + { + return GetSelItems(GetHWND()); + } + + string GetText(int nIndex) //杩斿洖鏂囨湰 + { + return GetText(GetHWND(), nIndex); + } + + int GetTextLen(int nIndex) //杩斿洖褰撳墠閫変腑椤规枃鏈暱搴� + { + GetTextLen(GetHWND(), nIndex); + } + int GetTopIndex() //绗竴涓彲瑙侀」鐨勭储寮� + { + return GetTopIndex(GetHWND()); + } + int ResetCount()//娓呴櫎鎵�浠ュ垪琛ㄩ」 + { + return ResetCount(GetHWND()); + } + int SelectString(int nIndex, string str) //閫変腑浠巒Index寮�濮嬬涓�涓猻tr锛岃繑鍥為�変腑鐨処ndex锛屽彧鐢ㄥ湪鍗曢�夊垪琛ㄦ涓� + { + return SelectString(GetHWND(), nIndex, str); + } + + int SelItemRangeEx(int sIndex, int eIndex)//浠呯敤浜庡閲嶉�夋嫨锛屼粠璧风偣-缁堢偣 + { + return SelItemRangeEx(GetHWND(), sIndex, eIndex); + } + int SetAnchorIndex(int nIndex)//璁剧疆榧犳爣鏈�鍚庨�変腑鐨勮〃椤规垚鎸囧畾琛ㄩ」 + { + return SetAnchorIndex(GetHWND(), nIndex); + } + /*int SetCarerIndex(int nIndex,bool lParam)//璁剧疆閿洏杈撳叆鐒︾偣鍒版寚瀹氳〃椤� + { + return SetCarerIndex(GetHWND(),nIndex,lParam); + }*/ + int SetColumnWidth(int nWidth)//璁剧疆澶氬垪鍒楄〃妗嗗搴︼紝style涓哄鍒楀垪琛ㄦ鏃舵湁鏁� + { + return SetColumnWidth(GetHWND(), nWidth); + } + int SetCount(int nCnt)//璁剧疆琛ㄩ」鏁扮洰 + { + return SetCount(GetHWND(), nCnt); + } + int SetCurSel(int nIndex)//璁剧疆鎸囧畾鍒楄〃椤逛负褰撳墠閫夋嫨椤� + { + return SetCurSel(GetHWND(), nIndex); + } + /*int SetSel( bool lbSel,int nIndex)//浣挎寚瀹氱殑鍒楄〃椤归�変腑鎴栦笉閫夛紝鐢ㄤ簬澶氶�変腑 + { + return SetSel(lbSel, nIndex); + } + + static bool SetTopIndex(int nIndex)//灏嗘寚瀹氱殑鍒楄〃椤硅缃负绗竴涓彲瑙侀」 + { + return SetTopIndex(nIndex); + }*/ + + static int GetCount(HWND hWnd)//杩斿洖鍒楄〃椤规�婚」鏁� + { + int LB_GETCOUNT = 0x018B; + return SendMessage(hWnd, LB_GETCOUNT, 0, 0); + } + + static int AddItem(HWND hWnd, string str)//杩藉姞涓�涓垪琛ㄩ」锛屽鏋滄寚瀹氫簡LBS_SORT椋庢牸锛屽皢閲嶆帓搴忥紝鍚﹀垯杩藉姞鍒版渶鍚� + { + int LB_ADDSTRING = 0x0180; + return SendMessage(hWnd, LB_ADDSTRING, 0, (LPARAM)str); + } + + static int AddItem(HWND hWnd, string str, int p)//杩藉姞涓�涓垪琛ㄩ」锛屽鏋滄寚瀹氫簡LBS_SORT椋庢牸锛屽皢閲嶆帓搴忥紝鍚﹀垯杩藉姞鍒版渶鍚� + { + int LB_ADDSTRING = 0x0180; + int nIndex = SendMessage(hWnd, LB_ADDSTRING, 0, (LPARAM)str); + int LB_SETITEMDATA = 0x019A; + SendMessage(hWnd, LB_SETITEMDATA, nIndex, p); + return nIndex; + } + static int InsertItem(HWND hWnd, int nIndex, string str)//鎸囧畾浣嶇疆鎻掑叆锛寃Param=-1娣诲姞鍒版湯灏俱�傚鏋滄寚瀹氫簡LBS_SORT椋庢牸锛屽垯涓嶄細閲嶆帓搴忥紝鎵�浠BS_SORT椋庢牸涓嬩笉鐢ㄣ�� + { + int LB_INSERTSTRING = 0x0181; + return SendMessage(hWnd, LB_INSERTSTRING, nIndex, (LPARAM)str); + } + + static int DeleteItem(HWND hWnd, int nIndex) //鍒犻櫎鎸囧畾鐨勫垪琛ㄩ」锛宭Param is not used + { + int LB_DELETESTRING = 0x0182; + return SendMessage(hWnd, LB_DELETESTRING, nIndex, 0); + } + + static int FindString(HWND hWnd, int nIndex, string str)//浠庢寚瀹氬紑濮嬭〃椤瑰簭鍙峰紑濮嬫煡鎵炬寚瀹氶」锛屽拷鐣ュぇ灏忓啓锛寃Param=-1浠庣涓�椤规壘 + { + int LB_ERR = -1; + int LB_FINDSTRING = 0x018F; + int lResult = SendMessage(hWnd, LB_FINDSTRING, nIndex, (LPARAM)str); + return lResult; + } + + static int FindStringExact(HWND hWnd, int nIndex, string str)//鏁翠釜瀛楃涓插尮閰� + { + int LB_ERR = -1; + int LB_FINDSTRINGEXACT = 0x01A2; + int lResult = SendMessage(hWnd, LB_FINDSTRINGEXACT, nIndex, (LPARAM)str); + return lResult; + } + + static int GetAnchorIndex(HWND hWnd)//杩斿洖榧犳爣鏈�鍚庨�変腑鐨勯」鐨勭储寮� + { + int LB_GETANCHORINDEX = 0x019D; + return SendMessage(hWnd, LB_GETANCHORINDEX, 0, 0); + } + + static int GetCaretIndex(HWND hWnd)//杩斿洖鍏锋湁鐭╁舰鐒︾偣鐨勯」鐨勭储寮� + { + int LB_GETCARETINDEX = 0x019F; + return SendMessage(hWnd, LB_GETCARETINDEX, 0, 0); + } + + static int GetCurSel(HWND hWnd)//鍗曢�夛紝杩斿洖褰撳墠琚�変腑椤圭储寮� + { + int LB_GETCURSEL = 0x0188; + return SendMessage(hWnd, LB_GETCURSEL, 0, 0); + } + + static int GetHorizon(HWND hWnd)//杩斿洖鍒楄〃妗嗗彲婊氬姩鐨勫搴︼紙鍍忕礌锛� + { + int LB_GETHORIZONTALEXTENT = 0x0193; + return SendMessage(hWnd, LB_GETHORIZONTALEXTENT, 0, 0); + } + + static int GetItemData(HWND hWnd, int nIndex)//杩斿洖鎸囧畾鍒楄〃椤圭殑闄勫姞鏁版嵁锛涗笉鏄疞BS_HASSTRINGS椋庢牸鐨勶紝鍐呭鏉ヨ嚜浜嶭B_ADDSTRING鎴朙B_INSERTSTRING娑堟伅鐨刲Param鍙傛暟锛屽惁鍒欏唴瀹规潵鑷簬LB_SETITEMDATA娑堟伅鐨刲Param + { + int LB_GETITEMDATA = 0x0199; + return SendMessage(hWnd, LB_GETITEMDATA, nIndex, 0); + } + static int SetItemData(HWND hWnd, int nIndex, int str)//杩斿洖鎸囧畾鍒楄〃椤圭殑闄勫姞鏁版嵁锛涗笉鏄疞BS_HASSTRINGS椋庢牸鐨勶紝鍐呭鏉ヨ嚜浜嶭B_ADDSTRING鎴朙B_INSERTSTRING娑堟伅鐨刲Param鍙傛暟锛屽惁鍒欏唴瀹规潵鑷簬LB_SETITEMDATA娑堟伅鐨刲Param + { + int LB_SETITEMDATA = 0x019A; + return SendMessage(hWnd, LB_SETITEMDATA, nIndex, str); + } + + static int GetItemHeight(HWND hWnd, int nIndex)//杩斿洖鍒楄〃椤逛腑鏌愪竴椤圭殑楂樺害锛堝儚绱狅級锛涚敤浜嶭BS_OWNERDRAWVARIABLE椋庢牸鐨勶紝wParam鎸囧畾鐨勫弬鏁� + { + int LB_GETITEMHEIGHT = 0x01A1; + return SendMessage(hWnd, LB_GETITEMHEIGHT, nIndex, 0); + } + /*static Rect GetItemRect(HWND hWnd,int nIndex)//鑾峰緱鍒楄〃椤圭殑瀹㈡埛鍖篟ECT + { + int LB_GETITEMRECT = 0x0198; + xrect rect; + return SendMessage(hWnd,LB_GETITEMRECT,nIndex,rect); + }*/ + static int GetSel(HWND hWnd, int nIndex)//杩斿洖鎸囧畾鍒楄〃椤圭殑鐘舵�侊紝濡傛灉鏌ヨ鐨勫垪琛ㄩ」琚�夋嫨浜嗚繑鍥炰竴涓鍊硷紝鍚﹀垯杩斿洖0 + { + int LB_GETSEL = 0x0187; + return SendMessage(hWnd, LB_GETSEL, nIndex, 0); + } + static int GetSelCount(HWND hWnd)//杩斿洖閫夋嫨椤圭殑鏁扮洰锛屼粎鐢ㄤ簬澶氶噸閫夋嫨鍒楄〃妗� + { + int LB_GETSELCOUNT = 0x0190; + return SendMessage(hWnd, LB_GETSELCOUNT, 0, 0); + } + static int GetSelItems(HWND hWnd)//鑾峰彇閫変腑椤圭殑鏁扮洰鍜屼綅缃紝浠呯敤浜庡閲嶉�夋嫨鍒楄〃妗嗐�倃Param璇存槑鏁扮粍缂撳啿鍖虹殑澶у皬,lParam鎸囧悜涓�涓暣鍨嬫暟缁勭紦鍐插尯 + { + int LB_GETSELITEMS = 0x0191; + int nMax = GetSelCount(hWnd); + int nItems; + return SendMessage(hWnd, LB_GETSELITEMS, nMax, nItems); + } + + static string GetText(HWND hWnd, int nIndex) //杩斿洖鏂囨湰 + { + int LB_GETTEXT = 0x0189; + int LB_GETTEXTLEN = 0x018A; + int nLen = SendMessage(hWnd, LB_GETTEXTLEN, nIndex, 0); + string str = new wchar_t[nLen + 1]; + SendMessage(hWnd, LB_GETTEXT, nIndex, (LPARAM)str); + return str; + } + static int GetTextLen(HWND hWnd, int nIndex) //杩斿洖褰撳墠閫変腑椤规枃鏈暱搴� + { + int LB_GETTEXTLEN = 0x018A; + return SendMessage(hWnd, LB_GETTEXTLEN, nIndex, 0); + } + static int GetTopIndex(HWND hWnd) //绗竴涓彲瑙侀」鐨勭储寮� + { + int LB_GETTOPINDEX = 0x018E; + return SendMessage(hWnd, LB_GETTOPINDEX, 0, 0); + } + static int ResetCount(HWND hWnd)//娓呴櫎鎵�浠ュ垪琛ㄩ」 + { + int LB_RESETCONTENT = 0x0184; + return SendMessage(hWnd, LB_RESETCONTENT, 0, 0); + } + static int SelectString(HWND hWnd, int nIndex, string str) //閫変腑浠巒Index寮�濮嬬涓�涓猻tr锛岃繑鍥為�変腑鐨処ndex锛屽彧鐢ㄥ湪鍗曢�夊垪琛ㄦ涓� + { + int LB_SELECTSTRING = 0x018C; + return SendMessage(hWnd, LB_SELECTSTRING, nIndex, (LPARAM)str); + } + + static int SelItemRangeEx(HWND hWnd, int sIndex, int eIndex)//浠呯敤浜庡閲嶉�夋嫨锛屼粠璧风偣-缁堢偣 + { + int LB_SELITEMRANGEEX = 0x0183; + return SendMessage(hWnd, LB_SELITEMRANGEEX, sIndex, eIndex); + } + static int SetAnchorIndex(HWND hWnd, int nIndex)//璁剧疆榧犳爣鏈�鍚庨�変腑鐨勮〃椤规垚鎸囧畾琛ㄩ」 + { + int LB_SETANCHORINDEX = 0x019C; + return SendMessage(hWnd, LB_SETANCHORINDEX, nIndex, 0); + } + /*static int SetCarerIndex(HWND hWnd,int nIndex,bool lParam)//璁剧疆閿洏杈撳叆鐒︾偣鍒版寚瀹氳〃椤� + { + int LB_SETCARETINDEX = 0x019E; + return SendMessage(hWnd,LB_SETCARETINDEX,nIndex,lParam); + }*/ + static int SetColumnWidth(HWND hWnd, int nWidth)//璁剧疆澶氬垪鍒楄〃妗嗗搴︼紝style涓哄鍒楀垪琛ㄦ鏃舵湁鏁� + { + int LB_SETCOLUMNWIDTH = 0x0195; + SendMessage(hWnd, LB_SETCOLUMNWIDTH, nWidth, 0); + return 1; + } + static int SetCount(HWND hWnd, int nCnt)//璁剧疆琛ㄩ」鏁扮洰 + { + int LB_SETCOUNT = 0x01A7; + SendMessage(hWnd, LB_SETCOUNT, nCnt, 0); + return 1; + } + static int SetCurSel(HWND hWnd, int nIndex)//璁剧疆鎸囧畾鍒楄〃椤逛负褰撳墠閫夋嫨椤� + { + int LB_SETCURSEL = 0x0186; + return SendMessage(hWnd, LB_SETCURSEL, nIndex, 0);//鍙敤鍦ㄥ崟閫夊垪琛ㄦ涓�俷Index = -1涓哄叏涓嶉�� + } + /*static int SetSel(HWND hWnd, bool lbSel,int nIndex)//浣挎寚瀹氱殑鍒楄〃椤归�変腑鎴栦笉閫夛紝鐢ㄤ簬澶氶�変腑 + { + int LB_SETSEL = 0x0185; + return SendMessage(hWnd,LB_SETSEL,lbSel,nIndex);//鐢ㄥ湪澶氶�変腑锛寃Parm琛ㄧず鏄惁閫夛紝lParam涓�-1锛岄�夋嫨鎵�鏈� + } + + static bool SetTopIndex(HWND hWnd,int nIndex)//灏嗘寚瀹氱殑鍒楄〃椤硅缃负绗竴涓彲瑙侀」 + { + int LB_SETTOPINDEX = 0x0197; + return SendMessage(hWnd,LB_SETTOPINDEX,nIndex,0); + }*/ +}; \ No newline at end of file diff --git a/jrj/xframe/xcontrol/xlistview.hpp b/jrj/xframe/xcontrol/xlistview.hpp new file mode 100644 index 0000000..4f29612 --- /dev/null +++ b/jrj/xframe/xcontrol/xlistview.hpp @@ -0,0 +1,533 @@ +#pragma once + +#include "wobject/xcontrol.hpp" +#include "win32/win.hpp" + + +typedef struct tagLVITEMW +{ + UINT mask; + int iItem; + int iSubItem; + UINT state; + UINT stateMask; + LPWSTR pszText; + int cchTextMax; + int iImage; + LPARAM lParam; + int iIndent; + int iGroupId; + UINT cColumns; // tile view columns + UINT* puColumns; + int* piColFmt; + int iGroup; // readonly. only valid for owner data. +} LVITEMW, * LPLVITEMW; + +typedef struct tagLVCOLUMNW +{ + UINT mask; + int fmt; + int cx; + LPWSTR pszText; + int cchTextMax; + int iSubItem; + int iImage; + int iOrder; + int cxMin; // min snap point + int cxDefault; // default snap point + int cxIdeal; // read only. ideal may not eqaul current width if auto sized (LVS_EX_AUTOSIZECOLUMNS_) to a lesser width. +} LVCOLUMNW, * LPLVCOLUMNW; + +typedef struct tagLVFINDINFOW +{ + UINT flags; + LPCWSTR psz; + LPARAM lParam; + POINT pt; + UINT vkDirection; +} LVFINDINFOW, * LPFINDINFOW; + +typedef LVITEMW lvitem; +typedef LVCOLUMNW lvcolumn; +typedef LVFINDINFOW lvfindinfo; + +struct himagelist +{ +}; + +struct imagelist +{ + himagelist hlist; +}; + +struct NMLISTVIEW : public NMHDR +{ + NMHDR hdr; + int iItem; + int iSubItem; + UINT uNewState; + UINT uOldState; + UINT uChanged; + POINT ptAction; + LPARAM lParam; +}; + +class xlistview : public xcontrol +{ + static int SetdwStyle(HWND hWnd, int dwStyle)//璁剧疆椋庢牸 + { + int GWL_STYLE_ = -16; + int LVS_ICON_ = 0x0000;//澶у浘鏍� + int LVS_REPORT_ = 0x0001; + int LVS_SMALLICON_ = 0x0002; + int LVS_LIST_ = 0x0003;//鍒楄〃 + + int IStyle =GetWindowLong(hWnd, GWL_STYLE_); + int LVS_TYPEMASK_ = 0x0003; + int LVS_EDITLABELS_ = 0x0200; + IStyle &= ~LVS_TYPEMASK_;//娓呴櫎鏄剧ず鏂瑰紡浣� + return SetWindowLong(hWnd, GWL_STYLE_, IStyle | dwStyle); + } + static int SetReportStyle(HWND hWnd)//璁剧疆Report椋庢牸 + { + //鑾峰緱鍘熸湁椋庢牸 + int GWL_STYLE_ = -16; + int IStyle = GetWindowLong(hWnd, GWL_STYLE_); + int LVS_TYPEMASK_ = 0x0003; + int LVS_EDITLABELS_ = 0x0200; + IStyle &= ~LVS_TYPEMASK_;//娓呴櫎鏄剧ず鏂瑰紡浣� + + //璁惧畾涓�涓柊鐨勭獥鍙i鏍� + int LVS_REPORT_ = 0x0001; + int LVS_NOLABELWRAP_ = 0x0080; + int LVS_SHOWSELALWAYS_ = 0x0008; + IStyle |= LVS_REPORT_;//璁剧疆style涓簉eport + SetWindowLong(hWnd, GWL_STYLE_, IStyle | LVS_NOLABELWRAP_ | LVS_SHOWSELALWAYS_ | LVS_EDITLABELS_); + //璁剧疆鎵╁睍椋庢牸 + int dwStyle; + int LVM_FIRST_ = 0x1000; + int LVM_GETEXTENDEDLISTVIEWSTYLE_ = LVM_FIRST_ + 55; + dwStyle = SendMessage(hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE_, 0, 0);//鑾峰彇鎵╁睍椋庢牸 + int LVS_EX_FULLROWSELECT_ = 0x00000020;//鏁磋閫変腑,銆�applies to report mode only + int LVS_EX_GRIDLINES_ = 0x00000001; //缃戞牸绾� + int LVS_EX_SUBITEMIMAGES_ = 0x00000002;//鍙互鍦ㄥ垪琛ㄤ腑鍔營CON + int LVS_EX_CHECKBOXES_ = 0x00000004;//鍓嶉潰鍔犱釜checkbox + dwStyle |= LVS_EX_FULLROWSELECT_ | LVS_EX_GRIDLINES_ | LVS_EX_CHECKBOXES_ | LVS_EX_SUBITEMIMAGES_; + + int LVM_SETEXTENDEDLISTVIEWSTYLE_ = LVM_FIRST_ + 54; + return SendMessage(hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE_, dwStyle, dwStyle); + } + + static int GetImageList(HWND hWnd, int iImageList)//ImageList + { + int LVM_FIRST_ = 0x1000; + int LVM_GETIMAGELIST_ = LVM_FIRST_ + 2; + return SendMessage(hWnd, LVM_GETIMAGELIST_, iImageList, 0); + } + static int SetImageList(HWND hWnd, int iImageList, int himl)//璁剧疆ImageList + { + /*int LVSIL_NORMAL_ = 0; + int LVSIL_SMALL_ = 1; + int LVSIL_STATE_ = 2;*/ + int LVM_FIRST_ = 0x1000; + int LVM_SETIMAGELIST_ = LVM_FIRST_ + 3; + return SendMessage(hWnd, LVM_SETIMAGELIST_, iImageList, himl); + } + + static int InsertColumn(HWND hWnd, int nCol, string label, int nFormat, int nWidth, int nSubItem)//澧炲姞鍒楋紝鍔犲叆鍒楀ご + { + int LVM_FIRST_ = 0x1000; + int LVM_INSERTCOLUMN_ = LVM_FIRST_ + 97; + + int LVCF_FMT_ = 0x0001;//瀵归綈鏂瑰紡锛歭eft,right + int LVCF_WIDTH_ = 0x0002;//鍒楀搴� + int LVCF_TEXT_ = 0x0004;//鏂囨湰 + int LVCF_SUBITEM_ = 0x0008;//涓哄垎閰嶇粰璇ュ垪鐨勫垪绱㈠紩 + int LVCF_ORDER_ = 0x0020;//鍒楀亸绉婚『搴忎粠宸﹀埌鍙� + int LVCFMT_LEFT_ = 0x0000; + int LVCFMT_RIGHT_ = 0x0001; + int LVCFMT_CENTER_ = 0x0002; + + lvcolumn lvc; + lvc.mask = LVCF_FMT_ | LVCF_WIDTH_ | LVCF_TEXT_ | LVCF_SUBITEM_;//椋庢牸 + lvc.fmt = nFormat; + + xrect rect; + //GetWindowRect(hWnd,rect);//鍙栧緱绐楀彛鍦ㄥ睆骞曞潗鏍囩郴涓嬬殑RECT鍧愭爣锛堝寘鎷鎴峰尯鍜岄潪瀹㈡埛鍖猴級锛岃繖鏍峰彲浠ュ緱鍒扮獥鍙g殑澶у皬鍜岀浉瀵瑰睆骞曞乏涓婅(0,0)鐨勪綅缃�� + //GetClientRect; + lvc.cx = nWidth;//(rect.right - rect.left ) * 3/5; //LVCF_WIDTH 锛學idth of the column, in pixels. + lvc.pszText = (LPWSTR)label;//鏂囧瓧 + lvc.cchTextMax = 255; + lvc.iSubItem = nSubItem; + lvc.iImage = 0; + lvc.iOrder = 0; + return SendMessage(hWnd, LVM_INSERTCOLUMN_, nCol, (LPARAM) & lvc); + } + + static int InsertItem(HWND hWnd, int xIndex, string label, int pictureindex = 0)//only the label and picture index need to be specified + { + int LVM_FIRST_ = 0x1000;// ListView messages + int LVM_INSERTITEM_ = LVM_FIRST_ + 77; + + //LVITEM_mask + //int LVIF_COLFMT + //int LVIF_COLUMNS_ = 0x0200; + int LVIF_DI_SETITEM_ = 0x1000; + //int LVIF_GROUPID_ = 0x0100; + int LVIF_IMAGE_ = 0x0002; + //int LVIF_INDENT_ = 0x0010; + //int LVIF_NORECOMPUTE_ = 0x0800; + int LVIF_PARAM_ = 0x0004; + int LVIF_STATE_ = 0x0008; + int LVIF_TEXT_ = 0x0001; + //LVITEM_state + int LVIS_FOCUSED_ = 0x0001; + int LVIS_SELECTED_ = 0x0002; + int LVIS_OVERLAYMASK_ = 0x0F00; + + lvitem lvi; + lvi.mask = LVIF_TEXT_ | LVIF_IMAGE_; + lvi.iItem = xIndex; //鎸囧畾鎻掑叆椤圭洰鐨勮鍙� + lvi.iSubItem = 0; //鍒楀彿 + //lvi.state = LVIS_FOCUSED_ | LVIS_SELECTED_ | LVIS_OVERLAYMASK_; + //lvi.stateMask = ; + lvi.pszText = (LPWSTR)label; + lvi.cchTextMax = 255; + lvi.iImage = pictureindex; + //lvi.lParam = data; + //lvi.iIndent + + //int LVIF_GROUPID_ = 0x0100; + //int I_GROUPIDCALLBACK_ = -1; + //int I_GROUPIDNONE_ = -2; + //int iGroupId = 1; + //lvi.iGroupId = iGroupId; + return SendMessage(hWnd, LVM_INSERTITEM_, 0, (LPARAM) & lvi); + } + + static int InsertItemEx(HWND hWnd, int xIndex, string label, int pictureindex = 0, int data = 0)//only the label and picture index need to be specified + { + int LVM_FIRST_ = 0x1000;// ListView messages + int LVM_INSERTITEM_ = LVM_FIRST_ + 77; + + //LVITEM_mask + //int LVIF_COLFMT + //int LVIF_COLUMNS_ = 0x0200; + int LVIF_DI_SETITEM_ = 0x1000; + //int LVIF_GROUPID_ = 0x0100; + int LVIF_IMAGE_ = 0x0002; + //int LVIF_INDENT_ = 0x0010; + //int LVIF_NORECOMPUTE_ = 0x0800; + int LVIF_PARAM_ = 0x0004; + int LVIF_STATE_ = 0x0008; + int LVIF_TEXT_ = 0x0001; + //LVITEM_state + int LVIS_FOCUSED_ = 0x0001; + int LVIS_SELECTED_ = 0x0002; + int LVIS_OVERLAYMASK_ = 0x0F00; + + lvitem lvi; + lvi.mask = LVIF_TEXT_ | LVIF_IMAGE_ | LVIF_PARAM_; + lvi.iItem = xIndex; //鎸囧畾鎻掑叆椤圭洰鐨勮鍙� + lvi.iSubItem = 0; //鍒楀彿 + //lvi.state = LVIS_FOCUSED_ | LVIS_SELECTED_ | LVIS_OVERLAYMASK_; + //lvi.stateMask = ; + lvi.pszText = (LPWSTR)label; + lvi.cchTextMax = 255; + lvi.iImage = pictureindex; + lvi.lParam = data; + //lvi.iIndent + + //int LVIF_GROUPID_ = 0x0100; + //int I_GROUPIDCALLBACK_ = -1; + //int I_GROUPIDNONE_ = -2; + //int iGroupId = 1; + //lvi.iGroupId = iGroupId; + return SendMessage(hWnd, LVM_INSERTITEM_, 0, (LPARAM)&lvi); + } + + static int SetItemText(HWND hWnd, int nItem, int nSubItem, string label) + { + int LVM_FIRST_ = 0x1000; + int LVM_SETITEMTEXT_ = LVM_FIRST_ + 116; + int LVIF_TEXT_ = 0x0001; + + lvitem lvi; + lvi.mask = LVIF_TEXT_; + lvi.iSubItem = nSubItem; + lvi.pszText = (LPWSTR)label; + lvi.cchTextMax = 255; + return SendMessage(hWnd, LVM_SETITEMTEXT_, nItem, (LPARAM)&lvi); + } + + static int DeleteItemAll(HWND hWnd)//鍒犻櫎鎵�鏈� + { + int LVM_FIRST_ = 0x1000; + int LVM_DELETEALLITEMS_ = LVM_FIRST_ + 9; + return SendMessage(hWnd, LVM_DELETEALLITEMS_, 0, 0); + } + + static int DeleteColumn(HWND hWnd, int nCol)//鍒犻櫎鍒� + { + int LVM_FIRST_ = 0x1000; + int LVM_DELETECOLUMN_ = LVM_FIRST_ + 28; + return SendMessage(hWnd, LVM_DELETECOLUMN_, nCol, 0); + } + + static int DeleteItem(HWND hWnd, int nIndex)//鍒犻櫎琛� + { + int LVM_FIRST_ = 0x1000; + int LVM_DELETEITEM_ = LVM_FIRST_ + 8; + return SendMessage(hWnd, LVM_DELETEITEM_, nIndex, 0); + } + + static int EditLabel(HWND hWnd, int nIndex)//nIndex= -1琛ㄧず鍙栨秷缂栬緫 + { + int LVM_FIRST_ = 0x1000; + int LVM_EDITLABEL_ = LVM_FIRST_ + 118; + return SendMessage(hWnd, LVM_EDITLABEL_, nIndex, 0); + } + + static int FindItem(HWND hWnd, int iStart, string label, bool partial, bool wrap) + { + //FindItem( int iStart, string label, boolean partial,boolean wrap ) + //partial=true鎼滅礌鍖呭惈label寮�澶寸殑锛�=false蹇呴』鍖归厤鏁翠釜鏍囩 + //wrap =true杩斿洖绗竴涓壘鍒扮殑锛�=false杩斿洖鏈�鍚庢壘鍒扮殑 + int LVM_FIRST_ = 0x1000; + int LVM_FINDITEM_ = LVM_FIRST_ + 83; + + //flags + int LVFI_PARAM_ = 0x0001; + int LVFI_STRING_ = 0x0002; + int LVFI_PARTIAL_ = 0x0008; + int LVFI_WRAP_ = 0x0020; + int LVFI_NEARESTXY_ = 0x0040; + //vkDirection + int VK_PRIOR_ = 0x21; + int VK_NEXT_ = 0x22; + int VK_END_ = 0x23; + int VK_HOME_ = 0x24; + int VK_LEFT_ = 0x25; + int VK_UP = 0x26; + int VK_RIGHT_ = 0x27; + int VK_DOWN_ = 0x28; + + lvfindinfo lvfi; + if (partial == true) + { + lvfi.flags = LVFI_PARTIAL_ | LVFI_STRING_; + } + else + lvfi.flags = LVFI_STRING_; + if (wrap == true) + { + lvfi.flags |= LVFI_WRAP_; + } + lvfi.psz = label; + //lvfi.lParam = //涓篖VFI_PARAM鏃舵湁鏁� + //lvfi.pt //鍒濆鎼滅储浣嶇疆,涓篖VFI_NEARESTXY 鏃舵湁鏁� + //lvfi.vkDirection = VK_NEXT_; //鎼滅礌鏂瑰悜銆俆his member is valid only if LVFI_NEARESTXY is set in the flags member + + return SendMessage(hWnd, LVM_FINDITEM_, iStart, (LPARAM)&lvfi); + } + + static int GetColumn(HWND hWnd, int iCol, lvcolumn lvc) + { + int LVM_FIRST_ = 0x1000; + int LVM_GETCOLUMN_ = LVM_FIRST_ + 95; + return SendMessage(hWnd, LVM_GETCOLUMN_, iCol, (LPARAM)&lvc); + } + + static int GetItem(HWND hWnd, lvitem& lvi) + { + int LVM_FIRST_ = 0x1000; + int LVM_GETITEM_ = LVM_FIRST_ + 75; + return SendMessage(hWnd, LVM_GETITEM_, 0, (LPARAM)&lvi); + } + + static int GetItemCount(HWND hWnd) + { + int LVM_FIRST_ = 0x1000; + int LVM_GETITEMCOUNT_ = LVM_FIRST_ + 4; + return SendMessage(hWnd, LVM_GETITEMCOUNT_, 0, 0); + } + + static int GetItemText(HWND hWnd, int nIndex, lvitem lvi) + { + int LVM_FIRST_ = 0x1000; + int LVM_GETITEMTEXT_ = LVM_FIRST_ + 115; + return SendMessage(hWnd, LVM_GETITEMTEXT_, nIndex, (LPARAM)&lvi); + } + + static int GetNextItem(HWND hWnd, int nIndex, int flags)//nIndex=-1鏃朵粠绗竴涓紑濮� + { + int LVM_FIRST_ = 0x1000; + int LVM_GETNEXTITEM_ = LVM_FIRST_ + 12; + return SendMessage(hWnd, LVM_GETNEXTITEM_, nIndex, flags); + } + + static int GetSelectColumn(HWND hWnd) + { + int LVM_FIRST_ = 0x1000; + int LVM_GETSELECTEDCOLUMN_ = LVM_FIRST_ + 174; + return SendMessage(hWnd, LVM_GETSELECTEDCOLUMN_, 0, 0); + } + + static int GetSelectCount(HWND hWnd) + { + int LVM_FIRST_ = 0x1000; + int LVM_GETSELECTEDCOUNT_ = LVM_FIRST_ + 50; + return SendMessage(hWnd, LVM_GETSELECTEDCOUNT_, 0, 0); + } + + static int SetColumn(HWND hWnd, int iCol, lvcolumn lvc) + { + int LVM_FIRST_ = 0x1000; + int LVM_SETCOLUMN_ = LVM_FIRST_ + 96; + return SendMessage(hWnd, LVM_SETCOLUMN_, iCol, (LPARAM)&lvc); + } + + static int SetItem(HWND hWnd, lvitem lvi) + { + int LVM_FIRST_ = 0x1000; + int LVM_SETITEM_ = LVM_FIRST_ + 76; + return SendMessage(hWnd, LVM_SETITEM_, 0, (LPARAM)&lvi); + } + + static int SetItemText(HWND hWnd, int nIndex, lvitem lvi) + { + int LVM_FIRST_ = 0x1000; + int LVM_SETITEMTEXT_ = LVM_FIRST_ + 116; + return SendMessage(hWnd, LVM_SETITEMTEXT_, nIndex, (LPARAM)&lvi); + } + + static int InsertColumn(HWND hWnd, int nCol, int nFormat, int nWidth, string label, int nSubItem)//澧炲姞鍒� + { + lvcolumn lvc; // 鍒� + // ZeroMemory(&lvc, sizeof(lvcolumn)); + + int LVCF_FMT_ = 0x0001; + int LVCF_WIDTH_ = 0x0002; + int LVCF_TEXT_ = 0x0004; + int LVCF_SUBITEM_ = 0x0008; + int LVCFMT_LEFT_ = 0x0000; + lvc.mask = LVCF_FMT_ | LVCF_TEXT_ | LVCF_WIDTH_ | LVCF_SUBITEM_; // 椋庢牸 + lvc.fmt = nFormat;//鏂囨湰宸﹀榻� + lvc.cx = nWidth; // cx 鏄垪鐨勫搴︼紙浠ュ儚绱犵偣涓哄崟浣嶏級銆備互鍚庢偍鍙互鍙戦�佹秷鎭疞VM_SETCOLUMNWIDTH 鏉ユ敼鍙樺垪鐨勫搴︺�� + lvc.pszText = (LPWSTR)label; // 鏂囧瓧 + lvc.cchTextMax = 255; // 鏂囧瓧闀垮害 + lvc.iSubItem = nSubItem; // 鍒楀彿 + + int LVM_FIRST_ = 0x1000;// ListView messages + int LVM_INSERTCOLUMN_ = LVM_FIRST_ + 97; + return SendMessage(hWnd, LVM_INSERTCOLUMN_, nCol, (LPARAM)&lvc); + //lvc.pszText = "鍐呭瓨浣跨敤"; + //SendMessage(hWnd, LVM_INSERTCOLUMN_, 0, (LPARAM_)&lvc); + //lvc.pszText = "ID"; + //SendMessage(hWnd, LVM_INSERTCOLUMN_, 0, (LPARAM_)&lvc); + + } + static int InsertItem(HWND hWnd, int nItem, int nSubItem, string label, int pictureindex)//澧炲姞琛� + { + lvitem lvi; // 鍒� + // ZeroMemory(&lvi, sizeof(lvitem)); + + int LVIF_TEXT_ = 0x0001; + int LVIF_IMAGE_ = 0x0002; + int LVIF_PARAM_ = 0x0004; + int LVIF_STATE_ = 0x0008; + + int MAX_PATH_ = 255; + int LVIS_STATEIMAGEMASK_ = 0xF000; + int LVIS_FOCUSED_ = 0x0001; + int LVIS_SELECTED_ = 0x0002; + lvi.mask = LVIF_TEXT_ | LVIF_IMAGE_ | LVIF_STATE_ | LVIF_PARAM_; // 鏂囧瓧銆佸浘鐗�// 鎺╃爜浣嶇殑缁勫悎锛堜笅闈㈡湁瀵瑰簲鎺╃爜鐨勫厓绱犻兘宸插湪鎷彿涓爣鍑烘帺鐮侊級锛岃〃鏄庡摢浜涘厓绱犳槸鏈夋晥鐨� + lvi.iItem = nItem; //琛屽彿 + lvi.iSubItem = nSubItem; //鍒楀彿 + lvi.pszText = (LPWSTR)label; + lvi.cchTextMax = 255; // 鏂囧瓧闀垮害 + lvi.iImage = pictureindex; + lvi.state = LVIS_FOCUSED_; // 鐘舵�侊紝涓嬮潰浼氬垪鍑恒�傦紙LVIF_STATE锛� + lvi.stateMask = LVIS_STATEIMAGEMASK_;// 鐘舵�佹帺鐮侊紝鐢ㄦ潵璇存槑瑕佽幏鍙栨垨璁剧疆鍝簺鐘舵�併�� + int LVM_FIRST_ = 0x1000;// ListView messages + int LVM_INSERTITEM_ = LVM_FIRST_ + 77; + return SendMessage(hWnd, LVM_INSERTITEM_, 0, (LPARAM)&lvi); + //lvi.pszText = "鏃ユ湰"; + //SendMessage(hWnd, LVM_INSERTITEM_, 0, (LPARAM_)&lvi); + //lvi.pszText = "寰峰浗"; + //SendMessage(hWnd, LVM_INSERTITEM_, 0, (LPARAM_)&lvi); + } + + static string GetItemText(HWND hWnd, int nIndex) + { + int LVM_FIRST_ = 0x1000; + int LVM_GETITEMTEXT_ = LVM_FIRST_ + 115; + int LVIF_TEXT_ = 0x0001; + + lvitem lvi; + lvi.mask = LVIF_TEXT_; + lvi.iItem = nIndex; + lvi.pszText = new wchar_t[255]; + lvi.cchTextMax = 255; + int ret = SendMessage(hWnd, LVM_GETITEMTEXT_, nIndex, (LPARAM)&lvi); + //trace("result: %s", ret.toString()); + return lvi.pszText; + } + + /*static int AddItem(HWND hWnd,string label, int pictureindex = 0) //鍚嶅瓧鍜屽浘鐗� + { + int LVM_FIRST_ = 0x1000; + int LVM_INSERTITEM_ = LVM_FIRST_ + 77; + lvitem pitem; + pitem.iItem = 0; + pitem.iSubItem = 0; + pitem.pszText = label; + pitem.iImage = pictureindex; + + return win__::SendMessage(hWnd, LVM_INSERTITEM_, 0, &pitem); + } + + static int AddItem(HWND hWnd,lvitem hItem) + { + int LVM_FIRST_ = 0x1000; + int LVM_INSERTITEM_ = LVM_FIRST_ + 77; + return win__::SendMessage(hWnd, LVM_INSERTITEM_, 0, &hItem); + } + + + static int InsertItem(HWND hWnd,int nIndex,lvitem hItem )//more than the label and picture index need to be specified + { + int LVM_FIRST_ = 0x1000; + int LVM_INSERTITEM_ = LVM_FIRST_ + 77; + return win__::SendMessage(hWnd, LVM_INSERTITEM_, 0, &hItem); + } + + static int Sort (HWND hWnd,int hItem ,string sorttype ) + { + } + + //------- + static int AddLargePicture() + { + } + static int AddStatePicture() + { + } + static int DeleteLargePicture(int nIndex) + { + } + static int DeleteLargePictures() + { + } + static int DeleteStatePictures() + { + } + static int Drag () + { + //dragmode = Begin!锛孋ancel!,End! + } + static int SetColumn (HWND hWnd,int nIndex,string label,string alignment,int width ) + { + }*/ + +}; \ No newline at end of file -- Gitblit v1.9.3