How to display the resource name in the allocation.
Set the Options to include OwnerDrawAllocations, then insert the following code into the OnOwnerDrawAllocation event handler. Ensure that the RowHeight property is set to a large enough value for the font being used, or else no text will be shown.
procedure TMyForm.RACOwnerDraw(Sender: TObject; Resource: TssResource; Allocation: TssResourceAllocation; Canvas: TCanvas; Rct: TRect); var yb, yt, xs, xe, tw, th: integer; begin xs := Rct.Left; xe := Rct.Right; yt := Rct.Top; yb := Rct.Bottom; with Canvas do begin // for simplicity ignore the Resource.Style // and just draw blocks if xs = xe then begin MoveTo(xs, yt); LineTo(xs, yb); end else Rectangle(xs, yt, xe, yb); // don't show the description if we're // drawing the shadow if Pen.Color <> RAC.ShadowColor then begin tw := TextWidth(Resource.Name); th := TextHeight(Resource.Name); // is there room for the text in the rectangle? if (xe - xs > tw) and (yb - yt > th) then begin Brush.Style := bsClear; TextOut((xe + xs - tw) div 2, (yb + yt - th) div 2, Resource.Name); end; // else leave the block unlabelled end; end; end;
- Screen Shots
- FAQ & Getting Started
- User Comments
- Support Forum
- Change History
|What People Say|
I just wanted to let you know that I love your component! I find it extensible, easy to use, and the performance is top notch. I even think I understand much of the source. You hit a home run with this one!
Tom Kopeika, Illinois