program nonvcl;
uses windows, messages;
const
ClassName = '
nonvcl';
var
WindowLeft: integer = 100;
WindowTop: integer = 100;
WindowWidth: integer = 300;
WindowHeight: integer = 100;
function WNDProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM;
lParam: LPARAM): LRESULT;
stdcall;
var
IDOK: DWORD;
begin
Result := 0;
case uMsg
OF
WM_CREATE:
IDOK := CreateWindow('
BUTTON', '
caption of a button',
WS_VISIBLE
OR WS_CHILD
OR WS_BORDER, 100, 100, 200, 24,
hwnd, 0, hInstance,
nil);
WM_DESTROY:
PostQuitMessage(0);
WM_COMMAND:
if hiword(wparam) = BN_CLICKED
then
//########################################################################
if loword(wparam) = IDOK
then //HIER HIER HIER
//########################################################################
MessageBox(hwnd, '
button pressed', '
Info', 0);
else
Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
end;
end;
var
wc: TWndClassEx = (
cbSize: SizeOf(TWndClassEx);
style: CS_OWNDC
OR CS_HREDRAW
OR CS_VREDRAW;
cbClsExtra: 0;
cbWndExtra: 0;
hbrBackground: COLOR_WINDOW;
lpszMenuName:
NIL;
lpszClassName: ClassName;
hIconSm: 0);
msg: TMSG;
rect: trect;
deskh, deskw: integer;
ncm: tagNONCLIENTMETRICS;
begin
wc.hInstance := HInstance;
wc.hIcon := LoadIcon(HInstance, MAKEINTRESOURCE(1));
wc.hCursor := LoadCursor(0, IDC_ARROW);
wc.lpfnWndProc := @WndProc;
systemparametersinfo(SPI_GETWORKAREA, 0, @rect, 0);
deskw := rect.Right - rect.Left;
deskh := rect.Bottom - rect.Top;
ncm.cbSize := sizeof(ncm);
systemparametersinfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, @ncm, 0);
windowwidth := windowleft + windowwidth;
windowheight := windowtop + windowheight + ncm.iMenuHeight +
ncm.iCaptionHeight;
Windowleft := (deskw
DIV 2) - (windowwidth
DIV 2);
Windowtop := (deskh
DIV 2) - (windowheight
DIV 2);
RegisterClassEx(wc);
CreateWindowEx(WS_EX_WINDOWEDGE
OR WS_EX_CONTROLPARENT
OR WS_EX_APPWINDOW,
ClassName,
'
caption of a form',
WS_OVERLAPPED
OR WS_CAPTION
OR WS_SYSMENU
OR WS_MINIMIZEBOX
OR WS_VISIBLE,
windowleft,
windowtop,
windowwidth,
windowheight,
0,
0,
hInstance,
NIL);
while true
do begin
if not GetMessage(msg, 0, 0, 0)
then break;
translatemessage(msg);
dispatchmessage(msg);
end;
ExitCode := GetLastError;
end.