根据窗体句柄h,取得memo的句柄h1,然后向memo赋值
        h1:=FindWindowEx(h,0,'RE_show',nil);
        SendMessage(h1,WM_SETTEXT,0,0);
不知道怎么使用sendmessage,求助高手

解决方案 »

  1.   

    LRESULT SendMessage(    HWND hWnd, // handle of destination window
        UINT Msg, // message to send
        WPARAM wParam, // first message parameter
        LPARAM lParam  // second message parameter
       );
     ParametershWndIdentifies the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows. MsgSpecifies the message to be sent. wParamSpecifies additional message-specific information. lParamSpecifies additional message-specific information. 
      

  2.   

    你sendmessage的消息类型是什么呢?
    最好用spy++模拟一次
      

  3.   

    h1:=FindWindowEx(h,0,'RE_show',nil); 
    SendMessage(h1,WM_SETTEXT,0,PChar('dfsasfd'));
      

  4.   

    h1:=FindWindowEx(h,0,'RE_show',nil);  
    SendMessage(h1,WM_SETTEXT,0,Integer(PChar('dfsasfd')));
    还要强转,忘了
      

  5.   

    SendMessage函数可以向一个或多个窗体发送消息,在发送消息时此函数会调用窗体对应此消息处理过程(也可说是处理函数),直到从此窗体消息处理过程完成.
    En文:
    The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. 参数列表:
    LRESULT SendMessage(
        HWND hWnd, // handle of destination window,也就是消息发送的目标窗体对应的句柄,在D中如Button.Handle
        UINT Msg, // message to send 被发送的消息代号
        WPARAM wParam,// first message parameter 消息代号的第1个参数
        LPARAM lParam // second message parameter 消息代号的第2个参数
    );
      

  6.   

    下面给一个自定义消息的例子:
    Form2:unit Unit2;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;const
      WM_ADDOPER = WM_USER + 1234; //窗体2执行两个整数相加type
      TForm2 = class(TForm)
      private
        procedure DoWMAddOper(var Msg: TMessage); message WM_ADDOPER;
      public
        { Public declarations }
      end;var
      Form2: TForm2;implementation{$R *.dfm}{ TForm2 }procedure TForm2.DoWMAddOper(var Msg: TMessage);
    begin
      //  结果      第1个参数   + 第2个参数
      Msg.Result := Msg.LParam + Msg.WParam;
    end;end.Form1:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementationuses Unit2;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      i: Integer;
    begin
      //向Form2发WM_ADDOPE消息使其计算R12+24的,并结果显示
      i := SendMessage(Form2.Handle, WM_ADDOPER, 12, 24);
      ShowMessage(IntToStr(i));
    end;end.
      

  7.   

    这个函数比较简单,关键可能是要学习一些Windows消息
      

  8.   

    重要的不是SendMessage,而是WM_SETTEXT消息
    该消息是为了兼容以前的Windows版本,而使用了跨进程的通讯处理,所以即使是其他进程的窗体,系统也会将lParam中指向的字符串使用进程间通讯搞定
      

  9.   

    如果我是用shellexcute来调用另一个exe文件,那个exe是用vc写的,上面有一个编辑框,我要对那个编辑框传参数,然后做动作。
    我也可以这样来写吗?
    还有,我怎样获得那个编辑框的句柄啊?
    请赐教!
      

  10.   

    可以搞定,至于如何获得句柄你需要先分析它的窗体结构,用FindWindow找主窗体,然后用FindWindowEx找子窗体
    对于VC写的东西,窗体的ID是固定的,所以你可以先在文本框填一些数据,用标题找到句柄,然后用GetDlgCtrlID得到ID,当然你用Spy++这种工具直接看ID和句柄更方便。以后就可以用GetDlgItem通过ID来定位这个编辑框的句柄了(当然还是得先找到主窗体的句柄)