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

📄 unit1.~pas

📁 《Delphi 7应用编程150例》源码(全)
💻 ~PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Registry, StdCtrls, Buttons, ExtCtrls, ExtDlgs;

type
  TfrmMain = class(TForm)
    OpenPictureDialog1: TOpenPictureDialog;
    GroupBox1: TGroupBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    GroupBox2: TGroupBox;
    Image1: TImage;
    BitBtn1: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure TfrmMain.FormCreate(Sender: TObject);
begin
    if OpenPictureDialog1.Execute then
        Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName)
    else
        Application.Terminate;
end;

procedure TfrmMain.BitBtn1Click(Sender: TObject);
var
  Ini: TregIniFile;
  UpdateKey:PChar;
begin
    Ini := TRegIniFile.Create('Control Panel');
    Ini.WriteString('desktop', 'Wallpaper', OpenPictureDialog1.FileName);
    if RadioButton1.Checked then
    begin
        Ini.WriteString('desktop', 'TileWallpaper', '0');
        Ini.WriteString('desktop', 'WallpaperStyle', '0')
    end
    else if RadioButton2.Checked then
    begin
        Ini.WriteString('desktop', 'TileWallpaper', '1');
        Ini.WriteString('desktop', 'WallpaperStyle', '0')
    end
    else
    begin
        Ini.WriteString('desktop', 'TileWallpaper', '0');
        Ini.WriteString('desktop', 'WallpaperStyle', '2')
    end;
    Ini.Free;
    SystemParametersInfo(SPI_SETDESKWALLPAPER,0,nil,SPIF_SENDWININICHANGE);

    UpdateKey := 'HKEY_CURRENT_USER\Control Panel\desktop';
    SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETDESKWALLPAPER, integer(@UpdateKey));
end;

end.

⌨️ 快捷键说明

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