BCB 要求聲明與定義分離:
頭文件:extern int gVar;
源文件:#pragma package(smart_init) int gVar;
否則鏈接階段報「找不到目標模塊」。
設置 Button->Hint = "工具提示|狀態欄提示"。
Application->OnHint = DisplayHint;
void DisplayHint(TObject*) { StatusBar->SimpleText = GetLongHint(Application->Hint); }
工具提示顯示 | 前,狀態欄顯示 | 後。
AnsiString bak = ShortDateFormat;
ShortDateFormat = LongDateFormat;
Edit->Text = DateToStr(DateTimePicker->Date);
ShortDateFormat = bak;
臨時替換全局格式變量,解決 Y2K 顯示隱患。
{$IFDEF} 版本判斷導致誤編譯,手動清理條件編譯指令。Project Options → Forms 將非主窗體移至 Available Forms。
調用時:TForm1* f = new TForm1(this); f->ShowModal(); delete f;
避免啟動時佔用內存。
Form KeyPreview = true。
OnKeyPress: if (Key == VK_RETURN) { SendMessage(Handle, WM_NEXTDLGCTL, 0, 0); Key = 0; }
自定義結構體數組 CellStru { AnsiString msg; TColor color; } cells[Col][Row];
OnDrawCell: Canvas->Font->Color = cells[Col][Row].color; Canvas->TextOut(Rect.Left+3, Rect.Top+3, cells[Col][Row].msg);
WinMain 中:
1. FindWindow 防止重複運行。
2. 創建 TSplashForm(bsNone, fsStayOnTop, poScreenCenter)。
3. Show(); Update(); 繪製。
4. Application->Initialize(); CreateForm(...); 初始化主程序。
5. splash->Close(); delete splash; 釋放。
6. Application->Run();
參考文章 7212:DbiPackTable + 獨佔模式。
編譯器核心文件誤刪 → 只能從安裝光盤拷回或重裝 IDE。