Delphi IDE使用的一些主要技巧

1、查找和替换。

(1)<ctrl>+F[1]:选择页“Find”,进行查找,则根据查找方向继续查找。选择页“Find in Files”,则进行该工程内的全文查找。

(2)<ctrl>+R:替换。

(3)设置书签和定位:设置书签:<ctrl>+<shift>+数字[2]

  定位书签:<ctrl>+数字

        

2、窗体编辑。

(1)<F12>:在窗体编辑和代码编辑间进行切换。

(2)<F11>:调用窗体组件属性/事件浏览设置器(Object Inspector)。

(3)<菜单:view>+<菜单:Alignment Palette>:对齐面板:用于对齐各个可视组件。



3、代码编写方面。

(1)<ctrl>+J:调用自动代码完成模板,实现成段代码的自动完成。关于模板的配置,可以在<菜单:Tools> + <菜单:Editor Options…> + <面板:Source Options> + <按钮:Edit Code Templates…>中完成。

(2) <ctrl>+ <鼠标:单击>:查看所在方法的实现代码、所在变量的声明等内容。

(3)<ctrl>+<Space>:代码自动完成提示

 <ctrl>+<shift>+<Space>:方法体内参数提示。



4、程序编译和运行方面。

(1)<F9>:编译并运行(可以设置断点进行调试)。

 <F8>:单步调试,但是不进入到相关的子函数/过程体内

 <F7>:逐步调试,调试深入每一个相关的子函数/过程体内。

 <ctrl>+<F2>:结束程序调试运行状态,回到程序编辑状态。

(2)<F5>:设置/取消设置程序的断点。

(3)<ctrl>+<F7>:观察代码的值并附加新值(采用Modify功能)进行调试(注意:这个功能仅仅在程序暂时终止状态下有效[3]),内附的Inspector功能可以查看该值/对象更加详细的信息。

<ctrl>+<F5>:查看对象在不同数据类型下的值的情况,在使用<ctrl>+<F7>调用的“Evaluate/Modify”功能中,也能够通过[按钮:modify]调用该功能。



5、工程控制。

(1)To-do List。

【作用】对工作的一种进度的记载和提示。下次进入开发时,可迅速的紧接上次开发。

【操作方法】<鼠标右键>+:增加To-Do List内容。

<菜单:view>+<菜单:To-Do List>:查看并定位到To-Do List部分。

【操作技巧】To-Do List没有数目的限制,可以作为一个比较长期的设置程序书签(Bookmark)的工具来使用。







--------------------------------------------------------------------------------

[1] Delphi中提供了使用+E进行增量查找的方法,我个人不是特别的欣赏。

[2] 在此处,需要注意的是,所有的数字键不能使用小键盘上的数字键。

[3] 让程序暂时终止的方法有两个:(1)程序运行到断点处,程序自动暂时终止,等待调试;(2)调用<菜单:Run…>+ <菜单:Program Pause>完成程序的暂时终止,等待调试。

来自:www.delphifans.com

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
搜索TXT 文件的示例unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.ExtCtrls; type TForm1 = class(TForm) ListBox1: TListBox; Memo2: TMemo; Panel1: TPanel; Label1: TLabel; Label2: TLabel; Label3: TLabel; Edit1: TEdit; ButtonSearchFile: TButton; FolderPath: TEdit; FileExt: TEdit; ProgressBar1: TProgressBar; procedure ButtonSearchFileClick(Sender: TObject); procedure ListBox1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } procedure SearchFile1(FileName: string; FindText: string); function MakeFileList(Path, FileExt: string): TStringList; function FileInUsed(FileName: TFileName): Boolean; public { Public declarations } end; var Form1: TForm1; implementation uses StrUtils; {$R *.dfm} { Search Options KeyWord in file FileName FileSize FileCreateTime FileModifyTime keyword filepath openfile found addListbox } var FileNamePathList, FileNameList: TStringList; procedure TForm1.FormCreate(Sender: TObject); begin FileNameList := TStringList.Create; FileNamePathList := TStringList.Create; end; { if FileInUsed ('D:\Administrator\Documents\MyProjects\FileSearch\Win32\Debug\Project1.exe') then ShowMessage('File is in use.') else ShowMessage('File not in use.'); } function TForm1.FileInUsed(FileName: TFileName): Boolean; var HFileRes: HFILE; begin Result := False; if not FileExists(FileName) then Exit; // 如果文件不存在,返回false HFileRes := CreateFile(PChar(FileName), GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); Result := (HFileRes = INVALID_HANDLE_VALUE); if not Result then CloseHandle(HFileRes); end; procedure TForm1.SearchFile1(FileName: string; FindText: string); var SearchList: TStringList; begin try SearchList := TStringList.Create; if FileExists(FileName) and (not FileInUsed(FileName)) then begin SearchList.LoadFromFile(FileName); if Boolean(Pos(UpperCase(FindText), UpperCase(SearchList.Text))) then begin FileNameList.Add(ExtractFileName(FileName)); FileNamePathList.Add(FileName); end; end; finally SearchList.Free; end; end; procedure TForm1.ButtonSearchFileClick(Sender: TObject); var I, n: Integer; List: TStringList; begin try ButtonSearchFile.Caption := 'SearchFile'; List := TStringList.Create; List.Clear; FileNameList.Clear; FileNamePathList.Clear; List := MakeFileList(FolderPath.Text, FileExt.Text); ProgressBar1.Max := List.Count; for I := 0 to List.Count - 1 do begin Application.ProcessMessages; SearchFile1(List[I], Edit1.Text); ProgressBar1.Position := I; end; ListBox1.Items.Text := FileNameList.Text; ButtonSearchFile.Caption := IntToStr(FileNamePathList.Count) + ' 条'; finally List.Free; end; end; { 这个过程得显示进度 } function TForm1.MakeFileList(Path, FileExt: string): TStringList; var sch: TSearchrec; begin Result := TStringList.Create; if RightStr(Trim(Path), 1) '\' then Path := Trim(Path) + '\' else Path := Trim(Path); if not DirectoryExists(Path) then begin Result.Clear; Exit; end; if FindFirst(Path + '*', faAnyfile, sch) = 0 then begin repeat Application.ProcessMessages; if ((sch.Name = '.') or (sch.Name = '..')) then Continue; if DirectoryExists(Path + sch.Name) then begin Result.AddStrings(MakeFileList(Path + sch.Name, FileExt)); end else begin if (UpperCase(ExtractFileExt(Path + sch.Name)) = UpperCase(FileExt)) or (FileExt = '.*') then Result.Add(Path + sch.Name); end; until FindNext(sch) 0; FindClose(sch); end; end; procedure TForm1.ListBox1Click(Sender: TObject); var s: string; txt: string; begin if not FileExists(FileNamePathList[ListBox1.ItemIndex]) then Exit; Memo2.Lines.LoadFromFile(FileNamePathList[ListBox1.ItemIndex]); Caption := FileNamePathList[ListBox1.ItemIndex]; txt := Form1.Memo2.Text; if Boolean(Pos(UpperCase(Edit1.Text), UpperCase(txt))) then begin Memo2.SetFocus; Memo2.SelStart := Pos(UpperCase(Edit1.Text), UpperCase(txt)) - 1; Memo2.SelLength := Length(Edit1.Text); end; end; end.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值