在线程中使用SendMessage发送消息到主窗口
表示进度的数字标识做为SendMesage的lParam或wParam参数发过去.主窗口重载WndProc进行该消息处理. 示例如下const  //自定义消息
     MSG_MYPROGRESS= $0400 + 100;type
  TForm1 = class(TForm)
  private
    procedure WndProc(var Message: TMessage); override; //重载TForm的WndProc
  end;procedure TForm1.WndProc(var Message: TMessage);
var h: hwnd;
begin
  inherited;  //继续TForm原来的方法
  if Message.Msg = MSG_MYPROGRESS then begin
     ProgressBar1.Position := Message.LParam;
  end;
end;线程中发送消息, mainhand需要你创建线程时传进去
for i:=0 to n do begin
    //.........
    SendMessage(mainHand , MSG_MYPROGRESS, i, i);
end;

解决方案 »

  1.   

    我没有用过nmstrm。但
    Readbuffer、writebuffer
      

  2.   

    只要相关的都可以说一些,比如serversocket1clientread的线程接收
      

  3.   

    他说得没错,肯定有分,但这只是问题的一方面,另一方面是,我怎样才能得到nmatrm的onpacketsent事件呢?得不到他,我就没法知道已发送了多少阿!请问各位有何高见?
    我发送用的是myfile:tfilestream;
               myfile:=tfilestream.create(‘xxxxx’,fmopen);
      

  4.   

    使用线程的同步方法试试:Synchronize(onpacketsent);
      

  5.   

    他说得没错,肯定有分,但这只是问题的一方面,另一方面是,我怎样才能得到nmatrm的onpacketsent事件呢?得不到他,我就没法知道已发送了多少阿!请问各位有何高见?
    我发送用的是myfile:tfilestream;
              myfile:=tfilestream.create(‘xxxxx’,fmopen); 
      

  6.   

    写个参数和onpacketsent对应的过程,把该过程赋给该事件就可以了
      

  7.   

    telstar(小李大刀),您能不能给个例子,我真的没接触过这些,谢谢!一定给分!