如何在DLL中建立窗体? 不用VCL,那样dll好几百K. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在project单元的内容:library Project1;uses Forms, Unit1 in 'Unit1.pas' {Form1};procedure test;begin Application.CreateForm(TForm1, Form1); form1.show;end;{$R *.res}exports test;beginend.在unit单元的内容:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}end.这样编译后就是一个dll了。 调用dll的时候,在project的内容:program Project1;uses Forms, Unit2 in 'Unit2.pas' {Form1};{$R *.res}begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run;end.在unit单元的内容:unit Unit2;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;procedure test; far;external 'project2.dll';implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin test;end;end.如果这个看不懂,我就没办法了 to tomp()你这个DLL怕有200K吧?再加点控件就过300了我只是想知道怎么用SDK加上窗口,在窗口放一些控件,DLL和普通Exe不一样,有些工作要做,我想有经验的给点Tip, 我可以少走弯路. 单片机开发吗?怎么对DLL大小要求这么严. project-option-package-build with packages..然后发布的时候把bpl和所有dll放到同一目录下 只包含一个form的话,dll带包编译只有11k左右,如果是10个dll加上bpl也只有几百k,dll和bpl文件都可以加壳压缩 单片机开发吗?怎么对DLL大小要求这么严.我不想他太大而已,做成DLL就是为了小. 带包编译啊这样还是大(加上包),不过DLL多了就不觉得了,但其他语言能调用吗? 和EXE一样,只要接口函数中有SHOW就可以了 要小,可以在编译设置中做到,DLL也只有几十K 我来抛块砖吧:)DLL:unit U_APIform;interfaceuses Windows, Messages, SysUtils;function ShowAPIModlessForm(AHandle: THandle): Longint; stdcall;implementationconst AppName = 'DllAPIform';function DummyWindowProc (Wnd: hWnd; Msg, wParam: Word; lParam: LongInt): LongInt; stdcall;begin Result := 0; case Msg of WM_DESTROY: PostQuitMessage(0); else Result := DefWindowProc(Wnd, Msg, wParam, lParam); end;end;function ShowAPIModlessForm(AHandle: THandle): Longint;var cls: TWndClass; Wnd: hWnd;begin Result := 0; FillChar(cls, SizeOf(cls), 0); cls.lpfnWndProc := @DummyWindowProc; cls.hInstance := AHandle; cls.lpszClassName := AppName; RegisterClass(cls); Wnd := CreateWindowEx(0, AppName, AppName, WS_VISIBLE or //µ÷ÊÔʱÓÃ; WS_SIZEBOX or WS_CAPTION or WS_POPUP, 363, 278, 305, 200, 0, 0, AHandle, nil); if Wnd > 0 then begin UpdateWindow(Wnd); ShowWindow(Wnd, SW_SHOW); Result := Wnd; end;end;end.library DllAPIform;uses U_APIform in 'U_APIform.pas';{$R *.res}exports ShowAPIModlessForm;beginend.调用:function ShowAPIModlessForm(AHandle: THandle): Longint; stdcall; external 'DllAPIform.dll';procedure TForm1.btnShowAPIModlessFormClick(Sender: TObject);begin if FAPIForm = 0 then FAPIForm := ShowAPIModlessForm(Application.Handle);end;这样就可以把DLL中的无模式子窗体显示出来了:) 求ExpressQuantumGrid for D7 调用华为SMEIDLL.dll中的SubmitAExEx函数发送返回总是4,还请高手指教!(解决后另赠100分) 100分,在线等,第一个解决的全给! 个人认为比较难的问题 如何象winamp那样将窗口最小化到系统托盘? 为什么关闭delphi程序时出现堆栈溢出错误? 大家都进来,随便说说自己ID或中文昵称的由来 delphi里关于project运行的问题!!! 一个动态控件的问题..... 简单问题:进程(copy或load文件时)怎样控制? ListView、TreeView 图标 叠加的问题有点难! 如何读取LWP格式的文件
library Project1;uses
Forms,
Unit1 in 'Unit1.pas' {Form1};procedure test;
begin
Application.CreateForm(TForm1, Form1);
form1.show;
end;
{$R *.res}
exports test;
begin
end.在unit单元的内容:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}end.这样编译后就是一个dll了。
program Project1;uses
Forms,
Unit2 in 'Unit2.pas' {Form1};{$R *.res}begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.在unit单元的内容:
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;procedure test; far;external 'project2.dll';implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
test;
end;end.
如果这个看不懂,我就没办法了
你这个DLL怕有200K吧?再加点控件就过300了我只是想知道怎么用SDK加上窗口,在窗口放一些控件,DLL和普通Exe不一样,有些工作要做,我想有经验的给点Tip, 我可以少走弯路.
我不想他太大而已,做成DLL就是为了小.
带包编译啊
这样还是大(加上包),不过DLL多了就不觉得了,但其他语言能调用吗?
DLL:
unit U_APIform;interfaceuses
Windows, Messages, SysUtils;function ShowAPIModlessForm(AHandle: THandle): Longint; stdcall;implementationconst
AppName = 'DllAPIform';function DummyWindowProc (Wnd: hWnd; Msg, wParam: Word;
lParam: LongInt): LongInt; stdcall;
begin
Result := 0;
case Msg of
WM_DESTROY: PostQuitMessage(0);
else
Result := DefWindowProc(Wnd, Msg, wParam, lParam);
end;
end;function ShowAPIModlessForm(AHandle: THandle): Longint;
var
cls: TWndClass;
Wnd: hWnd;
begin
Result := 0;
FillChar(cls, SizeOf(cls), 0);
cls.lpfnWndProc := @DummyWindowProc;
cls.hInstance := AHandle;
cls.lpszClassName := AppName;
RegisterClass(cls); Wnd := CreateWindowEx(0, AppName, AppName,
WS_VISIBLE or //µ÷ÊÔʱÓÃ;
WS_SIZEBOX or WS_CAPTION or WS_POPUP,
363, 278, 305, 200, 0, 0, AHandle, nil);
if Wnd > 0 then
begin
UpdateWindow(Wnd);
ShowWindow(Wnd, SW_SHOW);
Result := Wnd;
end;
end;end.library DllAPIform;uses
U_APIform in 'U_APIform.pas';{$R *.res}exports
ShowAPIModlessForm;begin
end.调用:
function ShowAPIModlessForm(AHandle: THandle): Longint;
stdcall; external 'DllAPIform.dll';procedure TForm1.btnShowAPIModlessFormClick(Sender: TObject);
begin
if FAPIForm = 0 then
FAPIForm := ShowAPIModlessForm(Application.Handle);
end;这样就可以把DLL中的无模式子窗体显示出来了:)