动态创建form,把要传递的数据作为他的字段
解决方案 »
- 请问cxgrid 录入信息时 怎么添加本地图片 保存到数据库
- MID DlL窗体与Application.Messagebox 结合后控件失效???
- keiy 接分
- 请问谁有下载delphi教程的网站
- 一个奇怪的问题,真的狠奇怪
- 停靠工具栏如何做?工具栏上可以任何其它控件
- 用DELPHI做了个DVD播放器,但当没鼠标时怎选电影里的PLAY键?
- MSComm控件可以封装在动态链接库吗?
- 最近正在研究Smart Card,谁有读写卡的例子,我的读卡器是Alcor Micro的?
- 关于windows消息问题:::::wndproc(var msg:tmessage)在哪里??inherit怎样使用?...还有更多请进..!!!
- 很有兴趣!
- 怎么对Access数据库进行加密和破密? 谢谢!!
在Form2中Uses Form1, 就可以使用 Form1.Var1
举例说明好吗!在线等待。
piip
一个窗口在uses中加入窗体pas的名字,另一个窗口在implementation后加入一个uses,并在这个uses中加入前一个窗体pas的名字
后一个为主窗体,前一个为子窗体
再就是是外部程序的调用,需要用到sendmessage或postmessage
每个单元互访单元全局对。
像
Unit1.Form1.edit1.Text
Unit2.Form2.Edit1.Text
这样。VCL的做法:
设:
Form2要访问Form1的过程,或属性
Form2是依赖于Form1的对象。
1:
procedure TForm1.GetSome;
begin
with TForm2.Create(Self) do
try
if ShowModal = mrOK then
begin
Self.Param := Param;
...
end;
finally
Free;
end;
end;2:
procedure TForm1.GetSome;
begin
if not Assigned(FForm2) then
begin
FForm2 := TForm2.Create(Self);
FForm2.OwnerForm := Self;
//FForm2.DateField := Query1.FieldByName('date');//传指针对象
end;
FForm2.Show;
end;procedure TForm2.OnClose;
begin
FOwnerForm.Param := Param;
//or Call FOwnerForm.SomeProcdure(Param);
// if not (DateField.DateSet.State in [dsEdit, dsInsert]) then
// DateField.DataSet.Edit;
// DateField.AsDateTime := Date1.Date;
end;
Form1中private
FSenderString: String;
public
property SenderString: String read FSenderString write FSenderString;...
FSenderString:='****'; //赋值
...
Form2中引用Form1的单元...
var
S: String;
begin
S:=Form1.SenderString;end;
...
unit ...interfaceuses
...type
TForm2=class(TForm)
...
private
FParam: string;
procedure DoSomething;
public
constructor Create(AOwner: TComponent; AParam: string); reintroduce;
end;implementationTForm2.Create(AOwner: TComponent; AParam: string);
begin
FParam := AParam;
end;procedure TForm2.DoSomething
begin
if FParam <> '' then
//Do something here
end;//In TForm1's unit
//Calls TForm2
procedure TForm1.Test;
var
Param: string;
begin
//Set Param's value
with TForm2.Create(Application,Param) do
try
ShowModal;
//Other processes here
finally
Free;
end;
end;