Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TStringGrid.DefaultDrawing vs Marlett Font

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
Hi all,

I'm using D2006:XP-SP2.

My VCL (based on TStringGrid) implements a column's header sorting. That is, when the user clicks on the first row, the grid is sorted according to values of the specified column (FixedCols+FixedRows).

Ascending and Descending are possible and to show the order used, I'm printing a little arrow on the right corner of the cell clicked (font Marlett char '5'+'6') within OnDrawCell event.

This is working fine for all my forms (~30) except one:
'5'/'6' is displayed in Tahoma Font instead of Marlett. Here's my code:
------------------------------
procedure MyGrid.DrawCell(ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
inherited;
Canvas.Font.Name := 'Marlett';
if iColSort < 0 then
DrawText(Canvas.Handle, '5', -1, Rect,
DT_SINGLELINE or DT_CENTER or DT_VCENTER)
else if iColSort > 0 then
DrawText(Canvas.Handle, '6', -1, Rect,
DT_SINGLELINE or DT_CENTER or DT_VCENTER);
Canvas.Font.Name := 'Tahoma';
end;
------------------------------

If I set DefaultDrawing to False (while everywhere else is True), it's working fine... But I would like to keep DefaultDrawing to True to be more consistent in my code.

Thanks a lot for reading,

Rej Cloutier

 
NB The grid is inside a TPanel and I tried to change following lines with all possibilities...

Form.Font.Name := 'Tahoma' / 'MS Sans Serif'
Form.Panel.ParentFont := True / 'False'
Form.Grid.ParentFont := True / 'False'

Line [Canvas.Font.Name := 'Marlett';] (check 1st post)
really affects Font.Name but DrawText still use 'Tahoma'...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top