Mozna tak
unit window;
interface
uses Windows;
procedure WinMain;
implementation
uses Messages, StdCtrls;
const
ClassName = 'WindowTemp';
var
Btn:TButton;
function WindowProc(Window: Longint; Message: UINT; WPram: WPARAM; LPram: LPARAM): LRESULT; stdcall; StdCall;
begin
WindowProc := 0;
case Message of
wm_Create:begin
Btn:=TButton.Create(nil);
Btn.ParentWindow := Window;
btn.Top :=0;
Btn.Left :=0;
Btn.Height :=30;
Btn.Width :=100;
Btn.Caption := 'Butonik';
Btn.Visible := True;
end;
wm_Destroy:
begin
Btn.Free;
PostQuitMessage(0);
Exit;
end;
end;
WindowProc := DefWindowProc(Window, Message, WPram, LPram);
end;
procedure WinMain;
var
Window: HWND;
Message: TMsg;
WindowClass: TWndClass;
begin
WindowClass.style:= 0;
WindowClass.lpfnWndProc:= @WindowProc;
WindowClass.cbClsExtra:= 0;
WindowClass.cbWndExtra:= 0;
WindowClass.hIcon:= 0;
WindowClass.hCursor:= LoadCursor(0, IDC_ARROW);
WindowClass.hbrBackground:= COLOR_APPWORKSPACE;
WindowClass.lpszMenuName:= nil;
WindowClass.lpszClassName:= ClassName;
WindowClass.hInstance := HInstance;
RegisterClass(WindowClass);
Window := CreateWindow(
ClassName,
'',
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
100,
100,
0,
0,
HInstance,
nil);
ShowWindow(Window, SW_SHOW);
while GetMessage(Message, 0, 0, 0) do
begin
TranslateMessage(Message);
DispatchMessage(Message);
end;
Halt(Message.wParam);
end;
end.
Ale jakijest tego sens ?
Dodatkowo nie kazdy komponent poddaje sie takim manipulacja (popierwszemusi miec uchwyt a i to nie gwarantuje)
PS. TButton tonic jakklasa obudywywujaca BUTTON znany z WinAPI