Time of Update: 2018-12-07
//全以紅色舉例://1. RGB 模式:Self.Color := $0000ff; //不過和HTML中的 #ff0000 是反的,應該叫 BGR。//2. RGB 分值,譬如:Self.Color := RGB(255,0,0);//3. Delphi 中的標準模式:Self.Color :=
Time of Update: 2018-12-07
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Time of Update: 2018-12-07
//1. 標準方法:var MyArr: array[0..10] of Integer; //定義靜態數組//2. 可以使用非0下標:var MyArr: array[9..10] of Integer; //不能提倡,這樣不容易與系統函數溝通//3. 根據預定義類型來聲明數組:type TMyArr = array[0..10] of Integer; //先定義一個數群組類型var MyArr: TMyArr; //再定義靜態數組//4. 在非過程區可以直接賦值:var
Time of Update: 2018-12-07
//例1:var StrArr: array of String; //動態數組定義時不與維數begin SetLength(StrArr,6); //分配6個元素位置: 0-5 StrArr[0] := '萬一'; //動態數組的下界是 0 ShowMessage(StrArr[0]); //分配空間後和靜態數組一樣使用 StrArr := nil; //一般沒必要手動釋放, 動態數組離開範圍會自釋放end;//例2. 動態數組的引用:var
Time of Update: 2018-12-07
函數功能Chr將一個有序資料轉換為一個ANSI字元Ord將一個有序類型值轉換為它的序號Round轉換一個實型值為四捨五入後的整型值Trunc轉換一個實型值為小數截斷後的整型值Int返回浮點數的整數部分IntToStr將數值轉換為字串IntToHex將數值轉換為十六進位數字串StrToInt將字串轉換為一個整型數,如字串不是一個合法的整型將引發異常StrToIntDef將字串轉換為一個整數,如字串不合法返回一個預設值Val將字串轉換為一個數字(傳統Turbo
Time of Update: 2018-12-07
分類運算子操作運算元結果類型範例算術運算子+加整數,實數整數,實數X + Y-減整數,實數整數,實數Result - 1*乘整數,實數整數,實數P * InterestRate/實數除整數,實數實數X / 2div整數除整數整數Total div UnitSizemod模數整數整數Y mod 6+(一元)符號等同整數,實數整數,實數+7-(一元)符號相反整數,實數整數,實數-X布林運算子not否定布爾型Booleannot (C in MySet)and與布爾型BooleanDone and (
Time of Update: 2018-12-07
//通過 DLL Wizard 建立:library TestDLL;uses SysUtils, Classes, Dialogs;{$R *.res}//建立過程procedure Test;begin ShowMessage('TestDLL.Test');end;//輸出exports
Time of Update: 2018-12-07
虛擬鍵碼 對應值 對應鍵VK_LBUTTON1滑鼠左鍵VK_RBUTTON2滑鼠右鍵VK_CANCEL3CancelVK_MBUTTON4滑鼠中鍵VK_XBUTTON15VK_XBUTTON26VK_BACK8BackspaceVK_TAB9TabVK_CLEAR12ClearVK_RETURN13EnterVK_SHIFT16ShiftVK_CONTROL17CtrlVK_MENU18AltVK_PAUSE19PauseVK_CAPITAL20Caps
Time of Update: 2018-12-07
uses HTTPApp, Masks;procedure TForm1.Button1Click(Sender: TObject);var ss,s: string;begin //先提取一個檔案名稱的字串 ss := Application.ExeName; ShowMessage(ss); //C:\Documents and Settings\wy\My Documents\RAD Studio\Projects\Project1.exe //路徑 s :=
Time of Update: 2018-12-07
uses Masks;procedure TForm1.Button1Click(Sender: TObject);var s: string;begin s := 'http://www.132435.com'; MatchesMask(s,'http://*'); //True MatchesMask(s,'HTTP://*.com'); //True MatchesMask(s,'*.com');
Time of Update: 2018-12-07
uses WinSock;function LocalIP: String;type TaPInAddr = Array[0..10] of PInAddr; PaPInAddr = ^TaPInAddr;var phe: PHostEnt; pptr: PaPInAddr; Buffer: Array[0..63] of AnsiChar; i: Integer; GInitData: TWSAData;begin WSAStartup($101, GInitData);
Time of Update: 2018-12-07
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure
Time of Update: 2018-12-07
//類單元unit NumBox;interfacetype TNumBox = class private FCount: Integer; public procedure AddOne; procedure AddFive; procedure ZeroCount; function GetCount: Integer; end;implementation{ TNumBox }procedure TNumBox.AddOne;begin
Time of Update: 2018-12-07
//磁碟類型 GetDriveTypevar Drive: Char; DriveLetter: String[4];begin for Drive := 'A' to 'Z' do begin DriveLetter := Drive + ':\'; case GetDriveType(PChar(Drive + ':\')) of DRIVE_REMOVABLE: Memo1.Lines.Add(DriveLetter + ' Floppy
Time of Update: 2018-12-07
//類單元unit Person;interfaceuses Dialogs;type TPerson = class(TObject) private FName: string; FAge: Integer; public constructor Create(strName: string; intAge: Integer); destructor Destroy; override; function GetName: string;
Time of Update: 2018-12-07
//類單元unit Person;interfacetype TPerson = class(TObject) private FName: string; FAge: Integer; public procedure SetName(const strName: string); procedure SetAge(const intAge: Integer); property Name: string read FName write SetName;
Time of Update: 2018-12-07
function TColorToHex(Color: TColor): string;begin Result := IntToHex(GetRValue(Color), 2) + IntToHex(GetGValue(Color), 2) + IntToHex(GetBValue(Color), 2);end;function HexToTColor(sColor: string): TColor;begin Result := RGB( StrToInt(#3
Time of Update: 2018-12-07
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TForm1 = class(TForm) RadioGroup1: TRadioGroup; procedure FormMouseDown(Sender: TObject; Button:
Time of Update: 2018-12-07
移除的元素純表現的元素:basefont,big,center,font, s,strike,tt,u; 對可用性產生負面影響的元素:frame,frameset,noframes; 產生混淆的元素:acronym ,applet,isindex,dir。移除的屬性a,area,button,input,label,legend和textarea元素的accesskey屬性; link和a元素的rev和charset屬性; a元素的shape和coords屬性;
Time of Update: 2018-12-07
//尋找一個檔案 FileSearchvar FileName,Dir,s: string;begin FileName := 'notepad.exe'; Dir := 'c:\windows'; s := FileSearch(FileName,Dir); if s'' then ShowMessage(s) //c:\windows\notepad.exe else ShowMessage('沒找到');end;//搜尋檔案 FindFirst;