自绘下拉框演示

光庆 11天前 138

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=367;bottom=199)
winform.add(
combobox={cls="combobox";left=40;top=40;right=336;bottom=64;items={"啊撒旦法萨芬";"asdfasf";"asfdas啊撒旦法萨芬"};mode="dropdown";style=528;z=1}
)
/*}}*/

winform.combobox.wndproc = function(hwnd,message,wParam,lParam){
	select( message ) { 
		case 0x002B/*_WM_DRAWITEM*/ {
			import console
			var tag = {
  					INT     CtlType;
  					INT     CtlID;
  					INT     itemID;
  					INT     itemAction;
  					INT     itemState;
  					int     hwndItem;
  					ptr     hDC;
  					struct  rect = ::RECT();
  					int     itemData;
				};
			..raw.convert(topointer(lParam),tag);
			var font = ..gdi.getFont(owner.hwnd)
			if tag.itemState==1 {
				..gdi.fillRect(tag.hDC,0xFF8888,tag.rect);
			}  else {
				..gdi.fillRect(tag.hDC,0xFFFFFF,tag.rect);
			}
			tag.rect.left += 5;
			..gdi.drawText(tag.hDC,font,winform.combobox.items[tag.itemID+1],tag.rect,4/*_DT_VCENTER*/|0x20/*_DT_SINGLELINE*/);
		}
	}
}
winform.show();
::SendMessageInt(winform.combobox.hwnd,0x153,0,30);
::SendMessageInt(winform.combobox.hwnd,0x153,-1,30);
win.loopMessage();


最新回复 (2)
  • netfox 10天前
    1 2

  • amin 10天前
    0 3
    厉害啦!
返回