⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 Delphi实现获取网页源码
💻 PAS
字号:
unit Main;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, IniFiles, GetHTTPs;

type
  TMainForm = class(TForm)
    Memo1: TMemo;
    Panel1: TPanel;
    edURL: TEdit;
	btnGet: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btnGetClick(Sender: TObject);
    procedure edURLKeyPress(Sender: TObject; var Key: Char);
  private
	{ Private declarations }
	procedure LoadControl;
	procedure SaveControl;
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$R *.DFM}

procedure TMainForm.LoadControl;
var
	Path: String;
	IniFile: TIniFile;
begin
	Path := ExtractFilePath(Application.ExeName);
	IniFile := TIniFile.Create(Path + 'GetHTTPSTest.ini');
	Left := IniFile.ReadInteger('Coordination', 'MainLeft', 0);
	Top := IniFile.ReadInteger('Coordination', 'MainTop', 0);
	Width := IniFile.ReadInteger('Coordination', 'MainWidth', 640);
	Height := IniFile.ReadInteger('Coordination', 'MainHeight', 480);
	edURL.Text := IniFile.ReadString('Option', 'URL', 'http://www.gilgil.co.kr/');
	IniFile.Free;
end;

procedure TMainForm.SaveControl;
var
	Path: String;
	IniFile: TIniFile;
begin
	Path := ExtractFilePath(Application.ExeName);
	IniFile := TIniFile.Create(Path + 'GetHTTPSTest.ini');
	IniFile.WriteInteger('Coordination', 'MainLeft', Left);
	IniFile.WriteInteger('Coordination', 'MainTop', Top);
	IniFile.WriteInteger('Coordination', 'MainWidth', Width);
	IniFile.WriteInteger('Coordination', 'MainHeight', Height);
	IniFile.WriteString('Option', 'URL', edURL.Text);
	IniFile.Free;
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
	edURL.Anchors := [akLeft, akRight];
	btnGet.Anchors := [akRight];
	Memo1.Align := alClient;
end;

procedure TMainForm.FormShow(Sender: TObject);
begin
	LoadControl;
end;

procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
	SaveControl;
end;

procedure TMainForm.btnGetClick(Sender: TObject);
begin
	Memo1.Lines.Text := GetHTTP(edURL.Text);
end;

procedure TMainForm.edURLKeyPress(Sender: TObject; var Key: Char);
begin
	if Key = #13 then
	begin
		Key := #0;
		btnGet.Click;
	end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -