program
WinApiWindows;
uses
Windows,
Messages;
const
HBTN =
1
;
HLABEL =
2
;
var
window: TWndClassex;
Form, Form1, Button, Label1: hwnd;
mmsg: msg;
function
windowproc(wnd: hwnd; msg:
integer
; wparam: wparam; lparam: lparam):lresult;stdcall;
begin
case
msg
of
wm_destroy:
begin
postquitmessage(
0
);
result :=
0
;
exit;
end
;
WM_COMMAND:
begin
case
LoWord( wParam )
of
HBTN: MessageBox(Form,
'Вы нажали на кнопку'
,
'Загаловок'
,
0
);
end
;
end
;
else
result := defwindowproc(wnd,msg,wparam,lparam);
end
;
end
;
procedure
CreateWinApiForm;
begin
window
.
cbsize := sizeof (window);
window
.
style := cs_hredraw
or
cs_vredraw;
window
.
lpfnwndproc := @windowproc;
window
.
cbclsextra :=
0
;
window
.
cbwndextra :=
0
;
window
.
hinstance := hinstance;
window
.
hicon := loadicon(
0
,idi_application);
window
.
hcursor := loadcursor(
0
,idc_arrow);
window
.
hbrbackground:=
1
;
window
.
lpszmenuname :=
nil
;
window
.
lpszclassname :=
'main_window'
;
registerclassex(window);
Form:= createwindowex(
0
,
'main_window'
,
'Hello World from WinApi'
, WS_OVERLAPPEDWINDOW,
300
,
300
,
350
,
130
,
0
,
0
,hinstance,
nil
);
Form1:= createwindowex(
0
,
'main_window'
,
'Hello World from WinApi'
, WS_OVERLAPPEDWINDOW,
300
,
300
,
350
,
130
,
0
,
0
,hinstance,
nil
);
label1:=CreateWindow(
'static'
,
'Ты уже посмотрел на размер?'
,WS_VISIBLE
or
WS_CHILD
or
BS_TEXT,
6
,
25
,
330
,
40
,Form,HLABEL,hInstance,
nil
);
Button:=CreateWindow(
'button'
,
'Кликать сюда'
,WS_VISIBLE
or
WS_CHILD,
6
,
73
,
110
,
25
,Form,HBTN,hInstance,
nil
);
ShowWindow(Form,SW_SHOW);
ShowWindow(Form1,SW_SHOW);
end
;
begin
CreateWinApiForm;
while
getmessage(mmsg,
0
,
0
,
0
)
do
begin
translatemessage(mmsg);
dispatchmessage(mmsg);
end
;
end
.