namespace win.ui.ctrl.tab.icon;
import fsys;
import gdip.bitmap;
import win.imageList;
import util.metaProperty;
util.metaProperty.extend(..win.ui.ctrl.tab,{
setIcon = function( index,icoindex ){
if(index > #owner.items) return;
var n = icoindex-1;
if (n < 0) return;
if (owner.iconList && !owner.iconList.getIcon(n)) return;
var tci = owner.getItem(index);
tci.pszText = owner.getItemText(index)
tci.iImage = n;
owner.setItem(index,tci);
}
add = function(tParam){
var tci = ..win.ui.ctrl.tab.TCITEM();
tci.pszText = tParam.text;
tParam.text = null;
tParam.parent = owner ;
tParam.mode="child";
tParam.exmode="none";
tParam.border="none"
tParam.title=false;
if( !(tParam.right && tParam.bottom) ){
var rc = owner.getClientRect();
tParam.right = rc.right;
tParam.bottom = rc.bottom;
}
var wf = ..win.form(tParam);
if(!wf) return null,"创建窗口失败";
var index = ..table.push(owner._forms ,wf)-1;
var imageList = owner.imageList;
if (imageList && ..table.isArray(imageList)){
var icon = ..win.imageList(20,20);
for(i=1;#imageList;1){
var iconFile = imageList[i];
if (..fsys.getExtensionName(iconFile) == "ico"){
icon.addIcon(iconFile);
}else{
icon.addBitmap(..gdip.bitmap(iconFile).copyHandle(20,20));
}
}
imageList = icon;
}
owner.iconList = imageList;
var icoIndex;
if (tParam.ico){
icoIndex = tParam.ico-1;
}else {
icoIndex = index;
}
if (imageList && imageList.getIcon(icoIndex)){
owner.sendMessage(0x1303 /*_TCM_SETIMAGELIST*/,0,imageList[["handle"]]:imageList);
tci.iImage = icoIndex;
}
::SendMessageByStruct(owner.hwnd ,0x133E/*_TCM_INSERTITEMW*/, index,tci);
::SendMessage(owner.hwnd,0x5/*_WM_SIZE*/);
owner.modifyStyle(0x40 /*_TCS_FIXEDWIDTH*/);
owner.lastForm = wf;
wf._onDestroyInTabs = function(){
var i = ..table.find(owner.parent._forms,wf);
if(i) owner.parent.remove(i);
}
if(!index){
owner.form = wf;
owner.form.show(true);
owner.adjustRect();
}
else {
wf.show(false);
owner.adjustRect();
}
return wf;
}
})
/*****intellisense(!ui_tab.)
imageList = imageList图像列表对象,或者包含图标,图片的数组
setIcon(__/*选项卡索引*/,/*图标索引*/); = tab选项卡设置图标
end intellisense*****/
下载附件,放到
lib\win\ui\ctrl
或者自定义库的命名空间,放在lib下,导入即可