program nonVCL;
{$APPTYPE CONSOLE}
uses
SysUtils, Windows, Messages;
var
MyNoVCLClass: TWndClassEx;
function WndProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM;
lParam: LPARAM): LRESULT;
stdcall;
begin
Result := 0;
case uMsg
of
WM_ERASEBKGND:
begin
DefWindowProc(hWnd, uMsg, wParam, lParam);
//DC in wParam
MoveToEx(wParam, 10, 10,
nil);
LineTo(wParam, 180, 180);
Result:= 1;
end;
WM_CREATE:
begin
CreateWindow('
Edit', '
AEdit', WS_VISIBLE
or WS_CHILD,
80, 80, 100, 30, hWnd, 0, HInstance,
nil);
CreateWindow('
Button', '
AButton', WS_VISIBLE
or WS_CHILD,
0, 0, 100, 30, hWnd, 0, HInstance,
nil);
end;
WM_DESTROY:
begin
PostQuitMessage(0);
end;
else
Result:= DefWindowProc(hWnd, uMsg, wParam, lParam);
end;
end;
procedure InitWindowClass;
begin
MyNoVCLClass.style := 0;
MyNoVCLClass.cbSize := SizeOf(TWndClassEx);
MyNoVCLClass.lpfnWndProc:= @WndProc;
MyNoVCLClass.cbClsExtra:= 0;
MyNoVCLClass.cbWndExtra:= 0;
MyNoVCLClass.hInstance:= HInstance;
MyNoVCLClass.hIcon:= 0;
MyNoVCLClass.hCursor:= LoadCursor(0, IDC_ARROW);
MyNoVCLClass.hbrBackground:= COLOR_WINDOW;
MyNoVCLClass.lpszMenuName:=
nil;
MyNoVCLClass.lpszClassName:= '
MyTest';
MyNoVCLClass.hIconSm:= 0;
RegisterClassEx(MyNoVCLClass);
end;
var
MSG: TMSG;
TempError: Cardinal;
begin
InitWindowClass;
WriteLn(IntToStr(GetLastError));
//2
CreateWindowEx(WS_EX_WINDOWEDGE
or WS_EX_CONTROLPARENT
or WS_EX_APPWINDOW,
'
MyTest', '
Caption',
WS_OVERLAPPEDWINDOW
or WS_VISIBLE,
200, 200, 250, 200,
0, 0, hInstance,
nil);
WriteLn(IntToStr(GetLastError));
//0
while (GetMessage(MSG, 0, 0, 0))
do //verzichte auf Überprüfung auf -1, da hier unnötig
begin
TranslateMessage(MSG);
//nötig für Texteingaben
DispatchMessage(MSG);
TempError:= GetLastError;
if(TempError <> 0)
then
WriteLn(IntToStr(TempError));
end;
UnregisterClass(MyNoVCLClass.lpszClassName, HInstance);
end.