program LineDemo;
uses
Windows, Messages;
function WndProc(hWindow: HWND; msg, wParam, lParam: LongInt): LRESULT; stdcall;
const
{$J+}
cxClient: Integer = 0;
cyClient: Integer = 0;
{$J-}
var
ps: TPaintStruct;
hdc1: HDC;
begin
Result:= 0;
case msg of
WM_CREATE:
begin
end;
WM_DESTROY:
begin
PostQuitMessage(0);
end;
WM_SIZE:
begin
cxClient:= LoWord(lParam);
cyClient:= HiWord(lParam);
end;
WM_PAINT:
begin
hdc1:= BeginPaint(hWindow, ps);
Rectangle(hdc1, cxClient div 8, cyClient div 8,
7 * cxClient div 8, 7 * cyClient div 8);
MoveToEx(hdc1, 0, 0, nil);
LineTo(hdc1, cxClient, cyClient);
MoveToEx(hdc1, 0, cyClient, nil);
LineTo(hdc1, cxClient, 0);
Ellipse(hdc1, cxClient div 8, cyClient div 8,
7 * cxClient div 8, 7 * cyClient div 8);
RoundRect(hdc1, cxClient div 4, cyClient div 4,
3 * cxClient div 4, 3 * cyClient div 4,
cxClient div 4, cyClient div 4);
EndPaint(hWindow, ps);
end
else
Result:= DefWindowProc(hWindow, msg, wParam, lParam);
end;
end;
const
szAppName = 'LineDemo';
var
wndclass1: TWndClass;
hWindow: HWND;
msg: TMsg;
begin
wndclass1.style:= CS_VREDRAW or CS_HREDRAW;
wndclass1.lpfnWndProc:= @WndProc;
wndclass1.cbClsExtra:= 0;
wndclass1.cbWndExtra:= 0;
wndclass1.hInstance:= HInstance;
wndclass1.hIcon:= LoadIcon(0, 0);
wndclass1.hCursor:= LoadCursor(0, 0);
wndclass1.hbrBackground:= GetStockObject(0);
wndclass1.lpszMenuName:= nil;
wndclass1.lpszClassName:= szAppName;
if RegisterClass(wndclass1) = 0 then
begin
MessageBox(0, 'This program requires Windows NT!', szAppName, MB_ICONERROR);
exit;
end;
hWindow:= CreateWindow(szAppName, 'Line Demonstration', WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, HInstance, nil);
ShowWindow(hWindow, CmdShow);
UpdateWindow(hWindow);
while GetMessage(msg, 0, 0, 0) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
end.