Recent

Author Topic: AdvancedCustomDrawItem  (Read 3618 times)

kellemes

  • New Member
  • *
  • Posts: 13
AdvancedCustomDrawItem
« on: April 25, 2013, 09:37:41 pm »
So.. working with a treeview..I set the fontstyle of the node based on some database-check done by IsCategory().
This works as expected.. the fontstyle is set just fine.
But when the treeview is shown there is no visual feedback when I select a node.. Events are triggered but I see no selectioncolor, no visual feedback at all.

Now when I replace "if IsCategory(Node.Text)" with something like "if Node.Level = 0" this issue does not occur.

Code: [Select]
procedure TfrmConfig.tvMainAdvancedCustomDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage;
  var PaintImages, DefaultDraw: Boolean);
begin
  with tvMain.Canvas do begin
    if IsCategory(Node.Text) then
      Font.Style := [fsBold]
    else
      Font.Style := [];
    DefaultDraw := true;
  end;
end;                         

Code: [Select]
function IsCategory(sCategory: string) : boolean;
begin
  result := DM.qryEntry.Locate('entryNM;entryCAT', VarArrayOf([sCategory, TRUE]), []);
end;

Any hints?
« Last Edit: April 25, 2013, 09:39:59 pm by kellemes »

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: AdvancedCustomDrawItem
« Reply #1 on: April 26, 2013, 11:27:15 am »
You are doing "advanced custom drawing", so it is up to you to do ALL the drawing. Normally that includes looking at the State parameter and adjusting your painting code to suit.

Though I do see you set DefaultDraw, so maybe there is another bug in LCL? Can you test with other platforms or widgetsets to see if it is only affected in whatever LCL widgetset you use.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

 

TinyPortal © 2005-2018