unit uNCVLClasses;
interface
uses Windows, Messages, SysUtils;
type
TWndProc =
function (wnd: HWND; uMsg: UINT; wp: WPARAM; lp: LPARAM): LRESULT
of Object;
stdcall;
TNVCLControl =
class
private
FHandle: THandle;
FID: HMENU;
public
property Handle: THandle
read FHandle;
property ID: HMENU
read FID;
end;
TNVCLForm =
class(TNVCLControl)
private
wc: TWndClassEx;
FWndProc: TWndProc;
function WndProc(wnd: HWND; uMsg: UINT; wp: WPARAM; lp: LPARAM): LRESULT;
stdcall;
public
constructor Create(x,y,width,height: Cardinal);
end;
var
frmCount: Integer = 1;
implementation
{ TNVCLForm }
constructor TNVCLForm.Create(x, y, width, height: Cardinal);
begin
FWndProc := WndProc;
with wc
do
begin
cbSize := SizeOf(TWndClassEx);
lpfnWndProc := @FWndProc;
hInstance := SysInit.hInstance;
hbrBackground := COLOR_APPWORKSPACE;
lpszClassName := Pchar('
wnd' + IntToStr(frmCount));
end;
RegisterClassEx(wc);
inc(frmCount);
FHandle := CreateWindowEx(0,wc.lpszClassName,'
Test',
WS_VISIBLE
or WS_CAPTION
or WS_SYSMENU
or WS_SIZEBOX,
x,y,width,height,0,FID,hInstance,
nil);
end;
function TNVCLForm.WndProc(wnd: HWND; uMsg: UINT; wp: WPARAM;
lp: LPARAM): LRESULT;
begin
Result := 0;
case uMsg
of
WM_CREATE:
begin
// nix
end;
WM_DESTROY:
begin
PostQuitMessage(0);
end;
else Result := DefWindowProc(wnd, uMsg, wp, lp);
end;
end;
end.