Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi GetDisplayRect return 0 (left,right,top,bottom) (https://www.delphipraxis.net/160111-getdisplayrect-return-0-left-right-top-bottom.html)

jfarissi 28. Apr 2011 09:25


GetDisplayRect return 0 (left,right,top,bottom)
 
Hello,

GetDisplayRect return 0 (left,right,top,bottom)

I can't show the button in the VST !?
any idea ?



Delphi-Quellcode:
  TNodeData1 = class
  public
    Column0: String;
    Column1: String;
    Column2: String;
    Column3: String;
    Column4: String;
    Column5: String;
    Column6: TButton;

  end;


procedure TFormb.DoResize(node: pvirtualnode);
var
  CellRect: trect;
  d: TNodeData1;
begin
  d:=TNodeData1(VirtualStringTree1.GetNodeData(node)^);
  CellRect := VirtualStringTree1.GetDisplayRect(node, 6, false);
  with d.Column6 do
  begin
    Left  := CellRect.Left;
    Width := CellRect.Right-CellRect.Left;
    Top   := CellRect.Top;
    Height := CellRect.Bottom-CellRect.Top;
  end;
end;




Procedure TFormb.SPMEditQueryGrid(DBName, Statement: String; Target:TVirtualStringTree; Titles: Boolean);
Var Col,i,j, Lin, nCol: Integer;
    d: TNodeData1;
begin

      With TQuery.Create(Nil) Do
      Try
        DatabaseName := DBName;
        SQL.Text := Statement;
        Open;
        If Not IsEmpty Then
        Begin
          //For Col := 0 To FieldCount - 1 Do
          //   Target.Header.Columns[col].Text := Fields[Col].FieldName;
          While Not Eof Do
          Begin
            d:=TNodeData1.Create;
            d.Column1 := Fieldbyname('id_employe').AsString;
            d.Column2 := Fieldbyname('Collaborateur').AsString;
            d.Column3 := Fieldbyname('INTITULE_SERVICE').AsString;
            d.Column4 := formatfloat('0.00',Fieldbyname('NOMBRE_JOURS').Asfloat);
            d.Column5 := formatfloat('0.00',Fieldbyname('Montant').Asfloat);
            edtXnode := Target.AddChild(Target.FocusedNode,d);
            d.Column6 := TButton.Create(self);
            with d.Column6 do
            begin
              inc(incnamebutton);
              name   := 'tata'+inttostr(incnamebutton)+Fieldbyname('id_employe').AsString;
              Parent := VirtualStringTree1;
              OnClick := ButtonClick;
              Target.inValidateNode(edtXnode);
              DoResize(edtXnode);
            end;

            Next;
          End;
        End;
      Finally
        Close;
        Free;
      End;
end; { QueryGrid }

Thanks

DeddyH 28. Apr 2011 09:38

AW: GetDisplayRect return 0 (left,right,top,bottom)
 
Zitat:

TBaseVirtualTree.GetDisplayRect Method
Returns the visible region used by the given node in client coordinates.
Pascal
function GetDisplayRect(Node: PVirtualNode; Column: TColumnIndex; TextOnly: Boolean; Unclipped:
Boolean = False): TRect;
Description
If the given node cannot be found (because one of its parents is collapsed or it is invisible) then an empty rectangle is
returned. If TextOnly is true then only the text bounds are returned, that is, the resulting rectangle's left and right
border are updated according to the bidi mode, alignment and text width of the node. If Unclipped is true (which only
makes sense if also TextOnly is true) then the calculated text rectangle is not clipped if the text does not entirely fit into
the text space. This is special handling needed for hints.
If Column is NoColumn( see NoColumn Constant, page 686) then the entire client width is used before determining the
node's width otherwise the bounds of the particular column are used.
Notes
Column must be a valid column and is used independent of whether the header is visible or not.
Taken from here, hope it helps.

jfarissi 28. Apr 2011 12:16

AW: GetDisplayRect return 0 (left,right,top,bottom)
 
thanks that work


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:00 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz