sin¤µ¤ó¡¢¤³¤ó¤Ë¤Á¤Ï¡£¤ª¤â¤·¤í¤½¤¦¤ÊÂêºà¤À¤Ã¤¿¤Î¤ÇÄ´¤Ù¤Æ¤ß¤Þ¤·¤¿¡£
´Ø¿ô¤Î¥¢¥É¥ì¥¹¤òÅϤ¹ÊýË¡¤Ç¤¹¤¬¡Ê»ä¼«¿È¾Ü¤·¤¯¤Ï¤Ê¤¤¤Î¤Ç¼«¿®¤Ï¤¢¤ê¤Þ¤»¤ó¡Ë¡¢¥Ø¥ë¥×¤Ë¤è¤ì¤Ðlibptr()¤ÇÆÀ¤é¤ì¤ëÃͤϡÖSTRUCTDAT¹½Â¤ÂΤΥ¢¥É¥ì¥¹¡×¤Ç¤¢¤Ã¤Æ¡¢´Ø¿ô¼«ÂΤΥ¢¥É¥ì¥¹¤Ç¤Ï¤Ê¤¤¤½¤¦¤Ç¤¹¡£
¤â¤Á¤í¤ó¥æ¡¼¥¶¡¼ÄêµÁÌ¿Îá¤Ëvarptr()¤ÏÍøÍѤǤ¤Ê¤¤¤Î¤Ç¡¢¤Á¤ç¤¯¤È¤µ¤ó¤Îhscallbk.dll¤òÍøÍѤ¹¤ë¤Î¤¬°ìÈÖ´Êñ¤Ç¤Ï¤Ê¤¤¤«¤È»×¤¤¤Þ¤¹¡£
http://yokohama.cool.ne.jp/chokuto/download/index.html#hscallbk
DLL¤ÎÍøÍÑÊýË¡¤ÏÉÕ°¥Æ¥¥¹¥È¤ò¤´Í÷¤¯¤À¤µ¤¤¡£
ÌäÂê¤Î¹ß½ç¥½¡¼¥È¤Ç¤¹¤¬¡¢LVM_SORTITEMS¤è¤ê¤âLVM_SORTITEMSEX¤òÍøÍѤ·¤¿Êý¤¬ÌÜŪ¤Î¥×¥í¥°¥é¥à¤ò¼Â¸½¤·¤ä¤¹¤¤¤è¤¦¤Ç¤¹¡£
LVM_GETITEMTEXTA¥á¥Ã¥»¡¼¥¸¤òÍøÍѤ·¤ÆǤ°Õ¤Î¥¢¥¤¥Æ¥à¡¦¥µ¥Ö¥¢¥¤¥Æ¥à¤Î¥Æ¥¥¹¥È¤ò¼èÆÀ¤·¡¢¤½¤Î2¤Ä¤òÈæ³Ó¤¹¤ë´Ø¿ô¡Ê¾åµDLL¤òÍøÍѤ¹¤ë¾ì¹ç¤Ï¥µ¥Ö¥ë¡¼¥Á¥ó¡Ë¤òÍÑ°Õ¤¹¤ë¤À¤±¤Ç¼Â¸½¤Ç¤¤Þ¤·¤¿¡£
µÞ¤®¤Çºî¤Ã¤¿Êª¤Ç¥â¥¸¥å¡¼¥ë²½¤Ê¤É¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¤¬¡¢°ì±þÆ°ºî¤¹¤ë¥¹¥¯¥ê¥×¥È¤òºÜ¤»¤Æ¤ª¤¤Þ¤¹¡£
DLL¤ÎÍøÍÑË¡¤ä³Æ¥á¥Ã¥»¡¼¥¸¤ÎÍøÍÑÎã¤È¤·¤ÆÌòΩ¤Æ¤Æ¤¯¤À¤µ¤¤¡£
// »²¹Í»ñÎÁ¡§
// ¥ê¥¹¥È¥Ó¥å¡¼¤òºîÀ®¤·¤Æ¤ß¤ë
// http://yokohama.cool.ne.jp/chokuto/urawaza/listview1.html
// Windows32 API Constance ¸¡º÷
// http://hspnext.com/tool/hsptool04.htm
// MSDN - LVM_SORTITEMSEX
// http://msdn2.microsoft.com/ja-jp/library/bb761055(en-us).aspx
#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 NUM_FILES 10
randomize
gosub *createGuiObjects
setcallbk proc, sort_items, *sort
stop
// ¥µ¥Ö¥¢¥¤¥Æ¥à¡Ê¥Õ¥¡¥¤¥ë¥µ¥¤¥º¡Ë¤Ç¥½¡¼¥È
// Âè2°ú¿ô¤¬0¤Ê¤é¾º½ç¡¢1¤Ê¤é¹ß½ç
*sort
lvitem.2 = 1 // ¥µ¥Ö¥¢¥¤¥Æ¥à¤òÂоݤȤ¹¤ë
sortmode = callbkarg(2) & 1
repeat 2
lvitem.5 = varptr(item_name(cnt))
sendmsg objinfo_hwnd(id_list), LVM_GETITEMTEXTA, callbkarg(cnt^sortmode), varptr(lvitem)
loop
return int(item_name(0)) - int(item_name(1))
// ¥Ü¥¿¥ó¥¯¥ê¥Ã¥¯¤Ë¤è¤Ã¤Æ¸Æ¤Ó½Ð¤µ¤ì¤ë¥µ¥Ö¥ë¡¼¥Á¥ó
*sort_asc
sendmsg objinfo_hwnd(id_list), LVM_SORTITEMSEX, 0, varptr(proc)
return
*sort_desc
sendmsg objinfo_hwnd(id_list), LVM_SORTITEMSEX, 1, varptr(proc)
return
// ¥Ü¥¿¥ó¤È¥ê¥¹¥È¥Ó¥å¡¼¤ÎºîÀ®
*createGuiObjects
// ¥Ü¥¿¥ó¤òºîÀ®
objsize ginfo_winx / 2, 32
button gosub "¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤Ç¾º½ç¤Ë¥½¡¼¥È", *sort_asc
pos ginfo_winx / 2, 0 : button gosub "¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤Ç¹ß½ç¤Ë¥½¡¼¥È", *sort_desc
// ¥ê¥¹¥È¥Ó¥å¡¼¥³¥ó¥È¥í¡¼¥ëºîÀ®
w = ginfo_winx : h = ginfo_winy - 32
style = WS_VISIBLE | WS_CHILD | LVS_REPORT
pos 0, 32
winobj "SysListView32", "ListView", WS_EX_NOPARENTNOTIFY, style, w, h, 0, 0
id_list = stat
// ¥«¥é¥à¤òÄɲÃ
dim lvcolumn, 8
lvcolumn.0 = 0x000F
lvcolumn.2 = 100
column_name = "¥Õ¥¡¥¤¥ë̾", "¥Õ¥¡¥¤¥ë¥µ¥¤¥º"
repeat 2
lvcolumn(3) = varptr(column_name(cnt))
sendmsg objinfo_hwnd(id_list), LVM_INSERTCOLUMN, cnt, varptr(lvcolumn)
if stat == -1 {
dialog "¥«¥é¥à¤ÎÄɲä˼ºÇÔ", 1
end
}
loop
// ¥¢¥¤¥Æ¥à¤ÎÄɲÃ
dim lvitem, 13
sdim item_name, 64, 2
lvitem.0 = 0x0001
lvitem.6 = 64
repeat NUM_FILES
item_name = "¥Õ¥¡¥¤¥ë" + cnt
lvitem.1 = cnt
lvitem.5 = varptr(item_name)
sendmsg objinfo_hwnd(id_list), LVM_INSERTITEM, 0, varptr(lvitem)
if stat == -1 {
dialog "¥¢¥¤¥Æ¥à¤ÎÄɲä˼ºÇÔ", 1
end
}
loop
// ¥µ¥Ö¥¢¥¤¥Æ¥à¤ÎÄɲÃ
repeat NUM_FILES
item_name = "" + rnd(1000) + " KB"
lvitem.1 = cnt
lvitem.2 = 1
lvitem.5 = varptr(item_name)
sendmsg objinfo_hwnd(id_list), LVM_SETITEM, 0, varptr(lvitem)
if stat == -1 {
dialog "¥µ¥Ö¥¢¥¤¥Æ¥à¤ÎÄɲä˼ºÇÔ", 1
end
}
loop
return