 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Charles Ginzel Guest
|
Posted: Tue Aug 26, 2003 10:20 pm Post subject: Detect double-click near column resize for autosize column w |
|
|
I'm trying to implement the standard double-click auto-column width feature
on a TDrawGrid descendant. I believe I have the auto-sizing code figured
out, but I'm looking for a nice easy way to determine that the user has just
double-clicked the column header while the splitter cursor is being shown.
I thought I could just check screen.cursor or control.cursor o nthe dblclick
method, but the value is always zero (the default cursor) even when I know
the splitter cursor is being shown. I'm going to try and determine how
close the cursor is the edge of the column and use that, but I'd like to
hear from anyone with a better idea!
Thanks,
-Charles
|
|
| Back to top |
|
 |
Charles Ginzel Guest
|
Posted: Tue Aug 26, 2003 11:17 pm Post subject: Re: Detect double-click near column resize for autosize colu |
|
|
Here's what I came up with, any comments?!
procedure TResultsGrid.DblClick;
var
MouseCursor: TPoint;
Col, Row: Longint;
RowValues: TStrings;
NewWidth, MaxWidth: Integer;
begin
GetCursorPos(MouseCursor);
MouseCursor := ScreenToClient(MouseCursor);
MaxWidth := 0;
MouseToCell(MouseCursor.X, MouseCursor.Y, Col, Row);
if CellRect(Col, Row).Right - 5 > MouseCursor.X then exit;
if Col > 0 then
begin
for Row := 1 to self.RowCount - 1 do
begin
RowValues := ResultsSet.GetRow(Row - 1);
try
NewWidth := Canvas.TextWidth(RowValues.Strings[Col - 1]) + (2 *
GridLineWidth);
if NewWidth > MaxWidth then
MaxWidth := NewWidth;
finally
RowValues.Free;
end;
end;
ColWidths[Col] := MaxWidth;
end;
end;
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|