Lazarus Tutorial/zh CN: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | *这是Lazarus教程的起点。你可以自由地把自己的体会添加到这里。* | |
| 2 | 2 | ||
| 3 | 3 | ## 概述 | |
| 4 | 4 | ||
| 5 | 5 | Lazarus是一个自由并且开源的RAD(快速应用开发)开发工具,它基于同样自由开源的FreePascal(object pascal)编译器。Lazarus IDE([screenshot](http://lazarus-ccr.sourceforge.net/kbdata/lazide.jpg))可以创建独立的(原文是self-standing,我不确认是否准确)的图形或控制台程序,同时稳定并且富于特色.目前可以运行在Linux, FreeBSD和Win32平台下,同时提供可自定义的源代码编辑器,包含包管理器的可视化GUI设计环境,以及完整地集成在GUI环境中的调试器和FreePascal编译器。 | |
| 6 | 6 | ||
| 7 | 7 | ## 起点 - 你的第一个Lazarus程序! | |
| 8 | 8 | ||
| 9 | 9 | (感谢User:Kirkpatc) | |
| 10 | 10 | ||
| 11 | 11 | 首先,[[Installing Lazarus/zh CN|安装Lazarus]],然后运行Lazarus,当然还要确定你有可以使用的FreePascal编译器。 | |
| 12 | 12 | ||
| 13 | 13 | 桌面上将出现很多窗口:顶部是主菜单,左面是对象观察器,Lazarus源代码编辑器将占据大部分的桌面,而一个预置的Form1窗体将覆盖在源代码编辑器的上面。 | |
| 14 | 14 | ||
| 15 | 15 | 首先,如果你的Lazarus是全英文的,那么你可以通过主菜单上的Environment -\> Environment Options打开环境设置窗口,在Desktop标签下有Language选项,改成Chinese (zh_CN),确定后重新启动下Lazarus,绝大部分界面就是中文的了。 | |
| 16 | 16 | ||
| 17 | 17 | 注:对于linux用户,Lazarus的默认编译/安装很大可能是使用GTK1库(非常容易辩认...因为非常丑...),GTK1对于Unicode的支持不完善,无法显示中文,你可以使用GTK2重新编译Lazarus,具体方法请参照[[Quick start: Recompile the IDE]]。 | |
| 18 | 18 | ||
| 19 | 19 | 在顶部的主菜单上,菜单分隔线的下面有一排标签。如果Standard标签还未被选中,单击选中它。然后找到TButton图标(一个有OK字样的矩形),单击Tbutton图标,然后在Form1窗体上找个宽敞的地方单击一下。一个有着"Button1"标题的矩形按钮就出现了。重复一次,你将获得"Button2"按钮,建议你把它放到Button1的右面。 | |
| 20 | 20 | ||
| 21 | 21 | 现在单击Button1选中它,左侧的对象观察器上将出现Button1对象的所有属性。找到名为Caption的属性(你可以在"收藏夹"标签下更方便地找到它),现在这个属性的值是"Button1"。单击显示着"Button1"的方格,把里面"Button1"文本改成"Press",当你按下Enter(或者单击别的方格)后,你会看见Form1窗体上的Button1按钮上的文本变成了"Press"。然后找到对象观察器上的"事件"标签,你会看见可以给Button1关联很多事件(Event),包括OnClick,OnEnter,OnExit等等。选择OnClick右边的空白方格,将出现一个显示"..."(三个点,也就是省略号)的小方格,在这个方格上单击,你将自动跳转到源代码编辑器,同时你的光标会处于一段过程(procedure)代码中: | |
| 22 | 22 | ||
| 23 | 23 | ` procedure TForm1.Button1Click(Sender: TObject);`\ | |
| 24 | 24 | ` begin`\ | |
| 25 | 25 | ` {你的光标将位于这里,请输入后面的代码:}`\ | |
| 26 | 26 | ` Button1.caption := 'Press again';`\ | |
| 27 | 27 | ` {源代码编辑器已经自动完成了这个过程的其他部分}`\ | |
| 28 | 28 | ` end;` | |
| 29 | 29 | ||
| 30 | 30 | 按下F12选中Form1窗体。 | |
| 31 | 31 | ||
| 32 | 32 | 然后我们来编辑Button2的属性,将Caption修改为"Exit",然后选择OnClick事件,单击那个显示"..."的小方格,你又回到了源代码编辑器,光标位于另一段过程代码的中间: | |
| 33 | 33 | ||
| 34 | 34 | ` procedure TForm1.Button2Click(Sender: TObject);`\ | |
| 35 | 35 | ` begin`\ | |
| 36 | 36 | ` {输入:}`\ | |
| 37 | 37 | ` Close;`\ | |
| 38 | 38 | ` end;` | |
| 39 | 39 | ||
| 40 | 40 | 再次按下F12选中Form1窗体。现在可以尝试编译这个程序了。最简单的方法是在顶部主菜单中选择"运行",在弹出的子菜单中选择"运行"(你也可以使用快捷键F9)。如果一切顺利,你的程序将被编译执行。 | |
| 41 | 41 | ||
| 42 | 42 | 所有的编译信息都会出现在底部的"消息"窗口中。最终,一个没有刻度标记(编辑状态下才会出现)的Form1窗口将出现在屏幕上。这是你的应用程序的主窗口,它正等着你去按按钮(以及其他操作)。 | |
| 43 | 43 | ||
| 44 | 44 | 尝试下点击Press按钮,你会发现按钮的标签变成了"Press again"。之后你再怎么按,它依然显示"Press again"。 | |
| 45 | 45 | ||
| 46 | 46 | 现在点击Exit按钮,窗口将关闭,程序也就终止了。编辑状态下有着丑陋刻度标志的Form1又回到了屏幕上,准备接受更多的修改完善。 | |
| 47 | 47 | ||
| 48 | 48 | 现在你应该保存你的工作了(你应该经常这么做!),选择顶部主菜单上的" 工程 \> 保存工程 "来保存工程文件。 | |
| 49 | 49 | ||
| 50 | 50 | ### 第二步 | |
| 51 | 51 | ||
| 52 | 52 | 再次打开你保存的工程。 | |
| 53 | 53 | ||
| 54 | 54 | 在Form1窗体上选择Press按钮("Button1")。 | |
| 55 | 55 | ||
| 56 | 56 | 在"事件"标签中选择OnClick,点击出现的"..."方格,来回到源代码编辑器。 | |
| 57 | 57 | ||
| 58 | 58 | 按照下面的文本编辑你的代码: | |
| 59 | 59 | ||
| 60 | 60 | ` procedure TForm1.Button1Click(Sender: TObject);`\ | |
| 61 | 61 | `{这段代码使用了Button1的Tag属性,使Tag属性在0和1之间转换}`\ | |
| 62 | 62 | ` begin`\ | |
| 63 | 63 | ` if Button1.tag =0 then`\ | |
| 64 | 64 | ` begin`\ | |
| 65 | 65 | ` Button1.caption := 'Press again';`\ | |
| 66 | 66 | ` Button1.tag := 1`\ | |
| 67 | 67 | ` end else`\ | |
| 68 | 68 | ` begin`\ | |
| 69 | 69 | ` Button1.caption := 'Press';`\ | |
| 70 | 70 | ` Button1.tag := 0`\ | |
| 71 | 71 | ` end`\ | |
| 72 | 72 | ` end;` | |
| 73 | 73 | ||
| 74 | 74 | 保存你的工作,重新编译并且运行,Press按钮的标签将会在点击时,在两个不同的文本间来回变换了 | |
| 75 | 75 | ||
| 76 | 76 | 然后,随便玩吧:\] | |
| 77 | 77 | ||
| 78 | 78 | 如果你准备编写控制或者基于文本的Pascal程序(例如你正在使用一份基本的Pascal指南,准备编写在控制台环境下运行的程序,以及为系统底层编程等等),你依然可以使用Lazarus编写,编译并且运行你的程序。Lazarus是一个理想的Pascal开发环境。具体请参照[[Console Mode Pascal]]. | |
| 79 | 79 | ||
| 80 | 80 | ### 第三步 常用调试方法 | |
| 81 | 81 | ||
| 82 | 82 | 新人学习不少需要调试的内容 | |
| 83 | 83 | ||
| 84 | 84 | 所以需要一些直接有效的打印出调试内容. | |
| 85 | 85 | ||
| 86 | 86 | 比如像VB 下的 Debug.print 可直接在立即窗口中打印出调试内容 | |
| 87 | 87 | ||
| 88 | 88 | 其实可以使用 | |
| 89 | 89 | ||
| 90 | 90 | ` WriteLn('XXXX ', XXX); ` | |
| 91 | 91 | ||
| 92 | 92 | ` Write('XXXXXX'); ` | |
| 93 | 93 | ||
| 94 | 94 | 但是在网上发现不少新人使用会弹出: **project project1 raised exception class 'EInOutError' with <message:file> not open** | |
| 95 | 95 | ||
| 96 | 96 | 异常通知 | |
| 97 | 97 | ||
| 98 | 98 | 只需要在文件头部加入预编译指令 | |
| 99 | 99 | ||
| 100 | 100 | ` {$APPTYPE CONSOLE}` | |
| 101 | 101 | ||
| 102 | 102 | 这样调试时会弹出一个类dos对话框,输出调试的内容 | |
| 103 | 103 | ||
| 104 | 104 | ### 第四步 常用技巧 | |
| 105 | 105 | ||
| 106 | 106 | lazaurs的编辑器蛮强大的,支持代码补全,自动完成,模板编辑,多行缩进注释,选定代码后批量更改里面的单词! | |
| 107 | 107 | ||
| 108 | 108 | 1.代码补全 | |
| 109 | 109 | ||
| 110 | 110 | 按下键盘的Ctrl+W键!输入变量后按下这个键就OK啦~ | |
| 111 | 111 | ||
| 112 | 112 | 2.自动完成 | |
| 113 | 113 | ||
| 114 | 114 | 自动完成的快捷键大多数都冲突了,解决方法是打开 工具(T)-\>选项...-\>编辑器-\>键盘映射-\>CodeTools命令-\>标识符自动完成 上右键 编辑 ,然后根据实际情况修改吧,我的是再勾选Alt,也就是说,我的热键是Ctrl+Alt+Space!不懂的看图 | |
| 115 | 115 | ||
| 116 | 116 | 3.模板编辑 | |
| 117 | 117 | ||
| 118 | 118 | 这个也蛮简单,按下键盘的Ctrl+J,然后输入class,回车!是不是很酷! | |
| 119 | 119 | ||
| 120 | 120 | 4.多行缩进注释 | |
| 121 | 121 | ||
| 122 | 122 | 缩进的:向左 -\> Ctrl+U | |
| 123 | 123 | ||
| 124 | 124 | 向右 -\> Ctrl+I(选中多行代码更爽) | |
| 125 | 125 | ||
| 126 | 126 | 多行注释:Ctrl+/ | |
| 127 | 127 | ||
| 128 | 128 | 5.选定代码后批量更改里面的单词 先选中一行代码,然后点击编辑器左边显示行号左边的那支笔,看看图哦。 | |
| 129 | 129 | ||
| 130 | 130 | 这个时候你可以输入b,变量a就全部改为b,还可以按下tab跳到下一个单词。 | |
| 131 | 131 | ||
| 132 | 132 | 6.编辑器的高亮 | |
| 133 | 133 | ||
| 134 | 134 | `<?xml version="1.0"?>`\ | |
| 135 | 135 | `<CONFIG>`\ | |
| 136 | 136 | ` <EditorOptions Version="9">`\ | |
| 137 | 137 | ` <Display DoNotWarnForFont="Ubuntu Mono" EditorFont="Ubuntu Mono" EditorFontSize="13">`\ | |
| 138 | 138 | ` <MarkupCurrentWord NoKeyword="False"/>`\ | |
| 139 | 139 | ` </Display>`\ | |
| 140 | 140 | ` <KeyMapping>`\ | |
| 141 | 141 | ` <default Count="1">`\ | |
| 142 | 142 | ` <Version Value="6"/>`\ | |
| 143 | 143 | ` <Item1 Name="Identifier completion">`\ | |
| 144 | 144 | ` <KeyA Default="False" Key1="32" Shift1="5"/>`\ | |
| 145 | 145 | ` </Item1>`\ | |
| 146 | 146 | ` </default>`\ | |
| 147 | 147 | ` </KeyMapping>`\ | |
| 148 | 148 | ` <CodeTools CodeTemplateFileName="/home/lht/.lazarus/lazarus.dci" CompletionLongLineHintTypeCompletionLongLineHintType="sclpExtendRightOnly" AutoDelayInMSec="104"/>`\ | |
| 149 | 149 | ` <Mouse>`\ | |
| 150 | 150 | ` <Default Version="1"/>`\ | |
| 151 | 151 | ` </Mouse>`\ | |
| 152 | 152 | ` <Color Version="9">`\ | |
| 153 | 153 | ` <LangObjectPascal Version="9">`\ | |
| 154 | 154 | ` <ColorScheme Value="Twilight"/>`\ | |
| 155 | 155 | ` <SchemeTwilight>`\ | |
| 156 | 156 | ` <Space Background="1973790" FrameColor="5000268" FrameStyle="slsDotted" FrameEdges="sfeBottom"/>`\ | |
| 157 | 157 | ` <Number Foreground="7434751"/>`\ | |
| 158 | 158 | ` <String Foreground="7337839"/>`\ | |
| 159 | 159 | ` <Symbol Foreground="clYellow"/>`\ | |
| 160 | 160 | ` <Comment Foreground="clSkyBlue" Style="fsItalic"/>`\ | |
| 161 | 161 | ` <Assembler Foreground="11715098"/>`\ | |
| 162 | 162 | ` <Directive Foreground="22015"/>`\ | |
| 163 | 163 | ` <Case_label Foreground="16541892"/>`\ | |
| 164 | 164 | ` <IDE_Directive Foreground="1478752"/>`\ | |
| 165 | 165 | ` <Reserved_word Foreground="1023473"/>`\ | |
| 166 | 166 | ` </SchemeTwilight>`\ | |
| 167 | 167 | ` </LangObjectPascal>`\ | |
| 168 | 168 | ` <Globals Version="9">`\ | |
| 169 | 169 | ` <SchemeTwilight>`\ | |
| 170 | 170 | ` <ahaDefault Background="1973790"/>`\ | |
| 171 | 171 | ` </SchemeTwilight>`\ | |
| 172 | 172 | ` </Globals>`\ | |
| 173 | 173 | ` <LangPython Version="9">`\ | |
| 174 | 174 | ` <SchemeTwilight>`\ | |
| 175 | 175 | ` <Float Foreground="8345087"/>`\ | |
| 176 | 176 | ` <Octal Foreground="16755455"/>`\ | |
| 177 | 177 | ` <Number Foreground="8345087"/>`\ | |
| 178 | 178 | ` <String Foreground="8388522"/>`\ | |
| 179 | 179 | ` <Symbol Foreground="clYellow"/>`\ | |
| 180 | 180 | ` <Comment Foreground="clSkyBlue"/>`\ | |
| 181 | 181 | ` <Hexadecimal Foreground="8345087"/>`\ | |
| 182 | 182 | ` <SyntaxError Foreground="16755285"/>`\ | |
| 183 | 183 | ` <Documentation Foreground="16755370"/>`\ | |
| 184 | 184 | ` <Reserved_word Foreground="43775"/>`\ | |
| 185 | 185 | ` <Non_reserved_keyword Foreground="8366847"/>`\ | |
| 186 | 186 | ` </SchemeTwilight>`\ | |
| 187 | 187 | ` </LangPython>`\ | |
| 188 | 188 | ` </Color>`\ | |
| 189 | 189 | ` <Misc PasExtendedKeywordsMode="True"/>`\ | |
| 190 | 190 | ` <General>`\ | |
| 191 | 191 | ` <Editor TabIndent="True" TabWidth="2"/>`\ | |
| 192 | 192 | ` </General>`\ | |
| 193 | 193 | ` <DividerDraw>`\ | |
| 194 | 194 | ` <LangObjectPascal>`\ | |
| 195 | 195 | ` <TypeSect>`\ | |
| 196 | 196 | ` <TopColor Value="9157119"/>`\ | |
| 197 | 197 | ` </TypeSect>`\ | |
| 198 | 198 | ` <TypeGVar>`\ | |
| 199 | 199 | ` <TopColor Value="9157119"/>`\ | |
| 200 | 200 | ` </TypeGVar>`\ | |
| 201 | 201 | ` <TypeGStruct>`\ | |
| 202 | 202 | ` <TopColor Value="9157119"/>`\ | |
| 203 | 203 | ` </TypeGStruct>`\ | |
| 204 | 204 | ` <TypeProc>`\ | |
| 205 | 205 | ` <TopColor Value="9157119"/>`\ | |
| 206 | 206 | ` </TypeProc>`\ | |
| 207 | 207 | ` <TypeLStruct>`\ | |
| 208 | 208 | ` <MaxDepth Value="1"/>`\ | |
| 209 | 209 | ` <TopColor Value="9157119"/>`\ | |
| 210 | 210 | ` </TypeLStruct>`\ | |
| 211 | 211 | ` </LangObjectPascal>`\ | |
| 212 | 212 | ` </DividerDraw>`\ | |
| 213 | 213 | ` </EditorOptions>`\ | |
| 214 | 214 | `</CONFIG>` | |
| 215 | 215 | ||
| 216 | 216 | ## IDE窗口 | |
| 217 | 217 | ||
| 218 | 218 | 当你第一次运行Lazarus时,一系列独立的浮动窗口将出现在你的桌面上。 | |
| 219 | 219 | ||
| 220 | 220 | 首先,在桌面顶部有一个窗口,标题是**Lazarus vxxxx - project**。这是你工程的主要控制窗口,包括主菜单和组件面板。 | |
| 221 | 221 | ||
| 222 | - | ||
| 223 | - | ||
| 224 | - | ||
| 225 | - | ||
| 226 | - | ||
| 227 | - | ||
| 228 | - | ||
| 229 | - | ||
| 222 | + |  | |
| 230 | 223 | ||
| 231 | 224 | 标题栏下面是包括"文件""编辑""查找"等常见项目(以及Lazarus特有的一些项目)的主菜单。 | |
| 232 | 225 | ||
| 233 | 226 | 主菜单下面,组件面板的左侧是一组按钮,包括了主菜单中的常用项目,例如新建文件,保存等等。 | |
| 234 | 227 | ||
| 235 | 228 | 在这个窗口下面,左边是**对象查看器** | |
| 236 | 229 | ||
| 237 | - | ||
| 238 | - | ||
| 239 | - | ||
| 240 | - | ||
| 241 | - | ||
| 242 | - | ||
| 243 | - | ||
| 244 | - | ||
| 230 | + |  | |
| 245 | 231 | ||
| 246 | 232 | 右边是**源代码编辑器** | |
| 247 | 233 | ||
| 248 | - | ||
| 249 | - | ||
| 250 | - | ||
| 251 | - | ||
| 252 | - | ||
| 253 | - | ||
| 254 | - | ||
| 255 | - | ||
| 234 | + |  | |
| 256 | 235 | ||
| 257 | 236 | 也许会有一个小窗口覆盖在源代码编辑器上,是Lazarus预置的一个Form1窗体 | |
| 258 | 237 | ||
| 259 | - | ||
| 260 | - | ||
| 261 | - | ||
| 262 | - | ||
| 263 | - | ||
| 264 | - | ||
| 265 | - | ||
| 266 | - | ||
| 238 | + |  | |
| 267 | 239 | ||
| 268 | 240 | 如果你没有看见它,可以按下F12在源代码编辑器和窗体预览间来回切换。 | |
| 269 | 241 | ||
| 270 | 242 | 窗体预览展示了应用程序的图形界面,源代码编辑器则显示了应用程序所关联的Pascal代码。对象观察器则展示了组件的更多细节。 | |
| 271 | 243 | ||
| 272 | 244 | 当你创建一个新工程时(或者第一次运行Lazarus时),一个默认的窗体将被创建。这个窗体包含了一个带有刻度标尺(帮助你定位放置到窗体上的组件)的区域,以及包含常见的"最小化""最大化""关闭窗口"按钮的顶部标签。用鼠标点击这个窗体,左侧的对象观察器将显示这个窗体的属性。 | |
| 273 | 245 | ||
| 274 | 246 | 在你工作的时候,其他一些窗口也会出现: | |
| 275 | 247 | ||
| 276 | 248 | 包含你工程的一些细节,并且允许你从工程中添加或删除文件的**工程查看器**窗口 | |
| 277 | 249 | ||
| 278 | - | ||
| 279 | - | ||
| 280 | - | ||
| 281 | - | ||
| 282 | - | ||
| 283 | - | ||
| 284 | - | ||
| 285 | - | ||
| 250 | + |  | |
| 286 | 251 | ||
| 287 | 252 | 以及显示编译信息,错误以及运行报告的**信息**窗口 | |
| 288 | 253 | ||
| 289 | - | ||
| 290 | - | ||
| 291 | - | ||
| 292 | - | ||
| 293 | - | ||
| 294 | - | ||
| 295 | - | ||
| 296 | - | ||
| 254 | + |  | |
| 297 | 255 | ||
| 298 | 256 | 如果你从一个终端窗口中运行Lazarus,那么这个原始的终端窗口将被保留,编译信息也会显示在这个终端窗口中。 | |
| 299 | 257 | ||
| 300 | 258 | ## 主菜单 | |
| 301 | 259 | ||
| 302 | 260 | 主菜单内容仔细的说明在这里:[[Main menu/zh CN]] | |
| 303 | 261 | ||
| 304 | 262 | ## IDE选项 | |
| 305 | 263 | ||
| 306 | 264 | 在Lazarus 1.0.14版中,通过"工具"-\>"选项",可以打开IDE设置窗口。 在这里你可以对环境、编译器、JCF格式设置、代码工具、代码管理器、调试器、帮助等信息配置。 | |
| 307 | 265 | ||
| 308 | - | ||
| 309 | - | ||
| 310 | - | ||
| 311 | - | ||
| 266 | + |  | |
| 312 | 267 | ||
| 313 | 268 | - **环境** | |
| 314 | 269 | - **文件**:最大记录工程数、文件数及设置Lazarus目录、编译器路径、FPC源代码目录、Make文件目录等等。 | |
| 315 | 270 | - **桌面**:设置IDE语言、自动保存信息等等。 | |
| 316 | 271 | - **窗口**:可对窗口位置、终端输出进行相应设置。 | |
| 317 | 272 | - **窗体编辑器**:对颜色、风格等设置。 | |
| 318 | 273 | - **对象查看器**:对颜色、速度等设置。 | |
| 319 | 274 | - **备份**:工程文件备份设置,其他文件备份设置。 | |
| 320 | 275 | - **命名**:对Pascal后缀、可疑文件动作、自动重命名Pascal文件为小写、单元被重命名,更新引用等等配置。 | |
| 321 | 276 | - **FPDoc编辑器**:配置FPDoc。 | |
| 322 | 277 | - **文件筛选**:对单元、工程、窗体、包、其他文件设置筛选器。 | |
| 323 | 278 | ||
| 324 | 279 | - **编辑器** | |
| 325 | 280 | - **普通**:允许设置撤销/重做次数、滚动方式、缩进与制表符、光标等设置。 | |
| 326 | 281 | - **显示**:设置边界和边缝及默认编辑器字体。 | |
| 327 | 282 | - **键盘映射**:快捷键设置。 | |
| 328 | 283 | - **鼠标**:对鼠标操作进行相应设置。 | |
| 329 | 284 | - **自动化功能**:对自动补充信息进行设置。 | |
| 330 | 285 | - **代码折叠**:对代码折叠相关进行配置。 | |
| 331 | 286 | - **隔离区绘制**:代码块间线条设置。 | |
| 332 | 287 | - **页和Windows**:暂无。 | |
| 333 | 288 | ||
| 334 | 289 | - **JCF格式设置** | |
| 335 | 290 | - **文件格式**:暂无。 | |
| 336 | 291 | - **obfuscate**:暂无。 | |
| 337 | 292 | - **clarify**:暂无。 | |
| 338 | 293 | - **preprocessor**:暂无。 | |
| 339 | 294 | ||
| 340 | 295 | - **代码工具** | |
| 341 | 296 | - **普通**:方法跳转、工程附加源文件路径等设置、pascal源文件缩进设置。 | |
| 342 | 297 | - **类完成**:类、方法部分插入方式及属性自动完成配置。 | |
| 343 | 298 | - **创建代码**:插入过程策略、新单元添加到uses部分等配置。 | |
| 344 | 299 | - **单词**:设置关键字策略、标识符规则及例外等。 | |
| 345 | 300 | - **分割行**:可设置最大行宽、不拆分前面、后面行的条件。 | |
| 346 | 301 | - **空格**:空格插入方式,在关键字、标识符等前或后插入空格。 | |
| 347 | 302 | - **标识符自动完成**:设置标识符自动完成条件,如添加分号时。 | |
| 348 | 303 | ||
| 349 | 304 | - **代码管理器** | |
| 350 | 305 | - **更新**:设置优先表现模式(分类、源代码),自动刷新条件及跟随光标。 | |
| 351 | 306 | - **种类**:设置只在类模式中使用变量、常量、引入、定义等。 | |
| 352 | 307 | - **代码观察器**:对代码观察器进行一些配置。 | |
| 353 | 308 | ||
| 354 | 309 | - **调试器** | |
| 355 | 310 | - **普通**:可设置调试器类型和路径调试器特殊选项等。 | |
| 356 | 311 | - **事件日志**:对消息窗口进行设置,如错误时显示的颜色等。 | |
| 357 | 312 | - **语言异常**:设置忽略哪些异常,如 中止、代码工具错误、Fopen错误。并允许添加忽略。 | |
| 358 | 313 | - **操作系统异常**:设置操作系统异常处理方式。 | |
| 359 | 314 | ||
| 360 | 315 | - **帮助** | |
| 361 | 316 | - **帮助选项**:设置FPC HTML文件路径、默认查看器等。 | |
| 362 | 317 | - **外部**:对外部程序进行配置,如Windows、PostgreSQL、Gtk2配置名称、单元文件及位置。并允许添加外部程序。 | |
| 363 | 318 | ||
| 364 | 319 | ## 按钮栏 | |
| 365 | 320 | ||
| 366 | - | ||
| 367 | - | ||
| 368 | - | ||
| 369 | - | ||
| 370 | - | ||
| 371 | - | ||
| 372 | - | ||
| 373 | - | ||
| 321 | + |  | |
| 374 | 322 | ||
| 375 | 323 | 在主编辑器窗口左侧小工具栏位置,(主菜单下方与左侧组件面板中),包含一组按钮: | |
| 376 | 324 | ||
| 377 | 325 | “新建单元”、“新建窗体”、“打开”、“保存”、“保存所有”、“新窗体”、“切换窗体/单元”、 | |
| 378 | 326 | ||
| 379 | 327 | “查看单元”、“查看窗体”、“运行”、“暂停”、“步进”、“下一步”、“运行,直到函数返回”。 | |
| 380 | 328 | ||
| 381 | 329 | ## 组件面板 | |
| 382 | 330 | ||
| 383 | 331 | 标签式工具栏里显示常用组件图标。 | |
| 384 | 332 | ||
| 385 | 333 | 每个选项卡使用一组不同的图标显示,选项卡组最左边的第一个图片(指向箭头),称为选择工具。 | |
| 386 | 334 | ||
| 387 | 335 | 如果你将鼠标悬停在组件面板中的图标上,将会显示该组件的提示信息。T意味着,Type类型,或者是Class组件。在窗体中,使用组件时,类将会添加到类型和接口处(通常作为TForm1一部分)。实例化处,添加到VAR部分(通常作为Form1变量)。任何方法,设计时要使用窗体或组件(程序或函数),将被放置在implementation部分。如果你要找出某一特定组件的属性,可以看组件的继承,之后检查其派生的基类型的属性。例如,你要了解TMaskEdit,可以查看TcustomMaskEdit。 | |
| 388 | 336 | ||
| 389 | 337 | **选项卡**(通过名称可以了解的其包含了哪些组件): | |
| 390 | 338 | ||
| 391 | 339 | - **[标准组件](http://lazarus-ccr.sourceforge.net/index.php?wiki=StdCtrls)** | |
| 392 | 340 | ||
| 393 | - | ||
| 394 | - | ||
| 395 | - | ||
| 396 | - | ||
| 397 | - | ||
| 398 | - | ||
| 399 | - | ||
| 400 | - | ||
| 341 | + |  | |
| 401 | 342 | ||
| 402 | 343 | ||
| 403 | 344 | *通常使用的组件:* [TMainMenu](http://lazarus-ccr.sourceforge.net/docs/lcl/menus/tmainmenu.html), [TPopupMenu](http://lazarus-ccr.sourceforge.net/docs/lcl/menus/tpopupmenu.html), [TButton](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tbutton.html), [TLabel](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tlabel.html), [TEdit](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tedit.html), [TMemo](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tmemo.html), [TToggleBox](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/ttogglebox.html), [TCheckBox](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tcheckbox.html), [TRadioButton](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tradiobutton.html), [TListBox](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tlistbox.html), [TComboBox](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tcombobox.html), [TScrollBar](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tscrollbar.html), [TGroupBox](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tgroupbox.html), [TStaticText](http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tstatictext.html), [TRadioGroup](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tradiogroup.html), [TCheckGroup](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tcheckgroup.html), [TPanel](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tpanel.html), [TActionList](http://lazarus-ccr.sourceforge.net/docs/lcl/actnlist/tactionlist.html) | |
| 404 | 345 | ||
| 405 | 346 | - **[更多组件](http://lazarus-ccr.sourceforge.net/index.php?wiki=ExtCtrls)** | |
| 406 | 347 | ||
| 407 | - | ||
| 408 | - | ||
| 409 | - | ||
| 410 | - | ||
| 411 | - | ||
| 412 | - | ||
| 413 | - | ||
| 414 | - | ||
| 348 | + |  | |
| 415 | 349 | ||
| 416 | 350 | ||
| 417 | 351 | *更多经常使用的组件:* [TBitBtn](http://lazarus-ccr.sourceforge.net/docs/lcl/buttons/tbitbtn.html), [TSpeedButton](http://lazarus-ccr.sourceforge.net/docs/lcl/buttons/tspeedbutton.html), [TImage](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/timage.html), [TShape](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tshape.html), [TBevel](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tbevel.html), [TPaintBox](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tpaintbox.html), [TNotebook](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tnotebook.html), [TLabeledEdit](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tlabelededit.html), [TSplitter](http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tsplitter.html), [TMaskEdit](http://lazarus-ccr.sourceforge.net/docs/lcl/maskedit/tmaskedit.html), [TCheckListBox](http://lazarus-ccr.sourceforge.net/docs/lcl/checklst/tchecklistbox.html), [TScrollBox](http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tscrollbox.html), [TApplicationProperties](http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tapplicationproperties.html), [TStringGrid](http://lazarus-ccr.sourceforge.net/docs/lcl/grids/tstringgrid.html), [TDrawGrid](http://lazarus-ccr.sourceforge.net/docs/lcl/grids/tdrawgrid.html), [TPairSplitter](http://lazarus-ccr.sourceforge.net/docs/lcl/pairsplitter/tpairsplitter.html) | |
| 418 | 352 | ||
| 419 | 353 | - **[公共组件](http://lazarus-ccr.sourceforge.net/index.php?wiki=ComCtrls)** | |
| 420 | 354 | ||
| 421 | - | ||
| 422 | - | ||
| 423 | - | ||
| 424 | - | ||
| 425 | - | ||
| 426 | - | ||
| 427 | - | ||
| 428 | - | ||
| 355 | + |  | |
| 429 | 356 | ||
| 430 | 357 | ||
| 431 | 358 | TTrackBar, TProgressBar, TTreeView, TListView, TStatusBar, TToolBar, TUpDown, TPageControl, TImageList | |
| 432 | 359 | ||
| 433 | 360 | - **[对话框组件](http://lazarus-ccr.sourceforge.net/index.php?wiki=DialogsTxt)** | |
| 434 | 361 | ||
| 435 | - | ||
| 436 | - | ||
| 437 | - | ||
| 438 | - | ||
| 439 | - | ||
| 440 | - | ||
| 441 | - | ||
| 442 | - | ||
| 362 | + |  | |
| 443 | 363 | ||
| 444 | 364 | ||
| 445 | 365 | TOpenDialog, TSaveDialog, TSelectDirectoryDialog, TColorDialog, TFontDialog, TOpenPictureDialog, TSavePictureDialog, TCalendarDialog, TCalculatorDialog | |
| 446 | 366 | ||
| 447 | 367 | 有几个有用的**[对话框](http://lazarus-ccr.sourceforge.net/index.php?wiki=DialogExamples)**,它不在组件面板中显示,但在你可在过程函数中直接调用。 | |
| 448 | 368 | ||
| 449 | 369 | 有关组件使用的例子,请参看\$LazarusPath/lazarus/examples目录。许多程序不使用IDE组件而直接使用对话框或其他组件的调色板,或者有一个单独的窗体定义文件:所有组件中,在Pascal主程序部分定义使用。 | |
| 450 | 370 | ||
| 451 | 371 | 一些示例,不马上使用的:你可能需要调整路径和文件(目录)的执行权限。如果你想直接编译示例,请确保对文件(目录)具有读取/写入/执行权限。 | |
| 452 | 372 | ||
| 453 | 373 | 请尝试运行**testall程序**,以查看可用组件和示例菜单,大多数的测试,可以确定你的环境是否能够正常使用这些组件! | |
| 454 | 374 | ||
| 455 | 375 | - **杂项组件** | |
| 456 | 376 | ||
| 457 | - | ||
| 458 | - | ||
| 459 | - | ||
| 460 | - | ||
| 461 | - | ||
| 462 | - | ||
| 463 | - | ||
| 464 | - | ||
| 377 | + |  | |
| 465 | 378 | ||
| 466 | 379 | ||
| 467 | 380 | [TColorButton](http://lazarus-ccr.sourceforge.net/index.php?wiki=DialogsTxt), TSpinEdit, TArrow, TCalendar, TEditButton, TFileNameEdit, TDirectoryEdit, TDateEdit, TCalcEdit, TFileListBox | |
| 468 | 381 | ||
| 469 | 382 | - **数据组件** | |
| 470 | 383 | ||
| 471 | - | ||
| 472 | - | ||
| 473 | - | ||
| 474 | - | ||
| 475 | - | ||
| 476 | - | ||
| 477 | - | ||
| 478 | - | ||
| 384 | + |  | |
| 479 | 385 | ||
| 480 | 386 | ||
| 481 | 387 | *数据组件,通常用于数据库:* TDBNavigation, TDBText, TDBEdit, TDBMemo, TDBImage, TDBListBox,TDBComboBox, TDBCheckBox, TDBRadioGroup, TDBCalendar, TDBGroupBox, TdbGrid | |
| 482 | 388 | ||
| 483 | 389 | - **数据访问组件** | |
| 484 | 390 | ||
| 485 | - | ||
| 486 | - | ||
| 487 | - | ||
| 488 | - | ||
| 489 | - | ||
| 490 | - | ||
| 491 | - | ||
| 492 | - | ||
| 391 | + |  | |
| 493 | 392 | ||
| 494 | 393 | ||
| 495 | 394 | TDatasource | |
| 496 | 395 | ||
| 497 | 396 | - **系统组件** | |
| 498 | 397 | ||
| 499 | - | ||
| 500 | - | ||
| 501 | - | ||
| 502 | - | ||
| 503 | - | ||
| 504 | - | ||
| 505 | - | ||
| 506 | - | ||
| 398 | + |  | |
| 507 | 399 | ||
| 508 | 400 | ||
| 509 | 401 | [TTimer](http://lazarus-ccr.sourceforge.net/index.php?wiki=ExtCtrls#TTimer), TIdleTimer, [[doc:fcl/process/tprocess.html|TProcess]] | |
| 510 | 402 | ||
| 511 | 403 | - **SynEdit(~~编辑器组件~~)** | |
| 512 | 404 | ||
| 513 | - | ||
| 514 | - | ||
| 515 | - | ||
| 516 | - | ||
| 517 | - | ||
| 518 | - | ||
| 519 | - | ||
| 520 | - | ||
| 405 | + |  | |
| 521 | 406 | ||
| 522 | 407 | ||
| 523 | 408 | *SynEdit是一个高级的文本编辑器控制,对Borland的Delphi,Kylix、C++Builder等支持语法高亮和代码自动完成,并支持输出为HTML、Tex和RTF。这是一个VCL/CLX控件,意味着,适用于Microsoft的Windows,没有信赖的运行库,SynEdit作为跨平台组件,也是Lazarus IDE中的编辑器组件。* 查看 [sourceforge上的synedit](http://synedit.sourceforge.net). TSynEdit, TSynAutoComplete, TSynExporterHTML, TSynMacroRecorder, TSynMemo, TSynPasSyn, TSynCppSyn, TSynJavaSyn, TSynPerlSyn, TSynHTMLSyn, TSynXMLSyn, TSynLFMSyn, TSynUNIXShellScriptSyn, TSynCssSyn, TSynPHPSyn, TSynTeXSyn, TSynSQLSyn, TSynMultiSyn | |
| 524 | 409 | ||
| 525 | 410 | 要使用调色板,必须存在窗体(如果没有,选择文件-\>新建窗体)。单击调色板中需要使用的控件,在窗体上单击,这时候,窗体上,将显示出来调色板组件;你可以调整它到合适的位置,通过属性可以显示外观。 | |
| 526 | 411 | ||
| 527 | 412 | 如果你想安装额外的组件,无论是你自己编写的,还是第三方的;完成后,将在组件面板中显示出来。 | |
| 528 | 413 | ||
| 529 | 414 | ## 如何使用通用控件 | |
| 530 | 415 | ||
| 531 | 416 | **StdCtrls**、**ComCtrls**和**ExtCtrls**包含了常用控件的构建形式及Lazarus应用程序中常用对象。 | |
| 532 | 417 | ||
| 533 | - | ||
| 418 | + | 许多控件应用程序开发人员都要使用,如**TButton**、**TMemo**、**TScrollBar**等等。声明的控件都继承自父类。 | |
| 534 | 419 | ||
| 535 | 420 | 使用这些控件时,你可以选择相应控件,在窗体上拖放就可以了。也可以使用代码创建,但是,在你不需要时,你需要销毁它。 | |
| 536 | 421 | ||
| 537 | 422 | #### 设置属性 | |
| 538 | 423 | ||
| 539 | 424 | 在窗体设计器上放置控件后,在对象检查器中,你可以设置控件属性或编写相应事件代码。 | |
| 540 | 425 | ||
| 541 | 426 | 如,你在窗体上放置了一个按钮(TButton),选择它,并移动它以改变位置,你会可以看到它的top和left值的变化。在对象观察器中Height、Width值分别代表其大小高度和宽度。 | |
| 542 | 427 | ||
| 543 | 428 | 此外,你可以使用代码来改变对象属性: | |
| 544 | 429 | ||
| 545 | 430 | `Form1.Button1.Height := 48;` | |
| 546 | 431 | ||
| 547 | 432 | 在FormCreate过程中书写上面的代码,程序运行时,将看到效果。 | |
| 548 | 433 | ||
| 549 | 434 | 总之,有三种方法,可以设置对象的属性: | |
| 550 | 435 | ||
| 551 | 436 | - 通过鼠标在窗体上调整 | |
| 552 | 437 | - 通过设置对象观察器中的值 | |
| 553 | 438 | - 通过代码来设置属性 | |
| 554 | 439 | ||
| 555 | 440 | #### 公共属性 | |
| 556 | 441 | ||
| 557 | 442 | 每个组件(控件)都有不同的属性,有某些是相同的,常见的,下面这介绍这些常用属性: | |
| 558 | 443 | ||
| 559 | - | ||
| 444 | + | 通过选择属性或关键字,在对象观察器或源代码编辑器中按`F1`来获得帮助。 | |
| 560 | 445 | ||
| 561 | 446 | 如果该页面上的属性描述不够,您可以通过选择继承列表中的链接或在对象声明中选择祖先类型来导航到相应的祖先类别描述。 | |
| 562 | 447 | ||
| 563 | - | ||
| 564 | - | ||
| 565 | - | ||
| 566 | - | ||
| 567 | - | ||
| 568 | - | ||
| 569 | - | ||
| 570 | - | ||
| 571 | - | ||
| 572 | - | ||
| 573 | - | ||
| 574 | - | ||
| 575 | - | ||
| 576 | - | ||
| 577 | - | ||
| 578 | - | ||
| 579 | - | ||
| 580 | - | ||
| 581 | - | ||
| 582 | - | ||
| 583 | - | ||
| 584 | - | ||
| 585 | - | ||
| 586 | - | ||
| 587 | - | ||
| 588 | - | ||
| 589 | - | ||
| 448 | + | 常用属性 | |
| 590 | 449 | ||
| 591 | - | ||
| 450 | + | 属性 | |
| 592 | 451 | ||
| 593 | - | ||
| 452 | + | 说明 | |
| 594 | 453 | ||
| 595 | - | ||
| 454 | + | 介绍 | |
| 596 | 455 | ||
| 597 | 456 | Action | |
| 598 | 457 | ||
| 599 | - | ||
| 600 | - | ||
| 601 | - | ||
| 602 | - | ||
| 603 | 458 | 行动 | |
| 604 | 459 | ||
| 605 | - | ||
| 606 | - | ||
| 607 | - | ||
| 608 | - | ||
| 609 | 460 | 与对象关联的主要动作或事件。如,在选择“退出”时,会导致“关闭”。 | |
| 610 | 461 | ||
| 611 | - | ||
| 612 | - | ||
| 613 | - | ||
| 614 | - | ||
| 615 | - | ||
| 616 | - | ||
| 617 | - | ||
| 618 | - | ||
| 619 | 462 | Align | |
| 620 | 463 | ||
| 621 | - | ||
| 622 | - | ||
| 623 | - | ||
| 624 | - | ||
| 625 | 464 | 对齐 | |
| 626 | 465 | ||
| 627 | - | ||
| 628 | - | ||
| 629 | - | ||
| 630 | - | ||
| 631 | 466 | 定义与父对象对齐方式。alTop:顶对齐;alBottom:底对齐;alLeft、alRight:左对齐和右对齐;alNone:无;alClient:占用父对象所有空间。 | |
| 632 | 467 | ||
| 633 | - | ||
| 634 | - | ||
| 635 | - | ||
| 636 | - | ||
| 637 | - | ||
| 638 | - | ||
| 639 | - | ||
| 640 | - | ||
| 641 | 468 | Anchor | |
| 642 | 469 | ||
| 643 | - | ||
| 644 | - | ||
| 645 | - | ||
| 646 | - | ||
| 647 | 470 | 锚 | |
| 648 | 471 | ||
| 649 | - | ||
| 650 | - | ||
| 651 | - | ||
| 652 | - | ||
| 653 | - | ||
| 654 | - | ||
| 655 | - | ||
| 656 | - | ||
| 657 | - | ||
| 658 | - | ||
| 659 | - | ||
| 660 | - | ||
| 661 | - | ||
| 472 | + | 用于保持控件的父控件;当父控件调试大小将调整与其距离。\[akBottom,akRight\]将保持固定在父控制右下角距离。 | |
| 662 | 473 | ||
| 663 | 474 | AutoSelect | |
| 664 | 475 | ||
| 665 | - | ||
| 666 | - | ||
| 667 | - | ||
| 668 | - | ||
| 669 | 476 | 自动选择 | |
| 670 | 477 | ||
| 671 | - | ||
| 672 | - | ||
| 673 | - | ||
| 674 | - | ||
| 675 | - | ||
| 676 | - | ||
| 677 | - | ||
| 678 | - | ||
| 679 | - | ||
| 680 | - | ||
| 681 | - | ||
| 682 | - | ||
| 683 | - | ||
| 478 | + | 为True时,控件在获取到焦点,或当按下`Enter`键时选择所有文本。 | |
| 684 | 479 | ||
| 685 | 480 | AutoSelected | |
| 686 | 481 | ||
| 687 | - | ||
| 688 | - | ||
| 689 | - | ||
| 690 | - | ||
| 691 | 482 | 自动选中 | |
| 692 | 483 | ||
| 693 | - | ||
| 694 | - | ||
| 695 | - | ||
| 696 | - | ||
| 697 | 484 | True表示编辑框或组合框控件刚刚执行了“自动选择”操作,因此随后的鼠标点击和按键操作将正常进行而不会选中文本。 | |
| 698 | 485 | ||
| 699 | - | ||
| 700 | - | ||
| 701 | - | ||
| 702 | - | ||
| 703 | - | ||
| 704 | - | ||
| 705 | - | ||
| 706 | - | ||
| 707 | 486 | BorderSpacing | |
| 708 | 487 | ||
| 709 | - | ||
| 710 | - | ||
| 711 | - | ||
| 712 | - | ||
| 713 | 488 | 边框间距 | |
| 714 | 489 | ||
| 715 | - | ||
| 716 | - | ||
| 717 | - | ||
| 718 | - | ||
| 719 | 490 | **锚定**控件与其父级之间的边缘空间。 | |
| 720 | 491 | ||
| 721 | - | ||
| 722 | - | ||
| 723 | - | ||
| 724 | - | ||
| 725 | - | ||
| 726 | - | ||
| 727 | - | ||
| 728 | - | ||
| 729 | 492 | Caption | |
| 730 | 493 | ||
| 731 | - | ||
| 732 | - | ||
| 733 | - | ||
| 734 | - | ||
| 735 | 494 | 标题 | |
| 736 | 495 | ||
| 737 | - | ||
| 738 | - | ||
| 739 | - | ||
| 740 | - | ||
| 741 | 496 | 设置显示内容,如按钮标题为“关闭”或“执行”。默认情况下,标题名称与Name属性值相同。 | |
| 742 | 497 | ||
| 743 | - | ||
| 744 | - | ||
| 745 | - | ||
| 746 | - | ||
| 747 | - | ||
| 748 | - | ||
| 749 | - | ||
| 750 | - | ||
| 751 | 498 | CharCase | |
| 752 | 499 | ||
| 753 | - | ||
| 754 | - | ||
| 755 | - | ||
| 756 | - | ||
| 757 | 500 | 字符显示 | |
| 758 | 501 | ||
| 759 | - | ||
| 760 | - | ||
| 761 | - | ||
| 762 | - | ||
| 763 | 502 | 设置字母在编辑控件中显示方式:Normal:正常(不改变字母大小写);ecLowerCase:转换为小写;ecUppercase:转换为大写。 | |
| 764 | 503 | ||
| 765 | - | ||
| 766 | - | ||
| 767 | - | ||
| 768 | - | ||
| 769 | - | ||
| 770 | - | ||
| 771 | - | ||
| 772 | - | ||
| 773 | 504 | Constraints | |
| 774 | 505 | ||
| 775 | - | ||
| 776 | - | ||
| 777 | - | ||
| 778 | - | ||
| 779 | 506 | 限制 | |
| 780 | 507 | ||
| 781 | - | ||
| 782 | - | ||
| 783 | - | ||
| 784 | - | ||
| 785 | 508 | 设置控件最大、小、高、宽度。如果调整控件大小,新的大小将在此范围内。You should take care when setting these options that they do not conflict with the Anchors and Align settings. | |
| 786 | 509 | ||
| 787 | - | ||
| 788 | - | ||
| 789 | - | ||
| 790 | - | ||
| 791 | - | ||
| 792 | - | ||
| 793 | - | ||
| 794 | - | ||
| 795 | 510 | Color | |
| 796 | 511 | ||
| 797 | - | ||
| 798 | - | ||
| 799 | - | ||
| 800 | - | ||
| 801 | 512 | 颜色 | |
| 802 | 513 | ||
| 803 | - | ||
| 804 | - | ||
| 805 | - | ||
| 806 | - | ||
| 807 | 514 | 设置控件的文本颜色。 | |
| 808 | 515 | ||
| 809 | - | ||
| 810 | - | ||
| 811 | - | ||
| 812 | - | ||
| 813 | - | ||
| 814 | - | ||
| 815 | - | ||
| 816 | - | ||
| 817 | 516 | Enabled | |
| 818 | 517 | ||
| 819 | - | ||
| 820 | - | ||
| 821 | - | ||
| 822 | - | ||
| 823 | 518 | 启用 | |
| 824 | 519 | ||
| 825 | - | ||
| 826 | - | ||
| 827 | - | ||
| 828 | - | ||
| 829 | - | ||
| 830 | - | ||
| 831 | - | ||
| 832 | - | ||
| 833 | - | ||
| 834 | - | ||
| 835 | - | ||
| 836 | - | ||
| 837 | - | ||
| 520 | + | 设置控制是否可用,如果为False,在窗体上显示为灰色。 | |
| 838 | 521 | ||
| 839 | 522 | Font | |
| 840 | 523 | ||
| 841 | - | ||
| 842 | - | ||
| 843 | - | ||
| 844 | - | ||
| 845 | 524 | 字体 | |
| 846 | 525 | ||
| 847 | - | ||
| 848 | - | ||
| 849 | - | ||
| 850 | - | ||
| 851 | 526 | 设置对象的字体信息,通常(+)号展开详细,如字体、字号、颜色等。 | |
| 852 | 527 | ||
| 853 | - | ||
| 854 | - | ||
| 855 | - | ||
| 856 | - | ||
| 857 | - | ||
| 858 | - | ||
| 859 | - | ||
| 860 | - | ||
| 861 | 528 | Hint | |
| 862 | 529 | ||
| 863 | - | ||
| 864 | - | ||
| 865 | - | ||
| 866 | - | ||
| 867 | 530 | 提示 | |
| 868 | 531 | ||
| 869 | - | ||
| 870 | - | ||
| 871 | - | ||
| 872 | - | ||
| 873 | 532 | 鼠标悬停在控件上时,弹出的提示信息。请注意ShowHint属性为True时才显示。 | |
| 874 | 533 | ||
| 875 | - | ||
| 876 | - | ||
| 877 | - | ||
| 878 | - | ||
| 879 | - | ||
| 880 | - | ||
| 881 | - | ||
| 882 | - | ||
| 883 | 534 | Items | |
| 884 | 535 | ||
| 885 | - | ||
| 886 | - | ||
| 887 | - | ||
| 888 | - | ||
| 889 | 536 | 项目 | |
| 890 | 537 | ||
| 891 | - | ||
| 892 | - | ||
| 893 | - | ||
| 894 | - | ||
| 895 | 538 | 包含的数据信息,如果文本行等。 | |
| 896 | 539 | ||
| 897 | - | ||
| 898 | - | ||
| 899 | - | ||
| 900 | - | ||
| 901 | - | ||
| 902 | - | ||
| 903 | - | ||
| 904 | - | ||
| 905 | 540 | Lines | |
| 906 | 541 | ||
| 907 | - | ||
| 908 | - | ||
| 909 | - | ||
| 910 | - | ||
| 911 | 542 | 列表 | |
| 912 | 543 | ||
| 913 | - | ||
| 914 | - | ||
| 915 | - | ||
| 916 | - | ||
| 917 | 544 | 字符串数组,包含单个数据,数组为索引从0开始,即\[0..numLines-1\]。 | |
| 918 | 545 | ||
| 919 | - | ||
| 920 | - | ||
| 921 | - | ||
| 922 | - | ||
| 923 | - | ||
| 924 | - | ||
| 925 | - | ||
| 926 | - | ||
| 927 | 546 | Name | |
| 928 | 547 | ||
| 929 | - | ||
| 930 | - | ||
| 931 | - | ||
| 932 | - | ||
| 933 | 548 | 名称 | |
| 934 | 549 | ||
| 935 | - | ||
| 936 | - | ||
| 937 | - | ||
| 938 | - | ||
| 939 | 550 | 设置控件的标识符。如TBitButton的实例,为Form1.BitBitton1、Form1.BitButton2等等,程序员应该使用见名真义的名称,如ExitButton(退出按钮)或OKButton(确定按钮)。 | |
| 940 | 551 | ||
| 941 | - | ||
| 942 | - | ||
| 943 | - | ||
| 944 | - | ||
| 945 | - | ||
| 946 | - | ||
| 947 | - | ||
| 948 | - | ||
| 949 | 552 | PopUpMenu | |
| 950 | 553 | ||
| 951 | - | ||
| 952 | - | ||
| 953 | - | ||
| 954 | - | ||
| 955 | 554 | 弹出式菜单 | |
| 956 | 555 | ||
| 957 | - | ||
| 958 | - | ||
| 959 | - | ||
| 960 | - | ||
| 961 | 556 | 设置在控件上右击时,弹出的菜单。 | |
| 962 | 557 | ||
| 963 | - | ||
| 964 | - | ||
| 965 | - | ||
| 966 | - | ||
| 967 | - | ||
| 968 | - | ||
| 969 | - | ||
| 970 | - | ||
| 971 | 558 | Position (or Top, Left) | |
| 972 | 559 | ||
| 973 | - | ||
| 974 | - | ||
| 975 | - | ||
| 976 | - | ||
| 977 | 560 | 位置 | |
| 978 | 561 | ||
| 979 | - | ||
| 980 | - | ||
| 981 | - | ||
| 982 | - | ||
| 983 | 562 | 设置控件位置。 | |
| 984 | 563 | ||
| 985 | - | ||
| 986 | - | ||
| 987 | - | ||
| 988 | - | ||
| 989 | - | ||
| 990 | - | ||
| 991 | - | ||
| 992 | - | ||
| 993 | 564 | ReadOnly | |
| 994 | 565 | ||
| 995 | - | ||
| 996 | - | ||
| 997 | - | ||
| 998 | - | ||
| 999 | 566 | 只读 | |
| 1000 | 567 | ||
| 1001 | - | ||
| 1002 | - | ||
| 1003 | - | ||
| 1004 | - | ||
| 1005 | 568 | 为True时,控件只能被读取,不能被更改。如Edit。 | |
| 1006 | 569 | ||
| 1007 | - | ||
| 1008 | - | ||
| 1009 | - | ||
| 1010 | - | ||
| 1011 | - | ||
| 1012 | - | ||
| 1013 | - | ||
| 1014 | - | ||
| 1015 | 570 | ShowHint | |
| 1016 | 571 | ||
| 1017 | - | ||
| 1018 | - | ||
| 1019 | - | ||
| 1020 | - | ||
| 1021 | 572 | 显示提示 | |
| 1022 | 573 | ||
| 1023 | - | ||
| 1024 | - | ||
| 1025 | - | ||
| 1026 | - | ||
| 1027 | 574 | 设置鼠标'悬停'在控件上时,是否显示提示信息。 | |
| 1028 | 575 | ||
| 1029 | - | ||
| 1030 | - | ||
| 1031 | - | ||
| 1032 | - | ||
| 1033 | - | ||
| 1034 | - | ||
| 1035 | - | ||
| 1036 | - | ||
| 1037 | 576 | Size (or Height and Width) | |
| 1038 | 577 | ||
| 1039 | - | ||
| 1040 | - | ||
| 1041 | - | ||
| 1042 | - | ||
| 1043 | 578 | 大小 | |
| 1044 | 579 | ||
| 1045 | - | ||
| 1046 | - | ||
| 1047 | - | ||
| 1048 | - | ||
| 1049 | 580 | 设置控件尺寸。 | |
| 1050 | 581 | ||
| 1051 | - | ||
| 1052 | - | ||
| 1053 | - | ||
| 1054 | - | ||
| 1055 | - | ||
| 1056 | - | ||
| 1057 | - | ||
| 1058 | - | ||
| 1059 | 582 | Style | |
| 1060 | 583 | ||
| 1061 | - | ||
| 1062 | - | ||
| 1063 | - | ||
| 1064 | - | ||
| 1065 | 584 | 样式 | |
| 1066 | 585 | ||
| 1067 | - | ||
| 1068 | - | ||
| 1069 | - | ||
| 1070 | - | ||
| 1071 | 586 | 样式的选项取决于所考虑的控件类型:例如,样式可以由TFormStyle、TBorderStyle、TButtonStyle等定义。 | |
| 1072 | 587 | ||
| 1073 | - | ||
| 1074 | - | ||
| 1075 | - | ||
| 1076 | - | ||
| 1077 | - | ||
| 1078 | - | ||
| 1079 | - | ||
| 1080 | - | ||
| 1081 | 588 | TabOrder | |
| 1082 | 589 | ||
| 1083 | - | ||
| 1084 | - | ||
| 1085 | - | ||
| 1086 | - | ||
| 1087 | 590 | Tab键顺序 | |
| 1088 | 591 | ||
| 1089 | - | ||
| 1090 | - | ||
| 1091 | - | ||
| 1092 | - | ||
| 1093 | - | ||
| 1094 | - | ||
| 1095 | - | ||
| 1096 | - | ||
| 1097 | - | ||
| 1098 | - | ||
| 1099 | - | ||
| 1100 | - | ||
| 1101 | - | ||
| 592 | + | 输入整数,设置`Tab`的顺序。 | |
| 1102 | 593 | ||
| 1103 | 594 | TabStop | |
| 1104 | 595 | ||
| 1105 | - | ||
| 1106 | - | ||
| 1107 | - | ||
| 1108 | - | ||
| 1109 | 596 | 制表位 | |
| 1110 | 597 | ||
| 1111 | - | ||
| 1112 | - | ||
| 1113 | - | ||
| 1114 | - | ||
| 1115 | - | ||
| 1116 | - | ||
| 1117 | - | ||
| 1118 | - | ||
| 1119 | - | ||
| 1120 | - | ||
| 1121 | - | ||
| 1122 | - | ||
| 1123 | - | ||
| 598 | + | 为False时,`Tab`将无法选中此控件,否则可以。 | |
| 1124 | 599 | ||
| 1125 | 600 | Text | |
| 1126 | 601 | ||
| 1127 | - | ||
| 1128 | - | ||
| 1129 | - | ||
| 1130 | - | ||
| 1131 | 602 | 文本 | |
| 1132 | 603 | ||
| 1133 | - | ||
| 1134 | - | ||
| 1135 | - | ||
| 1136 | - | ||
| 1137 | 604 | 字符串文本,表示该控件包含的数据。适用于Text、Memo、StringList类型。Most of the editing operations (such as **Select**, **Clear**, **Cut**, **Copy**) are performed in this part of the object, which holds the actual string being edited. If the control contains more than a single line of text, for example **TMemo** or **TComboBox**, then the textual elements are arranged as an array of strings (zero-indexed, ie numbered from \[0..numLines-1\]) in **Lines**. | |
| 1138 | 605 | ||
| 1139 | - | ||
| 1140 | - | ||
| 1141 | - | ||
| 1142 | - | ||
| 1143 | - | ||
| 1144 | - | ||
| 1145 | - | ||
| 1146 | - | ||
| 1147 | 606 | Visible | |
| 1148 | 607 | ||
| 1149 | - | ||
| 1150 | - | ||
| 1151 | - | ||
| 1152 | - | ||
| 1153 | 608 | 可见 | |
| 1154 | 609 | ||
| 1155 | - | ||
| 1156 | - | ||
| 1157 | - | ||
| 1158 | - | ||
| 1159 | 610 | 为True,在窗体中可以看到此控件,否则将隐藏。 | |
| 1160 | 611 | ||
| 1161 | - | ||
| 1162 | - | ||
| 1163 | - | ||
| 1164 | - | ||
| 1165 | - | ||
| 1166 | - | ||
| 1167 | - | ||
| 1168 | - | ||
| 1169 | 612 | WordWrap | |
| 1170 | 613 | ||
| 1171 | - | ||
| 1172 | - | ||
| 1173 | - | ||
| 1174 | - | ||
| 1175 | 614 | 自动换行 | |
| 1176 | 615 | ||
| 1177 | - | ||
| 1178 | - | ||
| 1179 | - | ||
| 1180 | - | ||
| 1181 | 616 | 为True时,文本内容将自动换行。 | |
| 1182 | 617 | ||
| 1183 | - | ||
| 1184 | - | ||
| 1185 | - | ||
| 1186 | - | ||
| 1187 | - | ||
| 1188 | - | ||
| 1189 | 618 | #### 事件动作 | |
| 1190 | 619 | ||
| 1191 | 620 | 许多行动通常列在“对象观察器”中的“事件”选项卡里。在列表中选择相应事件,在下拉列表中将会显示你已经定义的方法,并允许你对其关联。点击旁边的"..."按钮,将跳到源代码编辑器里,你在那里可以编写相应程序。 | |
| 1192 | 621 | ||
| 1193 | 622 | “事件“选项卡中,显示了当前控件支持的事件,像OnClick事件:鼠标点击事件;OnEntry:当获得焦点时;OnExit:当失去焦点时;或者你可以编写:OnChange:内容改变时;或OnScroll:在滚动条上操作时等等,根据你的需要来选择使用哪些事件进行哪些操作。 | |
| 1194 | 623 | ||
| 1195 | 624 | 在窗体设计器上右击控件 ,“创建默认的事件“也有相同的效果,通常是OnClick(点击)事件。之后在源代码编辑器里编写相应操作。 | |
| 1196 | 625 | ||
| 1197 | 626 | 在面向对象程序设计中,使用 TActionList 组件是为了集中处理许多常用的操作,把用户界面和应用逻辑分开,减少程序的代码行数,方便程序的维护和调试。它用于维护一系列动作列表,以供其他组件或控制所使用,如菜单和按钮。 | |
| 1198 | 627 | ||
| 1199 | - | ||
| 1200 | - | ||
| 1201 | - | ||
| 1202 | - | ||
| 1203 | - | ||
| 1204 | - | ||
| 1205 | - | ||
| 1206 | - | ||
| 1207 | - | ||
| 1208 | - | ||
| 1209 | - | ||
| 1210 | - | ||
| 1211 | - | ||
| 1212 | - | ||
| 1213 | - | ||
| 1214 | - | ||
| 1215 | - | ||
| 1216 | - | ||
| 1217 | - | ||
| 1218 | - | ||
| 1219 | - | ||
| 1220 | - | ||
| 1221 | - | ||
| 1222 | - | ||
| 1223 | - | ||
| 1224 | - | ||
| 1225 | - | ||
| 628 | + | 常用事件 | |
| 1226 | 629 | ||
| 1227 | - | ||
| 630 | + | 事件 | |
| 1228 | 631 | ||
| 1229 | - | ||
| 632 | + | 说明 | |
| 1230 | 633 | ||
| 1231 | - | ||
| 634 | + | 介绍 | |
| 1232 | 635 | ||
| 1233 | 636 | OnChange | |
| 1234 | 637 | ||
| 1235 | - | ||
| 1236 | - | ||
| 1237 | - | ||
| 1238 | - | ||
| 1239 | 638 | 改变事件 | |
| 1240 | 639 | ||
| 1241 | - | ||
| 1242 | - | ||
| 1243 | - | ||
| 1244 | - | ||
| 1245 | 640 | 当检测到任何更改(如鼠标移动、点击、按键、编辑文字、更改图片等)都将触发此事件。 | |
| 1246 | 641 | ||
| 1247 | - | ||
| 1248 | - | ||
| 1249 | - | ||
| 1250 | - | ||
| 1251 | - | ||
| 1252 | - | ||
| 1253 | - | ||
| 1254 | - | ||
| 1255 | 642 | OnClick | |
| 1256 | 643 | ||
| 1257 | - | ||
| 1258 | - | ||
| 1259 | - | ||
| 1260 | - | ||
| 1261 | 644 | 点击事件 | |
| 1262 | 645 | ||
| 1263 | - | ||
| 1264 | - | ||
| 1265 | - | ||
| 1266 | - | ||
| 1267 | 646 | 鼠标点击时触发此事件(点击,指的是鼠标左键点击),点击事件大多是控件默认的事件,如点击一个按钮、单选框或复选框。 | |
| 1268 | 647 | ||
| 1269 | - | ||
| 1270 | - | ||
| 1271 | - | ||
| 1272 | - | ||
| 1273 | - | ||
| 1274 | - | ||
| 1275 | 648 | 单击方法 | |
| 1276 | 649 | ||
| 1277 | - | ||
| 1278 | - | ||
| 1279 | 650 | Click | |
| 1280 | 651 | ||
| 1281 | - | ||
| 1282 | - | ||
| 1283 | - | ||
| 1284 | - | ||
| 1285 | 652 | 单击方法 | |
| 1286 | 653 | ||
| 1287 | - | ||
| 1288 | - | ||
| 1289 | - | ||
| 1290 | - | ||
| 1291 | 654 | 单击方法,在代码中模拟点击控件。一个程序可以调用相同代码的OnClick事件,通过点击激活其他事件。这个方法可以在程序启动时使用,而不是用户点击后再进行某些操作。 | |
| 1292 | 655 | ||
| 1293 | - | ||
| 1294 | - | ||
| 1295 | - | ||
| 1296 | - | ||
| 1297 | - | ||
| 1298 | - | ||
| 1299 | - | ||
| 1300 | - | ||
| 1301 | 656 | OnDragDrop | |
| 1302 | 657 | ||
| 1303 | - | ||
| 1304 | - | ||
| 1305 | - | ||
| 1306 | - | ||
| 1307 | 658 | 拖放事件 | |
| 1308 | 659 | ||
| 1309 | - | ||
| 1310 | - | ||
| 1311 | - | ||
| 1312 | - | ||
| 1313 | 660 | 拖放操作之前,即当鼠标选中某些信息(如文本)要移动到新位置时。 | |
| 1314 | 661 | ||
| 1315 | - | ||
| 1316 | - | ||
| 1317 | - | ||
| 1318 | - | ||
| 1319 | - | ||
| 1320 | - | ||
| 1321 | - | ||
| 1322 | - | ||
| 1323 | 662 | OnEditingDone | |
| 1324 | 663 | ||
| 1325 | - | ||
| 1326 | - | ||
| 1327 | - | ||
| 1328 | - | ||
| 1329 | 664 | 编辑完成事件 | |
| 1330 | 665 | ||
| 1331 | - | ||
| 1332 | - | ||
| 1333 | - | ||
| 1334 | - | ||
| 1335 | 666 | 当用户完成编辑/修改时,通常用来验证输入内容,如检测输入的文本是不是有效的IP地址。 | |
| 1336 | 667 | ||
| 1337 | - | ||
| 1338 | - | ||
| 1339 | - | ||
| 1340 | - | ||
| 1341 | - | ||
| 1342 | - | ||
| 1343 | - | ||
| 1344 | - | ||
| 1345 | 668 | OnEntry | |
| 1346 | 669 | ||
| 1347 | - | ||
| 1348 | - | ||
| 1349 | - | ||
| 1350 | - | ||
| 1351 | 670 | 获得焦点事件 | |
| 1352 | 671 | ||
| 1353 | - | ||
| 1354 | - | ||
| 1355 | - | ||
| 1356 | - | ||
| 1357 | 672 | 当控件获取到焦点时,触发此事件。 | |
| 1358 | 673 | ||
| 1359 | - | ||
| 1360 | - | ||
| 1361 | - | ||
| 1362 | - | ||
| 1363 | - | ||
| 1364 | - | ||
| 1365 | - | ||
| 1366 | - | ||
| 1367 | 674 | OnExit | |
| 1368 | 675 | ||
| 1369 | - | ||
| 1370 | - | ||
| 1371 | - | ||
| 1372 | - | ||
| 1373 | 676 | 移出事件 | |
| 1374 | 677 | ||
| 1375 | - | ||
| 1376 | - | ||
| 1377 | - | ||
| 1378 | - | ||
| 1379 | 678 | 当鼠标移出控件区域时触发此事件。 | |
| 1380 | 679 | ||
| 1381 | - | ||
| 1382 | - | ||
| 1383 | - | ||
| 1384 | - | ||
| 1385 | - | ||
| 1386 | - | ||
| 1387 | - | ||
| 1388 | - | ||
| 1389 | 680 | OnKeyPress | |
| 1390 | 681 | ||
| 1391 | - | ||
| 1392 | - | ||
| 1393 | - | ||
| 1394 | - | ||
| 1395 | 682 | 按键事件 | |
| 1396 | 683 | ||
| 1397 | - | ||
| 1398 | - | ||
| 1399 | - | ||
| 1400 | - | ||
| 1401 | 684 | 按键事件,当按下某键时,将触发此事件。不同于OnKeyDown:当按下但不松开某键时触发此事件。 | |
| 1402 | 685 | ||
| 1403 | - | ||
| 1404 | - | ||
| 1405 | - | ||
| 1406 | - | ||
| 1407 | - | ||
| 1408 | - | ||
| 1409 | - | ||
| 1410 | - | ||
| 1411 | 686 | OnKeyDown | |
| 1412 | 687 | ||
| 1413 | - | ||
| 1414 | - | ||
| 1415 | - | ||
| 1416 | - | ||
| 1417 | 688 | 按下键不松事件 | |
| 1418 | 689 | ||
| 1419 | - | ||
| 1420 | - | ||
| 1421 | - | ||
| 1422 | - | ||
| 1423 | 690 | 如果一个键被按下,但不松开,将触发此事件。 | |
| 1424 | 691 | ||
| 1425 | - | ||
| 1426 | - | ||
| 1427 | - | ||
| 1428 | - | ||
| 1429 | - | ||
| 1430 | - | ||
| 1431 | - | ||
| 1432 | - | ||
| 1433 | 692 | OnKeyUp | |
| 1434 | 693 | ||
| 1435 | - | ||
| 1436 | - | ||
| 1437 | - | ||
| 1438 | - | ||
| 1439 | 694 | 松开键事件 | |
| 1440 | 695 | ||
| 1441 | - | ||
| 1442 | - | ||
| 1443 | - | ||
| 1444 | - | ||
| 1445 | 696 | 松开按键时触发此事件。 | |
| 1446 | 697 | ||
| 1447 | - | ||
| 1448 | - | ||
| 1449 | - | ||
| 1450 | - | ||
| 1451 | - | ||
| 1452 | - | ||
| 1453 | - | ||
| 1454 | - | ||
| 1455 | 698 | OnMouseMove | |
| 1456 | 699 | ||
| 1457 | - | ||
| 1458 | - | ||
| 1459 | - | ||
| 1460 | - | ||
| 1461 | 700 | 鼠标移动事件 | |
| 1462 | 701 | ||
| 1463 | - | ||
| 1464 | - | ||
| 1465 | - | ||
| 1466 | - | ||
| 1467 | 702 | 当鼠标在控件上移动时触发此事件。 | |
| 1468 | 703 | ||
| 1469 | - | ||
| 1470 | - | ||
| 1471 | - | ||
| 1472 | - | ||
| 1473 | - | ||
| 1474 | - | ||
| 1475 | - | ||
| 1476 | - | ||
| 1477 | 704 | OnMouseDown | |
| 1478 | 705 | ||
| 1479 | - | ||
| 1480 | - | ||
| 1481 | - | ||
| 1482 | - | ||
| 1483 | 706 | 鼠标按下事件 | |
| 1484 | 707 | ||
| 1485 | - | ||
| 1486 | - | ||
| 1487 | - | ||
| 1488 | - | ||
| 1489 | 708 | 鼠标按下但不松开时触发此事件。 | |
| 1490 | 709 | ||
| 1491 | - | ||
| 1492 | - | ||
| 1493 | - | ||
| 1494 | - | ||
| 1495 | - | ||
| 1496 | - | ||
| 1497 | - | ||
| 1498 | - | ||
| 1499 | 710 | OnMouseUp | |
| 1500 | 711 | ||
| 1501 | - | ||
| 1502 | - | ||
| 1503 | - | ||
| 1504 | - | ||
| 1505 | 712 | 鼠标松开事件 | |
| 1506 | 713 | ||
| 1507 | - | ||
| 1508 | - | ||
| 1509 | - | ||
| 1510 | - | ||
| 1511 | 714 | 鼠标按下并松开时触发此事件。 | |
| 1512 | 715 | ||
| 1513 | - | ||
| 1514 | - | ||
| 1515 | - | ||
| 1516 | - | ||
| 1517 | - | ||
| 1518 | - | ||
| 1519 | - | ||
| 1520 | - | ||
| 1521 | 716 | OnResize | |
| 1522 | 717 | ||
| 1523 | - | ||
| 1524 | - | ||
| 1525 | - | ||
| 1526 | - | ||
| 1527 | 718 | 改变大小事件 | |
| 1528 | 719 | ||
| 1529 | - | ||
| 1530 | - | ||
| 1531 | - | ||
| 1532 | - | ||
| 1533 | 720 | 调整控件大小时触发此事件。 | |
| 1534 | 721 | ||
| 1535 | - | ||
| 1536 | - | ||
| 1537 | - | ||
| 1538 | - | ||
| 1539 | - | ||
| 1540 | - | ||
| 1541 | 722 | #### 构造和析构函数 | |
| 1542 | 723 | ||
| 1543 | 724 | 每个对象都有两个相关联的方法: | |
| 1544 | 725 | ||
| 1545 | 726 | - **构造函数**:在创建时,即分配对象所需内存和资源时。 | |
| 1546 | 727 | - **析构函数**:在删除时,即释放分配对象所需内存和资源时。 | |
| 1547 | 728 | ||
| 1548 | - | ||
| 729 | + | 释放对象,你需要使用free方法,因为它会检测对象值是否为nil。如果你调用已经*销毁*的对象,它将产生一个错误。 | |
| 1549 | 730 | ||
| 1550 | 731 | *销毁*时,注意以下: | |
| 1551 | 732 | ||
| 1552 | - | ||
| 733 | + | - Declare **Destroy** with the override directive, because it is a virtual method. | |
| 1553 | 734 | - Always call **'inherited Destroy;**' as the last thing on the destructor code. | |
| 1554 | 735 | - Be aware that an **exception** may be raised on the **constructor** in case there is not enought memory to create an object, or something else goes wrong. If the **exception** is not handled inside the constructor, the object will be only partially built. In this case **Destroy** will be called when you weren't expecting it, so your destructor must check if the resources were really allocated before disposing of them. | |
| 1555 | 736 | - Remember to call **Free** for all objects created on the constructor. | |
| 1556 | 737 | ||
| 1557 | 738 | ## 为窗体创建菜单 | |
| 1558 | 739 | ||
| 1559 | 740 | *TMainMenu*是大多都使用的;在窗体顶部会出现菜单栏,设计者可以定制不同的菜单项。*TPopupMenu*是一个与上下文相关的菜单。通常是在控件附近点击时弹出的。 | |
| 1560 | 741 | ||
| 1561 | 742 | 主菜单是非可视组件:也就是说,在组件面板中选择菜单图标,放置在窗体上,运行时不会被显示,你需要创建菜单项,像TPopupMenu菜单,你需要关联相应组件的PopupMenu属性。 | |
| 1562 | 743 | ||
| 1563 | 744 | 若要使用菜单编辑器:右击窗体上的菜单控件,在弹出的菜单中选择*(Menu Editor)菜单编辑器*,在弹出的窗口中,对菜单进行设置。 | |
| 1564 | 745 | ||
| 1565 | 746 | 默认将显示一个NewItem1菜单项,右击它,弹出的菜单中,你可以继续在其上面或下面添加菜单,也可以子菜单。在对象观察器中,设置菜单项属性。 | |
| 1566 | 747 | ||
| 1567 | - | ||
| 748 | + | 当然,你应该给菜单项起个有意义的名字,如File open(打开文件)、Close(关闭)等。 如果你想热键,即在菜单项后显示(&N),你只需要直接输入即可。当然,你也可以给菜单项关联快捷键,对象观察器中的ShortCut和ShortCutKey2属性,分别设置第1,2快捷键;如(复制,`Ctrl`+`C`;粘贴,`Ctrl`+`V`)。 | |
| 1568 | 749 | ||
| 1569 | 750 | 另外,如需要在菜单项间插入一条分隔线,只需要设置菜单项的Caption属性为**-**即可。 | |
| 1570 | 751 | ||
| 1571 | 752 | 你可以结合ActionList组件,对菜单各项的事件进行统一编写。 | |
| 1572 | 753 | ||
| 1573 | 754 | By default, a number of standard actions are pre-loaded from *StdActns* or, if DataAware controls are used, from *DBActns*. These actions can be chosen using the ActionList editor which appears when you right-click on the ActionList icon on the Form Designer. | |
| 1574 | 755 | ||
| 1575 | 756 | ## 调试器 | |
| 1576 | 757 | ||
| 1577 | 758 | *`待写`*`。` | |
| 1578 | 759 | ||
| 1579 | 760 | 更多 [:category: IDE Window - Debug](/wiki-category/IDE%20Window%20-%20Debug) | |
| 1580 | 761 | ||
| 1581 | 762 | ## Lazarus 文件 | |
| 1582 | 763 | ||
| 1583 | 764 | ` (感谢 Kevin Whitefoot.)`\ | |
| 1584 | 765 | ` (Giuseppe Ridinò, `User:Kirkpatc` 和 Tom Lisjac 添加)` | |
| 1585 | 766 | ||
| 1586 | 767 | 当你保存时,实际上会保存两个文件: | |
| 1587 | 768 | ||
| 1588 | 769 | ` xxx.pas 和 yyy.lpr` | |
| 1589 | 770 | ||
| 1590 | 771 | 不止这些,还有项目文件(lpr)、单元文件(pas),名称不能相同,否则Lazarus会覆盖掉原文件,在编辑器会因为无法找到指定文件而报错。 | |
| 1591 | 772 | ||
| 1592 | 773 | 所以,你需要保存为一个不重名的项目。 | |
| 1593 | 774 | ||
| 1594 | 775 | 这是我最终的文件列表: | |
| 1595 | 776 | ||
| 1596 | 777 | e:/lazarus/kj/lazhello: | |
| 1597 | 778 | ||
| 1598 | 779 | `total 4740 free 76500`\ | |
| 1599 | 780 | `-rwxrwxrwx 1 kjwh root 4618697 Mar 24 11:19 again.exe`\ | |
| 1600 | 781 | `-rw-rw-rw- 1 kjwh root 3002 Mar 24 11:21 again.lpi`\ | |
| 1601 | 782 | `-rw-rw-rw- 1 kjwh root 190 Mar 24 11:18 again.lpr`\ | |
| 1602 | 783 | `-rw-rw-rw- 1 kjwh root 506 Mar 24 11:08 againu.lfm`\ | |
| 1603 | 784 | `-rw-rw-rw- 1 kjwh root 679 Mar 24 11:08 againu.lrs`\ | |
| 1604 | 785 | `-rw-rw-rw- 1 kjwh root 677 Mar 24 11:08 againu.pas`\ | |
| 1605 | 786 | `-rw-rw-rw- 1 kjwh root 2124 Mar 24 11:08 againu.ppu`\ | |
| 1606 | 787 | `-rwxrwxrwx 1 kjwh root 335 Mar 24 11:07 ppas.bat` | |
| 1607 | 788 | ||
| 1608 | 789 | Note that there are many more files than the two that I thought I was saving.(~~注意,好像是多了两个文件,我想是我存的吧。~~) | |
| 1609 | 790 | ||
| 1610 | 791 | 下面是对每个文件的简短介绍: | |
| 1611 | 792 | ||
| 1612 | 793 | **again.exe:** 二进制可执行文件,Win32中添加exe扩展名。linux没有。此文件在Linux上很大的原因是,加入了调试标记。 注意:在1.0.14版,可以勾选,“工程”-\>“工程选项”中的“编译选项”-\>“链接”:“从可执行程序中除去符号,可以减少程序体积(Strip Symbol)”;以减少程序体积。 | |
| 1613 | 794 | ||
| 1614 | 795 | **again.lpi:** 它以XML格式存储,是Lazarus项目的主要文件(项目信息);Delphi应用程序文件是.dpr。 | |
| 1615 | 796 | ||
| 1616 | 797 | **again.lpr:** 这是主程序的源代码文件,尽管使用了特定的扩展名,但它仍是正常的Pascal源文件。它有use部分,可以让编译器找到所需的单元。注意,程序名可以和该名称相同。 | |
| 1617 | 798 | ||
| 1618 | 799 | **againu.lfm:** 存储了Lazarus窗体布局信息;也包含了初始化部分的资源文件。Delphi的DFM文件可以转换为LFM格式:“工具“-\>“转换DFM文件为LFM文件”。 | |
| 1619 | 800 | ||
| 1620 | 801 | **againu.lrs:** 生成的资源文件。需要注意的是它不是Windows的资源文件。 | |
| 1621 | 802 | ||
| 1622 | 803 | **againu.pas:** The unit that contains the code for the form. 包含窗体代码的单元文件。 | |
| 1623 | 804 | ||
| 1624 | 805 | **againu.ppu:** 编译的单元文件。 | |
| 1625 | 806 | ||
| 1626 | 807 | **ppas.bat:** 一个简单的脚本,链接程序生成可执行文件。如果编译完成,将由编译器删除。 | |
| 1627 | 808 | ||
| 1628 | 809 | ## 原作者和变化 | |
| 1629 | 810 | ||
| 1630 | 811 | 这个页面来自 ~~[这里](http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusTutorial)~~(失效)。 | |
| 1631 | 812 | ||
| 1632 | 813 | - Created initial page and template. T. Lisjac - 11/04/2003 VlxAdmin | |
| 1633 | 814 | - Inserted a note containing instructions for writing your first Lazarus Program. Suggest an administrator places it in the appropriate place on the Tutorial menu. 3/09/2004 User:Kirkpatc | |
| 1634 | 815 | - Per above, moved Chris's writeup to the main body of the tutorial VlxAdmin | |
| 1635 | 816 | - Began to insert text describing the Lazarus Editor - more to follow! 24 Mar 2004 User:Kirkpatc | |
| 1636 | 817 | - Added some more to Lazarus Editor section of Tutorial. 25 Mar 2004 User:Kirkpatc | |
| 1637 | 818 | - Added screenshots and revised some of the page formatting VlxAdmin 3/25/2004 | |
| 1638 | 819 | - Moved some of kwhitefoot's comments into Tutorial section. Formatting not quite right, but have to go to bed now! 26 Mar 2004 User:Kirkpatc | |
| 1639 | 820 | - Formatted, added credits and comments. Removed original notes. VlxAdmin 3/26/2004 | |
| 1640 | 821 | - More material added to Editor section of tutorial. 26 Mar 2004 User:Kirkpatc | |
| 1641 | 822 | - More material added describing the Main Menu. Renamed 'Hello World' to 'Getting Started' and moved it to nearer the top. 31 March 2004 User:Kirkpatc | |
| 1642 | 823 | - Inserted section on Run sub-menu. Some general editing (eg ended each entry with a period to ensure consistency). 9 Apr 2004 User:Kirkpatc | |
| 1643 | 824 | - Inserted a new section on How to get started with MySQL in FPC/Lazarus. 13 Apr 2004 User:Kirkpatc | |
| 1644 | 825 | - Deleted the section on MySQL from here: it has been copied to Lazarus Database section of tutorial. 14 Apr 2004 User:Kirkpatc | |
| 1645 | 826 | - Added some more to the description of the Editor Main Menu. 18 Apr 2004 User:Kirkpatc | |
| 1646 | 827 | - Added section on Environment sub-menu. 19 Apr 2004 User:Kirkpatc | |
| 1647 | 828 | - Added section on Components sub-menu. 4 May 2004 User:Kirkpatc | |
| 1648 | 829 | - Adding Tools sub-menu description (incomplete). 7 May 2004 User:Kirkpatc | |
| 1649 | 830 | - Added some screenshots to Menu descriptions. 9 May 2004 User:Kirkpatc | |
| 1650 | 831 | - Fixed a bit in Environment Options - thanks VincentSnijders. 14 May 2004 User:Kirkpatc | |
| 1651 | 832 | - More additions to Tools sub-menu. 19 May 2004 User:Kirkpatc | |
| 1652 | 833 | - Added a section on the Button Bar and started work on The Component Palette. 20 May 2004 User:Kirkpatc | |
| 1653 | 834 | - Posted a description file for the StdCtrls unit of the LCL, in the hope that people will add comments. 26 May 2004 User:Kirkpatc | |
| 1654 | 835 | - Edited the StdCtrls file, removing a lot of repetitive material and doing some formatting. It is still far too long. 28 May 2004 User:Kirkpatc | |
| 1655 | 836 | - Expanding on the Components Palette. 5 June 2004 User:Kirkpatc | |
| 1656 | 837 | - Added a lot to the DialogExamples page. 10 June 2004 User:Kirkpatc | |
| 1657 | 838 | - Considerable revision of the StdCtrls page, hopefully making it clearer and encouraging people to contribute - particularly in the 'Description' sections. 14 June 2004 User:Kirkpatc | |
| 1658 | 839 | - Added pages for Menus and Dialogs units (linked to Component Palette description) - please feel free to add to these pages. 14 June 2004 User:Kirkpatc | |
| 1659 | 840 | - Added page for Common Controls (linked to Component Palette). 16 June 2004 User:Kirkpatc | |
| 1660 | 841 | - Added MaskEdit page (linked to Component Palette). 17 June 2004 User:Kirkpatc | |
| 1661 | 842 | - Added Buttons, ExtCtrls pages (linked to Component Palette). 17 June 2004 User:Kirkpatc | |
| 1662 | 843 | - Edited MainMenu component description page. 23 June 2004 User:Kirkpatc | |
| 1663 | 844 | - Some additions to Common Controls. 28 June 2004 User:Kirkpatc | |
| 1664 | 845 | - A new tutorial on Text-mode Pascal programming has been added. 5 July 2004 User:Kirkpatc | |
| 1665 | 846 | - Minor changes to ComCtrls, ExtCtrls, Environment Menu. 10 July User:Kirkpatc | |
| 1666 | 847 | - Added FormsTxt, component description page for Component Palette. 20 July 2004 User:Kirkpatc | |
| 1667 | 848 | - Some corrections to ConsoleModePascal. 21 July 2004 User:Kirkpatc | |
| 1668 | 849 | - Some small changes to ComponentPalette. 22 July 2004 User:Kirkpatc | |
| 1669 | 850 | - Returned after a long absence! Changed link for component descriptions in StdCntls group of ComponentPalette to point directly at the Lazarus on-line help html pages. 25 Sept 2007 User: Kirkpatc | |
| 1670 | 851 | - Uploaded some more up-to-date screenshots and fixed links in descriptions of the Menus. 2 October 2007 User: Kirkpatc | |
| 1671 | 852 | - Fixed links for component descriptions in Extra Controls section of Component Palette. 2 October 2007 User: Kirkpatc | |
| 1672 | 853 | - Uploaded some more up-to-date screenshots,and fix some more up-to-date item. 12 October 2018 User: robsean | |
| 1673 | 854 | - Uploaded some more up-to-date screenshots,and fix some more up-to-date item. 15 February 2019 User: robsean | |
| 1674 | 855 | ||
| 1675 | 856 | --- | |
| 1676 | 857 | *From the Free Pascal wiki, page "Lazarus Tutorial/zh CN", as it stood on 2023-03-31 after a change by Owenlmg, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 1677 | 858 | Category: zh |
