{******************************************************************************}
{ }
{ Fenster-Vorlage }
{ }
{ Copyright (c) 2002 Michael Puff }
{ [url]www.luckie-online.de[/url] }
{ [email]mpuff@luckie-online.de[/email] }
{ }
{******************************************************************************}
program Fenster_Vorlage;
uses
Windows,
Messages,SysUtils,Graphics;
const
ClassName = '
WndClass';
AppName = '
Fenster-Vorlage';
WindowWidth = 800;
WindowHeight = 600;
timebase = 25;
var
hwndMain: DWORD;
{ GetLastError }
function DisplayErrorMsg(hWnd: THandle): DWORD;
var
szBuffer:
array[0..255]
of Char;
begin
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
nil, GetLastError, 0, szBuffer,
sizeof(szBuffer),
nil);
MessageBox(hWnd, szBuffer, '
Fehler', MB_ICONSTOP);
result := GetLastError;
end;
function WndProc(hWnd: HWND; uMsg: UINT; wParam: wParam; lParam: LParam):
lresult;
stdcall;
var
x, y : integer;
begin
Result := 0;
case uMsg
of
WM_CREATE:
begin
{ Fenster zentrieren }
x := GetSystemMetrics(SM_CXSCREEN);
y := GetSystemMetrics(SM_CYSCREEN);
MoveWindow(hWnd, (x
div 2) - (WindowWidth
div 2),
(y
div 2) - (WindowHeight
div 2),
WindowWidth, WindowHeight, true);
end;
WM_DESTROY: PostQuitMessage(0);
WM_KEYDOWN:
begin;
case wparam
of VK_ESCAPE: sendmessage(hwnd,WM_CLOSE,0,0);
end;
end;
else
Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
end;
end;
var
wc: TWndClassEx = (
cbSize : SizeOf(TWndClassEx);
Style : CS_HREDRAW
or CS_VREDRAW;
lpfnWndProc : @WndProc;
cbClsExtra : 0;
cbWndExtra : 0;
lpszMenuName :
nil;
lpszClassName : ClassName;
hIconSm : 0;
);
msg: TMsg;
begin
wc.hInstance := hInstance;
wc.hIcon := LoadIcon(0, IDI_APPLICATION);
wc.hCursor := LoadCursor(0, IDC_ARROW);
wc.hbrBackground := GetStockObject(BLACK_BRUSH);
RegisterClassEx(wc);
hwndMain := CreateWindowEx(0, ClassName, AppName,WS_POPUP
or WS_VISIBLE,
0,0, WindowWidth, WindowHeight, 0,
0, hInstance,
nil);
showcursor(false);
while true
do
begin
peekMessage(msg, 0, 0, 0,PM_REMOVE);
TranslateMessage(msg);
DispatchMessage(msg);
end;
showcursor(true);
ExitCode := msg.wParam;
end.