Einzelnen Beitrag anzeigen

Benutzerbild von Piro
Piro

Registriert seit: 14. Jul 2003
Ort: Flintbek
810 Beiträge
 
Delphi XE2 Professional
 
#9

Re: VST mit ca. 50.000 Datensätze verdammt langsam, warum???

  Alt 7. Dez 2009, 20:47
In dem Videotutorial gab es kein BeginUpdate und EndUpdate. Wozu ist das relevant?

Delphi-Quellcode:
procedure Tfrm_main.FormCreate(Sender: TObject);
begin
 ...
 // Initialisierung - Speichergröße des Node bekanntgeben sonst Exceptions
 vst_network_subnetdetails.NodeDataSize := sizeof(TOSubnetDetailsData);
 ..

Hier meine Methoden für das VST:
Delphi-Quellcode:
procedure Tfrm_main.vst_network_subnetdetailsAdvancedHeaderDraw(
  Sender: TVTHeader; var PaintInfo: THeaderPaintInfo;
  const Elements: THeaderPaintElements);
begin
 if hpeBackground in Elements then
 begin
   PaintInfo.TargetCanvas.Brush.Bitmap := img_bg_20.Picture.Bitmap;

   if PaintInfo.Column <> nil then
     DrawFrameControl(PaintInfo.TargetCanvas.Handle, PaintInfo.PaintRectangle,DFC_BUTTON,DFCS_FLAT or DFCS_ADJUSTRECT);
   PaintInfo.TargetCanvas.FillRect(PaintInfo.PaintRectangle);
 end;
end;

procedure Tfrm_main.vst_network_subnetdetailsAfterItemErase(
  Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
  ItemRect: TRect);
begin
 if Sender.Selected[Node] then
   Exit;

 if Odd(Node.Index) then
   TargetCanvas.Brush.Color := $F8F8F8
 else
   TargetCanvas.Brush.Color := clWhite;

 TargetCanvas.FillRect(ItemRect);
end;

procedure Tfrm_main.vst_network_subnetdetailsBeforeCellPaint(
  Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
  Column: TColumnIndex; CellPaintMode: TVTCellPaintMode; CellRect: TRect;
  var ContentRect: TRect);
var
 SubnetDetailsData : TOSubnetDetailsData;
begin
 // Spalte 0 einfärben, wenn es sich um ein Exclude handelt
 SubnetDetailsData := TOSubnetDetailsData(vst_network_subnetdetails.GetNodeData(Node)^);
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'then
 begin
   if SubnetDetailsData.dhcp_exclude = 0 then
   begin
     TargetCanvas.Brush.Color := $D1D1D1;
     TargetCanvas.FillRect(CellRect);
   end;
 end;
end;

procedure Tfrm_main.vst_network_subnetdetailsCompareNodes(
  Sender: TBaseVirtualTree; Node1, Node2: PVirtualNode; Column: TColumnIndex;
  var Result: Integer);
var
 SubnetDetailsData1 : TOSubnetDetailsData;
 SubnetDetailsData2 : TOSubnetDetailsData;
begin
 SubnetDetailsData1 := TOSubnetDetailsData(vst_network_subnetdetails.GetNodeData(Node1)^);
 SubnetDetailsData2 := TOSubnetDetailsData(vst_network_subnetdetails.GetNodeData(Node2)^);
 
 if column > -1 then
 begin
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'Device'        then Result := CompareStr(SubnetDetailsData1.device, SubnetDetailsData2.device);
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'DHCP'          then Result := CompareStr(SubnetDetailsData1.dhcp_excludedname, SubnetDetailsData2.dhcp_excludedname);
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'DHCP MAC'      then Result := CompareStr(SubnetDetailsData1.dhcp_mac, SubnetDetailsData2.dhcp_mac);
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'Site'          then Result := CompareStr(SubnetDetailsData1.site, SubnetDetailsData2.site);
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'Building'      then Result := CompareStr(SubnetDetailsData1.building, SubnetDetailsData2.building);
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'Floor'         then Result := CompareStr(SubnetDetailsData1.floor, SubnetDetailsData2.floor);
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'Position'      then Result := CompareStr(SubnetDetailsData1.position, SubnetDetailsData2.position);
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'VLAN'          then Result := CompareStr(SubnetDetailsData1.vlan, SubnetDetailsData2.vlan);
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'Subnet Devicethen Result := CompareStr(SubnetDetailsData1.subnetdevice, SubnetDetailsData2.subnetdevice);
   if vst_network_subnetdetails.Header.Columns[Column].Text = 'Description'   then Result := CompareStr(SubnetDetailsData1.description, SubnetDetailsData2.description);
 end;
end;

procedure Tfrm_main.vst_network_subnetdetailsFreeNode(Sender: TBaseVirtualTree;
  Node: PVirtualNode);
var
 SubnetDetailsData : TOSubnetDetailsData;
begin
 SubnetDetailsData := TOSubnetDetailsData(vst_network_subnetdetails.GetNodeData(Node)^);
 SubnetDetailsData.Free;
end;

procedure Tfrm_main.vst_network_subnetdetailsGetText(Sender: TBaseVirtualTree;
  Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
  var CellText: WideString);
var
 SubnetDetailsData : TOSubnetDetailsData;
begin
 SubnetDetailsData := TOSubnetDetailsData(vst_network_subnetdetails.GetNodeData(Node)^);
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'IP Address'    then CellText := SubnetDetailsData.ipaddress;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'Device'        then CellText := SubnetDetailsData.device;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'DHCP'          then CellText := SubnetDetailsData.dhcp_excludedname;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'DHCP MAC'      then CellText := SubnetDetailsData.dhcp_mac;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'Site'          then CellText := SubnetDetailsData.site;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'Building'      then CellText := SubnetDetailsData.building;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'Floor'         then CellText := SubnetDetailsData.floor;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'Position'      then CellText := SubnetDetailsData.position;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'VLAN'          then CellText := SubnetDetailsData.vlan;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'Subnet Devicethen CellText := SubnetDetailsData.subnetdevice;
 if vst_network_subnetdetails.Header.Columns[Column].Text = 'Description'   then CellText := SubnetDetailsData.description;
end;

procedure Tfrm_main.vst_network_subnetdetailsHeaderClick(Sender: TVTHeader;
  Column: TColumnIndex; Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
 if Button = mbLeft then
 begin
   if Column = vst_network_subnetdetails.Header.SortColumn then
     vst_network_subnetdetails.Header.SortDirection := TSortDirection(1-ord(vst_network_subnetdetails.Header.SortDirection))
   else
     vst_network_subnetdetails.Header.SortColumn := Column;
 end;
end;

procedure Tfrm_main.vst_network_subnetdetailsHeaderDrawQueryElements(
  Sender: TVTHeader; var PaintInfo: THeaderPaintInfo;
  var Elements: THeaderPaintElements);
begin
 // Erforderlich für das Headerausehen
 Elements := [hpeBackground];
end;
Und was sagts jetzt dazu?
  Mit Zitat antworten Zitat