Hola aldemar.bohorqu.
Una forma bastante sencilla de hacerlo es:
- Al form que tiene el TLabeledEdit y el TRadioGroup, agregale un TPanel y dentro de él un TImage.
- A la propiedad Caption del TPanel ponele un texto como "Click para cargar foto" y ajusta su tamaño a gusto.
- Pone la propiedad Streetch del TImage = true y la propiedad Align = alClient para que ocupe toda la superficie del panel.
- Agrega dos TButton uno para añadir datos y otro para mostrarlos.
Código:
#include <fstream>
#include <string>
#define AGENDA "C:\\AGENDA.TXT"
using namespace std;
AnsiString PhotoName = "";
void __fastcall TForm1::LabeledEdit1Enter(TObject *Sender) {
PhotoName = "";
LabeledEdit1->Text = "";
RadioGroup1->ItemIndex = -1;
Image1->Picture = NULL;
}
void __fastcall TForm1::Image1Click(TObject *Sender) {
if (OpenPictureDialog1->Execute()) {
PhotoName = OpenPictureDialog1->FileName;
Image1->Picture->LoadFromFile(PhotoName);
}
}
void __fastcall TForm1::btnGuardarClick(TObject *Sender) {
ofstream agenda;
AnsiString s;
s = LabeledEdit1->Text + "," +
RadioGroup1->Items->Strings[RadioGroup1->ItemIndex] + "," +
PhotoName;
agenda.open(AGENDA, ios::out | ios::app);
agenda << s.c_str() << endl;
agenda.close();
}
void __fastcall TForm1::btnMostrarClick(TObject *Sender) {
string str = LabeledEdit1->Text.c_str();
if (str.size()) {
ifstream agenda;
agenda.open(AGENDA, ios::in);
string line;
size_t found = string::npos;
while (agenda.good() && found == string::npos) {
getline(agenda, line, '\n');
found = line.find(str);
}
if (found != string::npos) {
TStrings *TS = new TStringList;
__try {
TS->Delimiter = ',';
TS->DelimitedText = line.c_str();
RadioGroup1->ItemIndex = RadioGroup1->Items->IndexOf(TS->Strings[1]);
Image1->Picture->LoadFromFile(TS->Strings[2]);
}
__finally {
delete TS;
}
}
agenda.close();
}
}
Toma en cuenta que es un código orientativo y no realiza comprobación de tipo alguno, por ejemplo te permite guardar varios nombres iguales
Saludos.
Edito: Por algún motivo el mensaje quedó truncado a las primeras líneas y no me dí cuenta hasta ahora, disculpas.