criquio 21/12/2010, 00:04
Simples. Em um módulo, cole:
Option Compare Database
Option Explicit
Public strCaminho As String
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
Private Const WM_GETICON = &H7F
Private Const WM_SETICON = &H80
Private Const ICON_SMALL = 0
Private Const ICON_BIG = 1
Private Const IMAGE_BITMAP = 0
Private Const IMAGE_ICON = 1
Private Const IMAGE_CURSOR = 2
Private Const IMAGE_ENHMETAFILE = 3
Private Const LR_DEFAULTCOLOR = &H0
Private Const LR_MONOCHROME = &H1
Private Const LR_COLOR = &H2
Private Const LR_COPYRETURNORG = &H4
Private Const LR_COPYDELETEORG = &H8
Private Const LR_LOADFROMFILE = &H10
Private Const LR_LOADTRANSPARENT = &H20
Private Const LR_DEFAULTSIZE = &H40
Private Const LR_LOADMAP3DCOLORS = &H1000
Private Const LR_CREATEDIBHeader = &H2000
Private Const LR_COPYFROMRESOURCE = &H4000
Private Const LR_SHARED = &H8000
Function CurrentDbDir() As String
Dim strName As String
strName = Currentdb.Name
CurrentDbDir = Left(strName, Len(strName) - Len(Dir(strName)))
End Function
Function DefinirNomeAplicativo()
Dim intX As Integer
strCaminho = CurrentDbDir + "\Imagens\Icon.ico"
intX = AlterarPropriedade("AppTitle", dbText, "Título aqui")
intX = AlterarPropriedade("AppIcon", dbText, strCaminho)
RefreshTitleBar
End Function
Function AlterarPropriedade(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
On Error Resume Next
Dim prp As Property, DB As DAO.Database
Const conPropNotFoundError = 3270
Set DB = Currentdb
On Error GoTo Change_Err
DB.Properties(strPropName) = varPropValue
AlterarPropriedade = True
Change_Bye:
Set DB = Nothing
Exit Function
Change_Err:
If Err = conPropNotFoundError Then '
Set prp = DB.CreateProperty(strPropName, varPropType, varPropValue)
DB.Properties.Append prp
Resume Next
Else
AlterarPropriedade = False
Resume Change_Bye
End If
End Function
No formulário principal, coloque no evento "Ao carregar":
Call DefinirNomeAplicativo
Essa função muda o ícone e o título da janela do Access, caso ela esteja visível, bem como do botão na systray.
Observe as duas linhas em azul. Na parte vermelha dessas linhas você configura isso.