![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
Всех с наступающим!
Дорогие формучане, спасайте – туплю Есть "форма1", на ней динамически создаётся фрейм, и есть "форма2". Как из "форма2" воздействовать обьекты в фрейме? Суть: в «форма2» в Edit вводиться строка, и её нужно добавить в Listbox который находиться в фрейме. Код:
var f: Tframe; procedure TForm1.N3Click(Sender: TObject); begin if f<>nil then begin FreeAndNil(f); end; f:=TFrame11.Create(nil); f.Align:=alClient; f.Parent:=Form1; f.Visible:=true; end; |
|
#2
|
|||
|
|||
|
Вызывать форму 2 прямо из фрейма. Причем, я бы сделал так, что бы форма просто возвращала строку, а добавлял бы строку сам фрейм.
Код:
// TForm2, Просто пример function TForm2.Execute : String; begin ShowModal; Result := Edit1.Text; end; // TFrame1 procedure TFrame1.Button1Click(Sender : TObject); begin ListBox1.Items.Add(Form2.Execute); end; |
| Этот пользователь сказал Спасибо lmikle за это полезное сообщение: | ||
Killduettm (01.01.2013)
| ||
|
#3
|
|||
|
|||
|
Спасибо за решение, но:
Ошибка: does not contain a member named 'Execute' -Юзаю Embarcadero RAD Studio XE2 |
|
#4
|
||||
|
||||
|
Нужно добавить эту функцию в секцию public формы.
|
| Этот пользователь сказал Спасибо angvelem за это полезное сообщение: | ||
Killduettm (01.01.2013)
| ||
|
#5
|
|||
|
|||
|
Извените за конкретную тупость:
Form1 Код:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
f: Tframe;
implementation
{$R *.dfm}
uses Unit2;
procedure TForm1.Button1Click(Sender: TObject);
begin
if f<>nil then
begin
FreeAndNil(f);
end;
f:=TFrame2.Create(nil);
f.Align:=alClient;
f.Parent:=Form1;
f.Visible:=true;
end;
end.Frame2 Код:
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TFrame2 = class(TFrame)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
end;
implementation
{$R *.dfm}
uses Unit3;
procedure TFrame2.Button1Click(Sender: TObject);
begin
Edit1.text:=Form3.Execute;
end;
end.Код:
unit Unit3;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
Edit1: TEdit;
private
{ Private declarations }
public
function TForm3.Execute : String;
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
function TForm3.Execute(): String;
begin
ShowModal;
Result := Edit1.Text;
end;
end.По прежнему ошибка does not contain a member named 'Execute' |
|
#6
|
||||
|
||||
|
В полях формы не пишется указание на саму форму
Код:
...
public
function Execute : String;
end;
... |
| Этот пользователь сказал Спасибо angvelem за это полезное сообщение: | ||
Killduettm (01.01.2013)
| ||
|
#7
|
|||
|
|||
|
Ребята, спасибо огромное! Всё заработало!
|