代码全复制过去,直接用即可。
import win.graphics; import color.table; tb = color.table(); myColorList = {}; for(i=1;#tb;1){ myColorList[[tb[i][1]]] = { tb[i][2];tb[i][3]; }; }//这以上,全复制一下,初始颜色的
//下面这函数,参数是控件名 applyColorPickerComboBox = function( cmb ){ cmb.onMeasureItem = function(measureItem){ measureItem.itemHeight = 21; } cmb.onDrawItem = function(drawItem){ var cvs = win.graphics.canvas(); cvs.fromHDC(drawItem.hDC); if( drawItem.itemID<10000 ){ cvs.brush.color = myColorList[owner.items[drawItem.itemID+1]][2]; } else { cvs.brush.color = 0x333333; } var rc = ::RECT(drawItem.rcItem.left+3,drawItem.rcItem.top+3, 28,drawItem.rcItem.bottom-1); cvs.fillRect(rc); cvs.pen.color = 0x00FFFF; cvs.font.color = 0x333333; //焦点处理 if(drawItem.itemState&1/*_ODS_SELECTED*/){ cvs.textOut(rc.left+30, rc.top, owner.items[drawItem.itemID+1]) cvs.drawFocusRect(rc); }else { cvs.textOut(rc.left+30, rc.top, owner.items[drawItem.itemID+1]); } cvs.destroy(); } for(k,v in myColorList){ cmb.add( k ); } cmb.selIndex = 1; }
//这里调用一下,这个控件就变成颜色选择框了 applyColorPickerComboBox( winform.combobox );
发表评论