2012년 10월 17일 수요일

초 간단 버추얼트리뷰 예제 (개념잡기)

VirtualTreeView 는 공개된 컴포넌트 중에서 가장 쓸모 있는 것중 하나라고 할 수 있겠네요.
http://www.soft-gems.net/ 에가서 다운 받아 설치하면 됩니다.

기본 개념을 잡기 위하여 초 간단예제를 만들어 봅니다.
폼에 VirtualStringTree(이하 VST) 와 버튼을 올려 놓습니다.
랜덤 한 숫자 6500개를 생성하여 VST에 집어 넣어 보겠습니다.

1. 데이타는 노드에 집어 넣는데, 이 데이터의 길이를 지정해 줍니다.
  - 여기서는 Integer로 넣으니 Integer 가 되겠네요.
  - VST의 Event 에서 OnGetNodeDataSize를 더블크릭하여
procedure TForm3.VirtualStringTree1GetNodeDataSize(Sender: TBaseVirtualTree; var     NodeDataSize: Integer);
begin
  NodeDataSize:= SizeOf(Integer); // PInteger 가 아닙니다.
end;  

2. VST가 저장된 데이터를 화면에 뿌려 주게 지정합니다.
  - VST의 Event 에서 OnGetText를 더블 크릭하여
procedure TForm3.VirtualStringTree1GetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
  TextType: TVSTTextType; var CellText: string);
var iPData: PInteger;
begin
  iPData:= Sender.GetNodeData(Node);
  CellText:= IntToStr(iPData^);
end;

3. 데이터를 VST에 넣습니다.
  - Button을 더블크릭하여
procedure TForm3.Button1Click(Sender: TObject);
var idx: integer;
    iNode: PVirtualNode;
    iPData: PInteger;
begin
  VirtualStringTree1.BeginUpdate;
  for idx := 0 to 65000 do begin
    iNode:= VirtualStringTree1.AddChild(nil);
    iPData:= VirtualStringTree1.GetNodeData(iNode);
    iPData^:= Random(65000);
  end;
  VirtualStringTree1.EndUpdate;
end;

순식간에 자료가 들어가 집니다.

댓글 없음:

tensorflow gpu 사용하기에서

 tensorflow 설치시 주의해야 한다. # Anything above 2.10 is not supported on the GPU on Windows Native python - m pip install "tensorflow<2.11...