Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application Shortcut Icon

Status
Not open for further replies.

Shane1961

Programmer
Oct 1, 2015
14
0
0
AU
Hi all.
I have managed to programmatically display form and screen[_screen] ICON using a memo field in a business name [business.dbf]
table. However I am unable to transfer icon image to Application Shortcut Icon.
Many thanks.

 
To set up the exe icon, open your project, and Project->Project Info, then click attach icon in the lower right part of the window "Project information"

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Welcome to the forum.

Vilhelm-Ion has given you the correct answer. However, there is a little more you need to know. In order for the icon to appear correctly, the ICO file must contain two versions of the icon, one at 16 x 16, and the other at 32 x 32. The former will appear in folders (such as Windows Explorer or My Computer), and the latter in desktop shortcuts.

You can use any icon editor to create an ICO file with the correct images.

For further information, see Do your application icons always show up?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
In order to correctly display "medium icons" , "large icons", "extra large icons", you must create additional size of your icon (like 48x48, 64x64, 256x256)

More here
Icons (Windows)

Here is a set of VFP functions to manipulate icons and cursors
Each *** function from the package has a corresponding test***.prg
- cur2ico.prg convert cur(sor) to ico(n)
- ico2cur.prg convert ico(n) to cur(sor)
- genico.prg use one ore more png images (maximum 256x256) to create a ico / cur
- genicob.prg use one ore more bmp images (maximum 256x256) to create a ico / cur
- extractico.prg extract the compounding ico / cur from a multi ico / cur
(if the ico file contains 16x16 and 32x32 images, this functions creates two icons, on only with the 16x16 image, and the other containing only the 32x32 image)
- ico2img.prg extract the bmp / png images stored inside a ico / cur file

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Hi Mike.
I tried what you suggested. 1 at 16 x 16, and the other at 32 x 32.
I must confess I am a bit of a novice at DBMS programming, ie; I am not employed in the industry. !
But, I have managed to provide an option for the user to change their icon, ie; 'COMPANY LOGO' in their 'business details' form, as well as updating the main application screen icon.

However, I wish to provide an initial application icon in code, that is also the desktop shortcut icon. Whether that be cut & paste or during installation.

I need the desktop shortcut icon updated in code with the form and screen icon with user selection.

Can it be done ? Anything is possible (they say) :)
 
Well, Desktop Icons are higher Resolution, you Need to provide an ico with multiple Icons in more Resolution than just 16x16 and 32x32.

Up to 256x256. Then it'll automatically Show up.

If you do a shortcut and it has not set any Icon, you can choose a different Symbol, then browse to the exe and can pic the Icon from there. This is rather Windows Basics than VFP knowledge. Icons are either free files or resources from DLLs or EXEs and once you have an ico embedded in your VFP application exe via the Project info option, a shortcut can take it from there.

Bye, Olaf.
 
Shane, I'm not completely sure what you are asking.

You say you want to provide an "initial" icon, and you want to do it "in code". Do you mean you want to provide your own icon as a default? And that icon is to be part of the application at the point at which you install it? If so, then we have given you the answer: use the Project Info dialogue.

Or do you, for some reason, want to do the above programatically? In other words, you are happy to provide a default icon, but you don't want to actually go to the Project Info dialogue to select the relevant file? If so, you can execute a command like this, either from the command window or as part of your automated build process, if any:
[tt]
application.Projects(1).Icon = <path and name of ICO file>[/tt]

(For the above to work, you need the project to be open, and for it to be the only [or first] project open.)

If that's not what you are asking, perhaps you could clarify what you are trying to achieve.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Another thought: Maybe you mean you want the user to be able to select an icon as part of the installation process. If so, then you can certainly do that, but the method depends on which install utility you are using.

As an example, in Inno Setup, you would add some lines similar to the following to your script:

Code:
[Icons]
Name: "{group}\My Program"; Filename: "{app}\MYPROG.EXE"; WorkingDir: "{app}"; IconFilename: "{app}\myicon.ico"

For other installation utilities (e.g. InstallShield), check the documentation, or ask in an appropriate support forum.

Again, if this does not answer your question, please clarify.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Successfully tested.

Code:
losh = CreateObject("shell.application")
loFolder = losh.NameSpace(cPathToApplicationLink)
loItem = loFolder.ParseName(cApplicationLink.lnk)
loShortcut = loItem.GetLink
loShortcut.SetIconLocation(cExecutableOrDllFileWithFullPath, nIcon#FromIconsStoredInThisExecutable)
*like loShortcut.SetIconLocation("C:\Windows\System32\SHELL32.dll", 13)
loShortcut.Save

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Hi MikeLewis.
Sorry that I've been away.
Application.Projects(1).Icon=vNewIcon
The above code works perfect running the form in VFP9_2, updating the application icon, no problem.
However when I run the *.exe, this message appears.
Message OLE error code 0x80020003: Member not found. (80020003: MEMBER NOT FOUND)
Any help please.
 
Are you sure the OLE error code relates to the application icon? It doesn't sound likely to me, but it's easy to test it:

First, remove the icon, and see if the error goes away. If it doesn't, then the error has got nothing to do with your adding the icon. If it does go away, try adding the icon manually. If the error doesn't come back, then again the error has got nothing to do with the icon.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike.
Following is the code that allows the user to select an icon from explorer, changing the form,
screen and application icon. ie; it exists in Project Information waiting to be compiled \ generated.
Everything works except the last line of code, whilst running the application.


Local vNewIcon

vNewIcon = Getpict("ico")

Replace cTable.memofield With vNewIcon

Thisformset._image1.Picture = cTable.memofield

Save_Record()

Application.Projects(1).Icon=vNewIcon

Q:Also, do I need to recompile the application? If so, can this be done in run-time?

Many thanks ...
 
No, you can only access Application.Projects in the development environment. As I mentioned in my first post, it requires the project to be open, which can only happen in the development environment. It makes no sense to do it in a distributed executable. This is probably why you are getting that OLE error.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I thought I may have been trying the impossible, oh well.
Guess I'll have to get my head into manipulating class library's now. Wish me luck.
Thank you again Mike for your time and knowledge.
Much appreciated.
 
I don't know what the problem still is. The icon you set in the project info is put in the exe or dll you build. You only need to set this once for your project, no matter if by code or manually.

Bye, Olaf.
 
Olaf, I think what Shane is trying to achieve is to let the user assign their company logo as the application icon - and to do that at run time, in a distributed application.

If that's right, not only is it not possible to do that (as far as I know), but I'd argue that it is not a desirable thing to do. By all means let the user place their company logo on forms and reports, but the application icon belongs to the application, not the user. I don't know of any Windows application that lets the user change the application icon in this way.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Users have always had the ability to change an exe's icon. It's part of Windows Explorer. Right click the exe and use the "Change Icon" button.

That won't change it internally in forms inside the app. To do that, you'd need to give the user a similar button inside the application and then store their choice in a place where you can look it up when your app starts.

You cannot programmatically change the icon at runtime that is burned into the exe.
 
Yes, you can only change the icon in a shortcut, but the EXE icon remains the same. And now that we're on Windows 8+ the icon in the Start screen does not compare to the shortcut icon, it's taken from the EXE ,unless it's a modern EXE with code providing a tile graphic or even interactie info. Nothing you can do with VFP.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top