简单问题,在线等待,谢谢指教(39分)

  • 主题发起人 主题发起人 lzc1_nuaa
  • 开始时间 开始时间
L

lzc1_nuaa

Unregistered / Unconfirmed
GUEST, unregistred user!
大哥,不要紧张,非常简单,只是现在我还不知道
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure textout1;
procedure textout2;
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.textout1;
var
i:longint;
DC:HDC;
s:string;
begin
DC:=GetDC(Form1.Handle);
for i:=0 to 10000do
begin
s:=inttostr(i);
TextOut(DC,10,10,pchar(s),length(s));
end;
ReleaseDC(Form1.Handle,DC);
end;
procedure TForm1.textout2;
var
i:longint;
DC:HDC;
s:string;
begin
DC:=GetDC(Form1.Handle);
for i:=0 to 10000do
begin
s:=inttostr(i);
textout(DC,10,80,pchar(s),length(s));
end;
ReleaseDC(Form1.Handle,DC);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
begin
edit1.Clear;
edit1.Update;
i:=strtoint(edit1.Text);
edit1.Text:=inttostr(i*i);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
thread1,thread2:DWORD;
begin
CreateThread(nil,0,@TForm1.textout1,nil,0,thread1);
CreateThread(nil,0,@TForm1.textout2,nil,0,thread1);
end;
end.
问题是:
CreateThread(nil,0,@TForm1.textout1,nil,0,thread1);
CreateThread(nil,0,@TForm1.textout2,nil,0,thread1);
不能编译,textout1,textout2 不是TForm1 的方法,不能由TForm1调用
 
不解
textout1,textout2 不是TForm1 的方法

type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure textout1;
procedure textout2;
中的
procedure textout1;
procedure textout2;
是谁的
 

CreateThread(nil,0,@TForm1.textout1,nil,0,thread1);
錯誤
改為
function fTextOut1(p:Pointer): Integer;
begin
Form1.TextOut1;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
thread1,thread2:DWORD;
begin
CreateThread(nil,0,@fTextOut1,nil,0,thread1);
end;
end.
 
我的意思是,我那样写有错误,就好象TForm1不认识textout1,textout2一样,问题在那里?谢谢
 
程序是没有错的,
 
如果使用CreateThrad,不如用begin
Thread,用法一樣.
 
不能將textout1,textout2定義為TForm的過程
直接定義為
procedure textout1;
procedure textout2;
 
to:holyknight
我试一试
very right,thank you,accept my gift
to:p3vhp
thank for your answer
 
楼上的你试过没有?
我完全copy楼主的代码的,可以运行的,没有错误:)
 
当然试过了,不能通过。 我用的是D5
 
我说呢,我是D6
 
后退
顶部