We help IT Professionals succeed at work.

res file

hugh34
hugh34 asked
on
i have created a res file ok when i was putting bitmaps into them.

i used the following code in wordpad and saved it as bitmap.rc and draged it over brcc32.exe and it compiled my res file.

PIC1 BITMAP Starta.bmp
PIC2 BITMAP Startb.bmp
PIC3 BITMAP Startc.bmp
PIC4 BITMAP Startd.bmp
pic5 bitmap Starte.bmp
pic6 bitmap Startf.bmp


the problem is how can i make a res file using wordpad with ICONS in it?

i tried the following, but could not get it to compile into a res file!! Can someone please Tell me step-by-step how i can modify this so that i can get it to compile into a res WITHOUT using delphi's image editor!!!

thanx

hugh

PIC1 ICON Recycle Bin.ico
PIC2 ICON My Computer.ico
PIC3 ICON My Documents.ico

and when its compiled how can i call it into an image in delphi? can i used

Image1.Picture.Bitmap.LoadFromResourceName(hInstance,'ICON1');
Comment
Watch Question

Commented:
For icons, you are going to want to use the LoadIcon function which returns a handle to the icon:


Image1.Picture.Icon.Handle:=LoadIcon(hinstance,'Pic1')


*PS -Watch the names of your resources when you do this...'Icon1' isn't in the Res file you described.


Good luck!!

Commented:
For icons, you are going to want to use the LoadIcon function which returns a handle to the icon:


Image1.Picture.Icon.Handle:=LoadIcon(hinstance,'Pic1')


*PS -Watch the names of your resources when you do this...'Icon1' isn't in the Res file you described.


Good luck!!

Commented:
ooops! I seem to have stuttered a little there, s-s-s-sorry!<g>

Commented:
BTW, I forgot to mention that you'll probably find it easier in the long run to rename your icon files to something that does not contain spaces. BRCC32 sometimes burps on them (at least in my experience), and since you are going to be referencing the name of the resource rather than the file anyway, it won't change anything in terms of how you code. Food for thought. Now back to our regularly scheduled program, already in progress.....


Author

Commented:
thanx for the comments but HOW CAN I COMPILE THE ICONS INTO A RESOURCE FILE USING WORDPAD?

CAN SOMEONE GIVE ME AN EXAMPLE?

PLEASE

hugh

Author

Commented:
back again but with another problem


i managed to get the rc file compiled into a res file called "Icon.RES"
the contents of the rc file is shown below. Now i put the res file into
my project directory and put "{$resource Icon.RES} into my code as
shown below, i then tried to call an icon from the res file into an
image via a button click with the code below! The program compiles fine
but when i click on the button NOTHING happens! the images are still
BLANK!!!

can someone PLEASE PLEASE help me with this problem!

thanx

hugh


------------------------------------------
Icon1    ICO  "Recycle Bin.ico"
Icon2    ICO  "My Computer.ico"
Icon3    ICO  "My Documents.ico"

------------------------------------------
var
  Form1: TForm1;

implementation

{$R *.DFM}
{$resource Icon.RES}

procedure TForm1.Button1Click(Sender: TObject);
begin
Image1.Picture.Icon.Handle:=LoadIcon(hinstance,'Icon1');
Image2.Picture.Icon.Handle:=LoadIcon(hInstance,'Icon2');

end;

end.

Author

Commented:
PLEASE can someone help me A.S.A.P!
listening.....

Hi Hugh34
I tried to find you a solution and ended up with the identical problem you came up with.<drat!>
If at first....... etc
T.
Hi again.

I just searched the PAQs and found this:

http://www.experts-exchange.com/jsp/qShow.jsp?qid=20142074

Good luck
T.
Hi Hugh34, Thanks for the points.... now I will earn them;)
This will be useful for future resource files. I created this and tested it in D3 and it works ok;
/////////////////////////////////////////////{ //CREATING RESOURCE FILES// <<<ICONS>>>>
(1) create a new folder on desktop named RESOURCES
(2) Open your Delphi/Bin folder and copy these two files
to your newly created RESOURCES folder: Brcc32 and Rw32core.dll
(3) Name two icons, eg: A.ico & B.ico and place in RESOURCES folder
(4) Open Notepad and type the following:
   ICON_1 ICON "A.ico"
   ICON_2 ICON "B.ico"
(5) Save file as MyRes, Place in RESOURCES folder
(6) You now have a text file called MyRes, drag and drop this file on
Brcc32.exe // A file called MyRes.RES will be automatically
created.
(7) place the MyRes.RES file into your Delphi Project folder

(8) In your new Delphi project drop two TImage containers and
Two buttons on your Form1
(9) paste the code below into your Unit1
(10) Compile and run the application }

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
{$R myres.res}
procedure TForm1.Button1Click(Sender: TObject);

begin

     Image1.Picture.Icon.Handle := LoadIcon(HInstance ,'ICON_1');

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
     Image2.picture.icon.handle:=loadicon(Hinstance,'ICON_2');
end;

end.
/////////////////////////////////////////////////
Have fun.... I did creating this:)
Tongalite.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.