Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Grid doesn't receive click events

In our project we basically use a main formular as docking site and other forms which are docked to this site. Unfortunately if we place on one
of these forms a grid (e.g. TStringGrid), the forms parent is assigned to a docking panel and the panel is floating no clicks/cell selections are
coming through.

I basically traced down the problem to the grids click handler which checks for Screen.ActiveForm (which is nil then) but I hoped you guys have an
idea how to fix that....

kind regards
   Mike

Attached is a simple demo project which shows that behaviour.

Comments

  • 4 Comments sorted by Votes Date Added
  • hm... having troubles to upload the file so I simply post the dfm + pas code here:

    ---- Project1.dpr -----

    program Project1;

    uses
      Forms,
      Unit1 in 'Unit1.pas' {Form1},
      Unit2 in 'Unit2.pas' {Form2};

    {$R *.res}

    begin
      Application.Initialize;
      Application.MainFormOnTaskbar := True;
      Application.CreateForm(TForm1, Form1);
      Application.CreateForm(TForm2, Form2);
      Application.Run;
    end.


    ------ Unit1.pas -----

    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, sSkinProvider, sSkinManager, ExtCtrls, LMDDckSite;

    type
      TForm1 = class(TForm)
        Button1: TButton;
        LMDDockManager1: TLMDDockManager;
        LMDDockSite1: TLMDDockSite;
        procedure Button1Click(Sender: TObject);
        procedure LMDDockSite1GetSiteInfo(Sender: TObject; DockClient: TControl;
          var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
      private
        { Private-Deklarationen }
      public
        { Public-Deklarationen }
      end;

    var
      Form1: TForm1;

    implementation

    uses Unit2;

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender: TObject);
    var site : TLMDDockPanel;
    begin
         site := TLMDDockPanel.Create(self);
         form2.Parent := site;
         site.Parent := self;

         site.ManualFloat(Rect(form2.Left, form2.Top, form2.Left + form2.Width, form2.Top + form2.Height));
         form2.Show;
    end;

    procedure TForm1.LMDDockSite1GetSiteInfo(Sender: TObject; DockClient: TControl;
      var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
    begin
         CanDock := True;
    end;

    end.


    ----- Unit2.pas -----

    unit Unit2;

    interface

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

    type
      TForm2 = class(TForm)
        Button1: TButton;
        StringGrid1: TStringGrid;
        procedure Button1Click(Sender: TObject);
        procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
          var CanSelect: Boolean);
      private
        { Private-Deklarationen }
        fclickInc : integer;
      public
        { Public-Deklarationen }
      end;

    var
      Form2: TForm2;

    implementation

    uses LMDDckSite;

    {$R *.dfm}

    procedure TForm2.Button1Click(Sender: TObject);
    begin
         Close;
    end;

    procedure TForm2.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    begin
         CanSelect := True;

         StringGrid1.Cells[ACol, ARow] := IntToStr(fClickInc);
         inc(fclickInc);
    end;

    end.



    ------ Unit1.dfm ------

    object Form1: TForm1
      Left = 0
      Top = 0
      Caption = 'Form1'
      ClientHeight = 341
      ClientWidth = 643
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object Button1: TButton
        Left = 64
        Top = 32
        Width = 75
        Height = 25
        Caption = 'Button1'
        TabOrder = 0
        OnClick = Button1Click
      end
      object LMDDockSite1: TLMDDockSite
        AlignWithMargins = True
        Left = 176
        Top = 0
        Width = 449
        Height = 333
        OnGetSiteInfo = LMDDockSite1GetSiteInfo
        TabOrder = 1
        Layout = {
          EFBBBF3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D
          227574662D38223F3E0D0A3C736974656C6973743E0D0A093C73697465206964
          3D2253454C465F53495445223E0D0A09093C7A6F6E65206B696E643D2250414E
          454C222F3E0D0A093C2F736974653E0D0A3C2F736974656C6973743E}
      end
      object LMDDockManager1: TLMDDockManager
        Style.Painter = 'VS2005'
        Left = 64
        Top = 184
      end
    end


    ----- unit2.dfm -----

    object Form2: TForm2
      Left = 0
      Top = 0
      Caption = 'Form2'
      ClientHeight = 341
      ClientWidth = 643
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object Button1: TButton
        Left = 32
        Top = 24
        Width = 75
        Height = 25
        Caption = 'Button1'
        TabOrder = 0
        OnClick = Button1Click
      end
      object StringGrid1: TStringGrid
        Left = 96
        Top = 80
        Width = 465
        Height = 233
        TabOrder = 1
        OnSelectCell = StringGrid1SelectCell
      end
    end


  • Posts: 0 Accepted Answer Vote Up0Vote Down
    Hi,

    This is known bug. And this is a bug of TStringGrid. We had posted this bug to Quality Central, but I don't remeber the bug number.

    So, there are nothing to say from our side. You can ask Embarcadero or post the similar bug report to support our one.
  • Thanks for the info. I thought it might have something to do with a bug in TStringGrid. But can you post me the link to that qc entry so i can at least vote for that report?
Sign In or Register to comment.