WinXP
Delphi 7
Win32API + KOL
hi guys, im trying to give some colors to my treeview, my code
Code:
function TreeListWndProc(Sender: PControl; var Msg: TMsg; var Rslt: Integer): Boolean;
var
cdInfo: PNMTVCUSTOMDRAW;
iCanvas : PCanvas;
begin
Result := False;
if (Msg.message = WM_NOTIFY) and (PNMHdr(Msg.lParam).code = NM_CUSTOMDRAW) then
begin
Result := True;
cdInfo := PNMTVCUSTOMDRAW(Msg.lParam);
case cdInfo.nmcd.dwDrawStage of
CDDS_PREPAINT:
begin
Rslt := CDRF_NOTIFYITEMDRAW;
end;
CDDS_ITEMPREPAINT:
begin
if cdInfo.nmcd.uItemState and CDIS_SELECTED = CDIS_SELECTED then
begin
iCanvas := NewCanvas(0);
iCanvas.Font.FontStyle := [fsBold, fsItalic];
SelectObject(cdInfo.nmcd.hdc,iCanvas.Font.Handle);
iCanvas.Free;
cdInfo.clrText := clBlue;
cdInfo.clrTextBk := clSkyBlue;
Rslt := CDRF_NEWFONT;
end
else rslt := CDRF_DODEFAULT;
end;
else
rslt := CDRF_DODEFAULT;
end
end;
end;
result:
text get bigger than the rect, i don't know why, VCL uses the same method and it works nice, someone can help me here?
Bookmarks