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
过滤用户的鼠标和键盘事件,在让用户等待进度条时很有用