如题,xxxx:='aaa';
PostMessage(Application.MainForm.Handle,WM_SETSTATUSBAR,xxxx,0);
结果失败,
响应WM_SETSTATUSBAR的函数如何写

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, DB, ADODB, QuickRpt, ExtCtrls, QRCtrls, StdCtrls;
    const
        MY_MSG= WM_USER+100;
    type  TForm1 = class(TForm)
        Panel1: TPanel;
        Panel2: TPanel;
        Button2: TButton;
        procedure Button2Click(Sender: TObject);
        procedure GetStrMsg(var Msg:TMessage);message MY_MSG;
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button2Click(Sender: TObject);
    begin
      PostMessage(Handle,MY_MSG,Integer(PChar('abcd')),0);
    end;procedure TForm1.GetStrMsg(var Msg: TMessage);
    begin
      Caption := string(Msg.WParam);
    end;end.
      

  2.   

    var
      s: String;
    begin
      s := 'some string';
      PostMessage(Handle, WM_SETSTATUSBAR, Integer(s), 0);
    end;消息处理函数中使用如下语句取得字符串:
      s := String(Msg.WParam);