Solved

Can you change icon dynamically in Delphi?

Posted on 2014-09-10
3
666 Views
Last Modified: 2014-09-16
Back in the old-old days, I could change an application icon dynamically in the program code,

e.g. application.Icon.LoadFromResourceName(hInstance,'XIcon_Spanish');

This code now does not work; it appears that you can only set the icon through the options screen.
0
Comment
Question by:GrahamDLovell
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 40318135
Works for me - win 7 + Delphi 2007 + 4 bit , 16 bit, 32 bit icons....
You are sure that icon is in resource file? (use resource hacker application and look in exe)
Name of icon should be upper cased: XICON_SPANISH
0
 

Accepted Solution

by:
GrahamDLovell earned 0 total points
ID: 40318364
Thanks for the encouragement to look for the coding problem.

My application has the form name "fMain", so the code should have been:

fMain.Icon.LoadFromResourceName(hInstance,'XIcon_Spanish');

Simple. I am not sure whether it works the same way in Delphi 2007 - I am on XE6.

I have now realised that the run-time icon name serves a different purpose (as a Windows interface, not on the form).

BTW: I changed the resource icon name to upper case, but the compiler changed it back to the mixed case - I am not sure what the resource hacker would show.
0
 

Author Closing Comment

by:GrahamDLovell
ID: 40324961
My problem - my solution, admittedly with encouragement to have another look at the code.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Knowing where your website is hosted is as important as the features you receive, the monthly fee, and the support you receive. Due diligence should be done when choosing your next hosting provider.
The question appears often enough, how do I transfer my data from my old server to the new server while preserving file shares, share permissions, and NTFS permisions.  Here are my tips for handling such a transfer.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question