?
Solved

Can you change icon dynamically in Delphi?

Posted on 2014-09-10
3
Medium Priority
?
885 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

If you’re involved with your company’s wide area network (WAN), you’ve probably heard about SD-WANs. They’re the “boy wonder” of networking, ostensibly allowing companies to replace expensive MPLS lines with low-cost Internet access. But, are they …
By default Outlook 2016 displays only one time zone in the Calendar. The following article explains how to display two time zones in one calendar view.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

718 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