Ver Mensaje Individual
  #2  
Antiguo 13-07-2015
Rolando Glez Rolando Glez is offline
Miembro
 
Registrado: nov 2004
Ubicación: Havana
Posts: 66
Reputación: 22
Rolando Glez Va por buen camino
He solucionado la sincronizacion

Hola ,con la ayuda de un amigo se ha resuelto el algoristmo para sincronizar ambos componentes aqui le muestro :
Código Delphi [-]
procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
  //navegacion hacia el root del arbol
  if nodocursor<>root then
  begin
    nodocursor:=nodocursor.GetPrev;
    //buscando el primer nodo del level
    while nodocursor.getPrevSibling<>nil do
    nodocursor:=nodocursor.getPrevSibling;
    if not odd(NodoCursor.Level) then
      Label1.caption:='White Moves'
    else
      Label1.Caption:='Black Moves';
    llena_listbox(nodoCursor);//display nodos
  end;
end;

procedure TForm1.llena_listbox(n: TTreeNode);
var
  n1: TTreeNode;
  plyb:string;
begin 
  ListBox1.Clear;
  nodoCursor := n;
  n1 := n;
  //add todos los nodos sibling al listbox
  Repeat
    ListBox1.Items.Add(n1.text);
    n1 := n1.getNextSibling;
  Until n1 = nil;
end; 

procedure TForm1.ListBox1Click(Sender: TObject); 
var
  n3:Ttreenode;
begin 
  n3:=nodocursor.getnext;
  if n3.Text<>'End' then //ultimo nodo de la rama
  begin
    repeat
      //buscando item seleccionado del listbox en nodos de arbol
      if ListBox1.Items[ListBox1.ItemIndex] = nodoCursor.Text then
        break;
      nodoCursor := nodoCursor.getNextSibling;
    until nodoCursor = nil;
    //actualizando el puntero al arbol 
    nodoCursor := nodoCursor.getFirstChild;
    if not odd(NodoCursor.Level) then
      Label1.caption:='White Moves'
    else
      Label1.Caption:='Black Moves';
    llena_listbox(nodoCursor); //display nodos
  end
end;

Última edición por ecfisa fecha: 13-07-2015 a las 21:16:25. Razón: identación
Responder Con Cita