用delphi写一开发平台用平台开发程序。
工程A有窗体1,类TFrom1.类为自动生成。
工程B有窗体1,类TFrom1.类为自动生成。现在在工程A中窗体1上添加一按钮 点击弹出工程B的窗体1.uses
VT5004Unit2procedure Button1Click(Sender: TObject);
var
nForm:TForm1;
begin
nForm := TForm1.Create(Application);
nForm.Show;
end;其中VT5004Unit2为工程B文件。
现在的效果是点击按钮 弹出工程A的窗体1
而要的效果应该是弹出工程B的窗体1 应该怎么办
工程A有窗体1,类TFrom1.类为自动生成。
工程B有窗体1,类TFrom1.类为自动生成。现在在工程A中窗体1上添加一按钮 点击弹出工程B的窗体1.uses
VT5004Unit2procedure Button1Click(Sender: TObject);
var
nForm:TForm1;
begin
nForm := TForm1.Create(Application);
nForm.Show;
end;其中VT5004Unit2为工程B文件。
现在的效果是点击按钮 弹出工程A的窗体1
而要的效果应该是弹出工程B的窗体1 应该怎么办
var
nForm:TForm1;
begin
nForm := TForm1.Create(Application);
nForm.Show;
end;
你这个既然要调用工程B的窗口,为何还要到这里定义1个nForm。这就明显有问题嘛。你这里应该是
要调用工程B中定义的全局窗口对象才对啊。
为什么?
nForm := VT5004Unit2.TForm1.Create(Application);
类名前加单元名予以明确限制,很正常啊
VT5004Unit2 procedure Button1Click(Sender: TObject);
var
nForm:TForm1;
begin
nForm := TForm1.Create(Application);
nForm.Show;
end;
这段代码是自动生成的?
自动创建时,把tfrom1改为Tform_yyyymmddhhnnss?为什么uses了VT5004Unit2,tform1却还是另一个单元的tform?
------------------------------------加单元名是正确的,DELPHI的类的命名空间是包含单元名的。但是首先你声明变量的时候,也要加上单元名。
工程B有窗体1,类TFrom1.类为自动生成。 一个工程取调用另一个工程的?你强
var
nForm: VT5004Unit2.TForm1;
或许可以通过改变命名类的命名规则来改变 不过好像得去改变delphi底层的东西。
AActualObject: Classes.TPersistent;AActualObject := Classes.TPersistent.Create;你有没写错地方?
procedure TatCustomScripter.InternalCompileError(msg: string; row, col: integer; AScript: TatScript);
var
AShow: boolean;
begin
AShow := true;
if AScript.FUnitName <> '' then
msg := 'Unit ' + AScript.FUnitName + ': ' + msg; if not AScript.FIsDebugScript then
DoCompileError(msg, row, col, AShow, AScript);
if AShow then
// when the IDE is running an Exception can be triggered here
// when debugging options "stop on exception" is enabled.
// This exception is handled correct when run not from the IDE
raise EatCompileError.Create(msg+'.'#13#10+'Source position: '+inttostr(row)+','+inttostr(col))
else
Abort;
end在raise EatCompileError.Create这边停下来了
估计是解释器不支持 单元名作为前缀那么,自动创建时,把Tfrom1改为Tform_yyyymmddhhnnss?
楼主太牛了!