//imageList 图像列表 import win.image; import com.picture; namespace win { class imageList { ctor ( width, height ) { if (height !== null ) { this.handle = ::Comctl32.ImageList_CreateP(width, height, 0x00000020 | 0x1/*_ILC_MASK*/, 0, 1); this.width,this.height = width, height; } else{ this.handle = width; if( type(this.handle) != type.pointer ) error("无效的图标句柄",2); var width,height = {INT value},{INT value}; ::Comctl32.ImageList_GetIconSize(this.handle, width, height); this.width,this.height = width.value,height.value; } }; add = function (pic, color=0xff00ff) { var iPic = ..com.picture.load(pic); if(!iPic) error("加载图像失败",2); var idx = ::Comctl32.ImageList_AddMasked(this.handle, iPic.Handle, color); ..com.Release(iPic) if( idx > -1 ) return this,idx; error("加载图像失败",2); }; addBitmap = function(hbmp,color=0xff00ff){ var idx = ::Comctl32.ImageList_AddMasked(this.handle,hbmp, color); if( idx > -1 ) return this,idx; error("加载图像失败",2); }; addIcon = function (iconData) { var hIcon = ..win.image.createIcon(iconData,true,this.width); if(!hIcon) return; var idx = ::Comctl32.ImageList_ReplaceIcon(this.handle, -1, hIcon); if( idx > -1 ) return this,idx; }; loadIcon = function (id,hinst) { var hIcon = ::LoadIcon(hinst,type(id)==="number"? topointer(id) : id ); if(!hIcon) return; var idx = ::Comctl32.ImageList_ReplaceIcon(this.handle, -1, hIcon); if( idx > -1 ) return this,idx; }; getIcon = function(i,flags){ return ::Comctl32.ImageList_GetIconP(this.handle,i : 0 ,flags : 0 ); }; draw = function(i,hdc,x,y,fStyle){ if( fStyle === null ) fStyle = 1/*_ILD_TRANSPARENT*/; ::Comctl32.ImageList_Draw(this.handle,i,hdc,x,y,fStyle) }; destroy = function(){ if( this.handle ){ ::Comctl32.ImageList_Destroy(this.handle) this.handle = null; } }; @_meta } imagelist = imageList;//@Deprecated } namespace win.imageList { _meta = { _topointer = lambda() owner.handle; } ::Comctl32 := ..raw.loadDll("Comctl32.dll"); var shGetImageListA = ::Shell32.api("SHGetImageList","int(int iImageList,pointer riid,pointer &ppv)" ); IID_IImageList = '\x26\x59\xEB\x46\x2E\x58\x17\x40\x9F\xDF\xE8\x99\x8D\xAA\x09\x50'; shell = function(size){ var hr,hList = shGetImageListA( size,IID_IImageList); if( !hList && shilImg == 4/*_SHIL_JUMBO*/){ hr,hList = shGetImageListA( 2/*_SHIL_EXTRALARGE*/,IID_IImageList) } if( hr>=0/*_SUCCEEDED*/ ) return ..win.imageList(hList); } } /**intellisense(win) imageList = 图像列表,\n可用于工具条、树形控件等。\n\n图像列表默认并不会自适应 DPI 缩放(控件已实现缩放的除外),\n可在窗口或控件的 onDpiChanged 事件内更换不同大小的图像列表。\n\n建议改用 plus 控件、 win.ui.tabs 等,\n这些控件可以支持适合缩放的字体图标 imageList(__/*句柄*/) = 通过句柄创建一个 imageList imageList(.(宽度,高度) = 创建一个 imageList end intellisense**/ /**intellisense() win.imageList.shell( _SHIL___ ) = 调用SHGetImageList获取系统图像列表 win.imageList.shell() = !imageList. win.imageList() = !imageList. !imagelist.addIcon( = 添加图标 !imagelist.addIcon(.(图标数据) = 参数可指定图标数据或文件路径,支持资源路径,\n成功返回自身,失败返回null !imagelist.loadIcon(.(资源名,模块ID) = 自图标资源载入图标,\n参数@1可指定资源名或资源ID,\n参数@2可省略,\n成功返回自身,失败返回null !imagelist.addBitmap( = 添加位图 !imagelist.addBitmap(.(位图句柄,透明色) = 添加位图,\n成功返回自身,失败抛出异常,\n该函数会复制位图,不会接管或销毁传入的位图\n如果传入的位图句柄不再使用,应使用::DeleteObject销毁 !imagelist.add( = 添加图像 !imagelist.add(.(图像路径,透明色) = 添加图像,\n成功返回自身,失败抛出异常 !imagelist.draw(.(索引,hDC,x,y,fStyle) = 绘图 !imagelist.getIcon(.(索引,1/*_ILD_TRANSPARENT*/) = 返回图标句柄\n该句柄应使用 ::DestroyIcon 函数释放 !imagelist.width = 宽度 !imagelist.height = 高度 !imagelist.destroy() = 删除对象\n这个函数不会被在对象释放时被自动调用,\n应用程序应在图像列表不再使用时调用此函数销毁对象,\n注意treeview控件不负责自动销毁图像列表,\n而listview控件在销毁时负责自动销毁正在使用的图像列表.\n end intellisense**/ /**intellisense() _SHIL_LARGE=@0/*_SHIL_LARGE*/ _SHIL_SMALL=@1/*_SHIL_SMALL*/ _SHIL_EXTRALARGE=@2/*_SHIL_EXTRALARGE*/ _SHIL_SYSSMALL=@3/*_SHIL_SYSSMALL*/ _SHIL_JUMBO=@4/*_SHIL_JUMBO*/ _ILD_NORMAL=@0/*_ILD_NORMAL*/ _ILD_TRANSPARENT=@1/*_ILD_TRANSPARENT*/ _ILD_MASK=@0x10/*_ILD_MASK*/ _ILD_IMAGE=@0x20/*_ILD_IMAGE*/ _ILD_ROP=@0x40/*_ILD_ROP*/ _ILD_BLEND25=@2/*_ILD_BLEND25*/ _ILD_BLEND50=@4/*_ILD_BLEND50*/ _ILD_OVERLAYMASK=@0xF00/*_ILD_OVERLAYMASK*/ _ILD_PRESERVEALPHA=@0x1000/*_ILD_PRESERVEALPHA*/ _ILD_SCALE=@0x2000/*_ILD_SCALE*/ _ILD_DPISCALE=@0x4000/*_ILD_DPISCALE*/ _ILD_ASYNC=@0x8000/*_ILD_ASYNC*/ _ILS_NORMAL=@0/*_ILS_NORMAL*/ _ILS_GLOW=@1/*_ILS_GLOW*/ _ILS_SHADOW=@2/*_ILS_SHADOW*/ _ILS_SATURATE=@4/*_ILS_SATURATE*/ _ILS_ALPHA=@8/*_ILS_ALPHA*/ _ILC_MASK=@1/*_ILC_MASK*/ _ILC_COLOR=@0/*_ILC_COLOR*/ _ILC_COLORDDB=@0xFE/*_ILC_COLORDDB*/ _ILC_COLOR4=@4/*_ILC_COLOR4*/ _ILC_COLOR8=@8/*_ILC_COLOR8*/ _ILC_COLOR16=@0x10/*_ILC_COLOR16*/ _ILC_COLOR24=@0x18/*_ILC_COLOR24*/ _ILC_COLOR32=@0x20/*_ILC_COLOR32*/ _ILC_PALETTE=@0x800/*_ILC_PALETTE*/ _ILC_MIRROR=@0x2000/*_ILC_MIRROR*/ _ILC_PERITEMMIRROR=@0x8000/*_ILC_PERITEMMIRROR*/ end intellisense**/