快速鍵設定控制項: THotKey [2] – 自訂菜單快速鍵

運行: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;

顏色選取 – 權當給 supperment 的回複吧, 你的要求要用到”種子演算法”, 我暫時還沒算明白.

本例: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);

學習 TList 類的實現[2]

我原來以為 TList 可能是一個鏈表, 其實只是一個數組而已.你知道它包含著多大一個數組嗎? MaxListSize 個!MaxListSize 是 Delphi 在 Classes 單元定義的一個常量:MaxListSize = Maxint div 16; 也就是 134217727; 這也是 TList 的最大容量.其中的 Maxint(2147483647) 也就是 2個G, 這是 Win32 系統許可一個應用程式對空間的最大操控權; 16 是一個 TList 的大小. 可以測試一下:

學習 TList 類的實現[3] – 不能迴避的話題: 記憶體配置

在 Delphi 中, 幾乎所有的類型都有對應的指標類型, 譬如:Char PCharWord PWORDDouble PDoubleTPoint PPoint甚至一種類型對應這著幾種指標類型, 譬如:Integer PInteger PINTWideChar PWideChar PWChar即使它沒有定義, 我也可以直接使用一個類型的指標, 譬如聲明一個整數的指標變數:var px: ^Integer;也可以先自訂指標類型, 再使用, 譬如:type

學習 TList 類的實現[4]

現在準備一步步地類比 TList 類, 建立一個自己的 TMyList.首先, 這個類中應該包括前面提到的那個 Pointer 數組(TPointerList)的指標(PPointerList):TMyList = class(TObject) FList: PPointerList;end;既然是一個列表, 應該有 Count 欄位:TMyList = class(TObject) FList: PPointerList; FCount: Integer;end;TList 類還有一個

學習 TList 類的實現[5]

先來實現 TMyList.SetCapacity.馬上會想到下面代碼:procedure TMyList.SetCapacity(const Value: Integer);begin if FCapacity Value then FCapacity := Value;end;但這樣是遠遠不夠的, 關鍵是需要分配記憶體, 像這樣:ReallocMem(數組的起點指標, 元素個數*元素大小);數組的起點指標即是 FList; 元素個數就是 SetCapacity 的參數: Value;

學習 TList 類的實現[6]

實現 TMyList.Add 函數.TList 中的 Add 函數用到了一個 Grow 方法, 它的原理是元素越多就為以後準備更多記憶體, 我們這裡省略為預留 4 個元素的記憶體;TList 中的 Add 函數還同時觸動了一個 Notify 方法, 這應該是為它們的子類準備的(估計是用它來激發一個事件的), 也不要了.function TMyList.Add(Item: Pointer): Integer;begin {如果預申請的記憶體用完了, 再申請夠 4 個元素用的} if

System.Copy – 從字串或數組中複製

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);

System.Val – 將字串轉換為數字

舉例: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)

學習 TList 類的實現[7]

總結目前 TMyList 已具備的功能(3 個方法、3 個屬性):Add: 添加; Delete: 刪除; Clear: 清空;Count: 元素總數;Capacity: 已存在的所有元素位置數;List: 指向核心數組的指標(唯讀).舉例測試如下:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type

學習 TList 類的實現[8]

現在準備建立 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)

Delphi 的按位元運算詳解 – 回複來賓”初學彙編”的問題

問題來源: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 的組合;在

System.ReallocMem – 重新申請記憶體

本例是順著 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

System.GetMem、System.FreeMem – 申請和釋放記憶體

如果只為單個指標分配記憶體, 和 New 和 Dispose 是一樣的; 與之不同的是: GetMem 可以申請連續的多個記憶體塊.舉例:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject);

辛苦而有價值的一天!

下載不行了我覺得到目前為止, 最有價值的一套 Windows 編程中文參考資料還是當屬:Microsoft Win 32 程式員參考大全(一)- 視窗管理和圖形裝置介面Microsoft Win 32 程式員參考大全(二)- 系統服務、多媒體、系統擴充、應用程式須知Microsoft Win 32 程式員參考大全(三)- 函數(A—G)Microsoft Win 32 程式員參考大全(四)- 函數(H—Z)Microsoft Win 32 程式員參考大全 (五) -

System.Length – 擷取字串或數組的長度

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 :=

全域變數 HInstance 到底是在什麼時候賦值的?

在學習 資源檔 和 鉤子函數 時, 經常用到當前模組控制代碼(HInstance)這個全域變數. 今天特別想知道, 它到底是在什麼時候給賦值的.輸入 HInstance; "Ctrl+滑鼠" 找到它的聲明之處: SysInit 單元的第 29 行(Delphi 2007) - HInstance: LongWord;看來 Delphi 的隱含單元不只是 System.pas, 還有 SysInit.pas.在 SysInit 單元的 658 行找到了它的指派陳述式: HInstance :=

WinAPI: GetModuleHandle – 擷取一個模組(exe 或 dll)的控制代碼

定義:GetModuleHandle( lpModuleName: PChar {模組名; 只能是映射到當前進程的模組}): HMODULE; {返回模組控制代碼; 0 表示失敗}舉例://擷取當前模組的控制代碼var s: string; h: Cardinal;begin {先取得模組名} s := Application.ExeName; s := ExtractFileName(s); {擷取參數只要模組名就夠了; 不需要路徑(測試中有路徑也可以)}

System.Trunc、System.Round、System.Int – 返回整數部分

舉例: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 :=

如果提取網頁中的變數 – 回複 lancernig 的問題

問題來源: 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,

總頁數: 61357 1 .... 4790 4791 4792 4793 4794 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.