Re: Form's Icon



For those who are interested, I found the code that does what I was looking
for and it works perfectly:

'*********** Code Start ********
'Code courtesy of Klaus H. Probst
'// To be placed into a modulePublic 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

Public 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 Const WM_GETICON = &H7F
Public Const WM_SETICON = &H80
Public Const ICON_SMALL = 0
Public Const ICON_BIG = 1

'// LoadImage(), types d' image
Public Const IMAGE_BITMAP = 0
Public Const IMAGE_ICON = 1
Public Const IMAGE_CURSOR = 2
Public Const IMAGE_ENHMETAFILE = 3

'// LoadImage() flags
Public Const LR_DEFAULTCOLOR = &H0
Public Const LR_MONOCHROME = &H1
Public Const LR_COLOR = &H2
Public Const LR_COPYRETURNORG = &H4
Public Const LR_COPYDELETEORG = &H8
Public Const LR_LOADFROMFILE = &H10
Public Const LR_LOADTRANSPARENT = &H20
Public Const LR_DEFAULTSIZE = &H40
Public Const LR_LOADMAP3DCOLORS = &H1000
Public Const LR_CREATEDIBHeader = &H2000
Public Const LR_COPYFROMRESOURCE = &H4000
Public Const LR_SHARED = &H8000

Public Function SetFormIcon(hWnd As Long, IconPath As String) As Boolean
Dim hIcon As Long

hIcon = LoadImage(0&, IconPath, IMAGE_ICON, 16, 16, LR_LOADFROMFILE)

'// For small icons->wParam=1, for large icons->wParam=1
If hIcon <> 0 Then
Call SendMessage(hWnd, WM_SETICON, 0, ByVal hIcon)
SetFormIcon = True
End If
End Function
'*********** Code End********

"Warrio" <warrio@xxxxxxxxxxx> a écrit dans le message de news:
43b2a6ff$0$1156$5402220f@xxxxxxxxxxxxxxxxxx
> Hello!
>
> It is possible to set an icon for an Access database and the same icon for
> all its forms. But is it possible to set an different icon for each form?
>
> Thanks for any suggestion!
>
>


.



Relevant Pages

  • Re: Forms Icon
    ... 'Code courtesy of Klaus H. Probst ... Public Const WM_GETICON = &H7F ... If hIcon 0 Then ... > It is possible to set an icon for an Access database and the same icon for ...
    (microsoft.public.access.forms)
  • Re: Enumerate system tray
    ... >How do I make my own system tray and fill it with the appropriate icons, ... Private Sub Form_Unload ... 'this removes the icon from the system tray ... Public Const NIM_MODIFY = &H1 ...
    (microsoft.public.vb.winapi)
  • Re: Alt-tab icons
    ... How has the form been given its own custom icon? ... application then could it be that changing parent window to the desktop ... Public Const LR_LOADFROMFILE = &H10 ...
    (microsoft.public.vb.general.discussion)
  • Re: Alt-tab icons
    ... I'm adding the icon pretty much as you describe, ... SendMessage mFrmHwnd, WM_SETICON, ICON_SMALL, ByVal hIcon ... alt-tab list (because I've changed the form's parent to the desktop in order ... Public Const LR_LOADFROMFILE = &H10 ...
    (microsoft.public.vb.general.discussion)