Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding an icon to a library and not a progrm? 2

Status
Not open for further replies.

pierrotsc

Programmer
Nov 25, 2007
358
US
I am coding a photoshop filter and it is a library, not aprogram. When i go under options to add an icon to it, it is dimmed. Is there a way, I can add an icon to be shown on the top left of the menu bar?
Thanks.
PO
 
You mean you're making a DLL where you're trying to code an icon into it as a default? Not sure I'm understanding what you're looking to do?

----------
Measurement is not management.
 
The extension is 8bf for a photoshop filter.
Here what the main file looks like:
library POFilter;
{$E 8BF}
{$R *.res}
{$DEFINE PSSDK}



uses
FilterCore in 'FilterCore.pas',
NoiseFilter in 'NoiseFilter.pas' {NoiseForm},
PSAboutBox in 'PSAboutBox.pas';

end.

Does that help?
Thanks.
 
A little. So we've established you're making a DLL. So where do you want this icon to end up? You can't go into options and select an icon (it's greyed out) because this is not a full project (to EXE). So basically you have a form of some kind, and instead of the default Delphi icon on the corner you want your icon? Or are you wanting it to show your icon instead of the typical DLL icon in explorer?

----------
Measurement is not management.
 
I'm sure someone else might know, but I couldn't figure it out. I created a library with a VCL form in it and it didn't show the icon in either, but once I renamed it to EXE it did.

Probably something special with how Windows handles files - it must go looking for icons if it finds a file with EXE extension.

Sorry I couldn't be of any more help.

----------
Measurement is not management.
 
with an EXE file, windows will look for a MAINICON resource and use that. with a DLL you must include yourself an icon in the resource and load it and assign it on form creation.

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Okay, I didn't think of doing that. It works as far as VCL goes.

For the OP, this locates the mainicon resource and loads it up into the Application.Icon as part of the DLL initialization - actually I can include an icon as described above:

Code:
library printdll; uses Forms, Windows,
  pdll in 'pdll.pas' {Form1};

{$R *.RES}
procedure showmenu;
  begin
    Application.Run;
  end;

exports
  showmenu index 1;
var
  HI: HIcon;
  H: THandle;
begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  H := LoadLibrary('PRINTDLL.DLL');
  try
    HI := LoadIcon(h, PCHAR('MAINICON'));
    Application.Icon.Handle := HI;
  finally
    FreeLibrary(H);
  end;
end.

No picture of my icon in explorer, but it shows up on the form and the taskbar now.

----------
Measurement is not management.
 
Ok, I figure out on how to do the explorer part. Just right click on the file and under property, you can change its icon.
Now i guess i need to create a res file with my icon inside. I may have to google it as I never did it. I already have an ico ready.
Do I have to create a text file with an rc extension and add one line of text inside with my icon's name?
Thanks.
PO
 
Process described here:

thread102-1439357


----------
Measurement is not management.
 
Ok, i'm getting there. Now instead of a generic blank exe icon, i get the delphi 7 icon.
I have the command ($R *.res}
Does that mean the the program looks for all the res files in the working directory?
I tried to write ($R mainicon.res} but then the program is not recognized under the photoshop plugins anymore.
Do i need a special size too? I think my icon is 48x48. I may want to go smaller.
Thanks for all the help and tips.
 
Got it....I just had to edit the main res file...It works now....Thanks for pointing me to the right direction with your code.
PO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top