Solved

Can you change icon dynamically in Delphi?

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Let's take a look back at the commercialization of the internet to understand why keeping it open and neutral is in our best interest as a society.
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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