BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Detect double-click near column resize for autosize column w

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
Charles Ginzel
Guest





PostPosted: Tue Aug 26, 2003 10:20 pm    Post subject: Detect double-click near column resize for autosize column w Reply with quote



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





PostPosted: Tue Aug 26, 2003 11:17 pm    Post subject: Re: Detect double-click near column resize for autosize colu Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.