Ver Mensaje Individual
  #4  
Antiguo 11-01-2019
Avatar de Angel.Matilla
Angel.Matilla Angel.Matilla is offline
Miembro
 
Registrado: ene 2007
Posts: 1.350
Reputación: 19
Angel.Matilla Va por buen camino
Voy más allá. He simplificado el código haciendo un bucle:
Código PHP:
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "VirtualTrees.hpp"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:    // IDE-managed Components
     
TVirtualStringTree *VST;
     
void __fastcall FormCreate(TObject *Sender);
private:    
// User declarations
public:        // User declarations
     
__fastcall TForm1(TComponentOwner);
};

struct TRecBase
{
     
AnsiString Literal;
};

typedef TRecBase *PTrecBase// puntero al registro, se usa siempre.
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif 

Código PHP:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "VirtualTrees"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponentOwner)
     : 
TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
     
AnsiString cLiteral;
     
PTrecBase pRecData;
     
PVirtualNode Nodo;

     
VST->BeginUpdate();
     
VST->Clear();
     
VST->NodeDataSize sizeof(TRecBase);

     for (
int nItem 0nItem 10nItem ++)
     {
          
cLiteral "Nodo " IntToStr(nItem);
          
Nodo     VST->AddChild(NULL);
          
pRecData = (PTrecBaseVST->GetNodeData(Nodo);
          
pRecData->Literal cLiteral;
     }
     
VST->EndUpdate();
}
//--------------------------------------------------------------------------- 
Pues el VirtualStringTree sigue mostrándose como en la imagen de más arriba, pero si corro el programa con el depurador compruebo que pRecData->Literal va cambiando su valor correctamente (Nodo 0, Nodo 1, etc.) pero ese valor no se muestra en el VST. ¿Qué puedo estar haciendo mal?
Responder Con Cita