uses
windows,
sysutils,
messages,
classes;
const
WM_MY_SOCKET_DATA = WM_USER + 1;
WM_MY_SOCKET_ERROR = WM_USER + 2;
WM_MY_SOCKET_LOGON = WM_USER + 3;
WM_MY_SOCKET_CLIENT_DISCONNECT = WM_USER + 4;
function MainWndProc(wnd: HWND; Msg: Integer; wp: WPARAM;
lp: LPARAM): Integer;
stdcall;
forward;
var
_Terminated : Boolean;
_hWndMain : HWND;
MySocketMainWindowClass : TWndClass = (style: 0; lpfnWndProc: @MainWndProc;
cbClsExtra: 0; cbWndExtra: 0; hInstance: 0; hIcon: 0; hCursor: 0;
hbrBackground: 0; lpszMenuName:
nil; lpszClassName: '
MySocketWindowClass'
);
function MainWndProc(wnd: HWND; Msg: Integer; wp: WPARAM;
lp: LPARAM): Integer;
stdcall;
begin
Result := 0;
case Msg
of
WM_MY_SOCKET_DATA:
begin
//-- WMOnAsyncServerData(wp, lp);
end;
WM_MY_SOCKET_ERROR:
begin
//-- WMOnAsyncServerError(wp, lp);
end;
WM_MY_SOCKET_LOGON:
begin
//-- WMOnAsyncServerLogon(wp, lp);
end;
WM_MY_SOCKET_CLIENT_DISCONNECT:
begin
//-- WMOnAsyncServerDisconnect(wp, lp);
end;
WM_CLOSE:
begin
DestroyWindow(wnd);
end;
WM_DESTROY:
begin
end;
else
Result := DefWindowProc(wnd, Msg, wp, lp)
end;
end;
function InitAplication : Boolean;
begin
Result := FALSE;
MySocketMainWindowClass.hInstance := hInstance;
if Windows.RegisterClass(MySocketMainWindowClass) = 0
then
raise exception.Create('
InitAplication: RegisterClass FAILED');
_hWndMain := CreateWindowEx(WS_EX_TRANSPARENT ,
MySocketMainWindowClass.lpszClassName, '
', WS_DISABLED, 0, 0, 0, 0, 0, 0,
hInstance,
nil);
if _hWndMain = 0
then
raise exception.Create('
InitAplication: CreateWindowEx FAILED');
//-- Hier Socketverbindung aufbauen
//-- result := InitConnections(_hWndMain);
//-- if not result then
//-- raise exception.Create('InitAplication: InitConnections FAILED')
end;
procedure CleanupAplication;
begin
if _hWndMain <> 0
then begin
DestroyWindow(_hWndMain);
_hWndMain := 0;
end;
end;
procedure RunAplication;
var
MsgRec : TMsg;
begin
while GetMessage(MsgRec, 0, 0, 0)
do begin
DispatchMessage(MsgRec)
end;
_Terminated := TRUE;
end;
begin
InitAplication;
try
RunAplication;
finally
CleanupAplication;
end;
end.