我们在pb中截获到49417消息,在delphi里面我们需要对该消息进行处理,但是delphi所能处理的消息必须是小于49151.我们不知道delphi对这种大号消息号是怎么样处理的。有熟悉的高手请指教

解决方案 »

  1.   

    我们的问题是想在delphi里面怎么响应这个消息。我们通过registerwindowmessage('rasdialevent')来得到这个消息的。高手请教了啊
      

  2.   

    “delphi所能处理的消息必须是小于49151”
    你确定么?那么为什么sendmessage的第二个参数是cardinal类型的?
      

  3.   

    Windows预设的处理函数,如画窗体的WM_NCPAINT消息等
      Result := DefWindowProc(Handle, MsgID, wParam, lParam);
    end; begin
      // 首先使用RegisterClass()注册窗体的类,这可不是Delphi数据类型中的类哦!
      wc.style := CS_HREDRAW or CS_VREDRAW;
      wc.lpfnWndProc := @MainWndProc; // 消息处理函数的地址
      wc.hInstance := hInstance; // 程序的句柄,同时也是基地址
      wc.hIcon := LoadIcon(0, PChar(IDI_APPLICATION));
      wc.hCursor := LoadCursor(0, IDC_ARROW); // 图标
      wc.hbrBackground := GetStockObject(WHITE_BRUSH); // 背景画刷
      wc.lpszClassName := ClassName; // 前面定义的常量
      if RegisterClass(wc) = 0 then Halt(0);
      hWnd := CreateWindowEx(0,
        ClassName, // 刚才注册的类的名称
        'Sample', // 窗体的标题
        WS_OVERLAPPEDWINDOW, // 窗体有标题栏、系统菜单、最大小化菜单,以及拉伸边框
        Integer(CW_USEDEFAULT),
        Integer(CW_USEDEFAULT),
        Integer(CW_USEDEFAULT),
        Integer(CW_USEDEFAULT),
        0,
        0,
        hInstance,
        nil
      );
      if hWnd = 0 then Halt(0);
      ShowWindow(hWnd, CmdShow);
      UpdateWindow(hWnd);
      while GetMessage(Msg, 0, 0, 0) do begin
        TranslateMessage(Msg);
        DispatchMessage(Msg); // 该API将消息分派到相应的窗体消息处理函数
      end;
      ExitCode := Msg.wParam;
    end.
      

  4.   

    你是说:procedure test(var msg:tmessage);message 49157;编译不能通过么?
    那就重载wndproc:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
        procedure wndproc(var msg:tmessage);override;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
    sendmessage(handle,49157,0,0);
    end;procedure TForm1.wndproc(var msg: tmessage);
    begin
      if msg.Msg=49157 then
      beep
      else
      inherited;end;end.
      

  5.   

    重载WndProc过程, 在此过程中处理此消息。
      

  6.   

    0 to WM_USER - 1: Windowse system used
    WM_USER to $07FF(49151): custom use
    WM_APP to $BFFF: use for comunicating between applications
    $C000 to $FFFF: for string message (see also registerwindowmessage)
     > $FFFF: reserve by future use
      

  7.   

    搞错了:(0 to WM_USER - 1: Windowse system used
    WM_USER to $7FFF(49151): custom use
    WM_APP to $BFFF: use for comunicating between applications
    $C000 to $FFFF: for string message (see also registerwindowmessage)
     > $FFFF: reserve by future use
      

  8.   

    还有就是接管application.onmessage:
    但是不能得到sendmessage和perform的消息。
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
        procedure myonmessage(var Msg: TMsg; var Handled: Boolean);
        procedure wndproc(var msg:tmessage);override;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    function mousehookproc(ncode:smallint;wparam,lparam:integer):integer;stdcall;
    beginend;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    postmessage(handle,49157,0,0);
    end;
    procedure TForm1.wndproc(var msg: tmessage);
    begin
      if msg.Msg=49157 then
      beep
      else
      inherited;end;procedure TForm1.FormCreate(Sender: TObject);
    begin
    application.OnMessage:=myonmessage;
    end;procedure TForm1.myonmessage(var Msg: TMsg; var Handled: Boolean);
    begin
      if msg.message=49157 then
      begin
        showmessage('49157');
      end;
    end;end.