Solved

Detect resize on stringgrid column

Posted on 2000-05-11
2
1,492 Views
Last Modified: 2008-03-03
In Delphi 5, is there a way to detect when a TStringGrid column is being resized?
0
Comment
Question by:jpoz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
rene100 earned 10 total points
ID: 2802023
ok, here it comes:

unit StringGridEx;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids;

type
  TStringGridEx = class(TStringGrid)
  private
    FColWidthsChanged: TNotifyEvent;
    procedure ColWidthsChanged; override;
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    property OnColWidthsChanged: TNotifyEvent read FColWidthsChanged write FColWidthsChanged;
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Eigene', [TStringGridEx]);
end;

procedure tStringgridEx.ColWidthsChanged;
begin
inherited;
if Assigned(OnColWidthsChanged) then
   OnColWidthsChanged(Self)
end;
end.

now every time the width of a column has has been changed, OnColWidthsChanged is called.

regards
rene



0
 

Author Comment

by:jpoz
ID: 2802176
Very quick reply, I actually came up with another solution.  However, 'A' for effort, you can have the points.

My answer - in OnMouseUp, I determined where the mouse was based on the CellRect, and determined if it was within the area where the resize occurs.

procedure StringGrid1.OnMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState;
  X, Y: Integer)
var
  CellRect : TRect;
begin
  CellRect :=
    StringGrid1.CellRect(CellCoord.x,
                         CellCoord.y);

  if (x >= (CellRect.Right-3))
     or (x <= (CellRect.Left+3)) then
   { resize detected }
end;
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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