| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 27405 人关注过本帖, 5 人收藏
标题:[分享]新手和CN必看
只看楼主 加入收藏
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
-----------------------------------------------------------------------------
Low 传回注脚的最小值.
-----------------------------------------------------------------------------
Unit System
函数原型 function Low(X);
说明 Ordinal type The lowest value in the range of the type
Array type The lowest value within the range of the
index type of the array
String type Returns 0
Open array Returns 0
String parameter Returns 0
-----------------------------------------------------------------------------
Ord 传回列举型态的数值.
-----------------------------------------------------------------------------
Unit System
函数原型 function Ord(X): Longint;
范例 procedure TForm1.Button1Click(Sender: TObject);
type
Colors = (RED,BLUE,GREEN);
var
S: string;
begin
S := 'BLUE has an ordinal value of ' + IntToStr(Ord(RED)) +
#13#10;
S := S+'The ASCII code for "c" is ' + IntToStr(Ord('c')) + '
decimal';
MessageDlg(S, mtInformation, [mbOk], 0);
end;
-----------------------------------------------------------------------------
Round 将实数转为整数.(有四舍五入)
-----------------------------------------------------------------------------
Unit System
函数原型 function Round(X: Extended): Longint;
范例 var
S, T: string;
begin
Str(1.4:2:1, T);
S := T + ' rounds to ' + IntToStr(Round(1.4)) + #13#10;
Str(1.5:2:1, T);
S := S + T + ' rounds to ' + IntToStr(Round(1.5)) + #13#10;
Str(-1.4:2:1, T);
S := S + T + ' rounds to ' + IntToStr(Round(-1.4)) + #13#10;
Str(-1.5:2:1, T);
S := S + T + ' rounds to ' + IntToStr(Round(-1.5));
MessageDlg(S, mtInformation, [mbOk], 0);
end;
-----------------------------------------------------------------------------
Trunc 将实数转为整数.(小数直接舍弃)
-----------------------------------------------------------------------------
Unit System
函数原型 function Trunc(X: Extended): Longint;
Untyped file routines
var
S, T: string;
begin
Str(1.4:2:1, T);
S := T + ' Truncs to ' + IntToStr(Trunc(1.4)) + #13#10;
Str(1.5:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(1.5)) + #13#10;
Str(-1.4:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.4)) + #13#10;
Str(-1.5:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.5));
MessageDlg(S, mtInformation, [mbOk], 0);
end;
-------------------------
var

f: file of Integer;
i,j: Integer;
begin
AssignFile(f,'TEST.INT');
Rewrite(f);
for i := 1 to 6 do
Write(f,i);
Writeln('File before truncation:');
Reset(f);
while not Eof(f) do
begin
Read(f,i);
Writeln(i);
end;
Reset(f);
for i := 1 to 3 do
Read(f,j); { Read ahead 3 records }
Truncate(f); { Cut file off here }

Writeln;
Writeln('File after truncation:');
Reset(f);
while not Eof(f) do

begin
Read(f,i);
Writeln(i);
end;
CloseFile(f);
Erase(f);
end;

-----------------------------------------------------------------------------
BlockRead 读取档案至记忆体区块.
-----------------------------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
FromF, ToF: file;
NumRead, NumWritten: Integer;
Buf: array[1..2048] of Char;
begin
if OpenDialog1.Execute then { 开档对话盒}
begin
AssignFile(FromF, OpenDialog1.FileName);{}
Reset(FromF, 1); { Record size = 1 }
if SaveDialog1.Execute then { Display Save dialog box}
begin
AssignFile(ToF, SaveDialog1.FileName);{ Open output file }

Rewrite(ToF, 1); { Record size = 1 }
Canvas.TextOut(10, 10, 'Copying ' + IntToStr(FileSize(FromF))+'bytes...');
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);
CloseFile(FromF);
CloseFile(ToF);
end;
end;
end;
## BlockRead, BlockWrite, SaveDialog Example


情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:52
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
-----------------------------------------------------------------------------
BlockWrite 将记忆体区块写入档案.
-----------------------------------------------------------------------------
Unit System
函数原型 procedure BlockRead(var F: File; var Buf; Count: Integer
[; var Result: Integer]);
函数原型 procedure BlockWrite(var f: File; var Buf; Count: Integer
[; var Result: Integer]);
范例 var
FromF, ToF: file;
NumRead, NumWritten: Integer;
Buf: array[1..2048] of Char;
begin
if OpenDialog1.Execute then
{ Display Open dialog box }
begin
AssignFile(FromF, OpenDialog1.FileName);
Reset(FromF, 1); { Record size = 1 }
if SaveDialog1.Execute then
{ Display Save dialog box }
begin
AssignFile(ToF, SaveDialog1.FileName);
{ Open output file }
Rewrite(ToF, 1); { Record size = 1 }
Canvas.TextOut(10, 10,'Copying '+
IntToStr(FileSize(FromF))+ ' bytes...');
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <>
NumRead);
CloseFile(FromF);
CloseFile(ToF);
end;
end;
end;
======================================
Variant support routines 鬼牌变数函式
======================================
VarArrayCreate 建立一个variant array.
-----------------------------------------------------------------------------
Unit System
函数原型 function VarArrayCreate(const Bounds: array of Integer;
VarType: Integer): Variant;
范例 procedure TForm1.Button1Click(Sender: TObject);
var
A:Variant;
S:String;
begin
A:=VarArrayCreate([0,4],varVariant);
A[0]:=1;
A[1]:=1234.5678;
A[2]:='Hello world';
A[3]:=TRUE;
A[4]:=VarArrayOf([1 ,10 ,100 ,10000]);
S:=A[4][2];
S:=A[2]+' '+S;
Label1.Caption:=S;
end;
说明 S:=A[4][2]; Variant可以不用函数来做转换.
只能单独使用,如为下列则有误.
S:=A[2]+' '+A[4][2];

VarType
varEmpty $0000 The variant is Unassigned.
varNull $0001 The variant is Null.
varSmallint $0002 16-bit signed integer (type Smallint).
varInteger $0003 32-bit signed integer (type Integer).
varSingle $0004 Single-precision floating-point value
(type Single).
varDouble $0005 Double-precision floating-point value
(type Double).
varCurrency $0006 Currency floating-point value (type Currency).
VarDate $0007 Date and time value (type TDateTime).
VarOleStr $0008 Reference to a dynamically allocated
UNICODE string.
varDispatch $0009 Reference to an OLE automation object
(an IDispatch interface pointer).
VarError $000A Operating system error code.
varBoolean $000B 16-bit boolean (type WordBool).
varVariant $000C Variant (used only with variant arrays).
varUnknown $000D Reference to an unknown OLE object
(an IUnknown interface pointer).
varByte $0011 8-bit unsigned integer (type Byte).
VarString $0100 Reference to a dynamically-allocated long string
(type AnsiString).
varTypeMask $0FFF Bit mask for extracting type code. This constant
is a mask that can be combined with the VType
field using a bit-wise AND..
varArray $2000 Bit indicating variant array. This constant is a
mask that can be combined with the VType field
using a bit-wise AND to determine if the variant
contains a single value or an array of values.
VarByRef $4000 This constant can be AND'd with Variant.VType
to determine if the variant contains a pointer to
the indicated data instead of containing the data
itself.

范例 var
V1, V2, V3, V4, V5: Variant;
I: Integer;
D: Double;
S: string;
begin
V1 := 1; { Integer value }
V2 := 1234.5678; { Real value }
V3 := 'Hello world'; { String value }
V4 := '1000'; { String value }
V5 := V1 +V2 +V4; { Real value 2235.5678 }
I := V1; { I = 1 }
D := V2; { D = 1234.5678 }
S := V3; { S = 'Hello world' }
I := V4; { I = 1000 }
S := V5; { S = '2235.5678' }
end;
-----------------------------------------------------------------------------
VarArrayOf 建立一个简单的一维variant array
-----------------------------------------------------------------------------
Unit System
函数原型 function VarArrayOf(const Values: array of Variant): Variant;
范例 var
A:Variant;
begin
A:=VarArrayOf([1 ,10 ,'Hello ,10000]);
S:=A[1]+' '+IntToStr(A[2]);
Label1.Caption:=S;
end;


情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:53
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
-----------------------------------------------------------------------------
VarArrayRedim 重定variant阵列中高维部分的高注脚.
-----------------------------------------------------------------------------
Unit System
-----------------------------------------------------------------------------
函数原型 procedure VarArrayRedim(var A: Variant; HighBound:Integer);
-----------------------------------------------------------------------------
VarArrayDimCount 传回Variant阵列的维数.
-----------------------------------------------------------------------------
Unit System
函数原型 function VarArrayDimCount(const A: Variant): Integer;
-----------------------------------------------------------------------------
VarArrayHighBound 传回Variant阵列中一维的高注脚.
-----------------------------------------------------------------------------
Unit System
函数原型 function VarArrayHighBound(const A: Variant; Dim: Integer):Integer;
-----------------------------------------------------------------------------
VarArrayLowBound 传回Variant阵列中一维的低注脚.
-----------------------------------------------------------------------------
Unit System
函数原型 function VarArrayLowBound(const A: Variant; Dim: Integer):
Integer;
范例 procedure TForm1.Button1Click(Sender: TObject);
var
A:Variant;
Count:Integer;
HighBound:Integer;
LowBound:Integer;
i:Integer;
S:String;
begin
A:=VarArrayCreate([0,5, 1,3],varVariant);
Count:=VarArrayDimCount(A);
S:=#13+'维数:'+IntToStr(Count)+#13;
for i:=1 To Count do
Begin
HighBound:=VarArrayHighBound(A,i);
LowBound:=VarArrayLowBound(A,i);
S:=S+'HighBound: '+IntToStr(HighBound)+#13;
S:=S+'LowBound : '+IntToStr(LowBound)+#13;
End;
ShowMessage(S);
end;
-----------------------------------------------------------------------------
VarArrayLock 将variant阵列==>指定给一阵列变数.
-----------------------------------------------------------------------------
VarArrayUnLock 解除上述的指定.
-----------------------------------------------------------------------------
Unit System
函数原型 function VarArrayLock(var A: Variant): Pointer;
函数原型 procedure VarArrayUnlock(var A: Variant);
范例 procedure TForm1.Button1Click(Sender: TObject);
Const
HighVal=12;
type
TData=array[0..HighVal, 0..HighVal] of Integer;
var
A:Variant;
i,j:Integer;
Data:^TData;
begin
A:=VarArrayCreate([0,HighVal, 0,HighVal],varInteger);
for i:=0 to HighVal do
for j:=0 to HighVal do
A[i,j]:=i*j;
Data:=VarArrayLock(A);
for i:=0 to HighVal do
for j:=0 to HighVal do
Grid1.Cells[i+1,j+1]:=IntToStr(Data^[i,j]);
VarArrayUnLock(A);
end;
-----------------------------------------------------------------------------
VarIsArray 传回Variant是否为一个阵列.
-----------------------------------------------------------------------------
Unit System
函数原型 function VarIsArray(const V: Variant): Boolean;
VarIsEmpty 传回Variant是否尚未注册.(空的)
Unit System
函数原型 function VarIsEmpty(const V: Variant): Boolean;
范例 procedure TForm1.Button1Click(Sender: TObject);
var
A:Variant;
S:String;
begin
A:=VarArrayCreate([0,5, 0,7],varVariant);
if VarIsEmpty(A) Then
S:='True'
else
S:='False';
Label1.Caption:=S;
end;


情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:53
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
-----------------------------------------------------------------------------
** S:=False,A以经建立了.
-----------------------------------------------------------------------------
VarIsNull 传回Variant是否为NULL.
-----------------------------------------------------------------------------
Unit System
函数原型 function VarIsNull(const V: Variant): Boolean;
-----------------------------------------------------------------------------
VarAsType 将Variant转为另外一个型态的Variant.
-----------------------------------------------------------------------------
VarCast
-----------------------------------------------------------------------------
Unit System
函数原型 function VarAsType(const V: Variant; VarType: Integer):
Variant;
函数原型 procedure VarCast(var Dest: Variant; const Source: Variant;
VarType: Integer);
说明 VarType不可为varArray or varByRef.
-----------------------------------------------------------------------------
VarType 传回Variant的型态.
-----------------------------------------------------------------------------
Unit System
函数原型 function VarType(const V: Variant): Integer;
-----------------------------------------------------------------------------
VarClear 将variant清除,成为Unassigned状态.
-----------------------------------------------------------------------------
Unit System
函数原型 procedure VarClear(var V: Variant);
-----------------------------------------------------------------------------
VarCopy 拷贝一个variant.
-----------------------------------------------------------------------------
Unit System
函数原型 procedure VarCopy(var Dest: Variant; const Source: Variant);
说明 与Dest:=Source;效果一样.
-----------------------------------------------------------------------------
VarFromDateTime 将DateTime转为Variant.
-----------------------------------------------------------------------------
VarToDateTime 将Variant转为DateTime.
-----------------------------------------------------------------------------
Unit System
函数原型 function VarFromDateTime(DateTime: TDateTime): Variant;
函数原型 function VarToDateTime(const V: Variant): TDateTime;

=============================
函数
==============================
procedure TForm1.Button2Click(Sender: TObject);
var
Bitmap: TBitmap;
begin
Bitmap := TBitmap.Create;
try
Bitmap.LoadFromFile('G:\33.bmp ');
Form1.Canvas.Brush.Bitmap := Bitmap;
Form1.Canvas.FillRect(Rect(0,0,18,15));
finally
Form1.Canvas.Brush.Bitmap := nil;
Bitmap.Free;
end;
end;

## Canvas, Brush, Bitmap, FillRect Example


情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:53
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
=======================================
TextOut
=======================================
procedure TForm1.FormCreate(Sender: TObject);

var
HeaderSection: THeaderSection;
I: Integer;
begin
for I := 0 to 4 do
begin
HeaderSection := HeaderControl1.Sections.Add;
HeaderSection.Text := 'Text Section ' + IntToStr(I);
HeaderSection.MinWidth := length(HeaderSection.Text) * Font.Size;
// Owner draw every other section
if (I mod 2 = 0) then
HeaderSection.Style := hsOwnerDraw
else
HeaderSection.Style := hsText;

end;
end;

procedure TForm1.HeaderControl1DrawSection(HeaderControl: THeaderControl;
Section: THeaderSection; const Rect: TRect; Pressed: Boolean);
begin
with HeaderControl.Canvas do
begin
// highlight pressed sections
if Pressed then
Font.Color := clRed
else
Font.Color := clBlue;
TextOut(Rect.Left + Font.Size, Rect.Top + 2, 'Owner Drawn text');
end;
end;
## HeaderSection, OnDrawSection, Sections, Canvas, TextOut example
----------------------------------------------------------
Trunc Example
-----------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var
S, T: string;
begin
Str(1.4:2:1, T);
S := T + ' Truncs to ' + IntToStr(Trunc(1.4)) + #13#10;
Str(1.5:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(1.5)) + #13#10;
Str(-1.4:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.4)) + #13#10;
Str(-1.5:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.5));
MessageDlg(S, mtInformation, [mbOk], 0);
end;


                                             
未归类
--------------------
WrapText
--------------------
SysUtils
type TSysCharSet = set of Char
var
S, R: string;
begin
S:= '123456_123456_123456';
R:= WrapText( S, #13#10, ['1', '4'], 4);
MessageDlg( R, mtInformation, [mbOk], 0);
end;
================================
WideCharToStrVar(Source: PWideChar;var Dest: string );
-------------------------
System
-----------------

=========================
WideCharToString( Source: PWideChar ): string;
-------------------------
System

=============================
WideCharLenToStrVar( Source: PWideChar;SourceLen: Integer;var Dest: string );
------------------------------
System
==============================
WideCharLenToString(Source: PWideChar;SourceLen: Integer ): string
-----------------------
System


情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:53
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
============================
AnsiCompareFileName(const S1, S2: string ): Integer; SysUtils
===================================
AnsiExtractQuotedStr (var S: PChar;Quote: Char ): string;
SysUtils
var
S1: PChar;
S2: string;
begin
S1:= '/??. ?????????? /???.56/';
S2:= AnsiExtractQuotedStr(S1,'/'); // S2 := '??. ?????????? '
MessageDlg(S2, mtInformation, [mbOk], 0);
end;
----------------------------------------------------------
AnsiLastChar( const S: string ): PChar;
SysUtils

----------------------------------------------------------

AnsiLowerCaseFileName( const S: string ): string;
SysUtils
----------------------------------------------------------

AnsiPos ( const Substr, S: string ): Integer
SysUtils
var
Substr, S: string;
I: Integer;
begin
S:= '???????? ??????';
Substr:= '???';
I:= AnsiPos(Substr, S); // I:= 3
...
end;
----------------------------------------------------------

AnsiQuotedStr (const S: string;Quote: Char ): string;
SysUtils
var
S: string;
begin
S:= '1997-1998??.';
S:= AnsiQuotedStr(S, '-'); // S := '-1997--1998??.-'
MessageDlg(S, mtInformation, [mbOk], 0);
end;
----------------------------------------------------------
AnsiSameStr ( const S1, S2: string ): Boolean;
SysUtils
----------------------------------------------------------
AnsiSameText ( const S1, S2: string ): Boolean;
SysUtils
----------------------------------------------------------

AnsiStrComp( S1, S2: PChar ): Integer
SysUtils
----------------------------------------------------------
AnsiStrIComp( S1, S2: PChar ): Integer;
SysUtils
----------------------------------------------------------

AnsiStrLastChar( P: PChar ): PChar;
SysUtils
----------------------------------------------------------

AnsiStrLComp(S1, S2: PChar;MaxLen: Cardinal ): Integer;

SysUtils
var
P1,P2: PChar;
Len : Integer;
begin
P1:= '?????? ?????????? ?? ?????? ????????? ????????.';
P2:= '?????? ?????????? ?? ?????? ????????? ????????!';
Len:= length(p1)-1;
If AnsiStrLIComp(P1, P2, Len)=0 then MessageDlg( P1+ #13+ P2+ #13+ '??????, ? ???????? ?????? '+ IntTostr(Len)+' ????????, ?????', mtInformation, [mbOk], 0);
end;
----------------------------------------------------------

AnsiStrLIComp(S1, S2: PChar;MaxLen: Cardinal ): Integer;

SysUtils
var
P1,P2: PChar;
Len : Integer;
begin
Len:= 7;
P1:= '?????? 1';
P2:= '?????? 2';
If AnsiStrLIComp(P1, P2, Len)=0 then MessageDlg( P1+ #13+ P2+ #13+ '??????, ? ???????? ?????? '+ IntTostr(Len)+' ????????, ?????', mtInformation, [mbOk], 0);
end;


情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:54
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
----------------------------------------------------------
AnsiStrLower( S1, S2: PChar ): PChar;
SysUtils
----------------------------------------------------------

AnsiStrPos( S, SubStr: PChar ): PChar
SysUtils
var
S1,S2: Pchar;
begin
S1:= '???? ? ???? - ? ????? ????!';
S2:= AnsiStrPos(S1,'?????'); // S2 :='????? ????!'
MessageDlg( S2, mtInformation, [mbOk], 0);
end;
----------------------------------------------------------
AnsiStrRScan( S : PChar; Chr: Char ): PChar;
SysUtils
var
P1,P2: PChar;
begin
P1:= 'C:\windows\temp';
P2:= AnsiStrRScan(P1, '\'); { P2 := '\temp' }
MessageDlg( P2, mtInformation, [mbOk], 0);
end;
----------------------------------------------------------
AnsiStrScan( S : PChar; Chr: Char ): PChar;
SysUtils
var
P1,P2: PChar;
begin
P1:= 'http://www.atrussk.ru/delphi';
P2:= AnsiStrScan(P1, '/'); { P2 := '//www.atrussk.ru/delphi' }
MessageDlg( P2, mtInformation, [mbOk], 0);
end;
----------------------------------------------------------
AnsiStrUpper( S : PChar ): PChar

SysUtils
----------------------------------------------------------
AnsiUpperCaseFileName( const S: string ): string;

SysUtils
----------------------------------------------------------
ByteToCharIndex(const S: string;Index: Integer ): Integer;

SysUtils
----------------------------------------------------------
ByteToCharLen( const S: string;MaxLen: Integer ): Integer;

SysUtils
----------------------------------------------------------
ByteType(const S: string;Index: Integer ): TMbcsByteType;

SysUtils
mbSingleByte -
mbLeadByte -
mbTrailByte -
----------------------------------------------------------
CharToByteIndex(const S: string;Index: Integer ): Integer;

SysUtils
----------------------------------------------------------

CharToByteLen(const S: string;MaxLen: Integer ): Integer;

SysUtils
----------------------------------------------------------
Chr ( X: Byte ): Char;

SysUtils
MessageDlg('ASCII-???? 77 ????????????? ?????? - ' + Chr(77), mtInformation, [mbOk], 0);
----------------------------------------------------------
FormatMaskText(const EditMask: string;const Value: string ): string;

Mask


情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:54
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
----------------------------------------------------------
GetFormatSettings;
SysUtils
----------------------------------------------------------

IsDelimiter (const Delimiters, S: string;Index: Integer ): Boolean;

SysUtils
var
S: string;
begin
S:= '???????, ?????? ??????????!';
If IsDelimiter( '!.,-', S, 8) then
MessageDlg( '???????!', mtWarning, [mbOK], 0)
else
MessageDlg( '??????????!', mtWarning, [mbOK], 0);
end;
----------------------------------------------------------
IsPathDelimiter (const S: string;Index: Integer ): Boolean;

SysUtils
If IsPathDelimiter( S, Length(S))

then S:=Copy( S, 1, Length(S)-1);
----------------------------------------------------------
LastDelimiter (const Delimiters, S: string ): Integer;
SysUtils
var
I: Integer;
begin
I:= LastDelimiter('!;.,-', '???????, ??????, ??????????'); // I := 16
end;
----------------------------------------------------------
LineStart( Buffer, BufPos : PChar ): PChar
Classes--
--------------------------------------------------------
QuotedStr ( const S: string ): string;
SysUtils
----------------------------------------------------------
SetLength ( var S; Length: Integer );
System
----------------------------------------------------------

SetString (var S: string;Buffer: PChar;Length: Integer );

System
----------------------------------------------------------
Str ( X [: Width [: Decimals ]]; var S );
System
var

S: string;
I: Real;

begin

I:= -52.123456789;
Str( I:6:2, S); { S := ' -52.12' }
MessageDlg( S, mtInformation, [mbOk], 0);

end;
----------------------------------------------------------
StrBufSize( S: PChar ): Cardinal;
SysUtils
----------------------------------------------------------

StrByteType(S: PChar;Index: Cardinal ): TMbcsByteType;
SysUtils
----------------------------------------------------------
StringOfChar (Ch: Char;Count: Integer ): string;

System
S:= StringOfChar( '.' , 3); // S:= '...'
----------------------------------------------------------
StringReplace (const S, OldSubstr, NewSubstr: string;Flags: TReplaceFlags ): string;
SysUtils
type TReplaceFlags = set of ( rfReplaceAll, rfIgnoreCase );

var
S: string;
Flags: TReplaceFlags;
begin
Flags:= [ rfReplaceAll, rfIgnoreCase ];
S:= '???? - ????? ?????';
S:= StringReplace( S, '??', '??', Flags); // S :='???? - ????? ?????' }
MessageDlg( S, mtInformation, [mbOk], 0);
end;
----------------------------------------------------------

StringToWideChar(const Source: string;Dest: PWideChar;DestSize: Integer ): PWideChar

System
----------------------------------------------------------
UniqueString( var S: string );
System
----------------------------------------------------------



情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:54
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
==============================
讯息
==============================
---------------------------------------------------------------
ShowMessage 讯息
---------------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);

var
buffer: array [0..255] of char;
FileToFind: string;
begin
GetWindowsDirectory(buffer, SizeOf(buffer));
FileToFind := FileSearch(Edit1.Text, GetCurrentDir + ';' + buffer);
if FileToFind = ' then
ShowMessage('Couldn't find ' + Edit1.Text + '.')
else
ShowMessage('Found ' + FileToFind + '.');

end;
## FileSearch, ShowMessage Example
----------------------------------------------------------
FindComponent
范例(1)
type
LogPal = record
lpal : TLogPalette;
dummy:Array[0..255] of TPaletteEntry;
end;

procedure TForm1.SaveAsBmpClick(Sender: TObject);
var
Source: TComponent;
SysPal : LogPal;
tempCanvas: TCanvas;
sourceRect, destRect: TRect;
image2save: TImage;
notUsed: HWND;
begin
Source := FindComponent(Edit1.Text);
if (not Source is TControl) or
((not Source is TWinControl) and ((Source as TControl).Parent = nil)) then

begin
Beep;
ShowMessage(Edit1.Text + ' is not a valid control.');
Exit;

end;

tempCanvas := TCanvas.Create;
try
with Source as TControl do
tempCanvas.Handle := GetDeviceContext(notUsed);
image2save:=TImage.create(self);
try
with image2save do
begin
Height := (Source as TControl).Height;
Width := (Source as TControl).Width;
destRect := Rect(0,0,Width,Height);
if Source is TWinControl then

sourceRect := destRect;
else
sourceRect := (Source as TControl).BoundsRect;
Canvas.CopyRect(destRect,tempCanvas,sourceRect);
SysPal.lPal.palVersion:=$300;
SysPal.lPal.palNumEntries:=256;
GetSystemPaletteEntries(tempCanvas.Handle,0,256,SysPal.lpal.PalpalEntry);
Picture.Bitmap.Palette:= CreatePalette(Syspal.lpal);
end;
if SaveDialog1.Execute then

image2save.Picture.SaveToFile(SaveDialog1.FileName);
finally
image2save.Free;
end;
finally
tempCanvas.Free;
end;
end;
范例(2)
procedure TForm1.Button1Click(Sender: TObject);

var
i: Integer;
const
NamePrefix = 'MyEdit';
begin
for i := 1 to 20 do begin
TEdit.Create(Self).Name := NamePrefix + IntToStr(i);
with TEdit(FindComponent(NamePrefix + IntToStr(i))) do
begin
Left := 10;
Top := i * 20;
Parent := self;
end;
end;
end;
=========================================================
procedure TForm1.Button1Click(Sender: TObject);
var
A: Variant;
begin
A := VarArrayCreate([0, 4], varVariant);
A[0] := 1;
A[1] := 1234.5678;
A[2] := 'Hello world';
A[3] := True;
A[4] := VarArrayOf([1, 10, 100, 1000]);
Edit1.Text :=(A[2]); { Hello world }
Edit2.Text :=(A[4][2]); { 100 }
end;

procedure TForm1.Button2Click(Sender: TObject);
var
s: string;
begin
s := 'Honest Abe Lincoln';
Delete(s,8,4);
Canvas.TextOut(10, 130, s); { 'Honest Lincoln' }
end;

procedure TForm1.Button3Click(Sender: TObject);
var S: string;
begin
S := 'ABCDEF';
S := Copy(S, 2, 3);
Edit1.Text :=s;{ 'BCD' }
end;

procedure TForm1.Button4Click(Sender: TObject);
var
S: string;
begin
S := Concat('ABC', 'DEF');
Edit1.Text :=s; { 'ABCDE' }
end;

procedure TForm1.Button5Click(Sender: TObject);
var
S: string;
begin
S := 'Honest Lincoln';
Insert('Abe ', S, 8);
Edit1.Text :=s; { 'Honest Abe Lincoln' }
end;

procedure TForm1.Button6Click(Sender: TObject);
var
S: string;
begin
S := 'The Black Knight';
Canvas.TextOut(10, 130, 'String Length = ' + IntToStr(Length(S)));{String Length = 16}
Edit1.Text :=s;{The Black Knight}
end;

procedure TForm1.Button7Click(Sender: TObject);
var S: string;
begin
S := ' 123.5';
{ Convert spaces to zeroes }
while Pos(' ', S) > 0 do
S[Pos(' ', S)] := '0';
Edit1.Text :=s; {000123.5}
end;


情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:54
dzy
Rank: 2
等 级:新手上路
威 望:3
帖 子:708
专家分:0
注 册:2006-5-27
收藏
得分:0 
===========================================================================
数学函数 (Arithmetic Routines)

Unit: System
===========================================================================
Abs 传回叁数的绝对值。 function Abs(X);
ArcTan 传回正切函数的反函数值。 function ArcTan(X: Real): Real;
Cos 传回馀弦函数值 function Cos(X: Real): Real;
(X 以弧度为单位)。
Exp 传回自然指数值。 function Cos(X: Real): Real;
Frac 传回叁数的小数部份。 function Frac(X: Real): Real;
Int 传回叁数的整数部份。 function Int(X: Real): Real;
Ln 传回自然对数值。 function Ln(X: Real): Real;
Pi 传回圆周率π的值。 function Pi: Real;
Sin 传回正弦函数值。 function Sin(X: Real): Real;
Sqr 传回叁数的平方。 function Sqr(X: Real): (Real);
Sqrt 传回叁数的平方根。 function Sqrt(X: Real): Real;
===========================================================================
控制台函数 (Console Routines)
===========================================================================
Unit: WinCrt
函数名称 函数说明 函数语法
===========================================================================
AssignCrt 将文字档连结到一个控制台视窗。 procedure AssignCrt(var f: Text);
ClrEol 清附游标位置到该行最後的所有字元。procedure ClrEol;
ClrScr 清附萤幕并重置游标至左上角。 procedure ClrScr;
CursorTo 移动游标至给定座标。 procedure CursorTo(X, Y:Integer);
DoneWinCrt 结束控制台视窗。 procedure DoneWinCrt;
GotoXY 移动游标至给定座标。 procedure GotoXY(X, Y: Byte);
InitWinCrt 建立控制台视窗。 procedure InitWinCrt;
KeyPressed 判断是否有一按键。 function KeyPressed:Boolean;
ReadBuf 从控制台视窗读入一行。 function ReadBuf(Buffer: Pchar;Count: Word):
ReadKey 读取按键字元。function ReadKey: Char;
ScrollTo 卷动控制台视窗至显示位置。procedure ScrollTo(X, Y: Integer);
TrackCursor 卷动控制台视窗宜到游标可见。procedure TrackCursor;
WhereX 传回游标的X 座标。function WhereX: Byte;
WhereY 传回游标的Y 标标。function WhereY: Byte;
WriteBuf 写入一区块字元到控制台视窗。procedure WriteBuf
WriteChar 写一个字元到控制台视窗。procedure WriteChar(CH: Char);
=================================================
日期与时间函数 (Date and Time Routines)
Unit: SysUtils
========================================
Date 传回今天日期。function Date: TDateTime;
DateTimeToStr 将时间格式转为字串。function DateTimeToStr(DateTime: TDateTime):String;
DateTimeToString 将时间格式转为字串。
procedure DateTimeToString(var Result: string;const Format: string;DateTime: TDateTime);
DateToStr 将日期格式转为字串。function DateToStr(Date: TDateTime): String;
DayOfWeek 传回今天星期几。function DayOfWeek(Date: TDateTime): Integer;
DecodeDate 分解所指定的日期为年、月、日。
procedure DecodeDate(Date: TDateTime;var Year, Month, Day:Word);
DecodeTime 分解所指定的日期为时、分、秒。
procedure DecodeTime(Time: TDateTime;var Hour, Min, Sec,MSec: Word);
EncodeDate 传回将年、月、日所组合的日期格式。
function EncodeDate(Year, Month, Day: Word):TDateTime;
EncodeTime 传回将时、分、秒所组合的时间格式。
function EncodeTime(Hour, Min, Sec, MSec:Word): TDateTime;
FormatDateTime 以指定的格式传回日期时间。
function FormatDateTime(const Format: string;DateTime: TDateTime):String;
Now 传回现在的日期时间。function Now: TDateTime;
StrToDate 将字串转为日期格式。function StrToDate(const S:string): TDateTime;
StrToDateTime 将字串转为日期时间格式function StrToDateTime(const S: string): TDateTime;
StrToTime 将字串转为时间格式。function StrToTime(const S:string): TDateTime;
Time 传回现在时间。function Time: TDateTime;
TimeToStr 将时格式转为字串。function TimeToStr(Time:TDateTime): String;


情人太累,小姐太贵,友谊交往最实惠 ,没事开开“同学会”,拆散一对算一对!
2006-06-23 10:55
快速回复:[分享]新手和CN必看
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018949 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved