Window SubClassing另类运用(之二)[12]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 weizhisheng 的 blog

处理项目绘制的代码其实从原理上来讲非常简单,但是比较琐碎,必须大量调用sendmessageshell api接口函数,还包括gdi对象的管理。我不打算仔细解释下面这些代码;这些代码的效果就是在combobox中为每一个项目前面添加一个代表其文件夹的图标。


    wm_drawitem:


      begin


        pdis := pdrawitemstruct(lp);


        if pdis^.ctltype=odt_combobox then begin


           hcombo := pdis^.hwnditem;


           if pdis^.itemid=$ffffffff then exit;


           csidl := dword(sendmessage(hcombo, cb_getitemdata, pdis^.itemid, 0));


if (pdis^.itemstate and ods_selected)=ods_selected then begin


              fillrect(pdis^.hdc, pdis^.rcitem, getsyscolorbrush(color_highlight));


              settextcolor(pdis^.hdc, getsyscolor(color_highlighttext));


           end


           else begin


              fillrect(pdis^.hdc, pdis^.rcitem, getsyscolorbrush(color_window));


              settextcolor(pdis^.hdc, getsyscolor(color_windowtext));


           end;


           setbkmode(pdis^.hdc, transparent);


           if csidl<>555 then begin  // csidl


本文关键:Delphi,API,Subclass
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top