Solved

Toutline, TDrawGrid

Posted on 1997-03-15
3
189 Views
Last Modified: 2010-04-03
Do you know how I can make my own onDrawItem, onDrawCell resp. for a Toutline or a TDrawGrid. I've been trying to get bitmaps in both, and change the fonts per item in the Toutline but it doesn't come out right.
Thanks for any hint or example program,
Jan-Willem
0
Comment
Question by:jwk031597
  • 2
3 Comments
 
LVL 3

Expert Comment

by:sperling
Comment Utility
Not sure about what you're asking... Is the problem how to draw in the OnDrawItem, OnDrawCell events?




0
 

Author Comment

by:jwk031597
Comment Utility
Dear sperling,
Thanks for reading my question. The problem is how to draw in the Draw events. I know that's what they're there for, but when I try, either the drawing disappears immediately after drawing, or it isn't drawn at all. Besides that, I can find no examples on Internet where someone has used the Draw-events.
For the Toutline I've come quite close, but I can't seem to combine my drawings with the tree-structure.
0
 
LVL 3

Accepted Solution

by:
sperling earned 200 total points
Comment Utility
Okie...

Here's some sample code which works for me...



procedure TForm1.DrawGrid1DrawCell(Sender: TObject; Col, Row: Longint;
  Rect: TRect; State: TGridDrawState);
begin
  DrawGrid1.Canvas.TextRect(Rect, Rect.Left, Rect.Top, 'XXX');
end;

Rect is the Rectangle within you should draw.
Col and Row are the column and row of the grid which you should draw.
State is a set of values indicating whether the drawgrid hasd focus or not, if the cell you're about to draw is selected, fixed and so on.


procedure TForm1.Outline1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  Outline1.Canvas.TextRect(Rect, Rect.Left, Rect.Top, 'XXX');
end;

Rect is again the rectangle within which you should draw.

Index is the index of the Outline1.Lines which you should draw.

State indicates whether the Outline is focused or not, whether the item you're about to draw is enabled, checked, selected and so on.

The outline must have property Style set to otOwnerDraw.


Still, I'm not sure what the problem is. If this doesn't fix it, please leave a comment where you explain in some more detail what you want to do, and some code showing me what you have done.


Regards,

Erik.

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now