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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Icon in control box?

Status
Not open for further replies.

mike777

Programmer
Jun 3, 2000
387
US
Hello all.
Is there a way to change the icon in the upper left-hand corner of a form from the little MS Access Form icon, to the icon of my choice.
This is the part of the form that if you click it you get the "Move","Minimize","Maximize","Close","Restore" options.
Thank you for your help!!
-Mike
 
In the menu Tools->Startup there is an option called Application Icon. Enter the full path of the icon there or browse for it

Best of luck
 
MinusM,
Thanks for the word.
Thing is, though, I'm looking to replace the icon in the control box on a form, not the application window. I just checked, and if you change the application icon, the icons on the forms' control boxes stay the same.
What do you think.
Thanks again.
-Mike
 
Sorry for the delay,
As far as I know you can just SET THE CONTROLBOX property to No. Then this icon doesn't appear. I am not sure of whether you can insert your icon instead

Best of luck
 
A google search brought this code:
copy all of it into a module in your database:

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 GetSystemMetrics Lib "user32" (ByVal nIndex 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 put:
SetFormIcon Me.hwnd, "C:\xp.ico"
in the OnLoad event, passing the full path to the icon of your choice.


Cheers

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top