Solved

Detect resize on stringgrid column

Posted on 2000-05-11
2
1,470 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now