Delphi¶àÏß³Ìѧϰ£¨10£©£ºLabel(VCL)ͬ²½µÄÎÊÌâ
ÉÏÎÄÖУ¬¶àÏß³Ìͬ²½Ö÷´°ÌåµÄLabelµÄCaptionÊôÐÔÖµ£¬·¢ÏÖÒ»¸öÎÊÌ⣺ʹÓÃSynchronizeÓÃÓÚͬ²½µÄʱºò£¬Ö÷´°ÌåºÃÏñËÀµôÒ»Ñù£»¶øÖ±½ÓÓÃ×Ó³ÌÐòΪLabelµÄÒýÓø³Öµ£¬ÔòÓÐʱ»á³öÏÖ“Canvas does not allow drawing”´íÎó¡£ÊéÉÏ˵VCLͬ²½Ò»¶¨ÒªÓÃSynchronize£¬¶ø²»ÄÜÖ±½Ó·ÃÎÊ¡£
²âÊÔ£º
{Ö÷´°Ìå}
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses TestThread;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
TTestThread.Create(Label1);
//TTestThread.Create(Label2);
//TTestThread.Create(Label3);
end;
end.{¶àÏß³ÌÀà}
unit TestThread;
interface
uses
Classes,StdCtrls;
type
TTestThread = class(TThread)
private
{ Private declarations }
FLabel:TLabel;
Fstr:string;
procedure UpdateLabel;
protected
procedure Execute; override;
public
constructor Create(Lab:TLabel);
end;
implementation
uses Unit2,SysUtils,windows;
{ TTestThread }
constructor TTestThread.Create(Lab: TLabel);
begin
FLabel:=Lab;
Inherited Create(False);
FreeOnTerminate:=True;
end;
procedure TTestThread.Execute;
var
i:Integer;
begin
{ Place thread code here }
for i := 0 to 20000 do
begin
if Not Terminated then
begin
Fstr:=Format('Ïß³ÌID£º%d,µÚ%d¸öÑ»·',[GetCurrentThreadID,i]);
//UpdateLabel;
Synchronize(UpdateLabel);
end;
end;
end;
procedure TTestThread.UpdateLabel;
begin
FLabel.Caption:=Fstr;
end;
end.
¾¹ý²âÊÔ£¬Ö»´´½¨Ò»¸öỊ̈߳¬ÓÃSynchronizeͬ²½Ö÷´°ÌåµÄÒ»¸öLabel£¬ÄÇô³ÌÐòÎÞÎÊÌ⣬¿ÉÒÔ¼ûµ½Í¬²½µÄ¹ý³Ì¡£µ±Í
Ïà¹ØÎĵµ£º
Ò»¸öÑ¡µ¥´óÖÂÊÇÕâÑù£º
1.¿ÉÒÔ±»ÒÔijÖÖÐÎʽºô½Ð³öÀ´£¬Èç°´ÏÂesc£»
2.ÔÚÕâ¸öÑ¡µ¥Öй¦ÄܼüÓв»Í¬µÄ¶¨Ò壬ÈçÔ±¾·½Ïò¼ü¿ØÖÆ×ß·£¬µ«ÏÖÔÚ¸ÄΪ¿ØÖƹâ±êµÄλÖã»
3.°´ÏÂÈ·¶¨¼üºóÓжÔÓ¦¹¦Äܱ»Ö´ÐУ»
4.¿ÉÒÔ±»¹Ø±Õ¡£
ÄÇôÎҵİ취ÊDZàдÁ½¸ö×ӳ̣¬ÆäÖÐÒ»¸ö´¦ÀíÑ¡µ¥ÖеÄʼþ£¬ÁíÍâÒ»¸öרߺÔð»Ñ¡µ¥¡£
ÔÚ´Ó²½ÐÐÇл»µ½Ñ¡µ¥ ......
DelphiÖ®Tchart¿Ø¼þʹÓÃÐĵÃ
×î½üÔÚѧϰdelphi£¬×öÒ»¸öÈí¼þÁ·ÊÖ£¬Óõ½Tchart¿Ø¼þ£¬ÓÐЩ´ÖÂÔµÄʹÓÃÐĵ㬹©delphi³õѧÕ߲ο¼¡£
TChartÊÇdelphiÀïÃæÒ»¸ö±ê×¼µÄͼÐÎÏÔʾ¿Ø¼þ¡£Ëü¿ÉÒÔ¾²Ì¬Éè¼Æ£¨at design time£©Ò²¿ÉÒÔ¶¯Ì¬Éú³É¡£¿ÉÏÂÔØSteema TeeChart 7£¬Ã»ÓÐÔ´´úÂ룬ÄÜÓþͺã¡
&nb ......
¹ØÓÚdelphi Assigned
1.¸ù¾Ý Delphi Ö¸Áî²Î¿¼ÊÖ²áÖÐ
˵Ã÷£º
Assigned º¯Ê½ÔÚ²ÎÊý²»Îªnilʱ´«»ØTrue,±íʾָÕëÒѾָµ½Ä³¸öÄÚ´æµØÖ·£¬Õâ¸öÄÚ´æµØÖ·¿ÉÄÜÊÇÒ»¸ö¶ÔÏóµØÊ×µØÖ·£¬Ò²¿ÉÄÜÔÚº¯Êý»ò¹ý³ÌÖУ¬ÉùÃ÷Ò»¸öÖ¸Õë±äÁ¿£¬Ã»Óи³ÖµÎªnil £¬ÎÞÂÒµÄÖ¸Ïòij´¦£¬ÕâÁ½¸öÖÖÇé¿ö£¬Assigned£¨Ö¸Õë±äÁ¿£©¶¼²»Îªnil , º¯Êý·Å»ØTrue£»
¶ø² ......
http://www.91v1.cn/bbs/read.php?tid-1797.html
ÎÒÃÇÌṩµÄÊÇÈ«Ì×,ĿǰËûÃÇ·¢µÄ.ÉçÇøÒÑÂ¼ÖÆÍê±Ï.Ò»¸ùë²»ÉÙ.
-------------------------------------------------------------------------------------------------------------------------
¸Ã½Ì³ÌÓÉ91v1ÉçÇøÃâ·ÑÌṩ.¾ßÌåÃâ·ÑÁìÂëÏêÇé¹Û¿´ÖÖ×Ó°ü,
--------------- ......