Solved

Can you change icon dynamically in Delphi?

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

Expert Comment

by:Sinisa Vuk
Comment Utility
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
Comment Utility
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
Comment Utility
My problem - my solution, admittedly with encouragement to have another look at the code.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now