Delphi tips and FAQs Delphi技巧集索引
VCL:
#0002 How can I draw the rotated text on canvas?
如何在畫布上寫旋轉文字
#0005 To change a font style (bold nodes) in standard TTreeview component
改變TTreeview控制項的字型樣式
#0008 To disable a form movement
禁止Form表單移動
#0010 To add the horizontal scrollbar in listbox
在Listbox中增加水平捲軸
#0012 To set a checkbox without OnClick event
取消CheckBox的OnClick事件
#0013 To disable the on-fly tooltips in TTreeView
禁止TTreeView上的工具提示
#0018 The form life cycle after creation
form的生存周期
#0023 To get a line/column number that a memo/richtext cursor is on
擷取memo或者richtext上當前游標的行數或列數
#0025 To use a combobox instead inplace editor in TStringGrid
用Combobox替換TStringGrid中預設的編輯器
#0028 The offsets for TMemo
TMemo的分支
#0029 The quick filling a listbox with file names
用檔案名稱快速填入listbox
#0034 To change alignment for TEdit
設定TEdit的對齊
#0035 To make a form like system modal
將表單Form設定為系統模式
#0036 To create a non-rectangular control
建立不規則的控制項
#0038 How to add a flat/hot track effect to components
如何在控制項上添加熱鍵跟蹤
#0057 To delete the row in TStringGrid component
如何刪除TStringGrid中的行。
#0065 To save/restore the component into BLOB-field
使用Bolb-Field儲存和恢複控制項。
#0067 Access to some item of TRadioGroup component
訪問TRadioGroup的子項
#0085 To save/load the glyphs to/from external file
如何從外部檔案存取字形
#0094 To assign a values to TStrings instead objects
賦一個值給Tstring,用來代替對象
#0102 To scroll a text in memo in run-time
即時滾動memo中的文字
#0146 Standard RichEdit component and URL highlighting
RichEdit控制項中高亮顯示URL
#0148 Autocomplete for edit/combobox
在Edit或Combobox中實現自動完成功能。
#0154 To exchange items in TListView
擴充TListView的子項
#0158 To change a font for TListView header
改變TListView列頭的字型
#0159 Flat header for TListView
改變TListView的列頭為平坦樣式
#0160 Numeric editbox
如何只允許在EditBox中輸入數字
#0163 To print the TTreeView and TListView
列印TTreeView或TListView中的內容
#0164 To display week numbers in TDateTimePicker
在TDateTimePicker中顯示星期幾
Databases 資料庫
#0021 Database programming technology (Design Patterns)
資料庫編程技術(使用設計模式)
#0043 To navigate by selected rows in DBGrid
在DBGrid中,通過選擇的行導航
#0062 To get the alias list, tables list etc
得到類似於資料表的別名列表
#0063 To copy (to dublicate) the dataset record
複製資料集記錄
#0065 To save/restore the component into BLOB-field
使用Bolb-Field儲存和恢複控制項。
#0079 To export a dataset into XML-file
將資料庫的資料倒入xml檔案
#0081 To check if BDE exists
檢查BDE是否存在
#0091 To play a wav-file from memory or BLOB-field
從記憶體或者BLOB-field直接播放wav檔案
#0092 To switch a DBGrid in edit mode and set a cursor in some position
在DBGrid的特定位置,設定DBGrid進入編輯模式並且置當前游標
#0108 To generate the script for table creation
產生建立表的sql語句
#0109 To generate the script for SELECT-statement
產生select的sql語句
#0111 To create table in MS Access with DAO
在MS Access中,用DAO建立表
#0141 To save file in BLOB and restore later
使用Blob欄位存取檔案
#0150 Use TClientDataset as memory dataset
將TClientDataset作為Memory Dataset使用
#0168 To execute the query in MS Access
在Ms Access中執行查詢
Reports, printing
列印或報表
#0017 Printer settings - page sizes and margins (part1)
設定列印的大小和邊距
#0019 To get a printer settings (part 2)
獲得印表機的設定
#0020 To set a printer settings
設定印表機的設定
#0022 Printing on the TPrinter using default resident font (part 1)
使用TPrinter的預設字型列印
#0026 The printer capabilities to print a graphics
提高印表機列印圖形的能力
#0032 To change the default printer in Windows
改變Windows的預設印表機
#0047 The list of jobs in the MS Windows print spooler
列舉Windows列印緩衝區中的所有列印工作
#0068 To use a resident font for printing (part 2)
用預設字型列印
#0083 To print/preview the MS Access's report
列印或預覽Ms Access的報表
#0087 To send a command strings to printer
發送命令串給印表機
#0090 To print a bitmap on printer
列印BitMap
E-mail, Internet, Network
#0037 How to get your local IP?
怎樣獲得本地IP
#0041 PC is connected to a network
如何判斷PC是否連網。
#0049 To create the e-mail message in MS Outlook
通過Ms OutLook發信
#0080 To download the file from web
從Web上下載檔案
#0088 How do I find a MAC address?
獲得Mac地址
#0095 To receive a modem list, which is installed in Win95/98
如何獲得win95/98的安裝的modem列表
#0115 To create an email messaqe by MAPI
通過mapi發信
#0116 To download a file from internet using sockets
用socket從Internet下載檔案
#0117 To select a recipient from addressbook
從地址簿選擇收信人
#0120 To retrieve a folder list from MS Outlook
從ms outlook恢複檔案清單
#0121 To retrieve items (messages/tasks/etc) from any Outllok folder
從Outlook檔案加恢複內容
#0123 To retrieve and save the attachments from MS Outllok message
恢複和儲存OutLook郵件的附件
#0126 HTTP/Url encoding
Http/Url編碼
#0127 to print url/html file using IE browser
用IE瀏覽器列印Url/html檔案
#0139 TWebBrowser and POST request
使用TWebBrowse訪問網頁
#0161 to read the proxy information
擷取代理資訊
Windows API
#0001 How can I create a screenshot?
獲得截屏
#0004 How can I receive a list of processes running on a system?
如何獲得進程列表
#0006 Delete a file into Recycle Bin
將檔案刪除到資源回收筒
#0007 To detect a Windows version
檢測Windows版本
#0009 To switch a keyboard layout
轉換鍵盤配置
#0011 To add a some forms in Windows Task Manager
將子表單也加入到工作列中
#0014 To get a system icons
獲得系統表徵圖
#0016 Turn monitor power on/off
開啟或關閉顯示器電源
#0027 The current computer and user names
獲得當前電腦名稱和使用者名稱
#0052 To get a sizes of some system controls
獲得系統控制項的大小
#0053 To set the clock (system datetime) in Windows
設定Windows的系統時鐘
#0070 To read the environment string
獲得環境字串
#0082 To read the current code page of system
讀取系統當前字碼頁(獲得作業系統類型)
#0084 To load the icons from external dll/exe
從Dll或者exe提取表徵圖
#0086 To register the file extention and context menu
註冊副檔名和操作功能表
#0098 To retrieve a full path of module in DLL
擷取dll中模組的全路徑
#0105 To refresh a desktop
重新整理案頭
#0106 To read a path of system folder
擷取系統檔案夾路徑
#0112 To press a mouse button from code
在程式中產生點擊滑鼠動作
#0131 To use extended Windows dialogs
使用Windows擴充對話方塊
#0133 To read native text of current locale
擷取本地文本
#0138 To change a color of standard TProgressbar
改變TProgressbar的顏色
#0140 To define a custom icon for some folder
自訂檔案夾的表徵圖
#0147 To show/hide clocks in tray
在工作列裡顯示或隱藏時鐘
#0151 to display a Property dialog for file, folder or drive
顯示檔案、檔案夾、磁碟機的屬性對話方塊
#0156 alternative for TOpenDialog/TSaveDialog
使用api代替TOpenDialog/TSaveDialog
#0157 select the folder dialog
選擇檔案夾對話方塊
#0166 to change the view style for OpenDialog/SaveDialog
改變OpenDialog/SaveDialog的顯示樣式
#0167 to change the alignment for TButton
設定TButton的對齊
#0170 to add the chevron button for toolbar
在工具列添加特殊表徵圖按鈕
#0171 to add chevron to TToolbar if some buttons are invisible (part 2)
為非可視按鈕添加特殊表徵圖到工具列
Menu 菜單
#0030 To add item into system menu
在系統功能表裡增加一個菜單
#0033 To add bitmaps to menu items
在功能表項目中添加一個位元影像
#0060 To align a menu item to right
靠右對齊菜單
#0155 to show the system menu
顯示系統菜單
Tools API
#0003 How can I check the Delphi/C++Builder version?
如何檢測Delphi/C++Builder的版本
#0040 To read/write a property by name
通過名稱讀寫屬性
#0054 To get a name of enum value
擷取枚舉值得名稱
#0069 To receive a names of all registered components
擷取所有註冊的組件名
#0070 To receive a names of all palettes, which was registered in IDE
擷取已經註冊到ide的所有面板的名稱
#0073 To receive the list of published properties of component (part 1)
擷取組件的published屬性列表(方法一)
#0074 To receive the list of published properties of component (part 2)
擷取組件的published屬性列表(方法二)
#0103 To change a default font in IDE
改變IDE的預設字型
#0104 To disable a new project creation
禁止開啟IDE時自動建立工程
#0119 To register a component editor which will be activated by right mouse click in Delphi IDE
在Delphi IDE右擊滑鼠註冊組件編輯器
OLE, COM
#0049 To create the e-mail message in Outlook
藉助OutLook發送郵件
#0051 To create a shell link/shortcut
建立捷徑
#0083 print/preview the MS Access's report
調用access的列印和預覽
#0086 To register the file extention and context menu
註冊副檔名和菜單
#0089 Description of Instancing and Threading Models in COM-servers
com伺服器的執行個體和線程模式介紹
#0120 To retrieve a folder list from MS Outlook
枚舉Outlook資料夾清單
#0128 To create an appointment in MS Outlook
用OutLook建立一個指定
#0142 To to read a sender address for MailItem (MS Outlook)
從OutLook 郵件中讀取發信人的地址
#0143 To check if OLE object is installed
檢測OLE對象是否安裝
#0144 Fast data transfer to MS Excel
快速將資料寫到Excel
#0145 Contact list in MS Outlook
擷取OutLook連絡人資料
#0149 language for installed MS Office
擷取Office安裝的語言
#0152 replace text/font in doc-file
替換doc檔案中文本/字型
#0153 open the password-protected xls-file and save without password
開啟有密碼保護的xls檔案並另儲存為無密碼的xls檔案
可以改為一個暴力破解密碼
#0169 find the file name by ActiveX/OLE class name
通過ActiveX/Ole類名發現檔案名稱
Files, drives
#0031 To detect a drive type
檢測磁碟機的類型
#0046 To get a file datetime
用FileAge擷取檔案的時間
#0050 How do I execute a program and have my code wait until it is finished?
執行一個程式並且等待它結束
#0051 To create a shell link/shortcut
建立捷徑
#0055 To get the serial number of a disk
獲得磁碟的序號
#0058 To accept the dropped files from Windows Explorer
從Windows瀏覽器擷取下拉檔案
#0066 The file in use or not
檢查檔案是否已經被開啟
#0075 To map the network disk
映射網路磁碟
#0114 To load a file list by some wildcard
使用萬用字元擷取檔案清單
#0118 To recieve a number of files in some folder by wildcard
通過萬用字元擷取檔案數量
#0122 To change a creation date/time for file on disk
修改磁碟檔案的建立時間
Algorithms 演算法
#0039 To save/load a font information in INI/text-file
在Ini或txt本件中儲存和裝載字型
#0048 CRC32 calculation
crc32演算法
The writer supplys a method for build a crc table and calculate the File crc
#0056 To play with colors (dark/light)
設定顏色的亮暗
#0093 Hash function for strings
字串的hash函數
The writer finds a good hash function in delphi sources(dbtable.pas).
#0113 Correct round of number
四捨五入
#0124 extended DayOfWeek function
擴充的星期幾標記法
#0125 second Wednesday of November
計算11月的第二個星期三的日期
#0129 checksum by modulus 10
模10校正和,提供了演算法說明.並不是簡單的模數.
#0136 ELF hash algorithm
又一個hash演算法
#0162 to extract the plain text from html string
從html格式文本中提取純文字.
Conversions 轉換
#0042 To convert the bitmap to Jpeg and vice versa
bitmpa與jpeg相互轉轉換
Use the TBitmap and TJPEGImage
#0044 To convert a color string into HTML format
將顏色字串轉換為html格式
#0045 To convert color value into gray-scaled color value
將顏色值轉為灰階值
#0132 To add leading zeros for numbers
在數字前面增加前置字元為零
#0137 To create a disabled bitmap
建立一個灰色位元影像
#0165 To convert the file size to string (a-la Explorer)
轉換檔大小到字串(按explorer方式)
Multimedia
#0015 To open/close a CD-drive
開關光碟機
#0078 To sound a beep for some action
播放Beep
#0091 To play a wav-file from memory or BLOB-field
從記憶體或者Blob-Field欄位播放wav檔案
Miscellaneous
#0056 To play with colors (dark/light)
變換顏色的暗亮顯示
#0059 To draw in area of the form caption
操作Form的Caption
#0061 To retrieve the vertical refresh rate of the display
恢複顯示器的垂直重新整理速率
#0064 To draw a chart on some canvas
在Canvas上畫一個Chart
#0072 To change a line type for drawing
改變畫線的類型
#0076 To change button caption in Open/SaveDialog
使用SetDlgItemText修改Open/SaveDailog按鈕的名稱
#0077 To get a mouse position
使用GetCursorPos獲得滑鼠的位置,並控制快顯功能表的位置
#0094 To assign a values to TStrings instead objects
使用TStrings儲存普通類型,而不是儲存物件
#0096 To hide an application from TaskBar
使用SetWindowLong在TaskBar中隱藏應用程式
#0097 To hide/show the Start button from Windows TaskBar
隱藏顯示工作列上的開始菜單
#0107 To add a custom control in standard dialog
在標準對話方塊上增加自訂控制項
#0110 To increase a performance of standard TTreeView/TListView
提高TTreeview/TListView的效能
#0130 To use a procedure in dll from Delphi code
在Delphi中調用Dll中的過程
#0134 daylight saving time
讀取夏令時
#0135 To filter a mouse and keyboard
過濾使用者的滑鼠和鍵盤事件,在讓使用者等待進度條時很有用