2
I developed a auto build For my projects, everything works fine. However, in this application builder the user will be able to choose the icon to be used, but I do not know how to do it. I’ve done a brief search, but to no avail.
Grateful.
2
I developed a auto build For my projects, everything works fine. However, in this application builder the user will be able to choose the icon to be used, but I do not know how to do it. I’ve done a brief search, but to no avail.
Grateful.
2
Follow the code below an example I used a while ago.
unit icon;
interface
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, madRes, Vcl.StdCtrls,
  Vcl.Imaging.pngimage, Vcl.ExtCtrls, Vcl.ComCtrls, about;
type
  TForm1 = class(TForm)
    Image1: TImage;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    StatusBar1: TStatusBar;
    GroupBox2: TGroupBox;
    GroupBox3: TGroupBox;
    Button2: TButton;
    GroupBox4: TGroupBox;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Edit2: TEdit;
    Image2: TImage;
    OpenDialog2: TOpenDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
  begin
    Edit1.Text := OpenDialog1.FileName;
  end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  if OpenDialog2.Execute then
  begin
    Image2.Picture.LoadFromFile(OpenDialog2.FileName);
    Edit2.Text := OpenDialog2.FileName;
  end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
  op: string;
  change: dword;
  valor: string;
begin
  valor := IntToStr(128);
  op := InputBox('Backup', 'Backup ?', 'Yes');
  if op = 'Yes' then
  begin
    CopyFile(PChar(Edit1.Text), PChar(ExtractFilePath(Application.ExeName) +
      'backup' + ExtractFileExt(Edit1.Text)), True);
  end;
  try
    begin
      change := BeginUpdateResourceW(PWideChar(wideString(Edit1.Text)), false);
      LoadIconGroupResourceW(change, PWideChar(wideString(valor)), 0,
        PWideChar(wideString(Edit2.Text)));
      EndUpdateResourceW(change, false);
      StatusBar1.Panels[0].Text := '[+] Changed !';
      Form1.StatusBar1.Update;
    end;
  except
    begin
      StatusBar1.Panels[0].Text := '[-] Error';
      Form1.StatusBar1.Update;
    end;
  end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
  Form2.Show;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
  Form1.Close();
  Form2.Close();
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  OpenDialog1.InitialDir := GetCurrentDir;
  OpenDialog2.InitialDir := GetCurrentDir;
  OpenDialog2.Filter := 'Icons|*.ico|';
end;
end.
Credits: Hackman
Browser other questions tagged delphi
You are not signed in. Login or sign up in order to post.