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