function ShowAPIModlessForm(AHandle: THandle): Longint; stdcall;
implementation
const
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;