Einzelnen Beitrag anzeigen

Astat

Registriert seit: 2. Dez 2009
Ort: München
320 Beiträge
 
Lazarus
 
#4

Re: Unknown Directive Message

  Alt 1. Mär 2010, 14:53
Hallo jokerfacehro, anbei Template Vorlage, für Verwendung einer eigenen WndProc.

Delphi-Quellcode:

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.
lg. Astat
Lanthan Astat
06810110811210410503210511511603209711003210010110 9032084097103
03211611111604403209711003210010110903210010510103 2108101116122
11610103209010110510810103206711110010103210511003 2068101108112
10410503210310111509910411410510109810111003211910 5114100046
  Mit Zitat antworten Zitat