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

DelphiÖÐÁ÷µÄʹÓ㨱ȽÏÈ«Ã棩

Delphi ÖÐÁ÷µÄʹÓÃ(1) Óà TMemoryStream(ÄÚ´æÁ÷) ÈëÃÅ
Ç°ÑÔ:
Ëùν"Á÷", ¾ÍÊÇÒ»¶ÎÊý¾Ý»òÊÇÒ»¿éÄÚ´æ;
ÔÚ½øÐÐÁ÷²Ù×÷ʱ, ÎÒÃDz»±Ø¹ØÐÄÁ÷ÖеÄÊý¾Ýµ½µ×ÊÇʲô; Ö»ÐèÒªÖªµÀÁ÷µÄ´óСºÍµ±Ç°µÄÖ¸ÕëλÖÃ. ËùÒÔÁ÷Ö»ÓÐÁ½¸öÊôÐÔ:
Size¡¢Position.
¶ÔÁ÷µÄ²Ù×÷, ²»¹ý¾ÍÊǶÁÈ¡ºÍдÈë. ËùÒÔÁ÷×îÖ÷ÒªµÄ·½·¨¾ÍÊÇ Read ºÍ Write.
Ôںܶà¿Ø¼þµÄʹÓÃÖÐ, ¶ÁÈ¡Ö÷ÒªÓà LoadfromStream; дÈëÖ÷ÒªÓà SaveToStream.
¾Ù¸öÀý×Ó: (½¨Á¢Ð¹¤³Ì, Ìí¼ÓÁ½¸ö Memo¡¢Á½¸ö Button)
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
mStream: TStream; {ÉùÃ÷Ò»¸öÁ÷¶ÔÏó}
procedure TForm1.FormCreate(Sender: TObject);
begin
mStream := TMemoryStream.Create;
{TStream ÊdzéÏóÀà, Ö»ÄÜͨ¹ýÆä×ÓÀàʵÀý»¯; ÕâÀïÎÒÃÇÓÃÁËÄÚ´æÁ÷À´Éú³ÉʵÀý}
Memo1.Lines.Text := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
{¸ø Memo1 ¸ö³õʼֵ}
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.SaveToStream(mStream); {°Ñ Memo1 ÖеÄÄÚÈÝдÈëµ½Á÷}
ShowMessage(IntToStr(mStream.Size)); {26, µ±Ç°Á÷µÄ´óС}
ShowMessage(IntToStr(mStream.Position)); {26, µ±Ç°Á÷µÄÖ¸Õë}
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
mStream.Position := 4; {µ÷ÕûÁ÷µÄµ±Ç°Ö¸ÕëλÖÃ}
Memo2.Lines.LoadfromStream(mStream); {¶Á³öÁ÷ÖеÄÄÚÈݵ½ Memo2}
{
ÏÖÔÚ Memo2 ÖеÄÄÚÈÝÓ¦¸ÃÊÇ: EFGHIJKLMNOPQRSTUVWXYZ
Èç¹û Position ÊÇ 0, Memo2 ¶Á³öµÄÄÚÈÝ»áÊÇ: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Èç¹û Position µÈÓÚ Size, ÔÚÕâÀïÈç¹ûÊÇ 26, Memo2 ¾Í¶Á²»³öʲôÁË.
}
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
mStream.Free; {Á÷ÊÍ·Åʱ, ËùÓÃÄڴ浱ȻҲ»áͬʱÊÍ·Å}
end;
end.
ÓÃTFileStream£¨Îļþ


Ïà¹ØÎĵµ£º

ÔÚDELPHIÖÐÏÔʾGIF¶¯»­

ÏëûÏë¹ýÔÚDELPHIÖÐÏÔʾGIF¶¯»­£¿DelphiµÄÓû§ÊǷdz£ÐÒÔ˵ģ¬ÒòΪÓÐÃâ·Ñ¿Ø¼þ¿ÉÒÔʹÓá£×îÖøÃûµÄ¿Ø¼þÊÇAnders Melander±àдµÄTGifImage£¬²¢ÌṩÍêÕûµÄÔ´³ÌÐò¡£ËüÔ­À´µÄÖ÷Ò³ÊÇwww.melander.dk/delphi/gifimage/£¬²»¹ýÓкܳ¤Ê±¼äûÓиüÐÂÁË¡£Èç¹ûÒªÔÚа汾µÄDelphiÖÐʹÓ㬿ÉÒÔ´Óhttp://finn.mobilixnet.dk/delphi/ÏÂÔØFinn T ......

¹ØÓÚdelphiÖÐitemsºÍitemindexµÄÎÊÌâ

Ë÷ÒýÊÇitemindex
itemÊÇÀïÃæµÄÄÚÈÝ
Ë÷ÒýµÄ»°£¬ÊÇ´Ó0¿ªÊ¼
item   itemindex
A      1
B      2
C      3
listbox1.items.count¾ÍÊÇÕâ¸öÁбí¿òÀï×ܹ²ÓжàÉÙÏî. ......

delphiÖ¸Õë¼òµ¥ÈëÃÅ

delphiÖ¸Õë¼òµ¥ÈëÃÅ:  
   
  ¿´Ò»¸öÖ¸ÕëÓ÷¨µÄÀý×Ó£º  
  1         var  
  2             X,   Y:   Integer;       //   X   and   Y   ÕûÊýÀàÐÍ  
  3 ......

Delphi ÀàÓë¶ÔÏóÄÚ´æ½á¹¹Ç³Îö(ÏÂ)

¶ÔÏó¿Õ¼ä
ÄÚ´æ½á¹¹
¶ÔÏóµÄÄÚ´æ½á¹¹Êǹ̶¨µÄ£¬¶ÔÏó´´½¨Íê³Éºó¾ÍÎÞ·¨¸Ä±ä¡£ËüÖ÷Òª´æ´¢Á˶ÔÏóÖ±ÊôÀàµÄµØÖ·£¨µÈ¼ÛÓÚÀàµÄVMT£©£¬¶ÔÏó±¾ÉíµÄ³ÉÔ±Êý¾Ý£¬¶ÔÏóµÄ½Ó¿Ú·½·¨±íµØÖ·¡£½á¹¹ÈçͼËùʾ£º
˵Ã÷£ºÈôÀàδÉùÃ÷½Ó¿Ú£¬Ôò¶ÔÏó¿Õ¼ä²»´æ´¢½Ó¿Ú·½·¨±íµØÖ·¡£
 
Àà¿Õ¼äÓë¶ÔÏó¿Õ¼äµÄ¹Øϵ
Àà¿Õ¼äÓë¶ÔÏó¿Õ¼ä£º
ʾÀý£º·ÖÎö¶ÔÏóµÄ» ......

Delphi ÀàÓë¶ÔÏóÄÚ´æ½á¹¹Ç³Îö(¸½¼þ1)

¸½¼þ×ÊÁÏ
*ÀàµÄÄÚ´æÐÅÏ¢£¨´úÂ룩
ʾÀý£º»ñÈ¡ÀàÐÅÏ¢
˵Ã÷£º±È¶Ôͨ¹ýÀàµØÖ·ÒÔ¼°Í¨¹ýÀà·½·¨»ñÈ¡ÐÅÏ¢µÄЧ¹û¡£
´úÂ룺
type
    TMyObject = class(TObject)
    private
        FData: Integer;
    protected
    ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ