¥Æ¥¥¹¥È¤ÎÃæ±û·¤¨¤ÏLVCFMT_CENTER¤ò»ØÄꤷ¤Æ¤ä¤ë¤ÈÃæ±û¤Ë¤Ê¤ë¤Èʬ¤«¤Ã¤¿¤Î¤Ç¤¹¤¬
»ØÄê¤Î»ÅÊý¤¬Ê¬¤«¤ê¤Þ¤»¤ó¡£
¤Ç¤¤ì¤Ð¥Õ¥©¥ó¥È¤ÎÊѹ¹¤â¤Ç¤¤¿¤é¤¤¤¤¤Ê¤È»×¤Ã¤Æ¤Þ¤¹¡£
¼«Ê¬¤Ç¤¤¤í¤¤¤íÉÕ¤±²Ã¤¨¤¿¤ê¾Ã¤·¤¿¤ê¤·¤Þ¤·¤¿¤¬ÃÇÇ°¤·¤Þ¤·¤¿¡£
¤è¤í¤·¤¯¤ª´ê¤¤¤·¤Þ¤¹¡£
color 100,100,100 : boxf : color pos 0, 130 : objsize 480,320 make_listview listheight :id_list = stat column_name = "ÁǺà1", "ÁǺà2","ÁǺà3" repeat 3 add_column3 id_list, column_name(cnt), cnt loop item_name = "2016ǯ12·î25Æü","¡","¥Æ¥¥¹¥È1¥Æ¥¥¹¥È1¥Æ¥¥¹¥È1¥Æ¥¥¹¥È1" add_item id_list, item_name item_name = "2016ǯ11·î15Æü","¢","¥Æ¥¥¹¥È2¥Æ¥¥¹¥È2¥Æ¥¥¹¥È2" add_item id_list, item_name item_name = "2016ǯ8·î12Æü","£","¥Æ¥¥¹¥È3¥Æ¥¥¹¥È3¥Æ¥¥¹¥È3¥Æ¥¥¹¥È3¥Æ¥¥¹¥È3¥Æ¥¥¹¥È3" add_item id_list, item_name #module mod_listview #include "hscallbk.as" #uselib "" #func sort_items "" int, int, int #define LVM_SETITEM $00001006 #define LVM_INSERTITEM $00001007 #define LVM_INSERTCOLUMN $0000101B #define LVM_SORTITEMSEX $00001051 #define LVM_GETITEMTEXTA $0000102D #define LVS_REPORT $00000001 #define WS_EX_NOPARENTNOTIFY $00000004 #define WS_VISIBLE $10000000 #define WS_CHILD $40000000 #define LVM_SETIMAGELIST 0x1003 #define LVSIL_NORMAL 0x0000 #define LVSIL_SMALL 0x0001 #deffunc make_listview int objheight if vartype(proc) != vartype("callback") : gosub *init winobj "SysListView32", "ListView", WS_EX_NOPARENTNOTIFY, WS_VISIBLE | WS_CHILD | LVS_REPORT, -1, -1 newObjID = stat sendmsg objinfo_hwnd(newObjID), LVM_SETIMAGELIST, LVSIL_SMALL;, hSmallImgList return stat *init setcallbk proc, sort_items, *sort_flag sdim name, 64, 2 dim lvcolumn, 8 dim lvitem, 6 lvcolumn.0 = 0x000F lvcolumn.2 = 2 lvitem.0 = 0x0001 lvitem.6 = 64 return #deffunc add_column3 int id_list, str column_name, int index if(index < 0 | id_list < 0) { logmes "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔÀµ¤Ç¤¹¡£" return -1 } counter=counter+1 if counter = 1 : lvcolumn.2 = 120 if counter = 2 : lvcolumn.2 = 80 if counter = 3 : lvcolumn.2 = 350 if counter = 4 : lvcolumn.2 = 60 if counter = 5 : lvcolumn.2 = 60 if counter = 6 : lvcolumn.2 = 80: counter=0 name = column_name lvcolumn.3 = varptr(name) sendmsg objinfo_hwnd(id_list), LVM_INSERTCOLUMN, index, varptr(lvcolumn) return stat #deffunc add_item int id_list, array item, int index if(index < 0 | id_list < 0) { logmes "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔÀµ¤Ç¤¹¡£" return -1 } if vartype(item) != vartype("str") { logmes "ÇÛÎóÊÑ¿ô¤Î·¿¤¬ÉÔÀµ¤Ç¤¹¡£Ê¸»úÎ󷿤ÎÊÑ¿ô¤òÅϤ·¤Æ¤¯¤À¤µ¤¤¡£" return -1 } // ¥¢¥¤¥Æ¥à¤ÎºîÀ® lvitem.1 = index lvitem.2 = 0 lvitem.5 = varptr(item) sendmsg objinfo_hwnd(id_list), LVM_INSERTITEM, 0, varptr(lvitem) // ¥µ¥Ö¥¢¥¤¥Æ¥à¤ÎºîÀ® repeat length(item) - 1, 1 lvitem.2 = cnt lvitem.5 = varptr(item(cnt)) sendmsg objinfo_hwnd(id_list), LVM_SETITEM, 0, varptr(lvitem) loop return stat #deffunc sort int id_list, int column, int vtype, int sortmode if(column < 0 | id_list < 0 | vtype < 0) { logmes "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔÀµ¤Ç¤¹¡£" return -1 } lvitem.2 = column var_type = vtype sendmsg objinfo_hwnd(id_list), LVM_SORTITEMSEX, sortmode, varptr(proc) return #defcfunc local compareAsInt int id_list, int index1, int index2, int sortmode gosub *startCompare return int(name(sortmode & 1)) - int(name((sortmode & 1) ^ 1)) #defcfunc local compareAsStr int id_list, int index1, int index2, int sortmode gosub *startCompare return name(sortmode & 1) ! name((sortmode & 1) ^ 1) return *startCompare lvitem.5 = varptr(name(0)) sendmsg objinfo_hwnd(id_list), LVM_GETITEMTEXTA, index1, varptr(lvitem) lvitem.5 = varptr(name(1)) sendmsg objinfo_hwnd(id_list), LVM_GETITEMTEXTA, index2, varptr(lvitem) return // ¥µ¥Ö¥¢¥¤¥Æ¥à¡Ê¥Õ¥¡¥¤¥ë¥µ¥¤¥º¡Ë¤Ç¥½¡¼¥È // Âè3°ú¿ô¤¬0¤Ê¤é¾º½ç¡¢1¤Ê¤é¹ß½ç *sort_flag if var_type == vartype("int") { return compareAsInt@mod_listview(id_list, callbkarg(0), callbkarg(1), callbkarg(2)) } else : if var_type == vartype("str") { return compareAsStr@mod_listview(id_list, callbkarg(0), callbkarg(1), callbkarg(2)) } return 0 #global // end of mod_listview #module ;============= ¥ê¥¹¥È¥Ó¥å¡¼Áàºî¥â¥¸¥å¡¼¥ë =============== #uselib "comctl32.dll" #func InitCommonControlsEx "InitCommonControlsEx" int ; ³Æ¼ïÄê¿ôÄêµÁ #define ICC_LISTVIEW_CLASSES 4 #define WS_CHILD 0x40000000 #define WS_VISIBLE 0x10000000 #define LVS_REPORT 0x0001 #define LVM_SETITEM 0x1006 #define LVM_INSERTITEM 0x1007 #define LVM_DELETEITEM 0x1008 #define LVM_INSERTCOLUMN 0x101B #define LVM_GETNEXTITEM 0x100C #define LVM_GETITEMTEXT 0x102D #define LVCF_FMT 0x0001 #define LVCF_WIDTH 0x0002 #define LVCF_TEXT 0x0004 #define LVCF_SUBITEM 0x0008 #define LVIF_TEXT 0x0001 #define LVNI_SELECTED 0x0002 // ¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú¿ʬ LVCFMT_CENTER ¤Ç»ØÄꤹ¤ë¤ó¤À¤È»×¤¤¤Þ¤¹ ¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú¡ú // ; (³°Éô¤«¤é»²¾È¤Ç¤¤ë¤è¤¦¤Ë global »ØÄê) #define global LVCFMT_LEFT 0x0000 #define global LVCFMT_RIGHT 0x0001 #define global LVCFMT_CENTER 0x0002 ; ¥ê¥¹¥È¥Ó¥å¡¼ºîÀ® #deffunc CreateListView int sx, int sy ; ¥³¥â¥ó¥³¥ó¥È¥í¡¼¥ë¥é¥¤¥Ö¥é¥ê¤Î½é´ü²½ initinfo = 8, ICC_LISTVIEW_CLASSES InitCommonControlsEx varptr(initinfo) ; ¥ê¥¹¥È¥Ó¥å¡¼¤ÎºîÀ® styleFlags = WS_CHILD | WS_VISIBLE | LVS_REPORT winobj "SysListView32", "", 0, styleFlags, sx, sy return ; ¥ê¥¹¥È¥Ó¥å¡¼¤ËÎó¤òÄɲà #deffunc InsertListViewColumn int objID, int index, str text, int align, int pixels textbuf = text ; LVCOLUMN ¹½Â¤ÂΤò¥»¥Ã¥È dim lvcolumn, 8 lvcolumn(0) = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM lvcolumn(1) = align lvcolumn(2) = pixels lvcolumn(3) = varptr(textbuf) ; LVM_INSERTCOLUMN ¥á¥Ã¥»¡¼¥¸Á÷¿® sendmsg objinfo_hwnd(objID), LVM_INSERTCOLUMN, index, varptr(lvcolumn) return ; ¥ê¥¹¥È¥Ó¥å¡¼¤Ë¹àÌÜÄɲà #deffunc InsertListViewItem int objID, int index, str text textbuf = text ; LVITEM ¹½Â¤ÂΤò¥»¥Ã¥È dim lvitem, 13 lvitem(0) = LVIF_TEXT lvitem(1) = index lvitem(5) = varptr(textbuf) ; LVM_INSERTITEM ¥á¥Ã¥»¡¼¥¸Á÷¿® sendmsg objinfo_hwnd(objID), LVM_INSERTITEM, 0, varptr(lvitem) return ; ¥ê¥¹¥È¥Ó¥å¡¼¤Î¹àÌܤޤ¿¤Ï¥µ¥Ö¹àÌܥƥ¥¹¥ÈÀßÄê #deffunc SetListViewItemText int objID, int index, int subitem, str text textbuf = text ; LVITEM ¹½Â¤ÂΤò¥»¥Ã¥È dim lvitem, 13 lvitem(0) = LVIF_TEXT lvitem(1) = index lvitem(2) = subitem lvitem(5) = varptr(textbuf) ; LVM_SETITEM ¥á¥Ã¥»¡¼¥¸Á÷¿® sendmsg objinfo_hwnd(objID), LVM_SETITEM, 0, varptr(lvitem) return ; ¥ê¥¹¥È¥Ó¥å¡¼¤Î¹àÌܤޤ¿¤Ï¥µ¥Ö¹àÌܥƥ¥¹¥È¼èÆÀ #defcfunc GetListViewItemText int objID, int index, int subitem ; LVITEM ¹½Â¤ÂΤò¥»¥Ã¥È dim lvitem, 13 lvitem(2) = subitem textbufsize = 256 ; ¼èÆÀ¤Ç¤¤ë¤Þ¤Ç¥Ð¥Ã¥Õ¥¡¥µ¥¤¥º¤ò³ÈÄ¥ repeat sdim textbuf, textbufsize lvitem(5) = varptr(textbuf) lvitem(6) = textbufsize ; LVM_GETITEMTEXT ¥á¥Ã¥»¡¼¥¸Á÷¿® sendmsg objinfo_hwnd(objID), LVM_GETITEMTEXT, index, varptr(lvitem) if stat < textbufsize - 1 : break textbufsize *= 2 loop return textbuf ; ¥ê¥¹¥È¥Ó¥å¡¼¤Î¹àÌܺï½ü #deffunc DeleteListViewItem int objID, int index ; LVM_DELETEITEM ¥á¥Ã¥»¡¼¥¸Á÷¿® sendmsg objinfo_hwnd(objID), LVM_DELETEITEM, index, 0 return ; ¥ê¥¹¥È¥Ó¥å¡¼¤ÎÁªÂò¹àÌܤΥ¤¥ó¥Ç¥Ã¥¯¥¹¼èÆÀ #defcfunc GetSelectedListViewItem int objID, int startIndex ; LVM_GETNEXTITEM ¥á¥Ã¥»¡¼¥¸Á÷¿® sendmsg objinfo_hwnd(objID), LVM_GETNEXTITEM, startIndex, LVNI_SELECTED return stat #global ;================= ¥â¥¸¥å¡¼¥ë½ª¤ï¤ê ===================== ;¡ÚHSP3.x °Ü¿¢ÈÇ¡Û ;¡ØHSP¤Î΢µ»¡Ù¥ê¥¹¥È¥Ó¥å¡¼¤Ç¥¢¥¤¥³¥ó¤ò»È¤Ã¤Æ¤ß¤ë ; http://chokuto.ifdef.jp/urawaza/lv_icon.html ; ¢¨¥Õ¥¡¥¤¥ë iconlist.bmp ¤Ï¾åµURL¤Ç¸ø³«¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ò»ÈÍÑ ; ; [»²¾È]¡ØAdvanced HSP¡Ù¥Ó¥Ã¥È¥Þ¥Ã¥×¥ª¥Ö¥¸¥§¥¯¥È ; http://chokuto.ifdef.jp/advanced/bitmapobject.html #module ;###### ¥Ó¥Ã¥È¥Þ¥Ã¥×¥ª¥Ö¥¸¥§¥¯¥ÈºîÀ®¥â¥¸¥å¡¼¥ë ######### #uselib "gdi32.dll" #cfunc CreateCompatibleDC "CreateCompatibleDC" int #cfunc CreateCompatibleBitmap "CreateCompatibleBitmap" int, int, int #func SelectObject "SelectObject" int, int #func BitBlt "BitBlt" int, int, int, int, int, int, int, int, int #func DeleteDC "DeleteDC" int #func DeleteObject "DeleteObject" int #define SRCCOPY 0x00CC0020 ; DIB¥»¥¯¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥ÈºîÀ® #defcfunc CreateDIB int px, int py, int sx, int sy ; DIB¥»¥¯¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥ÈºîÀ® hBitmap = CreateCompatibleBitmap(hdc, sx, sy) ; ¥á¥â¥ê¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥ÈºîÀ® hdcMemory = CreateCompatibleDC(hdc) ; ¥Ó¥Ã¥È¥Þ¥Ã¥×¤ò¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥È¤ËÁªÂò SelectObject hdcMemory, hBitmap hOldBitmap = stat ; HSP¥¦¥£¥ó¥É¥¦¤«¤é¥Ó¥Ã¥È¥Þ¥Ã¥×¤Ë¥¤¥á¡¼¥¸¤ò¥³¥Ô¡¼ BitBlt hdcMemory, 0, 0, sx, sy, hdc, px, py, SRCCOPY ; ¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥È¤ÎÁªÂò¥Ó¥Ã¥È¥Þ¥Ã¥×¤òÌ᤹ SelectObject hdcMemory, hOldBitmap ; ¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥È¤òºï½ü DeleteDC hdcMemory ; ¥Ó¥Ã¥È¥Þ¥Ã¥×¥ª¥Ö¥¸¥§¥¯¥È(DIB¥»¥¯¥·¥ç¥ó)¤Î¥Ï¥ó¥É¥ë¤òÊÖ¤¹ return hBitmap ; DIB¥ª¥Ö¥¸¥§¥¯¥Èºï½ü #deffunc DeleteDIB int hbmp ; ¥Ó¥Ã¥È¥Þ¥Ã¥×¥ª¥Ö¥¸¥§¥¯¥È¤òºï½ü DeleteObject hbmp return #global ;############# ¥â¥¸¥å¡¼¥ë½ª¤ï¤ê ######################## #module ;########### ¥¤¥á¡¼¥¸¥ê¥¹¥ÈÁàºî¥â¥¸¥å¡¼¥ë ############## #uselib "comctl32.dll" #cfunc ImageList_Create "ImageList_Create" int,int,int,int,int #func ImageList_Destroy "ImageList_Destroy" int #func ImageList_AddMasked "ImageList_AddMasked" int,int,int #func ImageList_Draw "ImageList_Draw" int,int,int,int,int,int #define global ILC_COLOR 0x0000 #define global ILC_COLOR4 0x0004 #define global ILC_COLOR8 0x0018 #define global ILC_COLOR16 0x0010 #define global ILC_COLOR24 0x0018 #define global ILC_COLOR32 0x0020 #define global ILC_COLORDDB 0x00FE #define global ILC_MASK 0x0001 #define ILD_TRANSPARENT 0x0001 ; ¥¤¥á¡¼¥¸¥ê¥¹¥ÈºîÀ® #defcfunc CreateImageList int sx, int sy, int type, int num return ImageList_Create(sx, sy, type, num, 0) ; ¥á¡¼¥¸¥ê¥¹¥ÈÇË´þ #deffunc DestroyImageList int handle ImageList_Destroy handle return ; ¥¤¥á¡¼¥¸¥ê¥¹¥È¤ËÉÁ²èÃ楦¥£¥ó¥É¥¦¤Î¥¤¥á¡¼¥¸Äɲà #deffunc AddImageListItem int handle, int cx, int cy, int sx, int sy, int maskColor dialog AddImageListItem ; DIBºîÀ® hDIB = CreateDIB(cx, cy, sx, sy) ; ¥Ó¥Ã¥È¥Þ¥Ã¥×¤ò¥¤¥á¡¼¥¸¥ê¥¹¥È¤ËÄɲà ImageList_AddMasked handle, hDIB, maskColor firstItemIndex = stat ; DIBºï½ü DeleteDIB hDIB return firstItemIndex ; ¥¤¥á¡¼¥¸¥ê¥¹¥È¤Î¥¤¥á¡¼¥¸ÉÁ²è #deffunc DrawImageListItem int handle, int index, int cx, int cy ImageList_Draw handle, index, hdc, cx, cy, ILD_TRANSPARENT return #global ;############# ¥â¥¸¥å¡¼¥ë½ª¤ï¤ê ########################