Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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£¬ÄÇô³ÌÐòÎÞÎÊÌ⣬¿ÉÒÔ¼ûµ½Í¬²½µÄ¹ý³Ì¡£µ±Í


Ïà¹ØÎĵµ£º

SDL & Object Pascal (Delphi) [2] ÏÔʾÖÐÎÄ×Ö·û

һЩ»ù´¡µÄÎÊÌâÎÒ²»ÔÙ׸ÊöÁË£¬²éÔİïÖúÎĵµ£¨Object Pascal SDL Doc.chm£©ÏÔÈ»±ÈÔÚÕâ¿´ÎÒºú³¶ºÏÊʵöࡣÄÇЩ»­ÏñËØ£¬»ñÈ¡ÏñËØÐÅÏ¢£¬ÏÔʾBMPÎļþ¶àÊýʱºòÖ»Òª°ÑÄÇЩ´úÂë¸´ÖÆ¹ýÀ´»ù±¾¾ÍÄܹ¤×÷¡£ÏÂÃæËµµÄÊÇÔõÑùÏÔʾÖÐÎÄ¡£
ÆäʵSDL¼ÓÉÏttfÖ§³Öʱ£¨ÐèÒª½«¶ÔÓ¦µÄdllÎļþÌí¼Óµ½¹¤³ÌĿ¼ÀÊÇÍêÈ«¿ÉÒÔÏÔʾÖÐÎĵ쬼òÌåºÍ·±Ì嶼ûΠ......

Delphiµ÷ÊÔDLL ²»Äܵ÷ÊÔ ²»ÄܽøÈëµ÷ÊÔ ×¢Ò⣡£¡£¡

ÈçºÎµ÷ÊÔDLL£¬ÔÚÕâÀï¾Í²»ÔÙ׸ÊöÁË£¬µ«ÊÇ£¬½ñÌì¾ÍÅöµ½ÁËÒ»¸öÌØ±ðÆæ¹ÖµÄÎÊÌ⣬²ÎÊýÉèÖÃÕýÈ·£¬¾ÍÊDz»Äܵ÷ÊÔ£¿£¿ ͨ¹ýÉÏÍø²é×ÊÁÏ£¬·¢ÏÖÁËÎÊÌ⣬עÒ⣺
  1£¬ ½«ProjectÖ÷²Ëµ¥µÄProject Options¶Ô»°¿òµÄCompilerÒ³ÃæDebuggingÑ¡ÏîÖÐµÄ Debug informaton¡¢Local symbols¡¢Assertions¸´Ñ¡¿òÑ¡ÖÐ
  2£¬½«ToolsÖ÷²Ëµ¥µÄD ......

¹ØÓÚ Delphi TThread

TThreadÊÇÒ»¸ö³éÏóÀà,ÓÃÓÚÔÚdelphiÖд´½¨Ï̡߳£
´´½¨Ò»¸öTThreadµÄ×ÓÀà¶ÔÏó¼´Ï൱ÓÚ´´½¨Ò»¸öÏ̡߳£¡¡¡¡
µ±Ò»¸öÓ¦ÓóÌÐòÔËÐÐʱ£¬Ó¦ÓóÌÐò¾Í±»ÔØÈëÄÚ´æ×¼±¸Ö´ÐС£´Ëʱ£¬Ëü³ÉΪ°üº¬Ò»¸ö»ò¶à¸öÏ̵߳Ľø³Ì¡£Ïß³ÌÖ´ÐÐÓ¦ÓóÌÐòµÄ²¿·ÖÄÚÈÝ£¬²¢ÓɲÙ×÷ϵͳ·ÖÅäCPUʱ¼ä¡£Í¬Ò»½ø³ÌµÄËùÓÐÏ̹߳²ÏíͬһµØÖ·¿Õ¼ä£¬¿ÉÒÔ·ÃÎʽø³ÌµÄÈ«¾Ö±äÁ¿ ......

DELPHI Èô°Ìå²»ÔÚÈÎÎñÀ¸ÏÔʾ

ÐèÒªÓõ½µÄÒ»¸öº¯Êý£º
LONG SetWindowLong(
HWND hWnd,
int nIndex,
LONG dwNewLong
);
ÆäÖÐnIndex GWL_EXSTYLE     Retrieves the extended window styles.
dwNewLong   WS_EX_TOOLWINDOW     Creates a tool window; that is, a window intended to ......

Delphi¶àÏß³Ìѧϰ£¨3£©£ºÏß³Ìͬ²½µÄÔ­Òò

ÔÚʹÓöàÏ̵߳Äʱºò£¬Èç¹û¶àÏ̶߳Ôij¸öÌØ¶¨µÄ¹«¹²Êý¾Ý»ò×ÊÔ´½øÐзÃÎÊ£¬ÐèÒª¶Ô¶àÏ߳̽øÐÐЭµ÷²Ù×÷£¬½Ð×öÏß³Ìͬ²½¡£
     ÀýÈ磺Èý¸öÏ̷ֱ߳ðÑ­»·µØÏòListBoxÖÐдÈëÊý¾Ý¡£Ã»ÓнøÐÐͬ²½Ê±£¬Ð´ÈëµÄ˳ÐòÊDz»È·¶¨µÄ¡£
{Ö÷´°Ìå´úÂë}
unit Unit2;

interface

uses
Windows, Messages, SysUtils, V ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ