主程序加载动态库封装的子窗体打开后,如果再打开其它的窗体,那么如何激活上次打开的那个在动态库封装的子窗体
procedure TfrmMain.mi_inDLLClick(Sender: TObject);
var
DLLHandle: THandle;
DLLSub: InvokeDLLForm;begin
DLLHandle := LoadLibrary('prjDLL.dll');
if DLLHandle <> 0 then
begin
@DLLSub := GetProcAddress(DLLHandle, 'CreateDLLForm');
if Assigned(@DLLSub) then
begin
DLLForm := DLLSub(Application, Screen);
end;
end;
end;
procedure TfrmMain.mi_inDLLClick(Sender: TObject);
var
DLLHandle: THandle;
DLLSub: InvokeDLLForm;begin
DLLHandle := LoadLibrary('prjDLL.dll');
if DLLHandle <> 0 then
begin
@DLLSub := GetProcAddress(DLLHandle, 'CreateDLLForm');
if Assigned(@DLLSub) then
begin
DLLForm := DLLSub(Application, Screen);
end;
end;
end;
如果被挡住了,BringToFront
ShowWindow和BringToFront在一个程序里可以,也就是一个exe的程序,如果要是一个exe加多个dll就不太会用。
我也是每次调用dll时如果没有没窗体创建,就创建,可以如果已经创建那我不会让他怎用显示到上面来了
function CForm(App: TApplication; Scr: TScreen):TForm;begin Application := App;
Screen := Scr;
Application.CreateForm(TForm1, Form1);
result:=Form1;上面的是exe中的调用代码
我还是不是很清楚:
麻烦能再提示一下吗?
谢谢
create
Application.CreateForm(TfrmMain,frmMain);
frmMain.Show;
pBillHandle:=frmMain.Handle;
pBillName:=frmMain.Caption;
pBillID:=zBillID;
_AddRef;
delete
if frmMain<> nil then
begin
FreeAndNil(frmMain);
_Release;
end;
procedure TfrmMain.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
ADOQuery1.Close;
Action:=caNone;
SendMessage(LMDIParentHandle,WM_USER+888,500,zBillID);
end; //死放DLL 888
procedure TfrmMain.WndProc(var message: TMessage);
begin
if message.Msg =WM_USER+888 then
begin
if message.WParam=500 then
begin
hVariant.MDIName(message.LParam,x);
for i:=0 to BarMDIList.Items.Count-1 do
begin
if BarMDIList.Items[i]=x then
begin
BarMDIList.Items.Delete(i);
break;
end;
end;
hVariant.MDIFree(message.LParam);
end;
end;
//默认消息处理
inherited WndProc(Message);
end;