Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-10

VirtualTreeView bug

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

I'm trying to figure out why this keep on existing on VT from CCR virtualtree-new .

The problem is that it display only the first char instead of the whole string.

My code:
------------------
....
type

  PTreeData = ^TTreeData;
  TTreeData = record
    Column1,
    Column2,
    Column3  : String;
  end;
procedure TForm1.FormCreate ( Sender : TObject ) ;
var
  Column : TVirtualTreeColumn;
  i      : integer;
begin
  Randomize;
  VST.Header.Options := VST.Header.Options +[hoVisible];
  VST.Header.Style   := hsFlatButtons;
  for i := 1 to 3 do
    begin
     Column         := VST.Header.Columns.Add;
     Column.Text    := 'column #' + IntToStr(i);
     Column.Options := Column.Options + [coAllowClick, coResizable];
     Column.Width   := UTF8Length(Column.Text) + 100;
    end;
  VST.TreeOptions.MiscOptions      := VST.TreeOptions.MiscOptions +
                                       [toEditable,toGridExtensions];
  VST.TreeOptions.SelectionOptions := VST.TreeOptions.SelectionOptions +
                                       [toExtendedFocus, toMultiSelect];
end;
procedure TForm1.btnAddRootClick ( Sender : TObject ) ;
Var
  Data  : PTreeData;
  XNode : PVirtualNode;
  Rand  : Integer;
begin
  Rand  := Random(99);
  XNode := VST.AddChild(nil);
  if VST.AbsoluteIndex(XNode) > -1 then
  Begin
   Data := VST.GetNodeData(XNode);
   Data^.Column1 := 'One ' + IntToStr(Rand);
   Data^.Column2 := 'Two ' + IntToStr(Rand + 10);
   Data^.Column3 := 'Three ' + IntToStr(Rand - 5);
  End;
end;
procedure TForm1.VSTChange ( Sender : TBaseVirtualTree; Node : PVirtualNode ) ;
begin
  VST.Refresh;
end;
procedure TForm1.VSTFocusChanged ( Sender : TBaseVirtualTree;
  Node : PVirtualNode; Column : TColumnIndex ) ;
begin
  VST.Refresh;
end;
procedure TForm1.VSTGetNodeDataSize ( Sender : TBaseVirtualTree;
  var NodeDataSize : Integer ) ;
begin
  NodeDataSize := SizeOf(TTreeData);
end;
procedure TForm1.VSTGetText ( Sender : TBaseVirtualTree; Node : PVirtualNode;
  Column : TColumnIndex; TextType : TVSTTextType; var CellText : WideString ) ;
var
  Data : PTreeData;
begin
  Data := VST.GetNodeData(Node);
  case Column of
    0 : CellText := Data^.Column1;
    1 : CellText := Data^.Column2;
    2 : CellText := Data^.Column3;
  end;
end;
procedure TForm1.VSTNewText ( Sender : TBaseVirtualTree; Node : PVirtualNode;
  Column : TColumnIndex; NewText : WideString ) ;
var
  Data : PTreeData;
begin
  Data := VST.GetNodeData(Node);
  case Column of
    0 : Data^.Column1 := NewText;
    1 : Data^.Column2 := NewText;
    2 : Data^.Column3 := NewText;
  end;
end;

...

-------------------------
Any ideas why it happens and how to solve this ?

Thanks,
Ido
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vt.png
Type: image/png
Size: 12548 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121018/71194774/attachment-0001.png>

Reply by email

luiz americo pereira camara
to ik

2012/10/18 ik

Show quoted text 5 lines
Hello, I'm trying to figure out why this keep on existing on VT from CCR virtualtree-new .

A new release is already done (just i could not upload to Lazarus-ccr) so maybe is already fixed.

Anyway you can send the complete project here so i can test

Luiz

Show quoted text 120 lines
The problem is that it display only the first char instead of the whole string. My code: ------------------ .... type PTreeData = ^TTreeData; TTreeData = record Column1, Column2, Column3 : String; end; procedure TForm1.FormCreate ( Sender : TObject ) ; var Column : TVirtualTreeColumn; i : integer; begin Randomize; VST.Header.Options := VST.Header.Options +[hoVisible]; VST.Header.Style := hsFlatButtons; for i := 1 to 3 do begin Column := VST.Header.Columns.Add; Column.Text := 'column #' + IntToStr(i); Column.Options := Column.Options + [coAllowClick, coResizable]; Column.Width := UTF8Length(Column.Text) + 100; end; VST.TreeOptions.MiscOptions := VST.TreeOptions.MiscOptions + [toEditable,toGridExtensions]; VST.TreeOptions.SelectionOptions := VST.TreeOptions.SelectionOptions + [toExtendedFocus, toMultiSelect]; end; procedure TForm1.btnAddRootClick ( Sender : TObject ) ; Var Data : PTreeData; XNode : PVirtualNode; Rand : Integer; begin Rand := Random(99); XNode := VST.AddChild(nil); if VST.AbsoluteIndex(XNode) > -1 then Begin Data := VST.GetNodeData(XNode); Data^.Column1 := 'One ' + IntToStr(Rand); Data^.Column2 := 'Two ' + IntToStr(Rand + 10); Data^.Column3 := 'Three ' + IntToStr(Rand - 5); End; end; procedure TForm1.VSTChange ( Sender : TBaseVirtualTree; Node : PVirtualNode ) ; begin VST.Refresh; end; procedure TForm1.VSTFocusChanged ( Sender : TBaseVirtualTree; Node : PVirtualNode; Column : TColumnIndex ) ; begin VST.Refresh; end; procedure TForm1.VSTGetNodeDataSize ( Sender : TBaseVirtualTree; var NodeDataSize : Integer ) ; begin NodeDataSize := SizeOf(TTreeData); end; procedure TForm1.VSTGetText ( Sender : TBaseVirtualTree; Node : PVirtualNode; Column : TColumnIndex; TextType : TVSTTextType; var CellText : WideString ) ; var Data : PTreeData; begin Data := VST.GetNodeData(Node); case Column of 0 : CellText := Data^.Column1; 1 : CellText := Data^.Column2; 2 : CellText := Data^.Column3; end; end; procedure TForm1.VSTNewText ( Sender : TBaseVirtualTree; Node : PVirtualNode; Column : TColumnIndex; NewText : WideString ) ; var Data : PTreeData; begin Data := VST.GetNodeData(Node); case Column of 0 : Data^.Column1 := NewText; 1 : Data^.Column2 := NewText; 2 : Data^.Column3 := NewText; end; end; ... ------------------------- Any ideas why it happens and how to solve this ? Thanks, Ido -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121018/47fd3d79/attachment.html>

Reply by email

ik
to luiz americo pereira camara
luiz americo pereira camara wrote 15 lines
2012/10/18 ik > > Hello, > > I'm trying to figure out why this keep on existing on VT from CCR > virtualtree-new . A new release is already done (just i could not upload to Lazarus-ccr) so maybe is already fixed. Anyway you can send the complete project here so i can test

I attched it to here, hopefully others might also see and might find that I do something wrong, if it's not a bug

Luiz

Ido

Show quoted text 129 lines
> > > The problem is that it display only the first char instead of the whole > string. > > My code: > ------------------ > .... > type > PTreeData = ^TTreeData; > TTreeData = record > Column1, > Column2, > Column3 : String; > end; > > > procedure TForm1.FormCreate ( Sender : TObject ) ; > var > Column : TVirtualTreeColumn; > i : integer; > begin > Randomize; > VST.Header.Options := VST.Header.Options +[hoVisible]; > VST.Header.Style := hsFlatButtons; > for i := 1 to 3 do > begin > Column := VST.Header.Columns.Add; > Column.Text := 'column #' + IntToStr(i); > Column.Options := Column.Options + [coAllowClick, coResizable]; > Column.Width := UTF8Length(Column.Text) + 100; > end; > > VST.TreeOptions.MiscOptions := VST.TreeOptions.MiscOptions + > [toEditable,toGridExtensions]; > VST.TreeOptions.SelectionOptions := VST.TreeOptions.SelectionOptions + > [toExtendedFocus, toMultiSelect]; > > end; > > procedure TForm1.btnAddRootClick ( Sender : TObject ) ; > Var > Data : PTreeData; > XNode : PVirtualNode; > Rand : Integer; > begin > Rand := Random(99); > XNode := VST.AddChild(nil); > > if VST.AbsoluteIndex(XNode) > -1 then > Begin > Data := VST.GetNodeData(XNode); > Data^.Column1 := 'One ' + IntToStr(Rand); > Data^.Column2 := 'Two ' + IntToStr(Rand + 10); > Data^.Column3 := 'Three ' + IntToStr(Rand - 5); > End; > > end; > > procedure TForm1.VSTChange ( Sender : TBaseVirtualTree; Node : > PVirtualNode ) ; > begin > VST.Refresh; > end; > > procedure TForm1.VSTFocusChanged ( Sender : TBaseVirtualTree; > Node : PVirtualNode; Column : TColumnIndex ) ; > begin > VST.Refresh; > end; > > procedure TForm1.VSTGetNodeDataSize ( Sender : TBaseVirtualTree; > var NodeDataSize : Integer ) ; > begin > NodeDataSize := SizeOf(TTreeData); > end; > > procedure TForm1.VSTGetText ( Sender : TBaseVirtualTree; Node : > PVirtualNode; > Column : TColumnIndex; TextType : TVSTTextType; var CellText : > WideString ) ; > var > Data : PTreeData; > begin > Data := VST.GetNodeData(Node); > case Column of > 0 : CellText := Data^.Column1; > 1 : CellText := Data^.Column2; > 2 : CellText := Data^.Column3; > end; > end; > > procedure TForm1.VSTNewText ( Sender : TBaseVirtualTree; Node : > PVirtualNode; > Column : TColumnIndex; NewText : WideString ) ; > var > Data : PTreeData; > begin > Data := VST.GetNodeData(Node); > case Column of > 0 : Data^.Column1 := NewText; > 1 : Data^.Column2 := NewText; > 2 : Data^.Column3 := NewText; > end; > end; > > ... > > ------------------------- > Any ideas why it happens and how to solve this ? > > Thanks, > Ido > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtv.tar.gz
Type: application/x-gzip
Size: 67087 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121018/fba40102/attachment-0001.bin>

Reply by email

luiz americo pereira camara
to ik

2012/10/19 ik

Show quoted text 16 lines
On Fri, Oct 19, 2012 at 2:58 AM, luiz americo pereira camara wrote: > > > 2012/10/18 ik >> >> >> I attched it to here, hopefully others might also see and might find >> that I do something wrong, if it's not a bug > > > Replace Widestring references by String Thanks, that solved it. When was it changed ?

More than 3 years ago (widestring had been replaced even before):

http://lazarus-ccr.svn.sourceforge.net/viewvc/lazarus-ccr/components/virtualtreeview-new/VirtualTrees.pas?view=log&pathrev=1034

The demo code in wiki is based in the original VTV port

Luiz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121019/42ef0f83/attachment.html>

Reply by email