unit Main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls;

type
  TfMain = class(TForm)
    btnStartThread: TButton;
    st: TStaticText;
    procedure btnStartThreadClick(Sender: TObject);
  private
  end;

var fMain: TfMain;

implementation

{$R *.DFM}

function ThreadFunc(Param: Integer) :Integer;
var
  i : integer;
  s : string;
begin
  for i:= 0 to 2000000 do
    if i mod 10 = 0 then begin
      s := IntToStr(i);
      SendMessage(Param, WM_SETTEXT, 0, Integer(PChar(s)));
    end;
  Result := 0;
end;

procedure TfMain.btnStartThreadClick(Sender: TObject);
var
  h : THandle;
  ThreadId :Cardinal;
begin
  h := BeginThread (nil, 128, @ThreadFunc, Pointer(st.Handle), 0, ThreadId);
  CloseHandle(h);
end;

end.
