// Window-Prozedur
function WndProc(hWnd: HWND; uMsg: UINT; wParam: wParam; lParam: LParam): lresult;
stdcall;
begin
Result := 0;
case uMsg
of
WM_DESTROY: WMDestroy(hWnd);
// Timer löschen und PostQuitMessage();
WM_CREATE: hTimer := WMCreate(hWnd);
// Timer erstellen
WM_CLOSE: PostQuitMessage(0);
WM_TIMER: WMTimer(hWnd);
// Timer zum neuzeichnen
else
Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
end;
end;
// Preview-Main
procedure PreView;
var
parentwindow: HWND;
Rec: TRect;
begin
Window.hbrBackground := CreateSolidBrush(
RGB(0, 0, 0));
Window.hInstance := hInstance;
Window.hIcon := LoadIcon(hInstance,MAKEINTRESOURCE(100));
Window.hCursor := LoadCursor(0, IDC_ARROW);
Window.lpszClassName := ClassName;
Window.lpfnWndProc := @WndProc;
RegisterClassEx(Window);
parentwindow := StrToIntDef(ParamStr(2), 0);
GetWindowRect(parentwindow, Rec);
Width := Rec.Right - Rec.Left;
Height := Rec.Bottom - Rec.Top;
CreateWindowEx(0, ClassName, AppName,
WS_VISIBLE
or WS_CHILD
or WS_POPUP,
Rec.Left, Rec.Top, Width, Height,
parentwindow, 0, hInstance,
nil);
// [...] weiter mit nachrichtenschleife
end;