2025年12月8日 星期一
2025年6月17日 星期二
2025年6月11日 星期三
QuickReport 調整 QRShape 配合 DetailBand 展延
begin
DetailBand1.ExpandedHeight(h);
QRShape1.Size.Height := h - QRShape1.Size.Top - 1;
end;
2025年6月8日 星期日
2025年6月4日 星期三
2025年5月21日 星期三
藍寶石
藍寶石
- 剛玉的化學成分是氧化鋁(Al₂O₃)。
- 純淨的剛玉其實是無色透明的。
- 當剛玉中含有不同的微量元素時,會呈現不同的顏色。
- 比如:黃色叫「黃寶石」實際上是「黃色藍寶石」。
- 粉色叫「粉紅藍寶石」、綠色叫「綠色藍寶石」。
2025年5月19日 星期一
常用函數
String
System
function Copy(S: String; Index: Integer; Count: Integer): string;
System.SysUtils
function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;function FormatDateTime(const Format: string; DateTime: TDateTime): string;function FormatFloat(const Format: string; Value: Extended): string;function FormatCurr(const Format: string; Value: Currency): string;function Trim(const S: string): string;function TrimLeft(const S: string): string; overload;function TrimRight(const S: string): string; overload;function QuotedStr(const S: string): string; overload;
比對字串 (不區分大小寫)
function CompareText(const S1, S2: string): Integer;
function UpperCase(const S: string): string;function UpperCase(const S: string; LocaleOptions: TLocaleOptions): string;function LowerCase(const S: string): string; overload;function LowerCase(const S: string; LocaleOptions: TLocaleOptions): string;function Languages: TLanguages;
System.StrUtils
回傳Text存在於Array裡的索引值 (區分大小寫)
function IndexStr(const AText: string; const AValues: array of string): Integer;
回傳Text存在於Array裡的索引值 (不區分大小寫)
function IndexText(const AText: string; const AValues: array of string): Integer;
function LeftStr(const AText: string; const ACount: Integer): string; overload;function RightStr(const AText: string; const ACount: Integer): string; overload;function MidStr(const AText: string; const AStart, ACount: Integer): string; overload;function ReverseString(const AText: string): string;
function SplitString(const S, Delimiters: string): TStringDynArray;
function IfThen(AValue: Boolean; const ATrue: string; AFalse: string = ''): string; overload;
Integer / Float
System
是否為奇數function Odd(X: Integer): Boolean;
procedure Inc(var X: Integer);procedure Inc(var X: Integer; N: Integer);
System.SysUtils
function StrToIntDef(const S: string; const Default: Extended): Extended;function StrToFloatDef(const S: string; const Default: Extended): Extended;function TryStrToFloat(const S: string; out Value: Extended): Boolean;function TryStrToCurr(const S: string; out Value: Currency): Boolean;function TryStrToInt(const S: string; out Value: Integer): Boolean; overload;
System.Math
平方function Power(const Base, Exponent: Double): Double;
將變數向上捨入至正無窮大。function Ceil(const X: Double): Integer;
將變數向負無窮方向舍入。function Floor(const X: Double): Integer;
Form.Width / 2 回傳浮點數Form.Width div 2 回傳整數值 (不計小數)
function Max(const A, B: Integer): Integer; overload;function MaxValue(const Data: array of Double): Double; overload;function MaxIntValue(const Data: array of Integer): Integer;function Min(const A, B: Integer): Integer; overload;function MinValue(const Data: array of Double): Double; overload;function MinIntValue(const Data: array of Integer): Integer;function InRange(const AValue, AMin, AMax: Int64): Boolean; overload;取整數function Int(const X: Extended): Extended;取小數function Frac(const X: Extended): Extended;
判斷正/負號
function Sign(const AValue: Integer): TValueSign;
Array中的平均值
function Mean(const Data: array of Single): Single;
function IfThen(AValue: Boolean; const ATrue: Integer; const AFalse: Integer = 0): Integer; overload;
Datetime
System.DateUtils
function IsPM(const AValue: TDateTime): Boolean;
function IsAM(const AValue: TDateTime): Boolean;
function IsValidDate(const AYear, AMonth, ADay: Word): Boolean;
傳回指定 TDateTime 值所在年份的週數。
function WeeksInYear(const AValue: TDateTime): Word;
傳回指定年份的週數。
function WeeksInAYear(const AYear: Word): Word;
傳回指定 TDateTime 值所在年份的天數。
function DaysInYear(const AValue: TDateTime): Word;
傳回指定年份的天數。
function DaysInAYear(const AYear: Word): Word;
傳回指定月份的天數。
function DaysInMonth(const AValue: TDateTime): Word;
傳回指定年份的指定月份的天數。
function DaysInAMonth(const AYear, AMonth: Word): Word;
function Today: TDateTime;
function Yesterday: TDateTime;
function Tomorrow: TDateTime;
function YearOf(const AValue: TDateTime): Word;
function MonthOf(const AValue: TDateTime): Word;
function WeekOf(const AValue: TDateTime): Word;
function DayOf(const AValue: TDateTime): Word;
function HourOf(const AValue: TDateTime): Word;
function MinuteOf(const AValue: TDateTime): Word;
function SecondOf(const AValue: TDateTime): Word;
function MilliSecondOf(const AValue: TDateTime): Word;
function StartOfTheMonth(const AValue: TDateTime): TDateTime;
function EndOfTheMonth(const AValue: TDateTime): TDateTime;
function StartOfAMonth(const AYear, AMonth: Word): TDateTime;
function EndOfAMonth(const AYear, AMonth: Word): TDateTime;
function StartOfTheWeek(const AValue: TDateTime): TDateTime;
function EndOfTheWeek(const AValue: TDateTime): TDateTime;
function StartOfAWeek(const AYear, AWeekOfYear: Word;const ADayOfWeek: Word = 1): TDateTime;
function EndOfAWeek(const AYear, AWeekOfYear: Word;const ADayOfWeek: Word = 7): TDateTime;
function YearsBetween(const ANow, AThen: TDateTime): Integer;
function MonthsBetween(const ANow, AThen: TDateTime): Integer;
function WeeksBetween(const ANow, AThen: TDateTime): Integer;
function DaysBetween(const ANow, AThen: TDateTime): Integer;
function HoursBetween(const ANow, AThen: TDateTime): Int64;
function MinutesBetween(const ANow, AThen: TDateTime): Int64;
function SecondsBetween(const ANow, AThen: TDateTime): Int64;
function MilliSecondsBetween(const ANow, AThen: TDateTime): Int64;
function IncYear(const AValue: TDateTime; const ANumberOfYears: Integer = 1): TDateTime; inline;
function IncWeek(const AValue: TDateTime;const ANumberOfWeeks: Integer = 1): TDateTime; inline;
指定天數偏移的日期
function IncDay(const AValue: TDateTime; const ANumberOfDays: Integer = 1): TDateTime; inline;
function IncHour(const AValue: TDateTime; const ANumberOfHours: Int64 = 1): TDateTime; inline;
function IncMinute(const AValue: TDateTime; const ANumberOfMinutes: Int64 = 1): TDateTime;
function IncSecond(const AValue: TDateTime; const ANumberOfSeconds: Int64 = 1): TDateTime;
function IncMilliSecond(const AValue: TDateTime; const ANumberOfMilliSeconds:Int64 = 1): TDateTime;
File/Fold
System.SysUtil
資料夾是否存在.function DirectoryExists(const Directory: string; FollowLink: Boolean = True): Boolean;檔案是否存在function FileExists(const FileName: string; FollowLink: Boolean = True): Boolean;檔案放置的資料夾function ExtractFileDir(const FileName: string): string;檔案放置的路徑function ExtractFilePath(const FileName: string): string;檔案放置的磁碟代號function ExtractFileDrive(const FileName: string): string;檔案名稱function ExtractFileName(const FileName: string): string;變更副檔名function ChangeFileExt(const FileName, Extension: string): string;檔案是否唯讀function FileIsReadOnly(const FileName: string): Boolean;檔案設定唯讀function FileSetReadOnly(const FileName: string; ReadOnly: Boolean): Boolean;刪除檔案function DeleteFile(const FileName: string): Boolean;檔案名稱更名function RenameFile(const OldName, NewName: string): Boolean;檔案搜尋function FileSearch(const Name, DirList: string): string;目前的使用路徑function GetCurrentDir: string;設定目前的使用路徑function SetCurrentDir(const Dir: string): Boolean;建立資料夾(樹狀)function ForceDirectories(Dir: string): Boolean;建立資料夾function CreateDir(const Dir: string): Boolean;移除資料夾function RemoveDir(const Dir: string): Boolean;
2025年4月18日 星期五
2025年4月7日 星期一
康斯坦丁:驅魔神探 (Constantine, 2005)
在電影《康斯坦丁:驅魔神探》(Constantine, 2005)中,**加百列(Gabriel)**是一位墮落的天使,在電影後段她與主角約翰·康斯坦丁(John Constantine)對峙時,說出了一段令人印象深刻的話。
在劇情高潮時,加百列透露她的動機是要「讓人類值得神的愛」,而她的方法是讓人類經歷痛苦與苦難,從而讓人類變得「純潔」和「強大」,這樣才「配得上」天堂的愛。她認為神對人類太過仁慈,而這份仁慈讓人類墮落。
這段經典對白類似如下(非官方翻譯):
「你們這些人類得到了天堂的愛,卻不珍惜。你們浪費了那份恩典。我要讓你們經歷真正的痛苦,真正的挑戰,這樣你們才能變得配得上祂的愛。」
英文原文大致為:
"You don’t deserve to be saved. You get everything handed to you. Love, salvation. It’s a gift that’s been wasted on you. So I’m going to help you earn it. I’m going to bring you pain. I'm going to bring you horror, so that you can finally be worthy of God's love."
這段話表現了加百列以自以為是的「正義」名義做出極端行為的扭曲心理,也點出了電影中神祕主義與人性救贖的主題。
ChatGPT
2025年3月26日 星期三
世界正在無限循環,你要做的只有這件事 | 老高與小茉 Mr & Mrs Gao
所謂的"信仰"、所謂的"標準",這些都是絕對的,我們才去信它,
我們不能信一個不絕對的東西,
就好比說原則也好、信念也好都是這種東西,
雖然它是個理想化的東西,但是,由於我們相信它,
我們才能在這個世界上存活...
如果你不相信努力就有回報,你是不會努力的,
雖然我們努力了不一定有回報,
但是根本上你是相信努力會有回報你才在努力,
這就是你相信的東西,這就是你的信念,
也正因為有這個信念,我們才會忍受現在的一些痛苦,忍受現在的折磨,
去為我們的目標而努力。」
不管它是幸福還是不幸的,
因為只有命運是屬於你自己的,
你不愛你的命運,它就不愛你
你愛它,它就愛你...
命運是不能改變的,但內心是可以改變,
你想法是可以改變,
這個事你永遠都要經歷,不過巡迴多少次人生你都要經歷,
但是你的想法可以改變。」
「諸神黃昏」為何會爆發?誰該為這場北歐神幾乎全滅的悲劇負責?【神話故事集】#31|奇幻圖書館
2025年3月25日 星期二
曾是神最寵愛的光之天使首領,路西法為何背叛上帝,成為墮落天使?【奇幻百科全書】#19|奇幻圖書館
所謂的魔鬼與異端真的都是邪惡不堪的存在嗎,
其實很多時候,惡魔只是不被這社會的規則秩序所接受的一方而已吧,
畢竟當你手裡握有權力,要編故事與羅織罪名根本不是什麼困難的事情」
這種想法本身就是一種權威感,
只是差別在你有沒有辦法對質疑你的人做出制裁而已,
儘管我們小心翼翼,不想變成那個墮落天使,
諷刺的是,我們每個人都可能成為別人眼中的路西法,不是嗎」
2025年2月20日 星期四
Delphi 表單建立/釋放時的事件順序
在 Delphi 中,當一個表單 (Form) 被建立時,會依序觸發以下事件:
Constructor (Create):
在這個階段,表單的物件會被建立,但視窗還沒有初始化。
如果使用的是 TForm.Create(nil),此時還沒有分配 Parent,也沒有顯示。
CreateWnd:
建立表單的 Windows 視窗句柄 (Handle)。
此時可以進行與視窗句柄相關的操作,例如 API 呼叫。
Loaded:
當表單是從 DFM (表單文件) 加載時會觸發。
所有的組件屬性和子組件都已經被初始化。
適合在這裡進行一些屬性設定或初始化動作。
OnCreate (或 FormCreate 事件):
當表單完成建立時觸發。
通常用於初始化變數、設定控制項屬性或載入資料。
OnShow:
當表單即將顯示在螢幕上時觸發。
表單已經可見,但還沒有繪製完全。
適合用於需要在顯示時更新畫面的操作,例如 UI 資料刷新。
OnActivate:
當表單獲得焦點 (成為最上層視窗) 時觸發。
每次表單被切換回來時都會觸發,不只是第一次顯示時。
OnPaint:
當表單需要重繪時觸發。
一般用於自訂繪圖邏輯,例如畫布 (Canvas) 操作。
OnResize (可選,視情況而定):
當表單大小改變時觸發。
可用於調整內部控制項的佈局。
當表單關閉或釋放時,事件順序如下:
OnCloseQuery:
在關閉前詢問是否允許關閉 (CanClose 參數)。
可用於彈出確認視窗或檢查條件。
OnClose:
當表單正在關閉時觸發。
可透過 Action 參數決定是隱藏還是釋放表單。
OnHide:
當表單從螢幕上消失時觸發。
OnDestroy (或 FormDestroy 事件):
在表單物件被釋放前觸發。
通常用於釋放資源、清理記憶體或結束程序。
Destructor (Destroy):
最後的資源釋放動作,然後表單物件從記憶體中移除。

