我在Dll中加载了一个窗体,然后在主应用程序中调用Dll中显示窗体的函数,将dll中的窗体显示出来,操作完成后关掉这个dll窗体,当再次在主应用程序中调用这个显示窗体的函数时,dll窗体只是闪了一下,并没有显示到屏幕上。请问这是怎么回事!?!?!
我写的显示dll窗体的函数是:
procedure ShowForm(hdl:THandle);stdcall;
begin
Application.Handle:=hdl;
frmLogin:=TfrmLogin.Create(Application);
try
frmlogin.ShowModal;
finally
frmlogin.Free;
end;
end;
我写的显示dll窗体的函数是:
procedure ShowForm(hdl:THandle);stdcall;
begin
Application.Handle:=hdl;
frmLogin:=TfrmLogin.Create(Application);
try
frmlogin.ShowModal;
finally
frmlogin.Free;
end;
end;
解决方案 »
- 通过线程读取数据到DBGrid时不正常显示!!!!!!!!!
- 如何实现一个增强型的任务管理器:能记录长期的历史数据、支持重播
- Access数据类型不对
- 点击DBGrid的选中区域按回车显示动态窗体时产生的问题 向大虾求解大虾
- 高分>求救TQRChart
- 不用FileExists,就用Windows API能否判断c:\a.txt是否存在?
- 请问TTcpServer怎么向TTcpClint发信息?,为什么D7的TClintSocket和TServerSocket都不见了?
- 转让:超市POS收银系统,支持条形码扫描、票据打印 (含完整Delphi源代码、正式版程序、使用文档和技术支持)
- WebBrowser打印设置
- 关于Soap Server Wizard的Apache shared module(Dll)?
- 考试随机抽题问题
- 简单 问题。
看看别人的说法吧
所以需要反复的关掉,打开。
beginfrmLogin:=TfrmLogin.Create(hdl);
try
frmlogin.ShowModal;
finally
frmlogin.Free;
end;
end;
调动:
ShowForm(Application);试试。
var
i:integer;
begin
Result:=-1;
if Not Assigned(car_f) then
begin
try
Application.Handle:=Handle_car;
car_f.WindowState:=wsMaximized;
//Windows.SetParent(car_f.Handle,Parent.Handle);
car_f.Show;
Result:=Longint(car_f);
except
end;
end
else
begin
if car_f.WindowState=wsMinimized then
car_f.WindowState:=wsMaximized
else
car_f.Show;
end;end;exports
OpenAM_Car;begin
end.
library feemod;uses
SysUtils,
fee in 'fee.pas' {FeeForm};{$R *.res}exports
ShowFeeFrm;begin
end.
=====================DLL 窗体文件:unit fee;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
Dialogs, ExtCtrls, ActiveX, StdCtrls, ADODB, DB;type
TFeeForm = class(TForm)
Form1: TForm;
ADOConnection1: TADOConnection;
Query1: TADOQuery;
Table1: TADOTable;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
ContentEdit: TEdit;
MonEdit: TEdit;
DatePicker: TDateTimePicker;
PayMethodCombo: TComboBox;
DepartmentCombo: TComboBox;
Button1: TButton;
Button2: TButton;
function CheckNum:boolean;
function CheckInput:boolean;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;{
注意这里!!
var
FeeForm: TFeeForm;
上面两行注释掉了,在ShowFeeFrm过程里面定义
}
procedure ShowFeeFrm(Hwd,HIcon:THandle);stdcall;
implementation{$R *.dfm}procedure ShowFeeFrm(Hwd,HIcon:THandle);
var
FeeForm: TFeeForm; //改在这里定义了!
begin
Application.Handle:=Hwd;
Application.Icon.Handle:=HIcon;
FeeForm:=TFeeForm.Create(Application);
FeeForm.ShowModal;
FeeForm.Free;
end;procedure TFeeForm.Button1Click(Sender: TObject);
var
SqlStr:string;
begin
if CheckNum and CheckInput then
begin
SqlStr:='Sql语句';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(SqlStr);
try
Query1.ExecSQL;
Showmessage('数据保存成功!');
except
Showmessage('数据保存出错!');
end;
end;
end;procedure TFeeForm.Button2Click(Sender: TObject);
begin
close;
end;{
注意如果使用的是ADO数据控件,要加上以下几行 !!!!
切记引用 ActiveX 单元!
}
initialization
CoInitialize(nil);
finalization
CoUninitialize;end.====================调用窗体代码:unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;procedure ShowFeeFrm(Hwd,HIcon:THandle);stdcall;external 'feemod.dll';
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
ShowFeeFrm(Applicatioin.Handle,Application.Icon.Handle);
end;end.
======================我的代码在 DELPHI 7+ACCESS2000+WIN2003 运行正常