AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

VirtualStringTree and a Queue

Ein Thema von sdean · begonnen am 1. Sep 2013
Antwort Antwort
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#1

VirtualStringTree and a Queue

  Alt 1. Sep 2013, 21:41
Delphi-Version: 7
Hi i've a project that uses the VirtualStringTree , with this Record :

Delphi-Quellcode:
type

  TStudentsSession = record
    StudentName : String;
    StudentClass : String;
    StudentHandRaised:Boolean;

  end;
And i've these Procedures :

Delphi-Quellcode:
Procedure TMainForm.StudentHandRaised(AStudentName:String)
var
    Node:PVirtualNode;
    Data:^TStudentsSession;
begin
    Node:=StudentsVst.GetFirst;
    while Node<>nil do begin
      Data:=StudentsVst.GetNodeData(Node);
      if Data.StudentName=AStudentName then
        begin
          Data.StudentHandRaised:=True;
          Break;
        end ;
       Node:=StudentsVst.GetNext(Node);
  end;
  end;
  
Procedure TMainForm.StudentHansDown(AStudentName:String)
var
    Node:PVirtualNode;
    Data:^TStudentsSession;
begin
    Node:=StudentsVst.GetFirst;
    while Node<>nil do begin
      Data:=StudentsVst.GetNodeData(Node);
      if Data.StudentName=AStudentName then
        begin
          Data.StudentHandRaised:=False;
          Break;
        end ;
       Node:=StudentsVst.GetNext(Node);
  end;
  end;


We Have these 4 Students in Order:
StudentA
StudentB
StudentC
StudentD


What i want is this :

* StudentB raises his Hand :

StudentB
StudentA
StudentC
StudentD


* StudentC raises his Hand :

StudentB
StudentC
StudentA
StudentD


StudentC will not Jump on StudentB ( Because StudentB is still raising his Hand )

* StudentD raises his Hand :

StudentB
StudentC
StudentD
StudentA


StudentC will not Jump on StudentB or StudentC ( Because both are still raising their Hands )

* StudentB withdraws his hand :


StudentC
StudentD
StudentA
StudentB


* StudentB will be moved to the last position


I tried to use this procedure :

Delphi-Quellcode:
procedure TMainForm.ReArrangeStudents;
var
    Node,PreviNode: PVirtualNode;
    Data:^TStudentsSession;
begin
  Node:=StudentsVst.GetFirst;
  while Node<>nil do begin
 Data:=StudentsVst.GetNodeData(Node);

     if Data.StudentHandRaised Then
       PreviNode :=StudentsVst.GetPrevious(Node,false)
       else PreviNode := StudentsVst.GetNext(Node);
       StudentsVst.MoveTo(Node,PreviNode,amInsertBefore,false);

        Node:=StudentsVst.GetNext(Node);
  end;

end;

But this ends with always jumping to the First position .
So please can some one helps me to Do the correct Order .

Geändert von sdean ( 1. Sep 2013 um 22:43 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:12 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