主程序调用DLL文件里的FORM,为什么form关闭的时候主程序窗口莫名其妙的最小化阿? (200分)

  • 主题发起人 主题发起人 aocandy
  • 开始时间 开始时间
A

aocandy

Unregistered / Unconfirmed
GUEST, unregistred user!
主程序调用DLL文件里的FORM,当关闭Form后,主窗体再屏幕上没有了,好像最小化了,
任务栏上有执行程序的条子,当点击这个条子,好像使主程序最小化了,再点,主窗体才显露
这是怎么回事阿,我把DLL的FORM的关闭事件里试过用close,和application.te...什么的都不行
FormStyle都是fsNormal
我的主窗体不是DLL理的,是单独的form
 
dll中调用含有Form的单元:
uses cf_grcf_chax_Unit;
.........
procedure show_grcf_chax(Ahandle:Thandle);
Begin
Application.handle:=Ahandle;
with Tcf_chax_grcf_Form.Create(Application) do
begin
try
showmodal;
finally
free;
end;
End;
end;

在cf_chax_grcf_Form 的onclose:
Action:=cafree;

如果这样不行,您肯定处理了别的消息事件!
 
源码呢?
 
调用的form
procedure TForm1.T_1Click(Sender: TObject);
var
HDLL1:THandle;
SFb1:TSFb1;
begin
HDLL1:=LoadLibrary('fdll.dll');
try
@SFb1:=GetProcAddress(HDLL1,'SFb1');
if Assigned(@SFb1) then
SFb1(Application.Handle);
finally
FreeLibrary(HDLL1);
end;
end;

///////////////////DLL文件
unit fdll1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Inifiles, StdCtrls, TFlatEditUnit, XP_Button, TFlatComboBoxUnit, ExtCtrls,
XP_Form;

type
TFormx1 = class(TForm)
XP_Form1: TXP_Form;
Panel1: TPanel;
Label1: TLabel;
ComboBox1: TFlatComboBox;
XP_Button3: TXP_Button;
FlatEdit4: TFlatEdit;
FlatEdit3: TFlatEdit;
FlatEdit2: TFlatEdit;
FlatEdit1: TFlatEdit;
Label2: TLabel;
ComboBox2: TFlatComboBox;
XP_Button4: TXP_Button;
FlatEdit8: TFlatEdit;
FlatEdit7: TFlatEdit;
FlatEdit6: TFlatEdit;
FlatEdit5: TFlatEdit;
Label3: TLabel;
FlatEdit9: TFlatEdit;
Label4: TLabel;
FlatEdit10: TFlatEdit;
FlatEdit11: TFlatEdit;
FlatEdit12: TFlatEdit;
FlatEdit14: TFlatEdit;
Label6: TLabel;
FlatEdit13: TFlatEdit;
Label5: TLabel;
Label7: TLabel;
FlatEdit15: TFlatEdit;
Label8: TLabel;
FlatEdit16: TFlatEdit;
FlatEdit17: TFlatEdit;
Label9: TLabel;
XP_Button1: TXP_Button;
XP_Button2: TXP_Button;
Label10: TLabel;
FlatEdit18: TFlatEdit;
Label11: TLabel;
FlatEdit19: TFlatEdit;
Label12: TLabel;
FlatEdit20: TFlatEdit;
Label13: TLabel;
FlatEdit21: TFlatEdit;
Label14: TLabel;
FlatEdit22: TFlatEdit;
procedure FormShow(Sender: TObject);
procedure XP_Button3Click(Sender: TObject);
procedure XP_Button4Click(Sender: TObject);
procedure XP_Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure XP_Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


Function SF1(AHandle:THandle):integer;StdCall;
implementation

{$R *.dfm}
Function SF1(AHandle:THandle):integer;
var
Formx1: TFormx1;
begin
Application.Handle:=AHandle;
Formx1:=TFormx1.Create(Application);
try
//Windows.SetParent(Formx1.Handle, aPnl.Handle);
Formx1.ShowModal;
Result:=1;
finally
//Formx1.Close;
Formx1.Free;
end;
end;



procedure TFormx1.FormShow(Sender: TObject);
begin
Label1.Width:=100;
Label2.Width:=100;
Label3.Width:=100;
Label4.Width:=100;
Label5.Width:=100;
Label6.Width:=100;
Label7.Width:=100;
Label8.Width:=100;
Label9.Width:=100;
Label10.Width:=100;
Label11.Width:=100;
Label12.Width:=122;
Label13.Width:=100;
Label14.Width:=100;
end;

procedure TFormx1.XP_Button3Click(Sender: TObject);
var IniFile:TIniFile;
begin
IniFile:=TIniFile.Create(GetCurrentDir()+'/company.ini');
if XP_Button3.Caption='保存' then
begin
IniFile.WriteString('Company','CName1',FlatEdit1.Text);
IniFile.WriteString('Company','CName2',FlatEdit2.Text);
IniFile.WriteString('Company','CName3',FlatEdit3.Text);
IniFile.WriteString('Company','CName4',FlatEdit4.Text);
//IniFile.WriteString('Company','CName',ComboBox1.Text);
Application.MessageBox(' 保存完成 ','OK',MB_OK);
XP_Button3.Caption:='修改';
FlatEdit1.Text:='';
FlatEdit2.Text:='';
FlatEdit3.Text:='';
FlatEdit4.Text:='';
IniFile.Free;
exit;
end;
if XP_Button3.Caption='修改' then
begin
FlatEdit1.Text:=Inifile.ReadString('Company','CName1','NUll');
FlatEdit2.Text:=Inifile.ReadString('Company','CName2','NUll');
FlatEdit3.Text:=Inifile.ReadString('Company','CName3','NUll');
FlatEdit4.Text:=Inifile.ReadString('Company','CName4','NUll');
XP_Button3.Caption:='保存';
IniFile.Free;
end;
end;

procedure TFormx1.XP_Button4Click(Sender: TObject);
var IniFile:TIniFile;
begin
IniFile:=TIniFile.Create(GetCurrentDir()+'/company.ini');
if XP_Button4.Caption='保存' then
begin
IniFile.WriteString('bank','bk1',FlatEdit5.Text);
IniFile.WriteString('bank','bk2',FlatEdit6.Text);
IniFile.WriteString('bank','bk3',FlatEdit7.Text);
IniFile.WriteString('bank','bk4',FlatEdit8.Text);
Application.MessageBox(' 保存完成 ','OK',MB_OK);
XP_Button4.Caption:='修改';
FlatEdit5.Text:='';
FlatEdit6.Text:='';
FlatEdit7.Text:='';
FlatEdit8.Text:='';
IniFile.Free;
exit;
end;
if XP_Button4.Caption='修改' then
begin
FlatEdit5.Text:=Inifile.ReadString('bank','bk1','NUll');
FlatEdit6.Text:=Inifile.ReadString('bank','bk2','NUll');
FlatEdit7.Text:=Inifile.ReadString('bank','bk3','NUll');
FlatEdit8.Text:=Inifile.ReadString('bank','bk4','NUll');
XP_Button4.Caption:='保存';
IniFile.Free;
end;
end;

procedure TFormx1.XP_Button2Click(Sender: TObject);
begin
Close;
end;

procedure TFormx1.FormCreate(Sender: TObject);
var
IniFile:TIniFile;
begin
IniFile:=TIniFile.Create(GetCurrentDir()+'/company.ini');

ComboBox1.Items.Clear;
ComboBox1.Items.Add(Inifile.ReadString('Company','CName','NUll'));
ComboBox1.Items.Add(Inifile.ReadString('Company','CName1','NUll'));
ComboBox1.Items.Add(Inifile.ReadString('Company','CName2','NUll'));
ComboBox1.Items.Add(Inifile.ReadString('Company','CName3','NUll'));
ComboBox1.Items.Add(Inifile.ReadString('Company','CName4','NUll'));
ComboBox1.Text:=Inifile.ReadString('Company','CName','NUll');
ComboBox2.Items.Clear;
ComboBox2.Items.Add(Inifile.ReadString('bank','bk','NUll'));
ComboBox2.Items.Add(Inifile.ReadString('bank','bk1','NUll'));
ComboBox2.Items.Add(Inifile.ReadString('bank','bk2','NUll'));
ComboBox2.Items.Add(Inifile.ReadString('bank','bk3','NUll'));
ComboBox2.Items.Add(Inifile.ReadString('bank','bk4','NUll'));
ComboBox2.Text:=Inifile.ReadString('bank','bk','NUll');
FlatEdit9.Text:=Inifile.ReadString('All','leixing','NUll');
FlatEdit10.Text:=Inifile.ReadString('All','b1','NUll');
FlatEdit11.Text:=Inifile.ReadString('All','b2','NUll');
FlatEdit12.Text:=Inifile.ReadString('All','b3','NUll');
FlatEdit13.Text:=Inifile.ReadString('All','dwl','NUll');
FlatEdit14.Text:=Inifile.ReadString('All','grl','NUll');
FlatEdit15.Text:=Inifile.ReadString('All','jbs','NUll');
FlatEdit16.Text:=Inifile.ReadString('All','jbr','NUll');
FlatEdit17.Text:=Inifile.ReadString('All','jfr','NUll');
FlatEdit18.Text:=Inifile.ReadString('All','bh','NUll');
FlatEdit19.Text:=Inifile.ReadString('All','zh','NUll');
FlatEdit20.Text:=Inifile.ReadString('Company IDX','shbxdjhm','NUll');
FlatEdit21.Text:=Inifile.ReadString('Company IDX','jgdm','NUll');
FlatEdit22.Text:=Inifile.ReadString('Company IDX','jfrsbh','NUll');

IniFile.Free;
end;

procedure TFormx1.XP_Button1Click(Sender: TObject);
var
IniFile:TIniFile;
begin
IniFile:=TIniFile.Create(GetCurrentDir()+'/company.ini');
IniFile.WriteString('Company','CName',ComboBox1.Text);
IniFile.WriteString('bank','bk',ComboBox2.Text);
IniFile.WriteString('All','leixing',FlatEdit9.Text);
IniFile.WriteString('All','b1',FlatEdit10.Text);
IniFile.WriteString('All','b2',FlatEdit11.Text);
IniFile.WriteString('All','b3',FlatEdit12.Text);
IniFile.WriteString('All','dwl',FlatEdit13.Text);
IniFile.WriteString('All','drl',FlatEdit14.Text);
IniFile.WriteString('All','jbs',FlatEdit15.Text);
IniFile.WriteString('All','jbr',FlatEdit16.Text);
IniFile.WriteString('All','jfr',FlatEdit17.Text);
IniFile.WriteString('All','bh',FlatEdit18.Text);
IniFile.WriteString('All','zh',FlatEdit19.Text);
IniFile.WriteString('Company IDX','shbxdjhm',FlatEdit20.Text);
IniFile.WriteString('Company IDX','jgdm',FlatEdit21.Text);
IniFile.WriteString('Company IDX','jfrsbh',FlatEdit22.Text);

Application.MessageBox(' 保存完成 ','OK',MB_OK);
IniFile.Free;
close;
end;

end.
 
看不出来
发到油箱
liuyj@cbn.com.cn
 
我的问题已经解决了~请问我怎么能把这帖子删掉阿,不用附分
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
I
回复
0
查看
554
import
I
后退
顶部