The application is running from two different locations on a same station. I want different icons for each application, without having to rebuilt two executables with the good icon.
Create 2 shortcuts on the desktop or in a folder, then change the icon on each one. When you replace the exe, the shortcut icons will NOT be updated. Snaggs
tribesaddict@swbell.net
OK, it's an idea, but I'm worry with the task bar.
In fact, when you want to change the active task with the commande ALT-TAB, the visible icon will be always the same project icon and not the shortcut icon. Then the user who execute two sessions of the executable have a problem to know the selected task.
It's why I want to change exactly the project icon.
1. Include both icons in your project.
2. When you start an instance of your application you can get the path where the app is located. By testing this path you can set one icon or other depending of the result.
If doesn't matter the location, you can test if an instance of your application already run and change the icon for the second one.
Try this as a test. Create a new project with three forms. Assign different icons to Form2 and Form3. Form2 and 3 will srve no function other than to be containers for icons.
[tt]
Private Sub Form_Load()
If App.Path = "C:\MyPath" Then
[tab]Form1.Icon = Form2.Icon
Else
[tab]Form1.Icon = Form3.Icon
End Sub
[/tt]
If an instance of your app starts in "C:\MyPath" the icon for Form1 will be the icon for Form2, otherwise it will be the icon for Form3. Whenever the project is minimized you will be able to see the appropriate icon in the taskbar.
Include a default icon with your project (This is necessary in case my method fails) ;-)
Place the icon you want associated with the program in the same path as the program and rename it to appicon.ico
Here's a fragment
sIconFile = App.Path & "\appicon.ico"
If Dir(sIconFile) <> "" then
Form1.Icon = LoadPicture(sIconFile)
End If
This solution is good if you watch the taskbar at the bottom of the desktop.
My problem is to view different icons in the taskbar who appears in the center of screen when you type ALT-TAB.
And this method doesn't matter.
The project exist in two locations. I want a icon for each project / location, without having to built two projects :
one time with a first icon, two times with a other icon.
It's necessary to keep one project (for a elementary solution of installation and update of my software).
I believe you have already received more than one good answer. You just haven't stopped to consider it yet.
The icon associated with a given project is irrelevant. You can't see that icon unless it is associated with a form. If you are running multiple instances of an app you will see a unique icon for each in the taskbar. The icon associated with a form appears on the left side of a form's title bar. When you switch tasks and reveal a form you can identify the app instance by glancing at the title bar.
If you need to make the ID of the app more obvious you can place a timer on a form, set the interval to 100 and add this code:
[tt]
Private Sub Timer1_Timer()
If Form1.Caption = App.Path Then
Form1.Caption = ""
Else
Form1.Caption = App.Path
End If
End Sub
[/tt]
It should be pretty obvious which app instance is flashing its location five times every second. It would be a little hard to miss.
There is a totally different way to do this.
You can store the icons for your application in a resource file (use the resource editor in vb), and use a resource script to set a icon for the project.
I could explain it here, but there's a good explanation and a downloadable example at vbaccelerator:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.