aardio 文档
aardio 范例: 列表视图(listview)控件 - 自绘
//列表视图(listview)控件 - 自绘
import win.ui;
/*DSG{{*/
var winform = win.form(text="listview custom draw";right=627;bottom=294;bgcolor=128)
winform.add(
listview={cls="listview";left=12;top=13;right=614;bottom=287;bgcolor=128;dl=1;dr=1;fullRow=1;z=1}
)
/*}}*/
//移除列标题
winform.listview.modifyStyle(,0x4000/*_LVS_NOCOLUMNHEADER*/)
winform.listview.insertColumn("列标题3",100)
winform.listview.insertColumn("列标题2",100)
winform.listview.insertColumn("列标题1",100)
winform.listview.addItem( {
text={"第一行内容";"1";"1,2"}
} )
winform.listview.addItem( {
text={"第二行内容";"2";"2,2"}
} )
winform.listview.addItem( {
text={"第三行内容";"3";"3,2"}
} )
winform.listview.adjust = function(cx,cy){
winform.listview.fillParent(3);
}
//自绘
winform.listview.onnotify = function(id,code,ptr){
if( code == 0xFFFFFFF4/*_NM_CUSTOMDRAW*/ ){
var lvcd = winform.listview.getNotifyCustomDraw(code,ptr);
if( lvcd.nmcd.dwDrawStage == 0x10001/*_CDDS_ITEMPREPAINT*/)
return 0x20/*_CDRF_NOTIFYSUBITEMDRAW*/
elseif( lvcd.nmcd.dwDrawStage == 1/*_CDDS_PREPAINT*/ ){
return 0x20/*_CDRF_NOTIFYITEMDRAW*/;
}
elseif( lvcd.nmcd.dwDrawStage == ( 0x10001/*_CDDS_ITEMPREPAINT*/ | 0x20000/*_CDDS_SUBITEM*/) ){
//注意这里 iSubItem 的索引自0开始( 其他函数通常自1开始 )
lvcd.clrText = lvcd.iSubItem % 2 ? gdi.RGB(255,255,255) : gdi.RGB(12,255,120);
lvcd.clrTextBk = lvcd.iSubItem % 2 ? gdi.RGB(0,12,223) : gdi.RGB(128,23,0);
lvcd.update()
return 0/*_CDRF_DODEFAULT*/
}
}
}
winform.show()
win.loopMessage();
Markdown 格式