0

If i'm not mistaken delphi has the ability to show a list of options after you insert a component name followed by the "." (dot) that precedes more arguments.

My delphi 7 is not showing this list after the "."

Ex: When I enter

form1.edit1.

It should show a list of options for an "TEdit" component. Not happening, what's wrong?

Code:

unit Banri;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Clipbrd;

type
  TForm1 = class(TForm)
    EditTexto: TEdit;
    ButtonGO: TButton;
    procedure ButtonGOClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  SL: TStringList;
  Count: Integer;
  Appwin : hWnd;

implementation

{$R *.dfm}

  var
  TextoCompleto: String;



begin
  TextoCompleto:= EditTexto.Text;
  Appwin:= FindWindow(PChar(0),'Banrisul');
  if Appwin <> 0 then
  begin
      StringReplace(TextoCompleto, '.', '', [rfReplaceAll, rfIgnoreCase]);

      SL:= TStringList.Create;
      try
        ExtractStrings([' '], [], PChar(TextoCompleto), SL);
        WriteLn(SL.Text);
        ReadLn;
      finally
        SL.Free;
  end;
      Count:= 0;
      while Count <> SL.Count - 1 do
        begin
          Clipboard.AsText:= SL[Count];; //place text in clipboard
          //if Clipboard.HasFormat(CF_TEXT) then
          //do something with text
          ShowMessage(Clipboard.AsText);
          Clipboard.AsText:= SL[Count + 1];; //place next line text in clipboard
          //if Clipboard.HasFormat(CF_TEXT) then
          //do something with text
          inc(Count);
        end; //while Count <> SL.Count - 1 do
      SL.Free;
  end; //if Appwin <> 0 then


end.
4

4 回答 4

1

它被称为代码完成。您可能无意中在选项中将其关闭。查看 Tools / Options / Editor Options / Code Insight,并确保选中 Code Completion。

于 2013-05-07T00:59:57.173 回答
1

您将两种不同的 Delphi 单元样式混合为一种。您正在使用的单位.pas是表单后面的单位 ( ) 文件。但是,项目主文件 ( .dpr) 具有不同的样式。

项目的主文件是唯一应该包含一个begin..end.部分的文件。另一方面,其余单元必须有一个implementation部分,其中实际代码驻留在多个功能/过程/方法等。

因此,在您的情况下,您需要保持默认表单的单元在默认情况下是如何创建的。

一个新的 Delphi主项目文件如下所示:

program Project1;

uses
  Vcl.Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

一个新的 Delphi标准单元文件看起来像这样:

unit Unit2;

interface

implementation

end.

一个新的 Delphi vcl 表单单元文件看起来像这样:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.

如果你实现任何代码......

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure DoSomething;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Form1.DoSomething;
end;

procedure TForm1.DoSomething;
begin
  //Do Something...

end;

end.

您可能犯的一个错误是您添加到表单单元的原始代码是示例控制台应用程序的形式,它不同于 VCL 表单应用程序。控制台应用程序主要基于命令提示符,这对于演示示例代码似乎很常见。但是,您永远不应将该代码样式与任何其他标准单元样式混为一谈。

于 2013-05-07T02:16:13.603 回答
0

因此,正如其他人发现的那样,问题出在我的编码结构中,这是令人难以置信的错误。

unit Banri;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Clipbrd;

type
  TForm1 = class(TForm)
    EditTexto: TEdit;
    ButtonGO: TButton;
    procedure ButtonGOClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  SL: TStringList;
  Count: Integer;
  Appwin : hWnd;

**implementation

{$R *.dfm}

  var
  TextoCompleto: String;



begin
  TextoCompleto:= EditTexto.Text;
  Appwin:= FindWindow(PChar(0),'Banrisul');
  if Appwin <> 0 then**

很容易看出,我已经开始在没有函数或过程的情况下进行编码。这就是为什么“提示”(实际上称为“代码洞察”,因为我也在其他人的帮助下发现)不起作用。Delphi 没有将代码识别为任何事物的一部分,因此无法提供代码洞察力。

于 2013-05-09T00:43:00.963 回答
0

我在这里猜测了一下,假设上面粘贴的代码是未经编辑的。

我怀疑您需要做的是在代码中procedure TForm1.ButtonGOClick(Sender: TObject);的第一个之前添加begin

unit Banri;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Clipbrd;

type
  TForm1 = class(TForm)
    EditTexto: TEdit;
    ButtonGO: TButton;
    procedure ButtonGOClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ButtonGOClick(Sender: TObject); // <--- added line
var
  SL: TStringList;                               // <-- moved variables from global to local scope. Form1 needs to remain global
  Count: Integer;
  Appwin : hWnd;
  TextoCompleto: String;
begin
  TextoCompleto:= EditTexto.Text;
  Appwin:= FindWindow(PChar(0),'Banrisul');
  if Appwin <> 0 then
  begin
      StringReplace(TextoCompleto, '.', '', [rfReplaceAll, rfIgnoreCase]);

      SL:= TStringList.Create;
      try
        ExtractStrings([' '], [], PChar(TextoCompleto), SL);
        WriteLn(SL.Text);
        ReadLn;
      finally
        SL.Free;
  end;
      Count:= 0;
      while Count <> SL.Count - 1 do
        begin
          Clipboard.AsText:= SL[Count];; //place text in clipboard
          //if Clipboard.HasFormat(CF_TEXT) then
          //do something with text
          ShowMessage(Clipboard.AsText);
          Clipboard.AsText:= SL[Count + 1];; //place next line text in clipboard
          //if Clipboard.HasFormat(CF_TEXT) then
          //do something with text
          inc(Count);
        end; //while Count <> SL.Count - 1 do
      SL.Free;
  end; //if Appwin <> 0 then


end.
于 2013-05-07T02:14:59.290 回答