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. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately. 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.  Return ValuesThe return value specifies the result of the message processing and depends on the message sent.

解决方案 »

  1.   

    你查一下sendmessage函数的帮助即可.还要示例吗?
    如下:
    const
      MyMsg = WM_USER+ 20;....procedure TForm1.button1Click(Sender: TObject);
    begin
      SendMessage(Form2.handle, MyMsg, 0 ,0);
    end;...TForm2 = class(TForm)
     ..
    private
      procedure ProccessMyMsg(var Msg: TMessage);message MyMsg;
    end;procedure TForm2.ProcessMyMsg(var Msg: TMessage);
    begin
      showmessage('这是我的消息');
    end;给我分吧.
      

  2.   

    const
      MyMsg = WM_USER+ 20;
    写在那儿,曾么老是有错:
    [Error] CommTest.pas(17): Undeclared identifier: 'MyMsg'
      

  3.   

    呵呵,你在uses中加入unit1,
    把ProccessMyMsg()名称改为MyMsg 即可运行。
    注:win98,delphi5下测试通过
      

  4.   

    你在form2所在单元加入.
    unit unit2interfaceuses
      ....;const MyMsg = WM_USER + 20;type
      TForm2 = class(TForm)
        ...
      end;.....
    然后你在form1中加入unit2单元即可.
    uses unit2;
      .....