Application Icon

Eddie Mason

Registered User.
Local time
Today, 09:18
Joined
Jan 31, 2003
Messages
142
Hi All,

With applications sent out to clients using the set-up created by the packing wizard, I find that when the end user decides not to use the default folder, that the application icon I provide gets lost, the program icon reverts to the Microsoft default Access icon. I’ve tried putting $\(AppPath)\My.ico in the application start up but this does not work. Can anyone help with this?

Regards

Eddie
 
Eddie,

Set you icon to application startup as MyIcon.ico ( or whatever the name is) then when packaging the program in the install path but $AppPath.

This should install this install the Icon in the same dir as your program. The icon will need to be relative to the program so don't put any \ or / before or after Myicon.ico.

This should do the trick, Hopefully.

Andy
 
Hi Andy,

I’ve tried what you recommended and it does writes the icon file to the directory specified by the client, however it leaves the path in the icon start up as the default that I set. e.g. C:\RM2000\MyIcon.Ico, so Access cannot see it and reverts to the default icon.

Regards

Eddie
 
Eddie,

Just set the icon path as : Myicon.ico .(just the filename)
Do not put C:\......

This should set the icon path to read from the installed dir.

Andy
 
Hi Andy,

I’m sorry I am sure its me, but when I go into the application icon in set up, and delete the path leaving it as: myicon.ico, when I press OK, I get an error message ‘The application is unable to set the application icon to the file ‘myicon.ico’. Make sure the file is a valid Icon (ico) file. If your using windows, you can also use .bmp files.

When I exit the set up the icon has reverted to the Microsoft default icon, but, the setup still retains myicon.ico

Regards

Eddie
 
Eddie,

Sorry I misread the post, I was assuming you were packaging a vb program but your not.

Ok try this:

Copy the icon in c:\Windows\System32 folder
Set the application Icon to that file then

In the packaging wizard set the install location to $winsyspath

What this should do is because the user can change the install path, there is no way of setting the icon apart from the suggestion above.

Basically the Windows/System folder will always be there, so this is the ideal place for the icon.

Andy
 
Hi Andy,

Your a hero, everything is working perfectly, many thanks.

Regards

Eddie
 
I use the following fuction in a module, I suppose you use the same,

Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long

Private Const WM_SETICON = &H80
Private Const IMAGE_ICON = 1
Private Const LR_LOADFROMFILE = &H10
Private Const SM_CXSMICON As Long = 49
Private Const SM_CYSMICON As Long = 50

Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, LParam As Any) As Long

Public Function SetFormIcon(hWnd As Long, strIconPath As String) As Boolean
Dim lIcon As Long
Dim lResult As Long
Dim X As Long, Y As Long

X = GetSystemMetrics(SM_CXSMICON)
Y = GetSystemMetrics(SM_CYSMICON)
lIcon = LoadImage(0, strIconPath, 1, X, Y, LR_LOADFROMFILE)
lResult = SendMessage(hWnd, WM_SETICON, 0, ByVal lIcon)
End Function



And then in the Form_Load event:

SetFormIcon Me.hWnd, Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & "\MyIcon.ico"

This gets the current Db path and looks for the icon there.

Then the installation package installs everything in the same directory, no matter where it is.

HTH

Dave
 
Hi Dave,

Many thanks for the advice; I've certainly learnt something today. I never realised that you could customise the form icons. It was actually the application icon that I was concerned about, but thanks to your advice I can now add a new dimension to the customised look of my applications.

Regards

Eddie
 
On the On Load event of a splash form (which is the first to open) I put:

Private Sub Form_Load()
Dim intX As Integer
Dim s As String

s = Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & "\MyIcon.ico"
Const DB_Text As Long = 10
intX = AddAppProperty("AppTitle", DB_Text, "Your App Name - " & Format(Date, "long Date"))
intX = AddAppProperty("AppIcon", DB_Text, s)
Application.RefreshTitleBar

'Code to hide windows in taskbar and ensure Hidden Objects are hidden
Application.SetOption "ShowWindowsinTaskbar", False
Application.SetOption "Show Hidden Objects", False
Application.SetOption "Show Status Bar", False

End Sub

Function AddAppProperty(strName As String, varType As Variant, varValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo AddProp_Err
dbs.Properties(strName) = varValue
AddAppProperty = True

AddProp_Bye:
Exit Function

AddProp_Err:
If Err = conPropNotFoundError Then
Set prp = dbs.CreateProperty(strName, varType, varValue)
dbs.Properties.Append prp
Resume
Else
AddAppProperty = False
Resume AddProp_Bye
End If

End Function

This way the application icon and title are automatically set.

Also (A2000)

Application.SetOption "ShowWindowsinTaskbar", False
Application.SetOption "Show Hidden Objects", False
Application.SetOption "Show Status Bar", False

sets the options as indicated.

Dave
 
Hi Dave,

Many thanks for that fix, it makes life such a lot easier.

Regards

Eddie:D
 
Hi Dave:

I tried using your code for adding custom icon to the forms. But it doesn't seem to work. Can you please take a look at it. I am attaching the db and ico file.

Thanks
-Ekta
 

Attachments

Last edited:
Ekta,

Just added the code Dave had posted and changed the icon path to the icon you included and it works.

See attached db. You will just need to amend the icon path in the form load event, as I changed it to the same dir as the db.

Regards

Andy
 

Attachments

I have changed the icons on the forms, however what I really want to do is change the icon which appears on the task bar when the datadase is open. My users used a number of different databases and I would like each database and the forms for each database to have different icons on the task bar. Is this possible.
 
If you set an icon in the Tools -> Startup, this icon will be displayed in the top LH corner of the Access window and it will also be displayed against your app name in the taskbar.

HTH

Dae
 

Users who are viewing this thread

Back
Top Bottom