Ch 22 ³q¥Î±±¨î¶µ(2)¡GList View


¥Ñ¥~Æ[»¡©ú¤°»ò¬O List View ±±¨î¶µ

¤¤¤å§â List View ±±¨î¶µÂ½Ä¶¦¨¡u²M³æÀ˵ø¡v¡A¥¦¬O¤@­Ó¥i¥H¥]§t³\¦h¡u¶µ¥Ø¡v( item ) ªº³q¥Î±±¨î¶µ¡A³o¨Ç¶µ¥Ø¥i¥H¨Ñ¨Ï¥ÎªÌ¬D¿ï¡C¤U­±ªº¤»±i¹Ï¬O¦P¤@­Ó§t¦³ 18 ­Ó¶µ¥Øªº²M³æÀ˵ø±±¨î¶µ¦b¤£¦PÅã¥Ü¤è¦¡ªºµe­±¡CWindows 9x/Me ´£¨Ñ¥|ºØÅã¥Ü¤è¦¡ ( view type )¡Gicon view¡Bdetails view ( ¤]¥s report view )¡Bsmall icon view¡Blist view ¡A¦Ó Windows XP ´£¨Ñ¤@ºØ·sªºÅã¥Ü¤è¦¡¡Atile view¡C

¹Ï¤W¤èªº¥ª¹ÏÅã¥Ü¤è¦¡ºÙ¬°¡uicon view¡v¡A¨C­Ó¶µ¥Ø¶È¶ÈÅã¥Ü¹Ï¥Ü¤Î¶µ¥Ø¦WºÙ¡C¹Ï¤W¤èªº¤¤¹ÏÅã¥Ü¤è¦¡ºÙ¬°¡udetails view¡v¡A¤]¥s report view¡A³oºØÅã¥Ü¤è¦¡¯àÅã¥Ü³Ì¸ÔºÉ¸ê®Æ¡A¨C¤@¦C ( ¥Ñ¥ª¦Ó¥k ) ªº³Ì¥ªÃä ( ²Ä 0 Äæ ) ºÙ¬°¡u¶µ¥Ø¡v¡A¨ä¥k¥i¯à¥]§t¼Æ­Ó¡u¤l¶µ¥Ø¡v¡A³o¨Ç¤l¶µ¥Ø³£¦b¤£¦PªºÄæ¦ì±Æ¦C¾ã»ô¡A¦p¦P¤@±iªí®æ¡C²Ä 0 ­ÓÄæ¬OÅã¥Ü¶µ¥Ø¦WºÙ¡A¤]¥u¦³²Ä 0 ­ÓÄæ¦ì¥i¥HÅã¥Ü¹Ï¥Ü¡F²Ä¤@­ÓÄæ¦ì¥H«áªººÙ¬°¤l¶µ¥Ø¡A¶È¯àÅã¥Ü¤l¶µ¥Ø¦WºÙ¡C¹Ï¤W¤èªº¥k¹ÏÅã¥Ü¤è¦¡ºÙ¬°¡usmall icon view¡v¨C­Ó¶µ¥Ø¶È¶ÈÅã¥Ü¤p¹Ï¥Ü¤Î¶µ¥Ø¦WºÙ¡C¹Ï¤U¤èªº¥ª¹ÏÅã¥Ü¤è¦¡ºÙ¬°¡ulist view¡v¡A¤]¶È¶ÈÅã¥Ü¤p¹Ï¥Ü¤Î¶µ¥Ø¦WºÙ¡C¹Ï¤U¤èªº¤¤¹ÏÅã¥Ü¤è¦¡ºÙ¬°¡utile view¡v¡A¥¦¬O¥H¤j¹Ï¥ÜÅã¥Ü¡A¦P®É®ÇÃä¥i¥H¦AÅã¥Ü´X­ÓÄæ¦ìªº¸ê®Æ¡C

¡@¡@

¡@¡@

¨ì¤F XP ªº®É¥N¡A¡u²M³æÀ˵ø¡v±±¨î¶µ¤]¥i¥H¥Î¡u¸s²Õ¡v¼Ò¦¡Åã¥Ü¡A¦p¹Ï¤U¤èªº¥k¹Ï¬O¡usmall icon view¡vÅã¥Ü¤è¦¡®Éªº¸s²Õ¼Ò¦¡¡C¦ý¬O¨Ã«D©Ò¦³Åã¥Ü¤è¦¡³£¥i¥H¥H¸s²Õ¼Ò¦¡Åã¥Ü¡A¡ulist view¡v´NµLªk¥H¸s²Õ¼Ò¦¡Åã¥Ü¡A¦Ó¨ä¾l¥|ºØÅã¥Ü¤è¦¡³£¥i¥H¥H¸s²Õ¼Ò¦¡Åã¥Ü¡C

List View ªº¥~Æ[

­n«Ø¥ß List View ±±¨î¶µ¡A¥²¶·¥ý½T»{ COMCTL32.DLL ¬O§_¸ü¤J¨ì°O¾ÐÅé¡A­n½T©w³oÂI¥i¥H©I¥s InitCommonControls ©Î InitCommonControlsEx¡A³o­Ó¨BÆJ¦b«e¤@³¹¤w¸g±Ô­z¹L¤F¡C±µ¤U¨Ó´N¬O«Ø¥ß List View ±±¨î¶µ¡A§Ú­Ì¥i¥H¦b¸ê·½´y­zÀɤ¤¥[¤J

CONTROL "",IDC_ListView,"SYSListView32", style, x, y, width, height, exStyle

©ÎªÌ¬O¥H¡uSYSListView32¡v¬°Ãþ§O¡A©I¥s CreateWindowEx «Ø¥ß List View ¤lµøµ¡¡C³o¨Ç¨BÆJ¸ò«e­±«Ø¥ß¼ÐÅÒ±±¨î¶µ©Î¨ä¥L±±¨î¶µªº¹Lµ{¡A¨ÃµL¤£¦P¡C·í«Ø¥ß¡u²M³æÀ˵ø¡v±±¨î¶µ®É¡A·Q¥H¤W­±¤­ºØÅã¥Ü¤è¦¡ªº¬Y¤@ºØ¤è¦¡Åã¥Ü¶µ¥Øªº³Z¬¡A¨ä¹ê´N¬O¦b«Ø¥ß¡u²M³æÀ˵ø¡v±±¨î¶µ®É¡A±Ä¥Î¤£¦Pªº­·®æ©Ò­P¡C¤Uªí´N¬O³o¤­ºØÅã¥Ü¤è¦¡©Ò¨Ï¥Îªº­·®æ¡C

Åã¥Ü¤è¦¡
view type
¸ê·½´y­zÀÉ
¤¤ªº­·®æ
LVM_SETVIEW °T®§¤¤ªº
wParam °Ñ¼Æ
»¡¡@¡@©ú
Icon ViewLVS_ICONLV_VIEW_ICON ¨C­Ó¶µ¥Ø¥H¹Ï¥ÜÅã¥Ü¡A¦Ó¤å¦r¼ÐÅÒ ( label ) ¦b¹Ï¥Ü¤U­±¡C¨Ï¥ÎªÌ¥i¥H¦b¡u²M³æÀ˵ø¡v±±¨î¶µ¤º©ì°Ê¹Ï¥Ü¡C
Details ViewLVS_REPORTLV_VIEW_DETAILS ¤]¥s Report View¡C³Ì¤W­±·|¦³Äæ¦ì¦WºÙ¡AÄæ¦ì¦WºÙ©³¤U«h¬O¦U­Ó¶µ¥Ø¡A¨C¤@¶µ¥Ø¥H¦Cªí¤è¦¡Åã¥Ü©ó¤@¦C¤¤¡A¦Ó¨C­Ó¶µ¥Ø³Ì¥ªÃ䪺¤@¦C¥]§t¹Ï¥Ü¤Î¼ÐÅÒ¤å¦r¡A¦Ó¨ä¥kÃ䪺¨C¤@¦C³£ºÙ¬°¤l¶µ¥Ø ( subitem )¡C³Ì¤W­±À³¦³
Small Icon ViewLVS_SMALLICONLV_VIEW_SMALLICON ¨C­Ó¶µ¥Ø¥H¤p¹Ï¥ÜÅã¥Ü¡A¦Ó¤å¦r¼ÐÅÒ¦b¤p¹Ï¥Üªº¥kÃä¡C¨Ï¥ÎªÌ¥i¥H©ì°Ê¹Ï¥Ü¨ì¥ô·N¦a¤è¡C
List ViewLVS_LISTLV_VIEW_LIST ¨C­Ó¶µ¥Ø¥H¤p¹Ï¥ÜÅã¥Ü¡A¦Ó¥B¾ã²z¦¨¤@¦æÅã¥Ü¡C¨Ï¥ÎªÌµLªk©ì°Ê¹Ï¥Ü¡C
Tile View¡@LV_VIEW_TILE ¥u¦³ COMCTL32.DLL 6.0 ª©¥H«á¤~´£¨ÑªºÅã¥Ü¤è¦¡¡C¨C­Ó¶µ¥Ø¥H¤j¹Ï¥ÜÅã¥Ü¡A¤å¦r¼ÐÅÒ¦b¹Ï¥Ü¥kÃä¡A¦Ó¤å¦r¼ÐÅÒ©³¤U¥i¯àÁÙ¦³§ó¦hªº¸ê®Æ»¡©ú¡C

§ïÅÜ List View ªºÅã¥Ü¤è¦¡

¨Æ¹ê¤W¡A¦b¸ê·½´y­zÀɤ¤³]©w¦nªº­·®æ¡A¨Ã«D§¹¥þ¤£¯à§ó§ï¡C§Ú­Ì¥i¥H³z¹L¨âºØ¤èªk§ïÅÜ¡u²M³æÀ˵ø¡v±±¨î¶µªºÅã¥Ü¤è¦¡¡G¤@¬O¹ï¡u²M³æÀ˵ø¡v±±¨î¶µµo¥X LVM_SETVIEW °T®§¡A¤]´N¬O©I¥s SendMessage API¡C

INVOKE  SendMessage,hListView,LVM_SETVIEW,wParam,lParam

³o®É­Ô LVM_SETVIEW °T®§¤¤ªº wParam °Ñ¼Æ´N¬O¦p¤Wªí©Ò¥Ü¡A¦Ó lParam °Ñ¼Æ¬° 0¡C¨Ò¦p­ì¥ý¬O¥H List View ¤è¦¡Åã¥Ü¡A­nÅÜ§ó¬° Icon View¡A¨º»ò wParam °Ñ¼Æ´N¬O LV_VIEW_ICON¡CTile View ¬O XP ·s¼WªºÅã¥Ü¤è¦¡¡AµLªk¦b¸ê·½´y­zÀɤ¤³]©w¡A¦ý¥i³z¹L SendMessage µo¥X±aµÛ LV_VIEW_TILE °Ñ¼Æªº LVM_SETVIEW °T®§§ïÅÜ¡C

¥t¤@ºØ¤èªk¬O§ïÅܵøµ¡ªº­·®æ¡CŪªÌ­ÌÀ³¸ÓÁÙ°O±o¡A±±¨î¶µ¨ä¹ê´N¬O¤@ºØµøµ¡¡A§óºë½Tªº»¡ªk¡A¬O¡u¤lµøµ¡¡v¡C©Ò¥H±±¨î¶µ¤]¨ã¦³µøµ¡ªº©Ê½è¡C§Ú­Ì¥i¥HÂǥѩI¥s SetWindowLong ¨Ó§ïÅܵøµ¡­·®æ¡C¥Ñ©ó§Ú­Ì¥u§Æ±æ§ïÅÜ¡u²M³æÀ˵ø¡vªºÅã¥Ü¤è¦¡¡A¦Ó¤£§Æ±æ§ïÅܨä¥L­·®æ¡A¦]¦¹³Ì¦n¬O¥ý©I¥s GetWindowLong ¨ú±o²{¦³ªº²M³æÀ˵ø­·®æ¡A¦A§ó§ï¨ä¤¤ªºÅã¥Ü¤è¦¡¡CGetWindowLong ªº­ì«¬¬O¡G

LONG GetWindowLong ( 
    HWND hWnd,
    int  nIndex
);

§Ú­Ì¥i¥H¸g¥Ñ GetWindowLong API ¨ú±oµøµ¡ªº¸ê®Æ¡A³o¨Ç¸ê®Æ¥]§t¤Fµøµ¡­·®æ¡ChWnd ¬O§Ú­Ì­n¨ú±o¸ê®Æªºµøµ¡¥N½X¡AnIndex ¬O­n¨ú±oªº¸ê®Æ¡A¥i¥H¬O¤U­±´XºØ±¡§Î¡G

GetWindowLong ªº nIndex °Ñ¼Æ

nIndex»¡¡@©ú
GWL_EXSTYLE¨ú±oÂX¥Rªº­·®æ¡A¦¹ÂX¥R­·®æ¬O©I¥s CreateWindowEx ®É²Ä¤@­Ó°Ñ¼Æ dwExStyle ©Ò«ü©wªº¡C
GWL_STYLE¨ú±oµøµ¡­·®æ
GWL_WNDPROC¨ú±oµøµ¡¨ç¦¡¦ì§}¡A¨ú±o¦¹¦ì§}«á¡A¥i¥H¥Î CallWindowProc ©I¥s¦¹¦ì§}
GWL_HINSTANCE¨ú±oµøµ¡°õ¦æ¹ê¨Ò
GWL_HWNDPARENT¨ú±o¤÷µøµ¡ªº¥N½X
GWL_ID¨ú±oµøµ¡ÃѧO½X
GWL_USERDATA±o¨ì©Mµøµ¡¬ÛÃöÁpªº 32 ¦ì¤¸¼Æ­È¡A¨C¤@­Óµøµ¡³£¦³¤@­Ó¯S¦a¯dµ¹«Ø¥ßµøµ¡ªºµ{¦¡¥Îªº 32 ¦ì¤¸¼Æ­È
¦pªG hWnd ¬O¹ï¸Ü²°¡A¨º»ò¤]¥i¥H¨Ï¥Î¤U­±ªº¼Æ­È¨ú±o¯S©w¸ê®Æ
DWL_DLGPROC¨ú±o¹ï¸Ü®Ø¨ç¦¡¦ì§}¡A¨ú±o¦¹¦ì§}«á¡A¥i¥H¥Î CallWindowProc ©I¥s¦¹¦ì§}
DWL_MSGRESULT¨ú±o¹ï¸Ü®Ø¨ç¦¡°T®§³B²zªº¶Ç¦^­È
DWL_USER¨ú±oµøµ¡ÃB¥~¨p¦³ªº°T®§¡A¦p«ü¼Ð©Î¥N½X

SetWindowLong ¥Îªk©M GetWindowLong Ãþ¦ü¡A¥u¬O¥Ñ¨ú±o¸ê®ÆÅܦ¨³]©wµøµ¡ªº¸ê®Æ¡A¨ä­ì«¬¬°¡G

LONG SetWindowLong (
    HWND hWnd,
    int  nIndex,
    LONG dwNewLong
);

°Ñ¼Æ hWnd ¬O­n³]©w¸ê®Æªºµøµ¡¥N½X¡CnIndex ¸ò¤Wªí¡uGetWindowLong ªº nIndex °Ñ¼Æ¡vªº¡unIndex¡vÄæ¦ì¬Û¦P¡A¥u¬O¥Ñ¨ú±o§ï¬°³]©w¡CdwNewLong ¬O­n·s³]©wªº­È¡C¦pªG¦¨¥\ªº³]©wµøµ¡¸ê®Æ¡A«h·|¶Ç¦^­ì¥ýªºµøµ¡¸ê®Æ¡F¦pªG³]©w¥¢±Ñ¡A«h¶Ç¦^ FALSE¡C­n³]©w¡u²M³æÀ˵ø¡v±±¨î¶µªºÅã¥Ü¤è¦¡¡A¥²»ÝÁÙ­n¦A¸g¹L´X­Ó¨BÆJ¡C©³¤U¥H³]©wÀ˵ø²M³æÅã¥Ü¤è¦¡¬° Icon View ¬°¨Ò¡A¾ã­Ó¹Lµ{¦p¤U¡G

                INVOKE  GetWindowLong,hListView,GWL_STYLE   ;¨ú±o­ì¨Ó­·®æ
                and     eax,not LVS_TYPEMASK                ;²M°£Åã¥Ü¤è¦¡
                or      eax,LVS_ICON                        ;³]©w·sªºÅã¥Ü¤è¦¡
                INVOKE  SetWindowLong,hListView,GWL_STYLE,eax

°²¦p±z¬d¾\ WINDOWS.INC ÀÉ¡A·|µo²{©³¤Uªº²M³æÀ˵ø±±¨î¶µªº­·®æ¡G

LVS_ICON        EQU     0000H
LVS_REPORT      EQU     0001H
LVS_SMALLICON   EQU     0002H
LVS_LIST        EQU     0003H
LVS_TYPEMASK    EQU     0003H

¤W­±µ{¦¡½X¤¤³Ì«á¤@­Ó¡ALVS_TYPEMASK ¤§­È¬° 3¡A¤]´N¬O¤G¶i¦ìªº 11¡A¦Ó¨ä¥L¦³ÃöÅã¥Ü¤è¦¡ªº´X­Ó­·®æ³£¬O¦b 0¡ã3 ªº½d³ò¤º¡A¤]´N¬O¦û¾Ú²Ä 0¡B1 ¦ì¤¸¡C±z¥i¥H¬d WINDOWS.INC µo²{À˵ø²M³æªº¨ä¥L­·®æ«h¬O¦û¾Ú²Ä 2¡ã31 ¦ì¤¸¡C°²³]§Ú­Ì¶È¶È·Q­n§ïÅÜÅã¥Ü¤è¦¡¡A¦Ó¤£§ï¨ä¥L­·®æ¡A¨º»ò´N¥u¯à§ïÅÜ 0¡B1 ¦ì¤¸¡C¦]¦¹¨ú±oÀ˵ø²M³æ­ì¨Óªº­·®æ«á¡A»P NOT LVS_TYPEMASK ( NOT LVS_TYPEMASK ¤§­È¬° 1111 1111 1111 1100 ) §@ AND ¹Bºâ´N¥i¨Ï±o²Ä 0¡B1 ¦ì¤¸³Q²M°£¡A±µµÛ¦A»P·Q­nÅã¥ÜªºÅã¥Ü¤è¦¡§@ OR ¹Bºâ¡A´N¥i¥H±o¨ì·sªº­·®æ¡C


¦b List View ¤¤ªºÄæ¦ì ( column )

²K¥[Äæ¦ì

¥Ñ¤W­±ªº»¡©ú¡A±zÀ³·í¤wª¾¡A¦b²M³æÀ˵ø±±¨î¶µªºÅã¥Ü¤è¦¡¤¤¡A¯àÅã¥Ü³Ì¦h¸ê®Æªº¬O¡udetails view¡v¡C¥¦Åã¥Ü¤è¦¡¹³¬O¤@­Óªí®æ¡A³Ì¤W­±¦³¤@¦C¼ÐÃD¡A¼ÐÃD¬O¥Ñ³\¦hÄæ¦ì ( column ) ²Õ¦¨¡C¨C¤@­Ó¶µ¥Ø´N¹³¤@µ§¸ê®Æ¤@¼Ë¡A¥Ñ¤W¦V¤U¤@¶µ¤@¶µ¦C¥X©ó²M³æÀ˵ø¤¤¡A¦Ó¨C¤@¶µ¤S¥]§t³\¦hÄæ¦ì¡A²Ä¤@­ÓÄæ¦ìºÙ¬°¡u¶µ¥Ø¡v¡A¥H«áªºÄæ¦ì«hºÙ¬°¡u¤l¶µ¥Ø¡v¡C¦]¦¹¡A°²¦p±z³]­pªº²M³æÀ˵ø­n¥H¡udetails view¡vÅã¥Ü¡A¨º»ò´N¥²¶·¥ý³]¸m¼ÐÃD¤Î¦UÄæ¦ì¦WºÙ¡A¤èªk¬O©I¥s SendMessage¡A¹ï²M³æÀ˵øµo¥X LVM_INSERTCOLUMN °T®§¡A¦p¤U­±µ{¦¡¤ù¬q¡G

        INVOKE  SendMessage,hListView,LVM_INSERTCOLUMN,iCol,pcol

hListView ¬O­n·s²K¥[Äæ¦ìªº²M³æÀ˵ø±±¨î¶µ¥N½X¡FiCol Äæ¦ì½s¸¹¡A¥Ñ¹s¶}©l¡A0 ªí¥Ü¶µ¥Ø¡A1 ¤Î¨ä¥H«áªí¥Ü¤l¶µ¥Ø¡Fpcol ¬O«ü¦V¤@­ÓºÙ¬° LV_COLUMN ªºµ²ºcÅé¡A³o­Óµ²ºcÅé¤]¥s LVCOLUMN¡CLVCOLUMN µ²ºcÅé¤]¥Î¦b LVM_GETCOLUMN¡BLVM_SETCOLUMN¡BLVM_DELETECOLUMN °T®§¡A¤À§O¨ú±o¡B§ïÅÜ ( ¥ç§Y³]©w )¡B§R¥h²M³æÀ˵ø±±¨î¶µªº¬Y­ÓÄæ¦ì¡CLVCOLUMN ªºÄæ¦ì¦¨­û©w¸q¬O¡G

LVCOLUMN        STRUCT  
  imask         UINT    ?
  fmt           DWORD   ?
  lx            DWORD   ?
  pszText       LPTSTR  ?
  cchTextMax    DWORD   ?
  iSubItem      DWORD   ?
  iImage        DWORD   ?
  iOrder        DWORD   ?
  cxMin         DWORD   ?
  cxDefault     DWORD   ?
  cxIdeal       DWORD   ?
LVCOLUMN        ENDS

imask ¬O«ü LVCOLUMN µ²ºcÅ骺­þ´X¶µ¦¨­û¬O¦³®Äªº¡A¦b MSDN ùØ¡Aimask ºÙ¬° mask¡A¦ý¦b MASM32 ùØ¡Amask ¬O«O¯d¦r¡A¦]¦¹§ï¬° imask¡C¤£¦Pªº imask ¼Æ­È¡A¥Nªí LVCOLUMN ¤¤ªº¬Y¨ÇÄæ¦ì»Ý­n³]©w¡A©ÎªÌ¬Oªð¦^®É¬Y¨ÇÄæ¦ì¤w¶ñ¦n¸ê®Æ¡F´«¥y¸Ü»¡ imask ¤§­È¡A·|¼vÅT¬Y¨ÇÄæ¦ì¡A¦p¤Uªí¡J

imask ¼vÅTÄæ¦ì»¡¡@¡@¡@©ú
LVCF_FMT fmt fmt Äæ¦ì¬O¥Î¨Ó³]©wÄæ¦ì¤å¦r¦p¦ó¹ï»ô¡C¤£¹L³Ì¥ªÃ䪺Äæ¦ì¤å¦r®æ¦¡¬OµLªk³]©wªº¡A¨ä¾l¤l¶µ¥ØªºÄæ¦ì¤å¦r®æ¦¡«h¥i¥H³]©w¡Cfmt ¥i¥H¬O¤U­±´XºØ¼Æ­È¡G
LVCFMT_LEFT¡G¤å¦r¦V¥ª¹ï»ô¡A¨ä­È¬° 0¡C
LVCFMT_RIGHT¡G¤å¦r¦V¥k¹ï»ô¡A¨ä­È¬° 1¡C
LVCFMT_CENTER¡G¤å¦r¦V¤¤¶¡¹ï»ô¡A¨ä­È¬° 2¡C
LVCFMT_JUSTIFYMASK¡G¦¹¼Æ­È¥Î¨Ó¾B¸n¤å¦r±Æ¦C¤è¦¡¡A¨ä­È¬° 3¡A«ê¦n´N¬O LVCFMT_LEFT¡BLVCFMT_RIGHT¡BLVCFMT_CENTER ©Ò¦bªº¦ì¤¸¡C
LVCFMT_IMAGE¡G¥Ñ image list ¤¤¬D¤@±i¹Ï¤ùÅã¥Ü¡A­nÅã¥Üªº¹Ï¤ù¯Á¤Þ­È¶ñ¦b iImage Äæ¦ìùØ¡A©Ò¥H imask ¶·¬° LVCF_IMAGE or LVCF_FMT¡C4.70 ª©¥H«áªº COMCTL32.DLL ¤~¤ä´©¡C
LVCFMT_BITMAP_ON_RIGHT¡G4.70 ª©¥H«áªº COMCTL32.DLL ¤~¤ä´©¡A¨Ï¦ì¤¸¹Ï¥X²{¦b¤å¦r¥kÃä¡C
LVCFMT_COL_HAS_IMAGES¡GÄæ¦ì¥]§t image list ¤¤ªº¹Ï¤ù¡A4.70 ª©¥H«áªº COMCTL32.DLL ¤~¤ä´©¡C
LVCFMT_FIXED_WIDTH¡G¤£¯àÅܧóÄæ¦ì¼e«×¡A©M HDF_FIXEDWIDTH ¬Û¦P¡AXP ©Î COMCTL32.DLL ¦b 6.00 ª©¥H«á¤~¤ä´©¡C
LVCFMT_NO_DPI_SCALE¡G
LVCFMT_FIXED_RATIO¡G¼e«×·|ÀH°ª«×§ïÅÜ¡AXP ©Î COMCTL32.DLL ¦b 6.00 ª©¥H«á¤~¤ä´©¡C
LVCFMT_LINE_BREAK¡GXP ©Î COMCTL32.DLL ¦b 6.00 ª©¥H«á¤~¾A¥Î¡A¥u¥Î©ó Title View Åã¥Ü¤è¦¡®É¡A±j­¢¤å¦r¨ì¤U¤@Äæ¦ì¡A»Ý·f°t LVTVIF_EXTENDED ºX¼Ð¡C
LVCFMT_FILL¡GXP ©Î COMCTL32.DLL 6.00 ª©¥H«á¤~¾A¥Î¡A¥u¥Î©ó Title View Åã¥Ü¤è¦¡®É¡A¥i¥H¨Ï¾ã­ÓÄæ¦ì¶ñº¡¤å¦r¡A»Ý·f°t LVTVIF_EXTENDED ºX¼Ð¡C
LVCFMT_WRAP¡GXP ©Î COMCTL32.DLL 6.00 ª©¥H«á¤~¾A¥Î¡A¥u¥Î©ó Title View Åã¥Ü¤è¦¡®É¡A¥i¥H¨Ï©µ¦ùªº¤å¦r´«¦æ¡A»Ý·f°t LVTVIF_EXTENDED ºX¼Ð¡C
LVCFMT_NO_TITLE¡GXP ©Î COMCTL32.DLL ¦b 6.00 ª©¥H«á¤~¾A¥Î¡A¥u¥Î©ó Title View Åã¥Ü¤è¦¡®É¡A¨ÏÄæ¦ì¤£Åã¥Ü¤å¦r¡A»Ý·f°t LVTVIF_EXTENDED ºX¼Ð¡C
LVCFMT_TILE_PLACEMENTMASK¡GXP ©Î COMCTL32.DLL ¦b 6.00 ª©¥H«á¤~¾A¥Î¡A¬Û·í©óµ²¦X LVCFMT_LINE_BREAK »P LVCFMT_FILL¡A»Ý·f°t LVTVIF_EXTENDED ºX¼Ð¡C
LVCFMT_SPLITBUTTON¡GXP ¤Î©Î COMCTL32.DLL ¦b 6.00 ª©¥H«á¤~¾A¥Î¡AÄæ¦ì¬O¤@­Ó split button¡A»P HDF_SPLITBUTTON ¬Û¦P¡C
LVCF_WIDTH lx lx ¬OÄæ¦ì¼e«×¡A¥H¹Ï¯À ( pixel¡A§Y¿Ã¹õ¤Wªº¤@­ÓÂI ) ¬°³æ¦ì¡C¦b MSDN ¤åÄm¤¤¡A¦¹Äæ¦ì¦WºÙ¬° cx¡A¦ý¦b²Õ¦X»y¨¥ùØ©M¼È¦s¾¹ CX ¦P¦W¡A¬G§ïºÙ¬° lx¡C
LVCF_TEXT pszText ©Î
cchTextMax
pszText ¬O¥H 0 ¬°µ²§Àªº¦r¦ê¦ì§}¡A¦pªG¬O¦b LVM_GETCOLUMN °T®§¤¤¡A¥Nªí¨t²Î·|§â²M³æ±±¨î¶µªºÄæ¦ì¦WºÙ¶ñ¤J pszText ©Ò«ü¦ì§}ªº½w½Ä°ÏùØ¡A¨ä³Ì¤jªº¤j¤p¬O´X­Ó¼e¦r¤¸ªø«×¡AÀ³¸Ó¨Æ¥ý¦b cchTextMax ¤¤³]©w¡F¦pªG¬O LVM_SETCOLUMN¡BLVM_INSERTCOLUMN °T®§ùØ¡A·|¨Ï²M³æ±±¨î¶µªºÄæ¦ì¦WºÙ³]©w¬° pszText ¦ì§}©Ò«üªº¦r¦ê¡A¦Ó cchTextMax ¬OµL§@¥Î¡C
LVCF_SUBITEM iSubItem iSubItem ¬O²Ä´X­ÓÄæ¦ì¡A¥Ñ¹s¶}©l¡A¦¹Äæ¦ìÀ³»P iCol ¬Û¦P¡C0 ªí¥Ü¶µ¥Ø¡A1 ¤Î¨ä¥H«áªí¥Ü¤l¶µ¥Ø¡C
LVCF_IMAGE iImage ³o¬O COMCTL32.DLL ¦b 4.70 ª©¤Î¨ä¥H«á¤~¤ä´©ªºÄæ¦ì¡C( Ãö©ó COMCTL32.DLL ªºª©¥»¥i¥H°Ñ¦Ò²Ä 21 ³¹µù¤@¡C)iImage ¬O Image List ùØ­±²Ä´X­Ó¹Ï¥Ü¡A³o­Ó¹Ï¥Ü·|Åã¥Ü¦bÄæ¦ì¦WºÙ¤W¡C
LVCF_ORDER iOrder ³o¬O COMCTL32.DLL ¦b 4.70 ª©¤Î¨ä¥H«á¤~¤ä´©ªºÄæ¦ì¡C
LVCF_MINWIDTH cxMin ³o¬O COMCTL32.DLL ¦b 6.00 ª©¤Î¨ä¥H«á¤~¤ä´©ªºÄæ¦ì¡CcxMin ªí¥Ü³Ì¤pÄæ¦ì¼e«×¡A¥H¹Ï¯À¬°³æ¦ì¡C
LVCF_DEFAULTWIDTH cxDefault ³o¬O COMCTL32.DLL ¦b 6.00 ª©¤Î¨ä¥H«á¤~¤ä´©ªºÄæ¦ì¡CcxDefault ªí¥Ü¤º©wªºÄæ¦ì¼e«×¡A¥H¹Ï¯À¬°³æ¦ì¡C
LVCF_IDEALWIDTH cxIdeal ³o¬O COMCTL32.DLL ¦b 6.00 ª©¤Î¨ä¥H«á¤~¤ä´©ªºÄæ¦ì¡C

¦pªGµ{¦¡¹ï²M³æÀ˵øµo¥X LVM_INSERTCOLUMN °T®§¡A¨Ã¦¨¥\¦a³]¸m·sªºÄæ¦ì¡Aªð¦^­È¬°·sÄæ¦ìªº½s¸¹¡F­Y¥¢±Ñ¡A«hªð¦^ ¡Ð1¡C¦Ó LVM_DELETECOLUMN¡BLVM_GETCOLUMN¡BLVM_SETCOLUMN °T®§­Y¯à¦¨¥\¡Aªð¦^ TRUE¡F§_«hªð¦^ FALSE¡C

¦bÄæ¦ì¦WºÙ¤¤Åã¥Ü¹Ï¥Ü

¦pªG¡u²M³æÀ˵ø¡v±±¨î¶µ¥H details view ¤è¦¡Åã¥Ü¡A¨äµøµ¡ªº³Ì¤W­±¬O¥Ñ¦n´X­ÓÄæ¦ì©Ò²Õ¦¨ªº¼ÐÃD ( header )¡A¨Æ¹ê¤W¡A¼ÐÃD¤]¬O¤@ºØ³q¥Î±±¨î¶µ¡AºÙ¬°¡u¼ÐÃD±±¨î¶µ¡v¡C¦pªG­n¦b¼ÐÃD¤¤ªºÄæ¦ìÅã¥Ü¹Ï¥Üªº¸Ü¡A¥²¶·¥ý¨ú±o¡u¼ÐÃD±±¨î¶µ¡vªº¥N½X¡C

  1. ¨ú±o¦b²M³æÀ˵ø¤¤ªº¡u¼ÐÃD±±¨î¶µ¡v¥N½X¡J¥i¥H¹ï¡u²M³æÀ˵ø¡v±±¨î¶µµo¥X LVM_GETHEADER °T®§¡A¥HÀò±o¨ä¼ÐÃD±±¨î¶µ¥N½X¡C¤èªk¬O¡J
    INVOKE  SendMessage,hListView,LVM_GETHEADER,0,0  
    ªð¦^®É¡AEAX §Y¬°¡u¼ÐÃD±±¨î¶µ¡v¥N½X¡C

  2. §â¬Y­Ó¤w«Ø¥ßªº¡u¹Ï¤ù²M³æ¡v»P¡u¼ÐÃD±±¨î¶µ¡v³sµ²°_¨Ó¡J¥i¥H¹ï¼ÐÃD±±¨î¶µµo¥X HDM_SETIMAGELIST °T®§¡A³o¬O¼ÐÃD±±¨î¶µªº°T®§¤§¤@¡C
    INVOKE  SendMessage,hHeader,HDM_SETIMAGELIST,wParam,lParam
    ¤W­±µ{¦¡¤¤ªº wParam ¥i¥H¬O HDSIL_NORMAL ©Î HDSIL_STATE¡A¤À§O¥NªíÅã¥Ü¦bÄæ¦ì©Î¤£¦Pª¬ºA®É­Ôªº¹Ï¥Ü¡A¦pªG¬O¥u­n¦b¼ÐÃD±±¨î¶µªº¬Y­ÓÄæ¦ìÅã¥Ü¹Ï¥Üªº¸Ü¡A¨º»ò wParam ³]¬° HDSIL_NORMAL §Y¥i¡ClParam «h¬O¹Ï¤ù²M³æªº¥N½X¡C

  3. ¦b LVCOLUMN µ²ºcÅ餤ªº iImage ¦¨­û¤¤³]©w­nÅã¥Ü¦b¼ÐÃD±±¨î¶µ¤¤¡A¬Y­ÓÄæ¦ìªº¹Ï¥Ü¬O¦b¹Ï¤ù²M³æªº²Ä´X­Ó¹Ï¥Ü¡C¤èªk¬O¹ï²M³æÀ˵ø±±¨î¶µµo¥X LVM_SETCOLUMN¡A·íµM©I¥s¤§«e¥²¶·³]¦n LVCOLUMN ªº¾A·íÄæ¦ì¡A¦p¤U­±µ{¦¡¤ù¬q¡J
    mov     lvc.imask,LVCF_IMAGE
    mov     lvc.fmt,LVCFMT_IMAGE or LVCFMT_CENTER or LVCFMT_BITMAP_ON_RIGHT
    INVOKE  SendMesage,hListView,LVM_SETCOLUMN,1,ADDR lvc

¤W­±µ{¦¡ªº²Ä¤T¦æ¡Aµo°e LVM_SETCOLUMN °T®§®É¡AwParam ¥Nªí²Ä´X­Ó¤l¶µ¥Ø¡AlParam ¥Nªí LVCOLUMN µ²ºcÅé©Ò¦b¦ì§}¡C


¦b List View ¤¤¼W²K¶µ¥Ø ( item ) ©Î¤l¶µ¥Ø ( subitem )

­n¦b¡u²M³æÀ˵ø¡v±±¨î¶µùزK¥[¤@­Ó¶µ¥Ø¡A¥²¶·©I¥s SendMessage¡A¹ï¡u²M³æÀ˵ø¡vµo¥X LVM_INSERTITEM °T®§¡F­n¦b¦¹¶µ¥ØùزK¥[¤l¶µ¥Ø ( subitem )¡A¤]­n©I¥s SendMessage¡A¹ï¨äµo¥X LVM_SETITEM °T®§¡C¦pªG­n²K¥[¨â­Ó¤l¶µ¥Ø¡A´N±o¹ï²M³æÀ˵ø±±¨î¶µµo¥X¨â¦¸ LVM_SETITEM °T®§¡A±zµLªk¥Î LVM_INSERTITEM ¤¤²K¥[¤l¶µ¥Ø¡C¦p¤U­±µ{¦¡½X¡G¤W­±¬O²K¥[¶µ¥Ø¡A¦pªG¦¨¥\ªð¦^·s¶µ¥Øªº¯Á¤Þ­È¡A¦pªG¥¢±Ñ¶Ç¦^ -1¡F¤U­±¬O²K¥[¤l¶µ¥Ø¡A¦pªG¦¨¥\ªð¦^ TRUE¡A¦pªG¥¢±Ñªð¦^ FALSE¡J

INVOKE  SendMessage,hListView,LVM_INSERTITEM,0,pitem  ;²K¥[¶µ¥Ø
INVOKE  SendMessage,hListView,LVM_SETITEM,0,pitme     ;²K¥[¤l¶µ¥Ø

LVM_INSERTITEM ©M LVM_SETITEM °T®§ªº wParam §¡¬°¹s¡F¦Ó lParam °Ñ¼Æ³£¬O pitem¡A¥¦¬O«ü¦V¤@­Ó¦W¬° LVITEM ªºµ²ºcÅé¦ì§}¡C±zÀ³¸Ó¦b©I¥s SendMessage «e¥ý³]©w¦n LVITEM µ²ºcÅ骺¦U¶µÄæ¦ì¡C¦pªG±z·Q§ïÅܤw²K¥[¶µ¥Øªº¶µ¥Ø¦WºÙ¡B¤l¶µ¥Ø¦WºÙ¡Bª¬ºA¡K¡Kµ¥¡A¤]¬O¹ï²M³æÀ˵ø±±¨î¶µµo¥X LVM_SETITEM °T®§¡A¦P¼Ëªº¡A±z¤]»Ý­n¦b©I¥s SendMessage «e³]©w¦n LVITEM ¦UÄæ¦ì¤§­È¡CLVITEM µ²ºcÅéº٠LV_ITEM µ²ºcÅé¡A¨ä¦¨­û¦p¤U¡G

LVITEM          STRUCT
  imask         UINT    ?
  iItem         DWORD   ?
  iSubItem      DWORD   ?
  state         UINT    ?
  stateMask     UINT    ?
  pszText       LPTSTR  ?
  cchTextMax    DWORD   ?
  iImage        DWORD   ?
  lParam        LPARAM  ?
  iIndent       DWORD   ?
  iGroupId      DWORD   ?
  cColumns      UINT    ?
  puColumns     DWORD   ?
  piColFmt      DWORD   ?
  iGroup        DWORD   ?
LVITEM          ENDS

imask ¬O¥Î¨Óªí¥Ü LVITEM µ²ºcÅ骺­þ´X­ÓÄæ¦ì¦¨­û¬O¦³®Äªº¡A¤£¦Pªº imask ¤§­È¡A¥Nªí LVITEM µ²ºcÅ餤¬Y¨Ç¯S©wÄæ¦ì¥²¶·³]©w¡Cimask ­È¦³¤U¦C´XºØ¡G( ¦b MSDN ùØ¡Aimask ºÙ¬° mask¡A¦ý¦b MASM32 ùØ¡Amask ¬O«O¯d¦r¡A¦]¦¹§ï¬° imask¡A¨ä¸ê®Æ«¬ºA¬° 32 ¦ì¤¸ªøªºµL¸¹¾ã¼Æ¡A§Y UINT )

imask ¼vÅTÄæ¦ì»¡¡@¡@¡@©ú
LVIF_TEXT pszText ©Î
cchTextMax
pszText ¬O¤@­Ó«ü¼Ð¡A¦¹«ü¼Ð«ü¦V¤@­Ó¦r¦ê¡Aªí¥Ü¦¹¶µ¥Øªº¼ÐÅÒ¤å¦r¡A¼ÐÅÒ¤å¦rÁöµM¥i¥H¶W¹L 260 ¦r¤¸¡A¦ý¥u¦³«e­±ªº 260 ¦r¤¸·|Åã¥Ü¥X¨Ó¡C¦pªG¬O¥Î¦b¨ú±o¶µ¥Ø¸ê®Æªº°T®§®É¡ApszText ´N¬O±µ¦¬ªº½w½Ä°Ï¦ì§}¡A³o®É­n±µ¦¬ªº¦r¤¸ªø«× ( ¥]§t NULL ) ¥Ñ cchTextMax «ü©w¡C¦pªGµo°e LVM_SETITEM ©M LVM_INSERTITEM °T®§®É¡ApszText ´N¬O­n³]©wªº¶µ¥Ø©Î¤l¶µ¥Ø¦WºÙ¡A¦¹®É cchTextMax ´NµL§@¥Î¤F¡C
LVIF_IMAGE iImage iImage ¬O¹Ï¤ù²M³æ¤¤ªº¯Á¤Þ­È¡Aªí¥Ü­n§â¦¹¯Á¤Þ­È©Ò¥Nªíªº¹Ï¤ù«ü©wµ¹¦¹¶µ¥Ø¡C
LVIF_COLUMNS cColumns
puColumns
Windows XP ¤Î¨ä¥H«áªº§@·~¨t²Î¤~¤ä´©¦¹ºX¼Ð¡CcColumns ¬O¦b Tile View Åã¥Ü¤è¦¡¤U¡AÅã¥Ü´XÄ檺¤l¶µ¥Ø¡A³Ì¦h¬° 20¡C
LVIF_GROUPID iGroupId iGroupId ¬O COMCTL32.DLL 6.00 ª©¥H«á¤~¦³ªºÄæ¦ì¡A¬O¥Î¨Ó³]©w¦¹¶µ¥ØÄÝ©ó­þ¤@­Ó¸s²Õ¡C¦pªG¨S¦³³]©w LVIF_GROUPID¡A«h¨t²Î·|§â iGroupId µø¬° I_GROUPIDNONE¡Aªí¥Ü¦¹¶µ¥Ø¤£ÄÝ©ó¥ô¦ó¤@­Ó¸s²Õ¡FiGroupId ¤]¥i¥H¬O I_GROUPIDCALLBACK¡Aªí¥Ü¦¹²M³æÀ˵ø±±¨î¶µ·|¹ï¤÷µøµ¡µo¥X LVN_GETDISPINFO °T®§¡A¥H¨ú±o¸s²Õªº¯Á¤Þ­È¡C
LVIF_COLFMT piColFmt
cColumns
Windows Vista/7 ¤Î¨ä¥H«áªº§@·~¨t²Î¤~¤ä´©¦¹ºX¼Ð¡C
LVIF_INDENT iIndent iIndent Äæ¦ì¬O¦w¸Ë¤F IE 3.0 ¥H«á©Î COMCTL32.DLL §ó·s¨ì 4.70 ª©¥H«á¡A¤~¦³ªºÄæ¦ì¡F¥¦¬O¥Î¨Ó«ü©w¶µ¥Ø¼e«×¬°´X­Ó¹Ï¥Üªº¼e«×¡A¤]´N¬O»¡¦pªG iIndent ¬° 1¡Aªí¥Ü¶µ¥Ø³]¬°¤@­Ó¹Ï¥Ü¼e¡AiIndent ¬° 2¡Aªí¥Ü¶µ¥Ø³]¬°¨â­Ó¹Ï¥Ü¼e¡C
LVIF_PARAM lParam lParam ¬Oµ{¦¡¦Û¦æ©w¸qªº¼Æ­È¡A¥i¥H¥Î¦b±Æ§Ç ( µo¥X LVM_SORTITEMS °T®§ ) ©Î·j´M ( µo¥X LVM_FINDITEM °T®§ )¡C
LVIF_STATE state ²M³æÀ˵ø±±¨î¶µ¤¤ªº¶µ¥Ø¦³©³¤U´XºØª¬ºA¡J
  1. LVIS_FOCUSED¡J¨ä­È¬° 01H¡A¦¹¶µ¥Ø¬O¨ã¦³¿é¤JµJÂIªº¡C³Q¿ï©wªº¶µ¥Ø¥i¥H¦³¦n´X­Ó¡A¦ý¬O¶È¦³¤@­Ó¬O¨ã¦³¿é¤JµJÂIªº¡C
  2. LVIS_SELECTED¡J¨ä­È¬° 02H¡A¦¹¶µ¥Ø¬O³Q¿ï©wªº¡C
  3. LVIS_CUT¡J¨ä­È¬° 04H¡A¥Ñ©ó°Å¤Á³Q¿ï©w¡C
  4. LVIS_DROPHILITED¡J¨ä­È¬° 08H¡A¦¹¶µ¥Ø¥¿¦b³Q·Æ¹«©ì²¾¤¤¡C
  5. LVIS_ACTIVATING¡J¨ä­È¬° 20H¡A¥¼³Q¿ï©w¡A¥ç§Y¤@¯ëª¬ºA¡C
  6. LVIS_OVERLAYMASK¡J¨ä­È¬° 0F00H¡A
  7. LVIS_STATEIMAGEMASK¡J¨ä­È¬° 0F000H¡A
LVIF_NORECOMPUTE
LVIF_DI_SETITEM

iItem ¶µ¥Ø¯Á¤Þ¡A¥ç§Y²Ä´X­Ó¶µ¥Ø¡A¥Ñ¹s¶}©l½s¸¹¡A¦b²M³æÀ˵øùØ´¡¤J¶µ¥Ø®É¡A­n«ü©w¶µ¥Ø¯Á¤Þ­È¡CiSubItem ¬O¤l¶µ¥Øªº¯Á¤Þ­È¡A¥ç§Y²Ä´X­ÓÄæ¦ì¡A¥Ñ¤@¶}©l¡A¦]¬°¹sªí¥Ü¶µ¥Ø¡A¦b²M³æÀ˵øùØ´¡¤J¶µ¥Ø©Î³]©w¤l¶µ¥Ø®É¡AÀ³«ü©w¤l¶µ¥Ø¯Á¤Þ­È¡C¨Ò¦p§Ú­Ì¥ý²³æ¦Ò¼{¤U­±³oºØ±¡§Î¡J¦³­Ó¤p¤½¥q¶È¦³¤T¤H¡A·Q§â­û¤u°ò¥»¸ê®Æ ( ©m¦W¡B©Ê§O¡B¦~ÄÖ¡B¥X¥Í¦a ) Åã¥Ü¦b²M³æÀ˵ø±±¨î¶µ¤¤¡C¦]¦¹§Ú­Ì±o¦b¼ÐÃD¤¤·s¼W¥|­ÓÄæ¦ì¡J©m¦W¡B©Ê§O¡B¦~ÄÖ¡B¥X¥Í¦a¡A¨Ã¥[¤J¤T­Ó¶µ¥Ø¡A³o¤T­Ó¶µ¥Ø¤À§O¬O¤T­Ó¤Hªº¸ê®Æ¡Ð¡Ð©m¦W¡B©Ê§O¡B¦~ÄÖ¡B¥X¥Í¦a¡A¦p¤U¹Ï¡J

¨º»ò³o¤T­Ó¤Hªº©m¦WºÙ¬°¡u¶µ¥Ø¡v¡A¦Ó©Ê§O¡B¦~ÄÖ¡B¥X¥Í¦a«h¬O²Ä¤@¡B¤G¡B¤T­Ó¤l¶µ¥Ø¡C¨º»òµ{¦¡½XÀ³¸Ó¬O¹³¤U­±³o¼Ë¡J

.CONST
;Äæ¦ì¦W
szName          BYTE    'Name',0
szSex           BYTE    'Sex',0
szAge           BYTE    'Age',0
szBirthPlace    BYTE    'Birth Place',0
;²Ä 0 ­Ó¶µ¥Øªº¸ê®Æ
szNo1Name       BYTE    'John',0
szNo1Sex        BYTE    'Male',0
szNo1Age        BYTE    '40',0
szNo1BP         BYTE    'Taipei',0
;²Ä 1 ­Ó¶µ¥Øªº¸ê®Æ
szNo2Name       BYTE    'Mary',0
szNo2Sex        BYTE    'Female',0
szNo2Age        BYTE    '30',0
szNo2BP         BYTE    'Kaohsiung',0
;²Ä 2 ­Ó¶µ¥Øªº¸ê®Æ
szNo3Name       BYTE    'David',0
szNo3Sex        BYTE    'Male',0
szNo3Age        BYTE    '28',0
szNo3BP         BYTE    'Taichung',0
 . . . . . . . . . . . . . . . . . . .
        ;²K¥[¼ÐÃD¡A¦¹¼ÐÃD¦@¥|Äæ
                mov     lvc.imask,LVCF_FMT or LVCF_TEXT or LVCF_WIDTH or LVCF_SUBITEM
                mov     lvc.fmt,LVCFMT_CENTER
                mov     lvc.lx,45
                mov     lvc.pszText,OFFSET szName
                mov     lvc.iSubItem,0
                INVOKE  SendMessage,hListView,LVM_INSERTCOLUMN,0,ADDR lvc   ;²K¥[²Ä 0 Äæ¡A©m¦W
                mov     lvc.lx,50
                mov     lvc.pszText,OFFSET szSex
                mov     lvc.iSubItem,1
                INVOKE  SendMessage,hListView,LVM_INSERTCOLUMN,1,ADDR lvc   ;²K¥[²Ä 1 Äæ¡A©Ê§O
                mov     lvc.lx,50
                mov     lvc.pszText,OFFSET szAge
                mov     lvc.iSubItem,2
                INVOKE  SendMessage,hListView,LVM_INSERTCOLUMN,2,ADDR lvc   ;²K¥[²Ä 2 Äæ¡A¦~ÄÖ
                mov     lvc.lx,90
                mov     lvc.pszText,OFFSET szBirthPlace
                mov     lvc.iSubItem,3
                INVOKE  SendMessage,hListView,LVM_INSERTCOLUMN,3,ADDR lvc   ;²K¥[²Ä 3 Äæ¡A¥X¥Í¦a
        ;²K¥[²Ä¤@­Ó­û¤uªº¸ê®Æ
                mov     lvi.imask,LVIF_TEXT or LVIF_PARAM
                mov     lvi.iItem,0
                mov     lvi.iSubItem,0
                mov     lvi.lParam,0
                mov     lvi.pszText,OFFSET szNo1Name
                INVOKE  SendMessage,hListView,LVM_INSERTITEM,0,ADDR lvi
                mov     lvi.imask,LVIF_TEXT
                mov     lvi.iSubItem,1
                mov     lvi.pszText,OFFSET szNo1Sex
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi
                mov     lvi.iSubItem,2
                mov     lvi.pszText,OFFSET szNo1Age
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi
                mov     lvi.iSubItem,3
                mov     lvi.pszText,OFFSET szNo1BP
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi
        ;²K¥[²Ä¤G­Ó­û¤uªº¸ê®Æ
                mov     lvi.imask,LVIF_TEXT or LVIF_PARAM
                mov     lvi.iItem,1
                mov     lvi.iSubItem,0
                mov     lvi.lParam,1
                mov     lvi.pszText,OFFSET szNo2Name
                INVOKE  SendMessage,hListView,LVM_INSERTITEM,0,ADDR lvi
                mov     lvi.imask,LVIF_TEXT
                mov     lvi.iSubItem,1
                mov     lvi.pszText,OFFSET szNo2Sex
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi
                mov     lvi.iSubItem,2
                mov     lvi.pszText,OFFSET szNo2Age
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi
                mov     lvi.iSubItem,3
                mov     lvi.pszText,OFFSET szNo2BP
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi
        ;²K¥[²Ä¤T­Ó­û¤uªº¸ê®Æ
                mov     lvi.imask,LVIF_TEXT or LVIF_PARAM
                mov     lvi.iItem,2
                mov     lvi.iSubItem,0
                mov     lvi.lParam,2
                mov     lvi.pszText,OFFSET szNo3Name
                INVOKE  SendMessage,hListView,LVM_INSERTITEM,0,ADDR lvi
                mov     lvi.imask,LVIF_TEXT
                mov     lvi.iSubItem,1
                mov     lvi.pszText,OFFSET szNo3Sex
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi
                mov     lvi.iSubItem,2
                mov     lvi.pszText,OFFSET szNo3Age
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi
                mov     lvi.iSubItem,3
                mov     lvi.pszText,OFFSET szNo3BP
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi

lParam ¬Oµ{¦¡¦Û¦æ©w¸qªº¼Æ­È¡A¥i¥H¥Î¦b±Æ§Ç ( µo¥X LVM_SORTITEMS °T®§ ) ©Î·j´M ( µo¥X LVM_FINDITEM °T®§ )¡C¦pªG­n³]©w¶µ¥Øªº lParam ¼Æ­È¡A³Ì¦n¬O¦b LVM_INSERTITEM ®É´N³]©w¦n¡A¦b LVM_SETITEM ®É¡A³s¦P¤l¶µ¥Ø¤@°_³]©w¡A·|²£¥Í°ÝÃD¡C¦p¦ó±Æ§Ç¡A½Ð°Ñ¾\¤U­±ªº»¡©ú¡CLVITEM ¤¤ªº lParam Áö¥i¥H¥ô·N©w¸q¡A¦ý¬O¬°¤F¤è«K¡A¤@¯ë·|³]©w¬°©M iItem ¬Û¦P¡A¥H«K¦b±Æ§Ç®É¯à«Ü§ÖªºÂÇ¥Ñ lParam ´N¥i¨ú±o iItem¡A¶i¦Ó±o¨ì¬Y­Ó¶µ¥Øªº©Ò¦³¸ê®Æ¡C

¶µ¥Ø¦WºÙ¤¤Åã¥Ü¹Ï¥Ü

¦pªG­n¦b¶µ¥Ø¦WºÙ¤¤Åã¥Ü¹Ï¥Ü¡A¨º»ò­n¥ý¹ï²M³æÀ˵ø±±¨î¶µµo¥X LVM_SETIMAGELIST °T®§¡A¨Ï¬Y­Ó¹Ï¤ù²M³æ ( image list ) »P²M³æÀ˵ø±±¨î¶µ³s±µ°_¨Ó¡Aµ{¦¡½X¦p¤U¡J

        INVOKE  SendMessage,hListView,LVM_SETIMAGELIST,wParam,lParam

hListView ¬O²M³æÀ˵ø±±¨î¶µ¥N½X¡AlParam ¬O image list ¥N½X¡A¥Nªí­n§â lParam ¤¤ªº image list »P²M³æÀ˵ø±±¨î¤U³sµ²°_¨Ó¡A¥ç§Y¦b¦¹µ{¦¡½X¤§«á¡A¦pªG²M³æÀ˵ø±±¨î¶µ»Ý¥Î¨ì image list ®É¡A´N¬O¥H lParam ¤¤©Ò«ü©wªº image list ¨Ï¥Î¡CwParam ¥i¥H¬O¤U­±¼Æ­È¡J

  1. LVSIL_NORMAL¡JImage List ¬°¤j¹Ï¥Ü¡A¤@¯ë¬O¦b icon view ©M tile view ¤¤¨Ï¥Î¡C
  2. LVSIL_SMALL¡JImage List ¬°¤p¹Ï¥Ü¡A¤@¯ë¬O¦b detail view¡Bsmall icon view¡Blist view ¤¤¨Ï¥Î¡C
  3. LVSIL_STATE¡J¶µ¥Ø¦b¬YºØª¬ºA¤¤¨Ï¥Î¡C
  4. LVSIL_GROUPHEADER¡J¸s²Õ¼ÐÃD¤¤¨Ï¥Î¡C

¦b¤@¯ë±¡§Î¤U¡A¥u¦³¶µ¥ØÄæ¦ì¤~¯àÅã¥Ü¹Ï¥Ü¡A¦pªG±z·Q¦b¤l¶µ¥Ø¤¤¤]Åã¥Ü¹Ï¥Ü¡A¨º»ò¥²¶·¨Ï¥Î LVS_EX_SUBITEMIMAGES ÂX¥R­·®æ¡A½Ð°Ñ¦Ò List View ªºÂX¥R­·®æ¡C

Windows XP ¤¤ªº Tile View

Tile View ¬O Windows XP ¤¤·s¼Wªº¤@ºØÅã¥Ü¤è¦¡¡A¥¦¥i¥H¦b¹Ï¥Ü®ÇÃäÅã¥Ü¶µ¥Ø¦WºÙ¤Î¼Æ­Ó¤l¶µ¥Ø¦WºÙ¡C¶µ¥Ø¦WºÙ¬O¨t²Î¤º©wÅã¥Üªº¡A¦Ó¤l¶µ¥Ø¦WºÙ«h¬Oµ{¦¡¥i¥H¥Ñ details view ¤¤¿ï¾Ü­þ´X­ÓÄæ¦ì¥i¥HÅã¥Ü¡C¦Ü©ó­nÅã¥Ü¤l¶µ¥Ø¼Æ¥Ø¤Î­þ¨Ç¤l¶µ¥Ø¡A¥i¥H¥Ñ LVITEM ¤¤ªº cColumns ©M puColumns ¨M©w¡CcColumns ³Ì¤j­È¬O 20¡A¥ç§Y³Ì¦h¥u¯àÅã¥Ü 20 ­Ó¤l¶µ¥Ø¡A³s¦P¶µ¥Ø¦WºÙ¡A´N¦³ 21 µ§¸ê®ÆÅã¥Ü¦b¹Ï¥Ü®Ç¡CpuColumns ¬O«ü¦V¤@­Ó°}¦C¦ì§}¡A¦¹°}¦C¥Ñ cColumns ­ÓÂù¦r²Õ²Õ¦¨¡A¨ä¨C­Ó¦¨­û´N¥Nªí details view ¤¤ªº²Ä´X­ÓÄæ¦ì¡C

¦pªGÅã¥Üªº¤l¶µ¥Ø¤Ó¦h¡AªÅ¶¡¤£°÷®É¡A¥i¯à·|³Q¤Á°£¡A³o®É¥²¶·³]©w¨C­Ó¶µ¥Øªº°ª«×¡B¼e«×¡C¤èªk¬O¥ý³]©w LVTILEVIEWINFO µ²ºcÅé¡A¦A¹ï²M³æÀ˵ø±±¨î¶µµo¥X LVM_SETTILEVIEWINFO °T®§¡A¦p¤U­±µ{¦¡¤ù¬q¡J

        INVOKE  SendMessage,hListView,LVM_SETTILEVIEWINFO,wParam,lParam

wParam ¥²¶·¬° 0¡AlParam ¬O LVTILEVIEWINFO µ²ºcÅé¦ì§}¡C¦pªGªð¦^­È¬° TRUE¡A«h©I¥s¦¨¥\¡F­Y¬° FALSE¡A«h©I¥s¥¢±Ñ¡C°²¦p­n¨ú±o tile view ¤¤¨C¤@¶µ¥Øªºªø»P¼e¡A«h¥i¥H¹ï²M³æÀ˵ø±±¨î¶µµo¥X LVM_GETTILEVIEWINFO °T®§¡A¦p¤U­±µ{¦¡¤ù¬q¡J

        INVOKE  SendMessage,hListView,LVM_GETTILEVIEWINFO,wParam,lParam

wParam ¥²¶·¬° 0¡AlParam ¬O LVTILEVIEWINFO µ²ºcÅé¦ì§}¡C¨S¦³ªð¦^­È¡CLVTILEVIEWINFO µ²ºcÅéÄæ¦ì¦p¤U¡J

LVTILEVIEWINFO  STRUCT
  cbSize        UINT    ?
  dwMask        DWORD   ?
  dwFlags       DWORD   ?
  sizeTile      SIZEL   <>
  cLines        DWORD   ?
  rcLabelMargin RECT    <>
LVTILEVIEWINFO  ENDS

Äæ¦ì¤¤ªº cbSize ¬O LVTILEVIEWINFO ¤j¤p¡A¥H¦ì¤¸²Õ¬°³æ¦ì¡AÀ³¦b©I¥s«e´N¤w¸g¶ñ¦n¡A¤£ºÞ¬Oµo¥X LVM_SETTILEVIEWINFO °T®§ÁÙ¬O LVM_GETTILEVIEWINFO °T®§¡CdwMask ¬O«ü©w³o¨â­Ó°T®§­n³]©w©Î¨ú±o­þ¨Ç¸ê®Æ¡A¦]¦¹¤]·|¼vÅT dwFlags¡BsizeTile¡BcLines¡BrcLabelMargin µ¥¥|­ÓÄæ¦ì¡A­þ¨ÇÄæ¦ì»Ý­n³]©w©Î¬Oªð¦^®É·|³Q¨t²Î¶ñ¤J¾A·íªº¼Æ­È¡CdwMask ¥i¯àªº¼Æ­È¦³¤U­±¤TºØ¡J

dwMask ¼vÅTÄæ¦ì»¡¡@¡@¡@©ú
LVTVIM_TILESIZE dwFlags
sizeTile
dwFlags ¬O¥Î¨Ó³]©w tile view ¶µ¥Ø¤j¤pªº¤è¦¡¡A¥i¥H¬O¤U­±¤­­Ó¼Æ­È¤§¤@¡J
¡@¡@LVTVIF_AUTOSIZE¡J¨t²Î¦Û°Ê³]©w
¡@¡@LVTVIF_EXTENDED¡JVista ¤~¥i¥H¨Ï¥Î¦¹¼Æ­È¡A¥Î©ó extended tiles view
¡@¡@LVTVIF_FIXEDWIDTH¡J©T©w¼e«×
¡@¡@LVTVIF_FIXEDHEIGHT¡J©T©w°ª«×
¡@¡@LVTVIF_FIXEDSIZE¡J©T©w¼e«×»P°ª«×
¦pªG¨Ï¥Î©T©w¼e«×»P°ª«×¡AÁٻݳ]©w sizeTile¡C¨Ò¦p¡A¦pªG dwFlags ¬° LVTVIF_FIXEDWIDTH¡A´N¥²¶·³]©w sizeTile.x¡F¦pªG dwFlags ¬° LVTVIF_FIXEDHEIGHT¡A´N¥²¶·³]©w sizeTile.y¡F¦pªG dwFlags ¬° LVTVIF_FIXEDSIZE¡A´N¥²¶·¦P®É³]©w sizeTile.x ¤Î sizeTile.y¡CsizeTile ªº¸ê®Æ«¬ºA¬O SIZE¡A½Ð¬Ý¤U­±ªº»¡©ú¡C
LVTVIM_COLUMNS cLines Åã¥Ü¦b¹Ï¥Ü®Çªº¤l¶µ¥Ø¼Æ¥Ø¡A¦¹­ÈÀ³¸Ó»P LVITEM ¤¤ªº cColumns ¬Û¦P¡A¦pªG¤£¦P¡A¨t²Î·|¿ï¾Ü¸û¤pªº¨º¤@­Ó¡C
LVTVIM_LABELMARGIN rcLabelMargin

¦b MSDN ùØ¡ALVTILEVIEWINFO ¤¤ªº sizeTile ¬O¤@­ÓºÙ¬° SIZE ªºµ²ºcÅé¡A¨äÄæ¦ì¬°¡J

SIZE    STRUCT
  cx    DWORD   ?
  cy    DWORD   ?
SIZE    ENDS

¦ý¬O SIZE ¬O ML ªº«O¯d¦r¡Acx ¬O¼È¦s¾¹ªº¦WºÙ¡A¬G MASM32 ¥H SIZEL ¥N´À SIZE¡A¨äÄæ¦ì¤]¥H x¡By ¥N´À¡C¦]¦¹¦b MASM32 ùØ¡ASIZE µ²ºcÅéÅܬ°¡J

SIZEL   STRUCT
  x     DWORD   ?
  y     DWORD   ?
SIZEL   ENDS

LVM_SETTILEVIEWINFO ¤Î LVM_GETTILEVIEWINFO ¬O¥Î¨Ó³]©w©Î¨ú±o¥þ³¡¶µ¥Øªº¸ê®Æ¡A¦pªG·Q­n³B²z³æ¤@¤@­Ó¶µ¥Ø¡A©Î¬Y­Ó¯S©w¶µ¥Øªº¸ê®Æ¡A«h¥²¶·µo¥X LVM_SETTILEINFO ©Î LVM_GETTILEINFO °T®§¡C¸Ô²Ó±¡§Î¥i¬d¾\ MSDN¡C


List View ¤¤ªº¸s²Õ ( Group )

²M³æÀ˵ø±±¨î¶µ¥H¸s²ÕÅã¥Ü

¦b Windows XP ¤Î¨ä¥H«áªº¨t²ÎùØ¡A¤]¥i¥H¥Î¡u¸s²Õ¡v¼Ò¦¡Åã¥Ü²M³æÀ˵ø±±¨î¶µªº¤º®e¡A³o®É­n¹ï²M³æÀ˵ø±±¨î¶µµo¥X LVM_ENABLEGROUPVIEW °T®§¡A¤Á´«¬O§_¥H¸s²Õ¤è¦¡Åã¥Ü¡J

INVOKE  SendMessage,hWndControl,LVM_ENABLEGROUPVIEW,fEnable,0

hWndControl ¬O²M³æÀ˵ø±±¨î¶µ¥N½X¡A¦pªG fEnable ¬° TRUE¡A«h·|¨Ï hWndControl Åܬ°¸s²Õ¼Ò¦¡¡F¦pªG fEnable ¬° FALSE¡A«h¨Ï±o hWndControl Åܬ°«D¸s²Õ¼Ò¦¡¡C·íµM¦pªG²M³æÀ˵ø±±¨î¶µ¤¤¡A¨S¦³¸s²Õ¡A¨º»ò¤´µMµLªk¬Ý¨£¨ä®ÄªG¡C­n·s¼W¸s²Õªº¤èªk¬O¹ï²M³æÀ˵øµo¥X LVM_INSERTGROUP °T®§¡A¦bµo¥X°T®§«eÀ³¥ý«ü©w¸s²ÕÃѧO½X¤Î¸s²Õ¦WºÙ¡A³o¨Ç¸ê®Æ³Q¥]§t¦b LVGROUP µ²ºcÅ餺¡C

¦b²M³æÀ˵ø±±¨î¶µ¤¤·s²K¸s²Õ

¨Æ¹ê¤W¡A°£¤F LVM_INSERTGROUP °T®§·|²o¯A¨ì LVGROUP µ²ºcÅé¥~¡A³]¥ß©Î¨ú±o¸s²Õ¸ê®Æ¡A¤]·|²o¯A¨ì LVGROUP µ²ºcÅé¡C­n³]¥ß©Î¨ú±o¸s²Õ¸ê®Æªº¤èªk¬O¤À§O¹ï²M³æÀ˵ø±±¨î¶µµo¥X LVM_SETGROUPINFO ©Î LVM_GETGROUPINFO °T®§¡C³o¤T­Ó°T®§³£²o¯A¨ì¤@­ÓºÙ¬° LVGROUP ªºµ²ºcÅé¡A³o­Óµ²ºcÅé¥Î¨Ó¦s©ñ²M³æÀ˵øªº¸s²Õ¸ê®Æ¡ALVGROUP µ²ºcÅ馨­ûÄæ¦ì¦p¤U¡J

LVGROUP                 STRUCT
  cbSize                UINT    ?
  imask                 UINT    ?
  pszHeader             LPWSTR  ?
  cchHeader             UINT    ?
  pszFooter             LPWSTR  ?
  cchFooter             DWORD   ?
  iGroupId              DWORD   ?
  stateMask             UINT    ?
  state                 UINT    ?
  uAlign                UINT    ?
  pszSubtitle           LPWSTR  ?
  cchSubtitle           UINT    ?
  pszTask               LPWSTR  ?
  cchTask               UINT    ?
  pszDescriptionTop     LPWSTR  ?
  cchDescriptionTop     UINT    ?
  pszDescriptionBottom  LPWSTR  ?
  cchDescriptionBottom  UINT    ?
  iTitleImage           DWORD   ?
  iExtendedImage        DWORD   ?
  iFirstItem            DWORD   ?
  cItems                UINT    ?
  pszSubsetTitle        LPWSTR  ?
  cchSubsetTitle        UINT    ?
LVGROUP                 ENDS

cbSize ¬O¦¹µ²ºcÅé¤j¤p¡A¥H¦ì¤¸²Õ¬°³æ¦ì¡A¨t²ÎÂǦ¹¤À¿ëª©¥»¡A¥²¶·¦bµo¥X°T®§«e¡A¥ý³]©w¦n¦¹Äæ¦ì¡Cimask ¬O¥Î¨Ó¨M©w­þ¨ÇÄæ¦ì¬O¦³®Äªº¡A¥i¯àªº¼Æ­È¬°¡J

imask¼vÅTÄæ¦ì »¡¡@©ú
LVGF_HEADER pszHeader
cchHeader
pszHeader «ü¦V¤@­Ó¥H NULL ¬°µ²§Àªº¦r¦ê¦ì§}¡A¦¹¦r¦ê¬°¸s²Õ¦WºÙ¡CcchHeader ¬° pszHeader ªø«×¡A¥H¦r¤¸¬°³æ¦ì¡C¦pªG¬O³]©w©Î·s²K¸s²Õ¡A¨Ò¦pµo¥X LVM_SETGROUPINFO¡BLVM_INSERTGROUP °T®§®É¡AcchHeader ·|³Q©¿²¤¡A¸s²Õ¦WºÙ§Y¬° pszHeader ©Ò«üªº¦r¦ê¡F¦ý¦pªG¬O¨ú±o¸s²Õ¸ê®Æ¡A¨Ò¦pµo¥X LVM_GETGROUPINFO °T®§®É¡AcchHeader ´N±o¦bµo¥X°T®§«e³]¦n¡A¨t²Î¤~ª¾¹D½w½Ä°Ïùس̦h¥i¥H®e¯Ç¦h¤Ö¦r¤¸¡Aº¸«á©ÒÀò±oªº¸s²Õ¦WºÙ±N¦s©ó pszHeader ©Ò«ü¦ì§}¡C
LVGF_ALIGN uAlign Windows XP ¤Î¨ä¥H«áªºª©¥»¤~¥i¥H¨Ï¥Î¡AuAlign ¤§­È¥i¥H¬O LVGA_HEADER_CENTER¡BLVGA_HEADER_LEFT¡BLVGA_HEADER_RIGHT¡A¤À§Oªí¥Ü¸s²Õ¦WºÙÅã¥Ü¦b²M³æ±±¨î¶µªº¤¤¶¡¡B¥ª°¼¡B¥k°¼¦ì¸m¡C
LVGF_GROUPID iGroupId ¸s²ÕªºÃѧO½X¡C¦b¤@­Ó²M³æÀ˵ø¤¤À³¬O°ß¤@ªº¡A¥ç§Y·s¼W¸s²ÕªºÃѧO½X¤£¥i­«½Æ¡C
LVGF_SUBTITLE pszSubtitle Windows XP ¤Î¨ä¥H«áªºª©¥»¤~¥i¥H¨Ï¥Î¡A

List View ªºÂX¥R­·®æ ( Extended Style )

²M³æÀ˵ø±±¨î¶µ¦³ 30 ­ÓÂX¥R­·®æ¥i¥H¨Ï¥Î¡A³£¬O¥H¡uLVS_EX_¡v¬°¦r­º¡A¨Ò¦p LVS_EX_BORDERSELECT¡BLVS_EX_FULLROWSELECT µ¥µ¥¡C­n¨Ï¥Î³o¨ÇÂX¥R­·®æ¡A¦ü¥GµLªk¦b¸ê·½´y­zÀÉ ( *.RC ) ùتº±±¨î¶µ¤¤ªº exStyle ©w¸q¡A¦Ü¤Ö¤p¤ì°¸¨S¦¨¥\¹L¡C¦ý¬O¥i¥H³z¹L LVM_SETEXTENDEDLISTVIEWSTYLE °T®§¡A§â¸ê®Æ¶Ç»¼¨ì²M³æÀ˵ø±±¨î¶µ¤º¡A¨Ó³]©wÂX¥R­·®æ¡A¤èªk¬O¡G

        INVOKE  SendMessage,hListView,LVM_SETEXTENDEDLISTVIEWSTYLE,dwExMask,dwExStyle

°Ñ¼Æ wParam ¥Nªí dwExMask ¤§·N¡AWindows ¥Î¤@­ÓÂù¦r²Õ ( §Y 32 ¦ì¤¸ ) ¨Óªí¥Ü 30 ­ÓÂX¥R­·®æ¡A±z¦pªG¥´¶} WINDOWS.INC¡A¥i¥H§ä¨ì

LVS_EX_GRIDLINES                 equ 00000001h
LVS_EX_SUBITEMIMAGES             equ 00000002h
LVS_EX_CHECKBOXES                equ 00000004h
LVS_EX_TRACKSELECT               equ 00000008h
LVS_EX_HEADERDRAGDROP            equ 00000010h
LVS_EX_FULLROWSELECT             equ 00000020h
LVS_EX_ONECLICKACTIVATE          equ 00000040h
LVS_EX_TWOCLICKACTIVATE          equ 00000080h
LVS_EX_FLATSB                    equ 00000100h
LVS_EX_REGIONAL                  equ 00000200h
LVS_EX_INFOTIP                   equ 00000400h
LVS_EX_UNDERLINEHOT              equ 00000800h
LVS_EX_UNDERLINECOLD             equ 00001000h
LVS_EX_MULTIWORKAREAS            equ 00002000h
LVS_EX_LABELTIP                  equ 00004000h
LVS_EX_BORDERSELECT              equ 00008000h
LVS_EX_DOUBLEBUFFER              equ 00010000h
LVS_EX_HIDELABELS                equ 00020000h
LVS_EX_SINGLEROW                 equ 00040000h
LVS_EX_SNAPTOGRID                equ 00080000h
LVS_EX_SIMPLESELECT              equ 00100000h
LVS_EX_JUSTIFYCOLUMNS            equ 00200000h
LVS_EX_TRANSPARENTBKGND          equ 00400000h
LVS_EX_TRANSPARENTSHADOWTEXT     equ 00800000h
LVS_EX_AUTOAUTOARRANGE           equ 01000000h
LVS_EX_HEADERINALLVIEWS          equ 02000000h
LVS_EX_AUTOCHECKSELECT           equ 08000000h
LVS_EX_AUTOSIZECOLUMNS           equ 10000000h
LVS_EX_COLUMNSNAPPOINTS          equ 40000000h
LVS_EX_COLUMNOVERFLOW            equ 80000000h

¨C­ÓÂX¥R­·®æ¥H¤@­Ó¦ì¤¸¥Nªí¡A¦]¦¹·í§Ú­Ì¶È¶È·Q§ïÅܬY­ÓÂX¥R­·®æ¡A¦Ó¤£¼vÅT¨ä¥LÂX¥R­·®æ®É¡AÀ³±N¨ä¥L­·®æ©Ò¥Nªí¤§¦ì¤¸¤©¥H¾B¸n¡A¦Ó dwExMask ªí¥Ü°£¤F¦¹¦ì¤¸·|³Q§ïÅÜ¥~¡A¨ä¾l¦ì¤¸§¡¤£§ïÅÜ¡C¦Ó dwExStyle «hªí¥Ü±N³]©w¦¹¦ì¤¸¬° 1¡C¨Ò¦p¡A¦b¹w³]ªº±¡§Î¤U¡A¨Ï¥ÎªÌ¥H·Æ¹«ÂI¿ï details view ¤¤¬Y­Ó¶µ¥Ø®É¡Aµe­±¤W¥u¦³¸Ó¶µ¥Ø³Q°ª«G«×°é¦í¡A¦pªG­n³]©w©Ò¦³¤l¶µ¥Ø¤]¬°°ª«G«×©Ò°é¦í¡A¨º»ò´N±o³]©w LVS_EX_FULLROWSELECT ÂX¥R­·®æ¡A¦pªG±z¤S·Q¤£¼vÅT¨ä¥LÂX¥R­·®æ¡A¨º»òµ{¦¡À³¼g¦¨¡G

        INVOKE  SendMessage,hListView,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT

·í±z¤£·QÅý²M³æÀ˵ø±±¨î¶µ¦³ LVS_EX_FULLROWSELECT ÂX¥R­·®æ¡A¦ý¤S¤£¼vÅT­ì¦³ªº­·®æ®É¡A´N¥i¥H¥Î¤U­±ªºµ{¦¡¹F¦¨¡G

        INVOKE  SendMessage,hListView,LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT,0

·í±z·Q§ïÅܨâºØ©Î¨âºØ¥H¤WªºÂX¥R­·®æ®É¡AdwExMask »P dwExStyle ¤]¥i¥H¬O¼Æ­ÓÂX¥R­·®æ¥H or ¹Bºâ³s±µ¡A³o¼Ë´N¬Ù¨Æ¦h¤F¡CLVM_SETEXTENDEDLISTVIEWSTYLE °T®§ªºªð¦^­È¬O­ì¨ÓªºÂX¥R­·®æ¡C

©³¤U¤p¤ì°¸´£¤@´£´X­ÓÂX¥R­·®æ¡C

List view ÂX¥R­·®æ»¡¡@¡@¡@©ú
LVS_EX_BORDERSELECT ¦¹ÂX¥R­·®æ·|¦b details view Åã¥Ü¤è¦¡¤U¡A¦b¶µ¥Ø¥|©P³òµe¥XÃä®Ø¡A±z¤]¥i¥H¹ï²M³æÀ˵ø±±¨î¶µµo¥X LVM_SETOUTLINECOLOR °T®§§ïÅÜÃä®ØªºÃC¦â¡A¤èªk¬O¡J
INVOKE  SendMessage,hListView,LVM_SETOUTLINECOLOR,0,COLORREF
¦pªG¨S¦³ LVS_EX_BORDERSELECT ­·®æ¡A§Y¨Ïµo¥X LVM_SETOUTLINECOLOR °T®§¤]µLªkÅã¥ÜÃä®Ø¡C
LVS_EX_CHECKBOXES ³o­ÓÂX¥R­·®æ·|¦b¨C­Ó¶µ¥Ø«e­±¡AÅã¥Ü¤@­ÓÀËÅç²°¡A¥i¨Ñ¨Ï¥ÎªÌ¤Ä¿ï¡C
LVS_EX_FULLROWSELECT ¦b¹w³]ªº±¡§Î¤U¡A¨Ï¥ÎªÌ¥H·Æ¹«ÂI¿ï details view ¤¤¬Y­Ó¶µ¥Ø®É¡Aµe­±¤W¥u¦³¸Ó¶µ¥Ø³Q°ª«G«×°é¦í¡A¦pªG­n³]©w³QÂI¿ïªº¤l¶µ¥Ø¤]¬°°ª«G«×©Ò°é¦í¡A¨º»ò¥²¶·³]©w LVS_EX_FULLROWSELECT ÂX¥R­·®æ¡C³o­ÓÂX¥R­·®æ¥u¼vÅT details view¡C
LVS_EX_INFOTIP ¨ã¦³ LVS_EX_INFOTIP ªº²M³æÀ˵ø·|¦b·Æ¹«´å¼Ð°±¯d¦b¬Y­Ó¶µ¥Ø¤W®É¡AÅã¥Ü¥X¤u¨ã´£¥Ü ( tool tip )¡C¦bÅã¥Ü¤u¨ã´£¥Ü¤§«e¡A·|µo¥X LVN_GETINFOTIP ³qª¾½Xµ¹¤÷µøµ¡¡A¥HÅý¤÷µøµ¡¨M©w­n¦b¤u¨ã´£¥Ü¤WÅã¥Ü¥X¤°»ò¼Ëªº¸ê®Æ¡C
LVS_EX_GRIDLINES ·|¦b details view Åã¥Ü¤è¦¡¤¤¡Aµe¥X¨C¤@¦C¤Î¨C­Ó¤l¶µ¥Ø¤§¶¡ªº¤À®æ½u¡C
LVS_EX_HEADERDRAGDROP ¦¹­·®æ¥i¥HÅý¨Ï¥ÎªÌ¦b details view Åã¥Ü¤è¦¡¤U¡A§â·Æ¹«´å¼Ð²¾¨ìÄæ¦ì¦WºÙ¡A¨ÃÀ£¦í·Æ¹«¥ªÁ䤣©ñ¡A©ì©ÔÄæ¦ì¦WºÙ¨ì¾A·í¦ì¸m¡A½Õ¾ãÄæ¦ì¦WºÙ¶¶§Ç¡C
LVS_EX_ONECLICKACTIVATE ³o­Ó­·®æ·|Åý·Æ¹«´å¼Ð¦b¥ô¦ó¤@­Ó¶µ¥Ø¤W·Æ¹L®É¡A¤£ºÞ³o­Ó¶µ¥Ø¬O§_³Q¿ï©w ¡A³£·|§ïÅÜ´å¼Ð¡AÅý¨Ï¥ÎªÌ§ó©ö¹îı¡C¥t¥~¡A¦pªG¨Ï¥ÎªÌ¥H·Æ¹«ÂI¿ï¬Y­Ó¶µ¥Ø¡A·|¨Ï²M³æÀ˵ø±±¨î¶µ¹ï¤÷µøµ¡µo¥X LVN_ITEMACTIVATE ³qª¾½X¡C
LVS_EX_SUBITEMIMAGES ³o­ÓÂX¥R­·®æ¯à¨Ï¤l¶µ¥Ø¤]¯àÅã¥Ü¹Ï¥Ü¡A¤£¹L¥u¯à¦b details view ¤U¬Ý¨£¨ä®ÄªG¡C¤èªk¬O¥H LVM_SETITEM ©I¥s SendMessage ®É¡ALVITEM ¤¤³]©w iImage ¤Î LVIF_IMAGE¡C
LVS_EX_TWOCLICKACTIVATE ³o­ÓÂX¥R­·®æ¯àÅý·Æ¹«´å¼Ð¦b³Q¿ï©wªº¶µ¥Ø¤W·Æ¹L®É¡A§ïÅÜ´å¼Ð¡AÅý¨Ï¥ÎªÌ§ó©ö¹îı¡C¥t¥~¡A¦pªG¨Ï¥ÎªÌ¥H·Æ¹«ÂùÀ»¬Y­Ó¶µ¥Ø¡A·|¨Ï²M³æÀ˵ø±±¨î¶µ¹ï¤÷µøµ¡µo¥X LVN_ITEMACTIVATE ³qª¾½X¡C
LVS_EX_TRACKSELECT ¦¹ÂX¥R­·®æ·|³y¦¨¡uhot-track selection¡v¡A¥ç§Y·Æ¹«´å¼Ð¦b¬Y­Ó¶µ¥Ø¤W°±¯d¤@¬q®É¶¡«á¡A¦¹¶µ¥Ø´N·|³Q¿ï¨ú¡C¦Ü©ó³o¬q®É¶¡¬O¦h¤[¡A¥i¥Hµo°e LVM_SETHOVERTIME °T®§³]©w¡F¤]¥i¥H¥H SPI_GETMOUSEHOVERTIME ¬°°Ñ¼Æ©I¥s SystemParametersInfo ¨ú±o³o¬q®É¶¡¡C¨t²Î¨Ã¤£·|¦ì¨C­Ó²M³æÀ˵ø±±¨î¶µ³æ¿W³]©w³o¬q®É¶¡¡A¦Ó¬O¨C­Ó²M³æÀ˵ø±±¨î¶µ³£¨Ï¥Î¦P¼Ëªº°±¯d®É¶¡¡C·í·Æ¹«´å¼Ð²¾¨ì¬Y­Ó¶µ¥Ø¤W®É·|µo¥X LVN_HOTTRACK ³qª¾½Xµ¹¤÷µøµ¡¡A§Ú­Ì¥u­nÀˬd¦¹³qª¾½X¡A´N¥i¥Hª¾¨ì¬O§_µo¥Í¡uhot-track selection¡v¡C
LVS_EX_UNDERLINEHOT ³o­Ó­·®æ·|Åý·Æ¹«´å¼Ð¦b¥ô¦ó¤@­Ó¶µ¥Ø¤W·Æ¹L®É¡A¤£ºÞ³o­Ó¶µ¥Ø¬O§_³Q¿ï©w ¡A³£·|¦b¶µ¥Ø¦WºÙ¤W²K¥[©³½u¡AÅý¨Ï¥ÎªÌ§ó©ö¹îı¡C¦¹­·®æ»Ý­n³]©w LVS_EX_ONECLICKACTIVATE ¤~¯àÅã¥X®ÄªG¡C

List View ªº³qª¾½X ( Notification )

²M³æÀ˵ø±±¨î¶µ¥H³qª¾½Xªº¤è¦¡¡A±N°T®§¶Çµ¹¤÷µøµ¡¡A¨Æ¹ê¤W¡A¤£¬O¥u¦³²M³æÀ˵ø¦p¦¹¦Ó¤w¡A¤j³¡¤Àªº³q¥Î±±¨î¶µ³£¥H³qª¾½X¶Ç»¼°T®§µ¹¤÷µøµ¡¡C«e¤@³¹´£¹L¡A½Ð¦Û¦æ°Ñ¾\¡C²M³æÀ˵øªº³qª¾½X³Q¥]§t¦b¤@­ÓºÙ¬° NMLISTVIEW ªºµ²ºcÅ餺 ( ¤]ºÙ¬° NM_LISTVIEW )¡A¤÷µøµ¡¥i¥H±q²M³æÀ˵ø±±¨î¶µ¶Ç¨Óªº WM_NOTIFY °T®§¤¤ªº±oª¾¨ä¦ì§}¡AWM_VOTIFY ªº°Ñ¼Æ¡AlParam ¼Æ­È¨ä¹ê´N¬O NMLISTVIEW µ²ºcÅ骺¦ì§}¡C§Ú­Ì¥ý¨Ó¬Ý¬Ý NMLISTVIEW µ²ºcÅ骺¦UÄæ¦ì¡J

NMLISTVIEW      STRUCT
  hdr           NMHDR   <>
  iItem         DWORD   ?       ;µo¥X WM_NOTIFY °T®§®Éªº¶µ¥Ø¯Á¤Þ­È¡A­Y¬°¡Ð1¡Aªí¥Ü¨S¦³¨Ï¥Î
  iSubItem      DWORD   ?       ;µo¥X WM_NOTIFY °T®§®Éªº¤l¶µ¥Ø¯Á¤Þ­È¡A­Y¬° 0¡Aªí¥Ü¨S¦³¨Ï¥Î
  uNewState     DWORD   ?       ;µo¥X WM_NOTIFY °T®§®É¡A¸Ó¶µ¥Øªº³Ì·sª¬ºA
  uOldState     DWORD   ?       ;µo¥X WM_NOTIFY °T®§®É¡A¸Ó¶µ¥ØªºÂ¦³ª¬ºA
  uChanged      DWORD   ?
  ptAction      POINT   <>
  lParam        LPARAM  ?
NMLISTVIEW      ENDS

NMHDR µ²ºcÅéÄæ¦ì¦p¤U¡J

NMHDR           STRUCT
  hwndFrom      HWND    ?       ;µo¥X WM_NOTIFY ªº²M³æÀ˵ø±±¨î¶µ¥N½X
  idFrom        UINT    ?       ;µo¥X WM_NOTIFY ªº²M³æÀ˵ø±±¨î¶µÃѧO½X
  code          UINT    ?       ;³qª¾½X
NMHDR           ENDS

NMHDR µ²ºcÅé¬O¨C­Ó³q¥Î±±¨î¶µ³£¨ã¦³ªº¡A½Ð°Ñ¦Ò«e¤@³¹¡CptAction ¬O·í¨Æ¥óµo¥Í®É¡A¨Ò¦p¥H·Æ¹«ÂIÀ»¬Y­Ó¶µ¥Ø¡B©ÎÂùÀ»¬Y­Ó¶µ¥Øµ¥µ¥¡A·Æ¹«´å¼Ð©Ò¦b¦ì¸m¡CuChanged ¬O«üµo¥X WM_NOTIFY ®É¡A¬Y­Ó¶µ¥ØªºÄÝ©ÊÅܦ¨¬° uChanged ªº¤º®e¡A¨ä¤º®e©M LVITEM ªº imask ¬Û¦P¡C

¦b²Õ¦X»y¨¥¤¤¡A­n¦s¨ú NMLISTVIEW µ²ºcÅ骺¤º®e¡A¤@¯ë¬O¥H ASSUME °²«ü¥O«ü©w¬Y­Ó¼È¦s¾¹¬° NMLISTVIEW ªº¦ì§}¬°°ò·ÇÂI¡A·íµM¦¹¨BÆJ¶È¶È¬O°²«ü¥O¡A¨Ã¤£¬O¯u¥¿§â°O¾ÐÅé¦ì§}¦s¤J¼È¦s¾¹ùØ¡A©Ò¥HÁÙ¶·°õ¦æ mov «ü¥O¡A§â±N¦¹°O¾ÐÅé¦ì§}¦s¤J¸Ó¼È¦s¾¹ùØ¡CµM«á´N¥i¥H¥Î¡u[¼È¦s¾¹].hdr.hwndFrom¡v¦s¨úµo¥X WM_NOTIFY ªº²M³æÀ˵ø±±¨î¶µ¥N½X¡A¥H¡u[¼È¦s¾¹].hdr.idFrom¡v¦s¨úµo¥X WM_NOTIFY ªº²M³æÀ˵ø±±¨î¶µÃѧO½X¡C³Ì«áÁÙ­n°O±o¡A¥H¡uASSUME ¼È¦s¾¹:PTR NOTHING¡v«ì´_¸Ó¼È¦s¾¹¤£¥H¥ô¦ó¦ì§}¬°°ò·ÇÂI¡C¦p¤U­±ªºµ{¦¡¤ù¬q¡J

.IF uMsg==WM_INITDIALOG

.ELSEIF uMsg==WM_NOTIFY
                push    ebx
                ASSUME  ebx:PTR NM_LISTVIEW     ;§â NMLISTVIEW °_©l¦ì§}°ò·ÇÂI³]¬° EBX
                mov     ebx,lParam              ;§â NMLISTVIEW °_©l¦ì§}¦s¤J EBX 
                mov     eax,[ebx].hdr.hwndFrom  ;¨ú±o²M³æÀ˵ø±±¨î¶µ¥N½X¡A¦s¤J EAX
    .IF eax==hListView
        .IF [ebx].hdr.code==NM_CLICK            ;¤ñ¸û³qª¾½X¬O§_¬° NM_CLICK
     
        .ENDIF
    .ENDIF
                ASSUME  ebx:PTR NOTHING         ;¨ú®ø EBX ¬° NMLISTVIEW °_©l¦ì§}°ò·ÇÂIªº³]©w
                pop     ebx

.ELSEIF uMsg==WM_CLOSE

©³¤U¤p¤ì°¸¤¶²Ð´X­Ó±`¥Î²M³æÀ˵ø±±¨î¶µªº³qª¾½X¡C

LVN_COLUMNCLICK

·í¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂI«ö¼ÐÃD®É¡A²M³æÀ˵ø´N·|µo°e§t¦³ LVN_COLUMNCLICK ³qª¾½Xªº WM_NOTIFY °T®§µ¹¤÷µøµ¡¡CWM_NOTIFY °T®§¤¤ªº lParam «ü¦V¤@­ÓºÙ¬° NM_LISTVIEW ªºµ²ºcÅé¡A¦¹µ²ºcÅ餤ªº hdr §t¦³¤W­±©Ò»¡±o¦UºØ¸ê®Æ¡C¨ä¤¤³Ì­«­nªº¡A¤]¬O¤÷µøµ¡³ÌÀ³¸Óª¾¹Dªº¡A¤j·§´N¬O¨Ï¥ÎªÌ«ö¤F¼ÐÃDªº­þ¤@­Ó¤l¶µ¥Ø©O¡H³o­Ó¸ê®Æ¦s©ñ©ó iSubItem ùØ¡C¦Ó¦¹®É iItem Äæ¦ì¬°¡Ð1¡A¨ä¥LÄæ¦ì«h¬° 0¡C

NM_CLICK

·í¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂI«ö²M³æÀ˵ø¤¤ªº¤@­Ó¶µ¥Ø®É¡A²M³æÀ˵ø´N·|µo°e§t¦³ NM_CLICK ³qª¾½Xªº WM_NOTIFY °T®§µ¹¤÷µøµ¡¡C¦Ó WM_NOTIFY ¤¤ªº lParam °Ñ¼Æ©Ò«üªº¦ì§}¬O NMITEMACTIVATE µ²ºcÅé¦ì§}¡A¥¦»P NMLISTVIEW µ²ºcÅé´X¥G¬Û¦P¡A¥u¦h¤F³Ì«á¤@­ÓÄæ¦ì¡AuKeyFlags¡A¦p¤U©Ò¥Ü¡J

NMITEMACTIVATE  STRUCT
  hdr           NMHDR   <>
  iItem         DWORD   ?
  iSubItem      DWORD   ?
  uNewState     UINT    ?
  uOldState     UINT    ?
  uChanged      UINT    ?
  ptAction      POINT   <>
  lParam        LPARAM  ?
  uKeyFlags     UINT    ?
NMITEMACTIVATE  ENDS

uKeyFlags ¥NªíÁä½L¤Wªº Alt¡BCtrl¡BShift Áä¬O§_³Q«ö¤U¡A¦pªG³Q«ö¤U¡A«h uKeyFlags ¤§­È¤À§O¬O LVKF_ALT¡BLVKF_CONTROL¡BLVKF_SHIFT¡C

¦pªG¨Ï¥ÎªÌ¦b details view ¤¤¡A¥H·Æ¹«¥ªÁäÂI«ö¤l¶µ¥Ø°Ï°ìªº¸Ü¡AÁö¤]¯àµo°e NM_CLICK ³qª¾½X¡A¦ý¬O NMITEMACTIVATE µ²ºcÅ餤ªº iItem «o¬O¡Ð1¡A´«¥y¸Ü»¡µLªkÂÇ¥ÑÂI«ö¤l¶µ¥Ø¦Ó±oª¾¨Ï¥ÎªÌ¿ï¨ú­þ¤@­Ó¶µ¥Ø¡C¦pªG¤]­n¨ÏÂI«ö¤l¶µ¥Ø¤]¯à¿ï¨ú¶µ¥Ø¡A¦³¨âºØ¤èªk¡J²Ä¤@¬O¨Ï²M³æÀ˵ø±±¨î¶µ¨ã¦³ LVS_EX_FULLROWSELECT ­·®æ¡C²Ä¤G¬O¦b NM_CLICK ¤¤Àˬd iItem ¬O§_¬°¡Ð1¡A¦pªG¬Oªº¸Ü¡A¦A¹ï²M³æÀ˵øµo¥X LVM_SUBITEMHITTEST °T®§¡AÀˬd NMITEMACTIVATE ¤¤ªº pcAction ¸¨¦b­þ¤@­Ó¶µ¥Ø¤¤¡A½Ð°Ñ¦Ò¤U­±¦³Ãö LVM_SUBITEMHITTEST ªº»¡©ú¡C


±Æ§Ç

µo°e LVM_SORTITEMS »P¤ñ¸û¨ç¦¡ ( Comparison Function )

¦b«Ø¥ß²M³æÀ˵ø±±¨î¶µ®É¡A¥i¥H¥Î LVS_SORTASCENDING ©Î LVS_SORTDESCENDING ­·®æ¨Ó«ü©w±Æ§Ç¤è¦¡¡A·íµM±z¤]¥i¥H¦b¥ô¦ó®É­Ô¡A©I¥s SetWindowLong ¨Ó§ïÅܵøµ¡­·®æ¡A¨Ï¤§Åܦ¨¤É§Ç ( ¦b¶V¤U­±ªº¶µ¥Ø¶V¤j ) ©Î­°§Ç ( ¦b¶V¤U­±ªº¶µ¥Ø¶V¤p )±Æ¦C¡C¦ý¬O³o¨âºØ­·®æ¥u¯à±Æ§Ç¶µ¥Ø¦WºÙ¡A¦pªG·Q­n±Æ§Ç¤l¶µ¥Ø¡A«h¥²¶·µo°e LVM_SORTITEMS °T®§¨Ó§¹¦¨¡C¦b details view ®É¡A¨Ï¥ÎªÌ³q±`¥i¥H¦b¼ÐÃDÄ椤ªºÄæ¦ì¤W¡A¥H·Æ¹«¥ªÁäÂI«ö¤@¦¸¡A¥i¥H¨Ï±o²M³æÀ˵ø±±¨î¶µ¤ºªº¶µ¥Ø¨Ì©Ò«öÄæ¦ì±Æ§Ç¡A¦bµ{¦¡¤º´N¬Oµo°e LVM_SORTITEMS °T®§¡A¦p¤U¡J

        INVOKE  SendMessage,hListView,LVM_SORTITEMS,lParamSort,pfnCompare

lParamSort ¬O±Æ§Ç¤è¦¡¡A³o¬Oµ{¦¡©w¸qªº¼Æ­È¡A¤@¯ë´N¬O¥H¬Y¤@¼Æ¥Nªí¤É§Ç¡A¥t¤@¼Æ«h¥Nªí­°§Ç¡CpfnCompare ¬Oµ{¦¡³]­p®v¦Û¦æ©w¸qªº¤ñ¸û¨ç¦¡¦ì§}¡A¦pªG¤ñ¸û¨ç¦¡ªº¦WºÙ¬O compare_func¡A¨º»ò pfnCompare ´NÀ³¸Ó¬O OFFSET compare_func¡C¤ñ¸û¨ç¦¡¬O³Q¨t²Î©Ò©I¥sªº°Æµ{¦¡¡A¨ä°Ñ¼Æ©T©w¡A¥u¦³¤T­Ó¡A¨ä­ì«¬¬O¡J

compare_func    PROC    lParam1:PARAM, lParam2:PARAM, lParamSort:DWORD

«e¨â­Ó°Ñ¼Æ¡JlParam1¡BlParam2 ¬O¶µ¥Ø LVITEM ùتº lParam Äæ¦ì¡C³Ì«á¤@­Ó°Ñ¼Æ¡AlParamSort ¬O LVM_SORTITEMS °T®§ªº­Ë¼Æ²Ä¤G­Ó°Ñ¼Æ¡C·íµ{¦¡°õ¦æ¨ì¡uINVOKE SendMessage,hListView,lParamSort,pfnCompare¡v®É¡A¨t²Î·|¦Û¦æ¬D¿ï¨â­Ó¶µ¥Ø¡A¨Ã§â³o¨â­Ó¶µ¥Øªº lParam ¥H¤Î lParamSort ·í°µ°Ñ¼Æ¡A©I¥s¤ñ¸û¨ç¦¡¡A¨Ã¥B³sÄò©I¥s¦n´X¦¸¡Aª½¨ì¨C­Ó¶µ¥Ø³£»P¨ä¥L¶µ¥Ø¬° lParam1¡BlParam2 ¨â°Ñ¼Æ©I¥s¤ñ¸û¨ç¦¡¤@¦¸¬°¤î¡C¤]´N¹³ªwªj±Æ§Çªk¡A§â¨C­Ó­n¤ñ¸ûªº¼Æ¡A»P¥t¤@¼Æ³£¤ñ¸û¹L¤@¦¸¬°¤î¡C¦Ó¤ñ¸û¨ç¦¡©Ò­n°µªº´N¬O¨M©w¨º¤@­Ó¶µ¥Ø±Æ¦b«e¡J¦pªG²Ä¤@­Ó¶µ¥Ø±Æ¦b«e­±¡A«h¶Ç¦^­t­È¡F²Ä¤G­Ó¶µ¥Ø±Æ¦b«e­±¡A«h¶Ç¦^¥¿­È¡F¦pªG¬Ûµ¥¡A«h¶Ç¦^ 0¡C

¨Ò¦p¡A©µÄò¤W­±¤@­Ó¤p¤½¥qªº¨Ò¤l¡A°²³]·Q­n¹ï¦~ÄÖ°µ±Æ§Ç¡A¨º»ò¦bµøµ¡¨ç¦¡¤¤³¡¥÷µ{¦¡½X¦p¤U¡G

     .IF [ebx].hdr.code==LVN_COLUMNCLICK        ;­Y¨Ï¥ÎªÌ«ö¤U¼ÐÃDªº¬Y­Ó¤l¶µ¥Ø
        .IF [ebx].iSubItem==2   ;­Y¨Ï¥ÎªÌ«ö¤U¼ÐÃDªº¡u¦~ÄÖ¡v¤l¶µ¥Ø
                test    flag,1  ;Àˬd²{¦b¬O¤É§ÇÁÙ¬O­°§Ç
           .IF ZERO?
              ;­Y¬°ZR¡Aªí¥Ü²{¦b¬O²M³æÀ˵ø¶V¤U­±¡A¦~ÄÖ¶V¤j¡A»ÝÅܧ󦨶V¤U­±¡A¦~ÄÖ¶V¤p
                or      flag,1
                mov     ecx,1   ;ECX¡×wParam¡×1¡Aªí¥Ü¶V¤U­±¡A¦~ÄÖ¶V¤p
           .ELSE
              ;­Y¬°NZ¡Aªí¥Ü²{¦b¬O²M³æÀ˵ø¶V¤U­±¡A¦~ÄÖ¶V¤p¡A»ÝÅܧ󦨶V¤U­±¡A¦~ÄÖ¶V¤j
                and     flag,0fffffffeh
                mov     ecx,2   ;ECX¡×wParam¡×2¡Aªí¥Ü¶V¤U­±¡A¦~ÄÖ¶V¤j
           .ENDIF
                INVOKE  SendMessage,hListView,LVM_SORTITEMS,ecx,OFFSET compare_func
        .ENDIF
                call    update_item
     .ENDIF

¦b¦¹µ{¦¡¤¤¡Aflag ÅܼƬ° 0¡Aªí¥Ü¤É§Ç¡F¬° 1¡Aªí¥Ü­°§Ç¡C³B²z LVN_COLUMNCLICK ®É¡A¥ýÀˬd¬O§_¨Ï¥ÎªÌ«ö¤U¡u¦~ÄÖ¡vÄæ¦ì¡A¦pªG¬Oªº¸Ü¡A¦AÀˬd²{¦bªº±Æ§Ç¤è¦¡¬O¤É§ÇÁÙ¬O­°§Ç¡C¦pªG¬O¤É§Çªº¸Ü¡A«hµ{¦¡¶·§ï¦¨­°§Ç±Æ¦C¡A¨Ã¦bµo°e LVM_SORT °T®§®É¡AlParamSort ³]¬° 1¡Aªí¥Ü­n§ï¦¨­°§Ç±Æ¦C¡F­Y¬°­°§Ç¡A«h­n§ï¦¨¤É§Ç±Æ¦C¡A¦bµo°e LVM_SORT °T®§®É¡AlParamSort ³]¬° 2¡Aªí¥Ü­n§ï¦¨­°§Ç±Æ¦C¡C¤ñ¸û¨ç¦¡¦p¤U¡G

compare_func    PROC    lp1:LPARAM,lp2:LPARAM,lParamSort:DWORD
                LOCAL   buffer[20]:BYTE
                lea     ecx,buffer
                mov     lvi.imask,LVIF_TEXT
                mov     lvi.pszText,ecx
                mov     lvi.cchTextMax,20
                mov     lvi.iSubItem,2
                INVOKE  SendMessage,hListView,LVM_GETITEMTEXT,lp1,ADDR lvi
                INVOKE  string_to_dword,ADDR buffer
                push    eax
                INVOKE  SendMessage,hListView,LVM_GETITEMTEXT,lp2,ADDR lvi
                INVOKE  string_to_dword,ADDR buffer
                pop     ecx     ;¦¹®ÉEAX¡×²Ä¤G­Ó­û¤uªº¦~ÄÖ¡FECX¡×²Ä¤@­Ó­û¤uªº¦~ÄÖ
        .IF lParamSort==1       ;lParamSort¡×1¡Aªí¥Ü±N­n±Æ§Ç¡AÅܦ¨¶V¤U­±¦~ÄÖ¶V¤p
                sub     eax,ecx
        .ELSEIF lParamSort==2   ;lParamSort¡×2¡Aªí¥Ü±N­n±Æ§Ç¡AÅܦ¨¶V¤U­±¦~ÄÖ¶V¤j
                sub     ecx,eax
                mov     eax,ecx
        .ENDIF
                ret
compare_func    ENDP

¦b¤ñ¸û¨ç¦¡ùØ¡A¤p¤ì°¸©I¥s¨â¦¸ SendMessage¡A³£¬O§â LVM_GETITEMTEXT °T®§¶Çµ¹²M³æÀ˵ø±±¨î¶µ¡A¥ý«á­n¨D²M³æÀ˵ø±±¨î¶µ§â¨t²Î¶Ç¨Óªº¨â­Ó¶µ¥Ø¤¤¡A¡u¦~ÄÖ¡vªº¸ê®Æ¶Ç¹L¨Ó¡C³o¨âµ§¸ê®Æ¬O¥H¦r¦ê«¬ºA¦s¦b°Ï°ìÅÜ¼Æ buffer ùØ¡A±µµÛ§â¥¦­ÌÂà´«¦¨¤Q¤»¶i¦ì¼Æ­È ( ¥Ñ string_to_dword °Æµ{¦¡­t³d¡AÂà´««áªº¤Q¤»¶i¦ì¼ÆÂÇ¥Ñ EAX ªð¦^¤ñ¸û¨ç¦¡ )¡A²Ä¤@­Ó­û¤uªº¦~ÄÖ¦s©ó ECX¡A²Ä¤G­Ó­û¤uªº¦~ÄÖ¦s©ó EAX ùØ¡C±µ¤U¨Ó¡A®Ú¾Ú lParamSort¡A¨M©w±Æ§Ç¤è¦¡¬O¤É§ÇÁÙ¬O­°§Ç¡A¦pªG¬O 1¡Aªí¥Ü­nÅܧ󬰭°§Ç¡A¥ç§Y¶V¤U­±¡A¦~ÄÖ¶V¤p¡A¥H EAX ´î ECX ±o¨ìªº®t¦pªG¬°­t­È¡Aªí¥Ü²Ä¤G­Ó­û¤u¦~ÄÖ¸û¤p¡AÀ³¸Ó§â²Ä¤@­Ó­û¤u±Æ¦b«e­±¡A¨Ì¾Ú«e­±©Ò´y­zªº¡AÀ³¸Ó¶Ç¦^­t­È¡A¦Ó EAX ¦¹®É«ê¬°­t¡A©Ò¥H¥u­n¶Ç¦^ EAX ¨Ãµ²§ô¤ñ¸û¨ç¦¡§Y¥i¡F¦ý¦pªG EAX ´î ECX ¤§®t¬°¥¿­È¡Aªí¥Ü²Ä¤G­Ó­û¤u¦~ÄÖ¸û¤j¡AÀ³¸Ó§â²Ä¤G­Ó­û¤u±Æ¦b«e­±¡A¨Ì¾Ú«e­±©Ò´y­zªº¡AÀ³¸Ó¶Ç¦^¥¿­È¡A¦Ó EAX ¦¹®É«ê¬°¥¿¡A©Ò¥H¥u­n¶Ç¦^ EAX ¨Ãµ²§ô¤ñ¸û¨ç¦¡§Y¥i¡C¤Ï¤§¥çµM¡C

±Æ§Ç¤è¦¡¬Û´î¤§µ²ªG­þ¤@¶µ¦b«e¶Ç¦^­È
­nÅܬ°­°§Ç ( ¶V¤U­±¶V¤p )( ²Ä¤G­Ó )¡Ð( ²Ä¤@­Ó )¡Ö0 ²Ä¤G­Ó¦b«e¥¿
( ²Ä¤G­Ó )¡Ð( ²Ä¤@­Ó )¡Õ0²Ä¤@­Ó¦b«e­t
­nÅܬ°¤É§Ç ( ¶V¤U­±¶V¤j )( ²Ä¤@­Ó )¡Ð( ²Ä¤G­Ó )¡Ö0 ²Ä¤G­Ó¦b«e¥¿
( ²Ä¤@­Ó )¡Ð( ²Ä¤G­Ó )¡Õ0²Ä¤@­Ó¦b«e­t

¾ã²z¶µ¥Ø

·í±Æ§Ç§¹¦¨«á¡A¦U¶µ¥Øªº¯Á¤Þ iItem »P­ì¥ý lParam ´N¤£¦A¬Û¦P¤F¡A¦]¦¹±o­«·s½Õ¾ã¡C¤p¤ì°¸ÁÙ¬O¥H¤W­±¤@­Ó¤p¤½¥q­û¤uªº¨Ò¤l»¡©ú¡A·í±Æ§Ç§¹¦¨«á¡Aµ²§ô³B²z LVN_COLUMNCLICK ³qª¾½X¤§«e¡Aµ{¦¡ÁÙ©I¥s¤F update_item °Æµ{¦¡¡A´N¬O­«·s³]©w¦U¶µ¥Øªº lParam¡C¨äµ{¦¡½X¦p¤U¡J

update_item     PROC
                LOCAL   n:DWORD
                INVOKE  SendMessage,hListView,LVM_GETITEMCOUNT,0,0
                mov     n,eax
                mov     lvi.imask,LVIF_PARAM
                mov     lvi.iSubItem,0
                mov     lvi.iItem,0
        .WHILE n>0
                mov     eax,lvi.iItem
                mov     lvi.lParam,eax
                INVOKE  SendMessage,hListView,LVM_SETITEM,0,ADDR lvi
                inc     lvi.iItem
                dec     n
        .ENDW
                ret
update_item     ENDP

²M³æÀ˵ø±±¨î¶µªº³¡¥÷°T®§

¤W­±¤w¸g¤¶²Ð¹L´X­Ó¦³Ãö²M³æÀ˵ø±±¨î¶µªº°T®§¡A¦p LVM_SETVIEW ¬O¥Î¨Ó§ïÅÜÅã¥Ü¤è¦¡¡FLVM_GETCOLUMN¡BLVM_SETCOLUMN¡BLVM_DELETECOLUMN °T®§¡A¤À§O¨ú±o¡B§ïÅÜ ( ¥ç§Y³]©w )¡B§R¥h²M³æÀ˵ø±±¨î¶µªº¬Y­ÓÄæ¦ì¡FLVM_INSERTITEM¡BLVM_SETITEM¡BLVM_GETITEM¡A¤À§O¥Î¨Ó·s¼W¡B³]©w¡B¨ú±o¶µ¥Ø¡C¨Æ¹ê¤W¡AÁÙ¦³³\¦h¦³Ãö²M³æÀ˵ø±±¨î¶µªº°T®§¡A½Ð¬d¾\ MSDN¡A©³¤U¶È¦C¥X«Ý·|½d¨Ò»Ý­n¥Î¨ìªº°T®§¡CList view ©Ò¦³ªº°T®§¶}ÀY¥|­Ó¦r³£¬O¡uLVM_¡v¡Aªí¥Ü list view message ¤§·N¡C

LVM_GETITEMCOUNT

³o­Ó°T®§¬O¥Î¨Ó²Î­p²M³æÀ˵ø±±¨î¶µùئ³´X­Ó¶µ¥Ø¡Aµ{¦¡¦p¤U¡G

        INVOKE  SendMessage,hListView,LVM_GETITEMCOUNT,wParam,lParam

¨ä¤¤ wParam ©M lParam ³£¥²¶·³]¬° 0¡A¶Ç¦^­È¦s©ó EAX¡A§Y¶µ¥Ø­Ó¼Æ¡C

LVM_GETITEMRECT

³o­Ó°T®§¬O¥Î¨Ó¨ú±o·í«eÅã¥Ü¤è¦¡ªº¯x§ÎÃä¬É¡A¦p¤U­±µ{¦¡¡G

        INVOKE  SendMessage,hListView,LVM_GETITEMRECT,wParam,lParam

wParam ¬O¶µ¥Øªº¯Á¤Þ­È¡AlParam ¬O RECT µ²ºcÅé¦ì§}¡C¦¹°T®§·|§â¯Á¤Þ­È¬° wParam ªº¶µ¥Ø©Ò¦û¥Îªº¯x§Î¶ñ¤J lParam ©Ò«üªºµ²ºcÅéùØ¡CLVM_GETITEMRECT ÁÙ¥i¥H¿ï¾Ü¬O¹Ï¥Ü©Î¬O¶µ¥Ø¦WºÙ¡K¡K©Ò¦û¥Îªº¯x§Î¡A¤èªk¬O©I¥s SendMessage «e¡A¥ý³]©w RECT ªº left Äæ¦ì¡C¦¹Äæ¦ì¥i¥H¬O¤U­±¥|ºØ¼Æ­È¡G

  1. LVIR_BOUNDS¡G¨ú±o¾ã­Ó¶µ¥Ø©Ò¦ûªº¯x§Î¡A¥]§t¹Ï¥Ü¤Î¶µ¥Ø¦WºÙ¡C
  2. LVIR_ICON¡G¶È¨ú±o¹Ï¥Ü©Ò¦ûªº¯x§Î¤j¤p¡C
  3. LVIR_LABEL¡G¶È¨ú±o¶µ¥Ø¦WºÙ©Ò¦ûªº¯x§Î¤j¤p¡C
  4. LVIR_SELECTBOUNDS¡G¦pªG¨S¦³³]¸m¿ï¤¤¥þ¦æ¡A¨º»òÀò±oªº¬O¹Ï¥Ü¤Î¶µ¥Ø¦WºÙ©Ò¦ûªº¯x§Î¡F¦pªG³]¸m¿ï¤¤¥þ¦æ¡A¨º»òÀò±oªº¬O¾ã¦æªºÃä®Ø ( ¥]¬A¹Ï¼Ð¡A¦ý¤£¥]¬A¤pªÅ¥Õ )¡C

LVM_GETITEMTEXT

³o­Ó°T®§¬O¥Î¨Ó¨ú±o¬Y­Ó¶µ¥Ø©Î¬Y­Ó¤l¶µ¥Øªº¦WºÙ¡A¤èªk¬O©I¥s SendMessage¡G

        INVOKE  SendMessage,hListView,LVM_GETITEMTEXT,wParam,lParam

¨ä¤¤ wParam ¬O­n¨ú±oªº¶µ¥Ø¯Á¤Þ­È¡AlParam ¬O LVITEM µ²ºcÅé¦ì§}¡C¦pªG­n¨ú±o¬Y­Ó¶µ¥Øªº¦WºÙ¡ALVITEM ªº iSuItem ¥²¶·¬° 0¡AiItem ¥i¤£¶ñ¡A¦]¬°¦b wParam ¤¤¤w«ü©w¡A¦Ó pszText¡BcchTextMax ¤À§O¥Nªí­n¨ú±oªº¦WºÙ¦s©ñ¦ì§}¤Î¸Ó¦ì§}ªºªø«×¡A¥²¶·¦b©I¥s SendMessage ¤§«e¶ñ¦n¡C¦pªG­n¨ú±o¬Y­Ó¤l¶µ¥Øªº¦WºÙ¡ALVITEM ªº iSuItem ¥²¶·³]¬°¸Ó¤l¶µ¥Øªº¯Á¤Þ­È¡C

·íµM¡A±z¤]¥i¥H¥Î LVM_GETITEM ¨Ó°µ LVM_GETITEMTEXT °µªº¨Æ¡A¦ý¬O LVITEM ¤¤ªº iItem ´N¥²¶·¶ñ¦n¾A·íªº¼Æ­È¡C¦¹¥~ LV_GETITEM ©Ò¯àÀò±oªº¸ê®Æ¤ñ LVM_GETITEMTEXT ¦h¡C

LVM_HITTEST

´ú¸Õ²M³æÀ˵ø¤ºªº¬Y¤@ÂI¡A¸¨¦b­þ¤@­Ó¶µ¥Ø¤W¡C¤èªk¬O©I¥s SendMessage¡G

        INVOKE  SendMessage,hListView,LVM_HITTEST,wParam,lParam

°Ñ¼Æ wParam ¥²¶·¬O¹s¡AlParam ¬O¤@­Ó¦ì§}«ü¼Ð¡A«ü¦V LVHITTESTINFO µ²ºcÅé ( ¤]ºÙ¬° LV_HITTESTINFO µ²ºcÅé )¡ALVHITTESTINFO µ²ºcÅ骺¦UÄæ¦ì¬O¡G

LVHITTESTINFO   STRUCT
pt              POINT   <>
flags           DWORD   ?
iItem           DWORD   ?
iSubItem        DWORD   ?
LVHITTESTINFO   ENDS

­Y©I¥s SendMessage «á¡A¦¨¥\ªð¦^¡Aªð¦^­È¬°´ú¸ÕÂI©Ò¦b¤§¶µ¥Ø¯Á¤Þ­È¡F­Y¥¢±Ñ¡Aªð¦^¡Ð1¡C

LVM_SETICONSPACING

³o­Ó°T®§¬O³]©w icon view ¤¤¹Ï¥Üªº¶¡¹j¶ZÂ÷¡A¤èªk¬O©I¥s SendMessage¡G

        INVOKE  SendMessage,hListView,LVM_SETICONSPACING,wParam,lParam

°Ñ¼Æ wParam ¥²¶·¬O¹s¡AlParam ¬O­n³]©wªº¶¡¹j¶ZÂ÷¡A¥HÂI¬°³æ¦ì¡A§C¦r²Õªº¼Æ­È¥Nªí¤ô¥­¼e«× ( ¤]´N¬O¶¡¹j )¡F°ª¦r²Õªº¼Æ­È¥Nªí««ª½°ª«× ( ¶ZÂ÷ )¡C³o¨â­Ó¼Æ­È¬O¥Ñ¶µ¥Ø©Ò¦ûµe­±ªº¥ª¤W¨¤¶}©lºâ°_¡A¦pªG³o¨â­Ó¼Æ­È¤ñ¹Ï¥Ü¼e«×¡B°ª«×¤pªº¸Ü¡A¶µ¥Ø´N·|­«Å|¦b¤@°_¡A¦]¦¹³Ì¦n­n¤ñ¹Ï¥Ü¨Ó±o¤j¨Ç¡A¥t¥~¤]­n¦Ò¼{¶µ¥Ø¦WºÙªº¤j¤p¡C

LVM_SUBITEMHITTEST

¦¹°T®§¬O¥Î¨ÓÀË´ú¬Y­ÓÂI¸¨¦b²M³æÀ˵øªº­þ¤@­Ó¤l¶µ¥Ø¤W¡C©I¥s¤è¦¡¬°¡J

        INVOKE  SendMessage,hListView,LVM_SUBITEMHITTEST,wParam,lParam

¨ä¤¤ wParam ¥²¶·¬O 0¡AlParam ¬O«ü¦V¤@­ÓºÙ¬° LVHITTESTINFO µ²ºcÅ骺¦ì§}¡CLVHITTESTINFO ¦UÄæ¦ì¨£ LVM_HITTEST¡CLVHITTESTINFO µ²ºcÅ餤ªº pt ´N¬O­n´ú¸ÕªºÂI®y¼Ð¡A¦¹®y¼Ð¬O¥H²M³æÀ˵ø±±¨î¶µªº¤u§@°Ï¬°­ìÂI¡A¦p¥k¹Ï¬õ¦â½bÀY¦yºÝ©Ò«ü¤§³B¡C

¦b¥H LVM_SUBITEMHITTEST ¬°°Ñ¼Æ©I¥s SendMessage ¤§«e¡AÀ³¥ý¶ñ¦n pt Äæ¦ìªº´ú¸ÕÂI®y¼Ð¡A©I¥s¦¨¥\«á¡A¨t²Î·|¦b iItem¡BiSubItem¡BiGroup ¶ñ¦n¸ÓÂI¸¨¦b­þ¤@­Ó¶µ¥Ø¡B¤l¶µ¥Ø¡B¸s²Õ¡F­Y¥¢±Ñ¡A«h³o¨ÇÄæ¦ì¬°¡Ð1¡C


¤@­Ó¨Ò¤l¡JSELICON

³Ì«á¤p¤ì°¸ªþ¤W¤@­Ó¨Ò¤l¡JSELICON¡A¥¦¥i¥HÅý¨Ï¥ÎªÌ¿ï¾Ü¤@­Ó¹Ï¥ÜÀÉ¡B¥i°õ¦æÀÉ¡A©Î¬O°ÊºA³sµ²µ{¦¡®w¡AµM«á SELICON ·|§â¸ÓÀɤ¤©Ò¦³¹Ï¥ÜÂ^¨ú¥X¨Ó¡A¨ÃÅã¥Ü¦b²M³æÀ˵ø±±¨î¶µùØ¡AÅý¨Ï¥ÎªÌ¦b¨ä¤¤¬D¿ï¤@­Ó¹Ï¥Ü¨Ã¦s¦¨¹Ï¥ÜÀÉ¡C¨ä­ì©l½X¥i«ö¦¹³B¤U¸ü¡C


¨ì²Ä¤G¤Q¤@³¹¡A ¦^¨ì­º­¶¡A¨ì²Ä¤G¤Q¤T³¹