Change Access Icon (1 Viewer)

colinmunnelly

Registered User.
Local time
Today, 17:21
Joined
Feb 26, 2002
Messages
89
Does any one know if it is possible to change the icon of an access batabase. I have selected an icon within the startup menu and this changes the icon to the top left hand cornere when i am within the program. What i want to change is the icon that appears on the users desktop.
 

ghudson

Registered User.
Local time
Today, 12:21
Joined
Jun 8, 2002
Messages
6,195
Right click on the Desktop icon and select the Properties option and then click the Change Icon... button.

HTH
 

Trevor Howard

Registered User.
Local time
Today, 17:21
Joined
Aug 29, 2002
Messages
64
Oldsoftboss

Do you have a copy of the icon zip, if you have, could you email it to me please?

Your link draws a blank, looks like the site has closed down.

Thanks!
Trevor:)
 

kybb1

Registered User.
Local time
Today, 17:21
Joined
Dec 17, 2002
Messages
29
I too would....

like to know if you could email me the zip if you have it.

Thanks.
 

Oldsoftboss

AWF VIP
Local time
Tomorrow, 02:21
Joined
Oct 28, 2001
Messages
2,499
Sorry... I updated the web site and deleted the zip files (Ran out of web space:( )

Add the following code to a module:

Option Compare Database

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


Then there are 2 ways of getting an icon on each form:

SetFormIcon Me.hWnd, "C:\My Documents\myicon.ico" 'Location of icon file

or

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

The first example sets the path for the icon, the second will look for the icon in the same directory / folder as your .mdb is located.

I use the second way and then simply store the icons and mdb together.

HTH

Dave
 

kybb1

Registered User.
Local time
Today, 17:21
Joined
Dec 17, 2002
Messages
29
Icon

thanks....but the dummy that I am...not sure where to put:

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


If I put it in the line just above "End Function" nothing happens, if I put it in the OnLoad event of a form...an ambiguous error msg pops up...I know...I know...I am a dummy...

Can you tell me where this code is suppose to go?

Thanks.
 

Users who are viewing this thread

Top Bottom