Solved

Detect resize on stringgrid column

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 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