顯示具有 小技巧 標籤的文章。 顯示所有文章
顯示具有 小技巧 標籤的文章。 顯示所有文章

星期四, 9月 20, 2012

Timer使用技巧

1. 可以使用TELTimerPool來一次新增多個Timer,並方便管理

2. 預設為Timer.Enabled := False; 於onFormShow再將Timer.Enabled := True;

3. 為避免onTimer內程式跑沒完,下個時間的觸發又到,可加旗標來防止下個時間的進入。

4. 可以設定第一次跑15秒後跑,之後是1分半後跑一次,則預設Timer.Interval:=15000。然後在onTimer的程式內寫Timer.Interval:=90000

5. Timer的第一次觸發是inteval時間完後才跑。

星期三, 8月 31, 2011

MemoryStream To String

The code you have is unnecessarily complex, even for older Delphi versions. Why should fetching the string version of a stream force the stream's memory to be reallocated, after all?
function MemoryStreamToString(M: TMemoryStream): string;

begin
SetString(Result, M.Memory, M.Size div SizeOf(Char));
end;

That works in all Delphi versions, not just Delphi 2009. It works when the stream is empty without any special case. SetString is an under-appreciated function.

If the contents of your stream aren't changing to Unicode with your switch to Delphi 2009, then you should use this function instead:
function MemoryStreamToString(M: TMemoryStream): AnsiString;

begin
SetString(Result, M.Memory, M.Size);
end;

That's equivalent to your original code, but skips the special cases.

星期二, 11月 06, 2007

元件一起設定屬性(事件)

按Shift然後選所有要更動的元件,然後你就可以一起設定他們的屬性或事件囉!!

星期四, 11月 01, 2007

如何快速的跳到所要的函式位置

通常要追蹤函式位置時,會先按Ctrl然後點函式名字,接著跳到函式宣告的地方,然後再按Ctrl + Shift + "下"方向鍵,然後便自動跳到函式內容地方。

星期一, 10月 29, 2007

複製程序(procedure)或函式(function)的程式碼後,在private能自動產生的方法

在程序名或函式名上(不用圈選)按右鍵,選擇complete class at cursor即可。

星期二, 10月 09, 2007

讓Delphi在編輯程式碼時,能打幾個字就自動顯示函數


ChgIME.exe,這是我們大師兄anderson寫的,沒有像windows一樣,一定要全禁掉才可以使用,他的程式可以關掉左邊Ctrl給Delphi用,然後右邊給輸入法切換使用。
ps:設定完要重開機喔~