import win.ui;
import win.imageList;
import win.ui.ctrl.treeview;
import console;
import debug;
//todo: ico图像
var imagelist=..win.imageList(24,24);
imagelist.addIcon("\images\windows_24px.ico");
imagelist.addIcon("\images\media_player_24px.ico");
imagelist.addIcon("\images\twist_24px.ico");
var iStyle=0x10/*_LVCF_IMAGE*/ | 0x4/*_LVCF_TEXT*/ | 0x80/*_LVCF_DEFAULTWIDTH*/;
/*DSG{{*/
mainForm = win.form(text="树形框图标显示_treeview_icons";right=551;bottom=479)
mainForm.add(
button={cls="button";text="添加图标";left=16;top=16;right=160;bottom=56;dl=1;dt=1;z=2};
tvFiles={cls="treeview";left=16;top=72;right=536;bottom=464;asel=false;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;edge=1;z=1}
)
/*}}*/
mainForm.addTV_image=function(iImage,sText,bHasChildren,hParent)
{
/*
class TVITEM {
INT mask = 0;
pointer hItem;
INT state;
INT stateMask;
ptr textPtr;//这里有可能是无效的指针
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
INT lParam;
};
*/
var tvItem = ..win.ui.ctrl.treeview.TVITEM();
tvItem.mask = 1/*_TVIF_TEXT*/ | 0x20/*_TVIF_SELECTEDIMAGE*/ | 2/*_TVIF_IMAGE*/
| 1/*_TVIF_TEXT*/ | 0x40/*_TVIF_CHILDREN*/;
//tvItem.hItem=null;
tvItem.textPtr=..string.toUnicode( sText );
tvItem.cchTextMax=..string.len(sText);
tvItem.iImage=iImage;
tvItem.iSelectedImage=iImage;
tvItem.cChildren = bHasChildren; //有子节点,则为1 , 否则为 0 。
//winform.tvFiles.insertItem(tvItem); //todo: 这个无效,不知为什么。
var inst =
{
pointer hParent = hParent; //hItem
addr hInsertAfter;
struct item = tvItem;
}
inst.hInsertAfter = ::SendMessageByStruct(mainForm.tvFiles.hwnd,0x1132/*_TVM_INSERTITEMW*/,0,inst );
mainForm.tvFiles.expand(hParent);
return inst.hInsertAfter;
}
mainForm.button.oncommand = function(id,event)
{
var hInsertAfter=mainForm.addTV_image(0,"Windows 系统",1);
var hInsertAfter=mainForm.addTV_image(1,"媒体播放器",1,topointer(hInsertAfter));
var hInsertAfter=mainForm.addTV_image(2,"扭结",0,topointer(hInsertAfter));
}
mainForm.tvFiles.setImageList( imagelist,0/*_TVSIL_NORMAL*/ );
mainForm.show();
return win.loopMessage();
import win.imageList;
import win.ui.ctrl.treeview;
import console;
import debug;
//todo: ico图像
var imagelist=..win.imageList(24,24);
imagelist.addIcon("\images\windows_24px.ico");
imagelist.addIcon("\images\media_player_24px.ico");
imagelist.addIcon("\images\twist_24px.ico");
var iStyle=0x10/*_LVCF_IMAGE*/ | 0x4/*_LVCF_TEXT*/ | 0x80/*_LVCF_DEFAULTWIDTH*/;
/*DSG{{*/
mainForm = win.form(text="树形框图标显示_treeview_icons";right=551;bottom=479)
mainForm.add(
button={cls="button";text="添加图标";left=16;top=16;right=160;bottom=56;dl=1;dt=1;z=2};
tvFiles={cls="treeview";left=16;top=72;right=536;bottom=464;asel=false;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;edge=1;z=1}
)
/*}}*/
mainForm.addTV_image=function(iImage,sText,bHasChildren,hParent)
{
/*
class TVITEM {
INT mask = 0;
pointer hItem;
INT state;
INT stateMask;
ptr textPtr;//这里有可能是无效的指针
int cchTextMax;
int iImage;
int iSelectedImage;
int cChildren;
INT lParam;
};
*/
var tvItem = ..win.ui.ctrl.treeview.TVITEM();
tvItem.mask = 1/*_TVIF_TEXT*/ | 0x20/*_TVIF_SELECTEDIMAGE*/ | 2/*_TVIF_IMAGE*/
| 1/*_TVIF_TEXT*/ | 0x40/*_TVIF_CHILDREN*/;
//tvItem.hItem=null;
tvItem.textPtr=..string.toUnicode( sText );
tvItem.cchTextMax=..string.len(sText);
tvItem.iImage=iImage;
tvItem.iSelectedImage=iImage;
tvItem.cChildren = bHasChildren; //有子节点,则为1 , 否则为 0 。
//winform.tvFiles.insertItem(tvItem); //todo: 这个无效,不知为什么。
var inst =
{
pointer hParent = hParent; //hItem
addr hInsertAfter;
struct item = tvItem;
}
inst.hInsertAfter = ::SendMessageByStruct(mainForm.tvFiles.hwnd,0x1132/*_TVM_INSERTITEMW*/,0,inst );
mainForm.tvFiles.expand(hParent);
return inst.hInsertAfter;
}
mainForm.button.oncommand = function(id,event)
{
var hInsertAfter=mainForm.addTV_image(0,"Windows 系统",1);
var hInsertAfter=mainForm.addTV_image(1,"媒体播放器",1,topointer(hInsertAfter));
var hInsertAfter=mainForm.addTV_image(2,"扭结",0,topointer(hInsertAfter));
}
mainForm.tvFiles.setImageList( imagelist,0/*_TVSIL_NORMAL*/ );
mainForm.show();
return win.loopMessage();