Y
yl0971
Unregistered / Unconfirmed
GUEST, unregistred user!
library Project1;
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas' {FrmWTCD};
{$R *.res}
exports
ShowWTCD,
CloseWTCD;
begin
end.
//----------------------------------------------------------------
unit1
function ShowWTCD(AHandle: THandle; var PPanel: TPanel): LongInt;
var
FrmWTCD: TFrmWTCD;
begin
Application.Handle := AHandle;
FrmWTCD := TFrmWTCD.Create(Application); //这句动态调用出错
Result := LongInt(FrmWTCD);
Windows.SetParent(FrmWTCD.Handle, PPanel.Handle);
FrmWTCD.Show;
end;
procedure CloseWTCD(IFrm: LongInt);
begin
if IFrm > 0 then
TFrmWTCD(IFrm).Release;
end;
每次动态调用时创建窗体那一句提示"无效的句柄",但是静态调用没有问题,在网上查了资料,很多是模式窗体和子窗体的调用,无模式窗体调用给出的代码都是静态调用,实在找不到原因,大家帮忙给看看
调用代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
libhandle: THandle;
ShowWTCD: TShowWTCD;
begin
libHandle := Loadlibrary('Project1.dll');
@ShowWTCD := GetProcAddress(libHandle, 'ShowWTCD');
if @ShowWTCD <> nil then
tmpForm := TForm(ShowWTCD(Application.Handle, Panel1));//tmpForm是个临时窗体,每次都是这里出错,提示"无效的窗口句柄";
FreeLibrary(handle);
end;
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas' {FrmWTCD};
{$R *.res}
exports
ShowWTCD,
CloseWTCD;
begin
end.
//----------------------------------------------------------------
unit1
function ShowWTCD(AHandle: THandle; var PPanel: TPanel): LongInt;
var
FrmWTCD: TFrmWTCD;
begin
Application.Handle := AHandle;
FrmWTCD := TFrmWTCD.Create(Application); //这句动态调用出错
Result := LongInt(FrmWTCD);
Windows.SetParent(FrmWTCD.Handle, PPanel.Handle);
FrmWTCD.Show;
end;
procedure CloseWTCD(IFrm: LongInt);
begin
if IFrm > 0 then
TFrmWTCD(IFrm).Release;
end;
每次动态调用时创建窗体那一句提示"无效的句柄",但是静态调用没有问题,在网上查了资料,很多是模式窗体和子窗体的调用,无模式窗体调用给出的代码都是静态调用,实在找不到原因,大家帮忙给看看
调用代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
libhandle: THandle;
ShowWTCD: TShowWTCD;
begin
libHandle := Loadlibrary('Project1.dll');
@ShowWTCD := GetProcAddress(libHandle, 'ShowWTCD');
if @ShowWTCD <> nil then
tmpForm := TForm(ShowWTCD(Application.Handle, Panel1));//tmpForm是个临时窗体,每次都是这里出错,提示"无效的窗口句柄";
FreeLibrary(handle);
end;