Solved

Can you change icon dynamically in Delphi?

Posted on 2014-09-10
3
692 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
ConnectWise and their customers need to ensure critical alerts automatically reach the right person at the right time. MSP superheros efficiently respond to these alerts key is providing automatic, intelligent alerting that generates a complete audi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

839 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