100分求Delphi主窗体调用 Dll下的子Frame或form也就是将Form或frame封裝成dll供主窗體調用,关键是将这个form或frame加入到主窗体的pagecontrol中去,
這是一个经典而又古老的问题,很少有人知能真正解决,真是无奈......最好是有源碼,不要只言片语,如果哥哥你只给一部分代码还是算了。
非常感谢,
Mail:[email protected]
這是一个经典而又古老的问题,很少有人知能真正解决,真是无奈......最好是有源碼,不要只言片语,如果哥哥你只给一部分代码还是算了。
非常感谢,
Mail:[email protected]
解决方案 »
- 怎么看自己的积分呀!!!!!
- intraweb中如何使delphi取得自定义javascript函数的返回值??????
- 有没有现成的控件可以根据当前输入的内容实现动态过滤!!
- 我下载了条码字体,打印出来的内容扫描枪无法识别。
- 主副窗体的问题——————在线等待!!!!
- 请问在SQL Explore 中如何设置才能察看oracle7.3数据库的数据?
- 远程数据模块怎样得到客户端的名称和IP
- ComboBox1中当选中ComboBox1的某一个时知道表中另一个字段是什么信息!
- 怎样作Windows2000 Professionl的启动盘???
- 再问一次,看有人理吗??分数加到200分,欢迎高手,欢迎灌水!!!!
- Delphi下$作用?
- 非模态窗口与快捷键的问题?
SysUtils,
Classes,
Controls,
Forms,
Windows,
Unit2 in 'Unit2.pas' {Form2};{$R *.res}
procedure ShowForm(parent:THandle);stdcall;
var
frm : TForm2;
begin
frm := TForm2.Create(Application);
frm.ParentWindow := parent;
frm.Show;
frm.Align := alClient;
end;exports
ShowForm name 'ShowForm';beginend.
调用,传入Panel1的句柄
procedure ShowForm(parent:THandle);stdcall;external 'Project1.dll';procedure TForm1.Button1Click(Sender: TObject);
begin
ShowForm(Panel1.Handle);
end;
ShowForm(PageControl1.Pages[0].Handle);
------------------------------------------------------
DLL部分:
-------
library UDllFrom;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
SysUtils,
Classes,
forms,
controls,
UChildForm in 'UChildForm.pas' {childForm};{$R *.res}procedure run_form(parent:THandle);stdcall;
var
childForm: TchildForm;
begin
childForm:=TchildForm.Create(Application);
childForm.ParentWindow:=parent;
childForm.Show;
childForm.Align:=alclient;
end;
exports
run_form name 'run_form';
begin
end.
-------------------------------------------------------
调用:
-------
unit UTestForm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RzTabs, StdCtrls, Buttons, Menus, ExtCtrls;type
TTestForm = class(TForm)
rzpgc: TRzPageControl;
tbs: TRzTabSheet;
Panel1: TPanel;
MainMenu1: TMainMenu;
test1: TMenuItem;
procedure test1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure rum_Form(parent:THandle);stdcall;external 'UDllFrom.dll';
var
TestForm: TTestForm;implementation{$R *.dfm}procedure TTestForm.test1Click(Sender: TObject);
begin
rum_Form(Panel1.Handle);
end;end.
--------------------------------
一直接提示错误
library UDllFrom; //DLL庫封裝之處{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
SysUtils,
Classes,
forms,
RzTabs,
UChildForm in 'UChildForm.pas' {Form1};{$R *.res}
procedure AddTabSheet(FormClass: TFormClass;tbs:TRZTabSheet; rzpgc:TRZPagecontrol);
var
Form:TForm;
begin
rzpgc.ActivePage := tbs; //加上这一步算是双向指定了,指定激活页
Form := FormClass.Create(tbs); //创建Form(用TabSheet)实例
Form.Parent := tbs; //指定Form的父窗体
tbs.Caption := Form.Caption; //标题
tbs.TabVisible:=True;
Form.Show; //显示
end;
function run_form(hs:THandle;tbs:TRZTabSheet;rzpgc:TRZPagecontrol):integer;stdcall;
var
TForm1:TFormclass;
begin
Application.Handle:=hs;
AddTabSheet(TForm1,tbs,rzpgc);
end;
exports
run_form;
begin
end.
-----------------------------調用DLL窗體,將子窗体装入主窗体中
unit UTestForm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RzTabs, StdCtrls, Buttons;type
TTestForm = class(TForm)
rzpgc: TRzPageControl;
tbs: TRzTabSheet;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function rum_Form(hs:THandle;tbs:TRZTabSheet;rzpgc:TRZPagecontrol):Integer;stdcall;external 'UDllFrom.dll';
var
TestForm: TTestForm;implementation{$R *.dfm}procedure TTestForm.BitBtn1Click(Sender: TObject);
begin
rum_Form(Application.Handle,tbs,rzpgc);
end;end.
----------------------------
提示錯誤,無法找到程序的輸入點