Time of Update: 2018-12-07
運行:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls;type TForm1 = class(TForm) HotKey1: THotKey; Button1: TButton; Button2: TButton; Button3: TButton;
Time of Update: 2018-12-07
本例:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TForm1 = class(TForm) Button1: TButton; Image1: TImage; procedure FormCreate(Sender: TObject);
Time of Update: 2018-12-07
我原來以為 TList 可能是一個鏈表, 其實只是一個數組而已.你知道它包含著多大一個數組嗎? MaxListSize 個!MaxListSize 是 Delphi 在 Classes 單元定義的一個常量:MaxListSize = Maxint div 16; 也就是 134217727; 這也是 TList 的最大容量.其中的 Maxint(2147483647) 也就是 2個G, 這是 Win32 系統許可一個應用程式對空間的最大操控權; 16 是一個 TList 的大小. 可以測試一下:
Time of Update: 2018-12-07
在 Delphi 中, 幾乎所有的類型都有對應的指標類型, 譬如:Char PCharWord PWORDDouble PDoubleTPoint PPoint甚至一種類型對應這著幾種指標類型, 譬如:Integer PInteger PINTWideChar PWideChar PWChar即使它沒有定義, 我也可以直接使用一個類型的指標, 譬如聲明一個整數的指標變數:var px: ^Integer;也可以先自訂指標類型, 再使用, 譬如:type
Time of Update: 2018-12-07
現在準備一步步地類比 TList 類, 建立一個自己的 TMyList.首先, 這個類中應該包括前面提到的那個 Pointer 數組(TPointerList)的指標(PPointerList):TMyList = class(TObject) FList: PPointerList;end;既然是一個列表, 應該有 Count 欄位:TMyList = class(TObject) FList: PPointerList; FCount: Integer;end;TList 類還有一個
Time of Update: 2018-12-07
先來實現 TMyList.SetCapacity.馬上會想到下面代碼:procedure TMyList.SetCapacity(const Value: Integer);begin if FCapacity Value then FCapacity := Value;end;但這樣是遠遠不夠的, 關鍵是需要分配記憶體, 像這樣:ReallocMem(數組的起點指標, 元素個數*元素大小);數組的起點指標即是 FList; 元素個數就是 SetCapacity 的參數: Value;
Time of Update: 2018-12-07
實現 TMyList.Add 函數.TList 中的 Add 函數用到了一個 Grow 方法, 它的原理是元素越多就為以後準備更多記憶體, 我們這裡省略為預留 4 個元素的記憶體;TList 中的 Add 函數還同時觸動了一個 Notify 方法, 這應該是為它們的子類準備的(估計是用它來激發一個事件的), 也不要了.function TMyList.Add(Item: Pointer): Integer;begin {如果預申請的記憶體用完了, 再申請夠 4 個元素用的} if
Time of Update: 2018-12-07
function Copy( S: String; {字串或動態數組} Index: Integer; {起始位置} Count: Integer {Copy 個數}): String; {如果參數 S 是動態數組, 這裡也應該返回動態數組}舉例://從字串中提取var ss,s: string;begin ss := 'CodeGear Delphi 2007'; s := Copy(ss,5,4); ShowMessage(s);
Time of Update: 2018-12-07
舉例:var s: string; i: Real; j: Integer;begin s := '13.2435'; Val(s,i,j); ShowMessage(FloatToStr(i)); {13.2435} ShowMessage(IntToStr(j)); {返回 0 表示轉換成功} s := '13_2435'; Val(s,i,j); ShowMessage(FloatToStr(i)); {13} ShowMessage(IntToStr(j)
Time of Update: 2018-12-07
總結目前 TMyList 已具備的功能(3 個方法、3 個屬性):Add: 添加; Delete: 刪除; Clear: 清空;Count: 元素總數;Capacity: 已存在的所有元素位置數;List: 指向核心數組的指標(唯讀).舉例測試如下:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type
Time of Update: 2018-12-07
現在準備建立 Items 數組屬性; 在 public 區輸入下面代碼:property Items[Index: Integer]: Pointer;執行 Shift+Ctrl+C 後的代碼是:... TMyList = class(TObject) private ... function GetItems(Index: Integer): Pointer; procedure SetItems(Index: Integer; const Value: Pointer)
Time of Update: 2018-12-07
問題來源:http://www.cnblogs.com/del/archive/2008/04/02/1055762.html#1134153http://www.cnblogs.com/del/archive/2008/04/02/1055648.html#1134081Delphi 的按位元運算符共有六個: not and or xor shr shl; 其中的 not and or xor 也叫邏輯運算子, 其實功能都是一樣的, 因為不管什麼資料追到底都是 0 和 1 的組合;在
Time of Update: 2018-12-07
本例是順著 GetMem 的例子往下做的:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end;var Form1: TForm1;implementation{$R
Time of Update: 2018-12-07
如果只為單個指標分配記憶體, 和 New 和 Dispose 是一樣的; 與之不同的是: GetMem 可以申請連續的多個記憶體塊.舉例:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject);
Time of Update: 2018-12-07
下載不行了我覺得到目前為止, 最有價值的一套 Windows 編程中文參考資料還是當屬:Microsoft Win 32 程式員參考大全(一)- 視窗管理和圖形裝置介面Microsoft Win 32 程式員參考大全(二)- 系統服務、多媒體、系統擴充、應用程式須知Microsoft Win 32 程式員參考大全(三)- 函數(A—G)Microsoft Win 32 程式員參考大全(四)- 函數(H—Z)Microsoft Win 32 程式員參考大全 (五) -
Time of Update: 2018-12-07
function Length( S: String {字串; 也可以是數組}): Integer;舉例://string(在 Delphi 2007 下同 AnsiString)var s: string; i: Integer;begin s := 'Delphi'; i := Length(s); ShowMessage(IntToStr(i)); {6}end;//ShortStringvar s: ShortString; i: Integer;begin s :=
Time of Update: 2018-12-07
在學習 資源檔 和 鉤子函數 時, 經常用到當前模組控制代碼(HInstance)這個全域變數. 今天特別想知道, 它到底是在什麼時候給賦值的.輸入 HInstance; "Ctrl+滑鼠" 找到它的聲明之處: SysInit 單元的第 29 行(Delphi 2007) - HInstance: LongWord;看來 Delphi 的隱含單元不只是 System.pas, 還有 SysInit.pas.在 SysInit 單元的 658 行找到了它的指派陳述式: HInstance :=
Time of Update: 2018-12-07
定義:GetModuleHandle( lpModuleName: PChar {模組名; 只能是映射到當前進程的模組}): HMODULE; {返回模組控制代碼; 0 表示失敗}舉例://擷取當前模組的控制代碼var s: string; h: Cardinal;begin {先取得模組名} s := Application.ExeName; s := ExtractFileName(s); {擷取參數只要模組名就夠了; 不需要路徑(測試中有路徑也可以)}
Time of Update: 2018-12-07
舉例:var i: Integer; d: Real;begin i := Trunc(1234.5678); {截取整數} ShowMessage(IntToStr(i)); {1234} i := Trunc(-1234.5678); ShowMessage(IntToStr(i)); {-1234} i := Round(1234.5678); {四捨五入} ShowMessage(IntToStr(i)); {1235} i :=
Time of Update: 2018-12-07
問題來源: http://www.cnblogs.com/del/archive/2008/04/02/1131232.html#1133889答案: WebBrowser1.OleObject.Document.ParentWindow.變數名;譬如有這樣一個頁面(lancernig 舉的例子), 如何提取其中的 pvs 呢:...假定是把頁面儲存在 'c:\temp\test.htm', 測試代碼如下:unit Unit1;interfaceuses Windows, Messages,