Slut,
est-il possible d'imbriquer une fonction dans une autre ??
Voilà ce que je voudrais faire : je crée une fiche dynamiquement dans la méthode ci-dessous et je lui ajoute des composants (Button11 et ComboBox1) et je voudrais définir la méthode Button11Click dans cette méthode (comme c'est écrit ci-dessous...) pour pouvoir accéder à FormH et ComboBox1 (sinon, si je définis Button11Click hors de cette méthode, je ne peux plus y accéder). Mais ça ne compile pas de cette façon...
Alors y-a-t-il moyen de corriger, ou alors faut-il carrément faire autrement ? Dans ce cas, comment accéder aux composants FormH et ComboBox1 hors de la méthode Button3Click ?
(extrait)
void __fastcall TForm1::Button3Click(TObject *Sender)
{
unsigned int Winh = 300, Winl = 300;
TForm *FormH = new TForm(Form1); /*create a new form dynamically to choose the file to edit*/
FormH->Width=Winl; /*set the height and width of the child window*/
FormH->Height=Winh;
FormH->Visible=true; //display the child window
FormH->Align=alNone;
FormH->OnClose=FormCloseW;
TComboBox *ComboBox1 = new TComboBox (FormH);
ComboBox1->Parent = FormH;
ComboBox1->Style = csDropDownList;
TButton *Button11 = new TButton (FormH);
Button11->OnClick = Button11Click(TObject *Sender)
{
filetoedit = ComboBox1->Text;
ShellExecute(NULL, // Handle de la fenêtre parent
"open", // Action à effectuer
"notepad.exe", // Fichier
filetoedit.c_str(), // Paramètres
"", // Répertoire par défaut
SW_SHOWDEFAULT // Manière d'afficher
);
FormH->Close();
}
Button11->Parent = FormH;
Button11->Caption = "OK" ;
Button11->Left = 50;
Button11->Top = 50;
//ETC.....
}