我看了一些资料,但主要讲函数的调用,窗体的调用讲得很简单,看不明白(作者用一种太简单了,实在懒得再讲的口吻带了两句),哪位仁兄给我扫一下盲?
解决方案 »
- 菜鸟求助 关于MAPX在delphi中的应用
- 我的dblistbox加了数据 怎么无法点选?
- char和string转换的问题!
- 今天是个好日子,我喜得两个“千金”,大家帮忙给取个名字吧!
- 哪有model maker的书籍或资料下载?
- 请问:如何将DBGRID查询的结果中值小于0的数显示为红色,其他为黑色
- 小弟的新软件和新网站同时发布,希望大家支持
- 压缩bmp文件
- mdi窗口问题,模拟传真驱动编写
- cken快来拿分
- 建了一个UC(与QQ一样)组,共邀大家一起探讨
- SOS!SOS!HELP ME!!!斑竹救我!!!高人救我!!!大虾救我!!!做这个报表N天了,还是没有达到客户的要求,我太笨了,需要各位的指导!
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ToolWin, ComCtrls, Menus, ImgList;type
TMainForm = class(TForm)
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ImageList1: TImageList;
procedure fgf1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations } public
{ Public declarations }
procedure DllCall(Sender: TObject);
end; T_ProvaChild = procedure (ParentApplication: TApplication; parentform: TForm); stdcall;var
MainForm: TMainForm;implementation{$R *.DFM}procedure TMainForm.DllCall(Sender: TObject);
var
DllHandle: THandle;
ProcAddr: FarProc;
ProvaChild: T_ProvaChild;
str,str1,str2 : string;
begin
str := (Sender as TToolButton).Caption ;
str1 := copy(str,1,pos('@',str)-1); // str1:=ProjectDll // DLL文件名
str2 := copy(str,pos('@',str)+1,length(str)); //str2:=ProvaChild DllHandle := LoadLibrary(PChar(str1));
if DllHandle <> 0 then
begin
ProcAddr := GetProcAddress(DllHandle, PChar(str2));
if Assigned(ProvaChild) then
begin
ProvaChild := ProcAddr;
ProvaChild(Application,Self);
end;
//**** freelibrary(DllHandle);//注意!!!注!!!*************
end;end;procedure TMainForm.fgf1Click(Sender: TObject);
begin
//DllCall;
end;procedure TMainForm.FormCreate(Sender: TObject);
begin
toolbutton1.caption:= ProjectDll@ProvaChild;
toolbutton1.OnClick := DllCall;
end;end.//DLL文件/////////////////////////////////library ProjectDll;uses
Windows,
Messages,
SysUtils,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
ubasStatusaaRoom in 'ubasStatusaaRoom.pas' {FbasStatusaaRoom};procedure DLLUnloadProc(Reason: Integer); register;
begin
if Reason = DLL_PROCESS_DETACH then Application:=DllApplication;
end;procedure ProvaChild(ParentApplication: TApplication; ParentForm: TForm); export; stdcall;
begin
if not Assigned(FbasStatusaaRoom) then
begin
Application := ParentApplication;
FbasStatusaaRoom := TFbasStatusaaRoom.Create(nil);
FbasStatusaaRoom.MyParentForm := ParentForm;
FbasStatusaaRoom.MyParentApplication := ParentApplication;
end;
FbasStatusaaRoom.Show;
end;exports
ProvaChild;
begin
DllApplication:=Application;
DLLProc := @DLLUnloadProc;
end.//其中的一个子窗体/////////////////////////unit ubasStatusaaRoom;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, ExtCtrls, DB, DBClient, ImgList, Grids,
DBGridEh,ActiveX;type
TFbasStatusaaRoom = class(TForm)
Panel1: TPanel;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
tbfirst: TToolButton;
tbprev: TToolButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
MyParentForm: TForm;
MyParentApplication: TApplication;
end;var
FbasStatusaaRoom: TFbasStatusaaRoom;
implementation{$R *.dfm} procedure TFbasStatusaaRoom.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
action := caFree;
FbasStatusaaRoom := nil ;
end;
end.