Fale irmão Mauro, só na manhaaaaa
Vamos lá filhão
Erikson, vou aqui buscar lhe ajudar, certo
Vamos com calma e cautela para não escorregar......
Primeiro - temos um UserForm, um CheckBox1 e dois CommandButton1
Pois bem no UserForm inserimos o seguinte código
Código: Selecionar todos
Option Explicit
Dim mclsFormChanger As CFormChanger
Private Sub UserForm_Activate()
Set mclsFormChanger = New CFormChanger
cbIcon.Value = False
Set mclsFormChanger.Form = Me
End Sub
Private Sub cbIcon_Change()
mclsFormChanger.ShowIcon = cbIcon.Value
If cbIcon.Value And mclsFormChanger.IconPath = "" Then btnChangeIcon_Click
CheckEnabled
End Sub
Private Sub btnChangeIcon_Click()
Dim vFile As Variant
vFile = Application.GetOpenFilename("Icon files (*.ico;*.exe;*.dll),*.ico;*.exe;*.dll", 0, "Open Icon File", "Open", False)
If vFile = False Then Exit Sub
mclsFormChanger.IconPath = vFile
End Sub
Private Sub btnOK_Click()
Unload Me
End Sub
Private Sub CheckEnabled()
btnChangeIcon.Enabled = cbIcon.Value And cbIcon.Enabled
End Sub
Eita isso é um melzinho na chupeta em filhão . . .
Mais se acalme para não alterar seus batimentos cardíacos, muita calma nesta hora
Vamos para o próximo passo, estais pronto já tomou um pouco e água, molhou a cabecinha para esfriar, pois bem vamos lá
Agora vamos para a Classe, mais antes QUESTÃO DE VESTIBULAR para a provação, no código acima já foi feita a referencia para a Classe, QUAL SERIA O NOME DA CLASSE? A pergunta de Um Milhão de dólares, hei qual é?
Hummm, não sabeeeee, maaaissss não se preoculpe o titio vai lhe dizer, ou melhor lhe mostrar é é é é é é é, isso mesmo filho ” CFormChanger”
Aqui vamos disponibilizar o código . . . .
Código: Selecionar todos
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hWndLock As Long) As Long
Private Const WS_EX_APPWINDOW As Long = &H40000 'Application Window: shown on taskbar
Private Const WS_EX_TOOLWINDOW As Long = &H80 'Tool Window: small titlebar
Private Const WM_SETICON = &H80
Dim mbSizeable As Boolean, mbCaption As Boolean, mbIcon As Boolean
Dim msIconPath As String
Dim mhWndForm As Long
Public Property Set Form(oForm As Object)
If Val(Application.Version) < 9 Then
mhWndForm = FindWindow("ThunderXFrame", oForm.Caption) 'XL97 Muito cuidado
Else
mhWndForm = FindWindow("ThunderDFrame", oForm.Caption) 'XL2000+ Muito cuidado
End If
ChangeIcon
End Property
Public Property Let ShowIcon(bIcon As Boolean)
mbIcon = Not bIcon
ChangeIcon
End Property
Public Property Get ShowIcon() As Boolean
ShowIcon = (mbIcon <> 1)
End Property
Public Property Let IconPath(sNewPath As String)
msIconPath = sNewPath
ChangeIcon
End Property
Public Property Get IconPath() As String
IconPath = msIconPath
End Property
Private Sub SetBit(ByRef lStyle As Long, ByVal lBit As Long, ByVal bOn As Boolean)
If bOn Then
lStyle = lStyle Or lBit
Else
lStyle = lStyle And Not lBit
End If
End Sub
Private Sub ChangeIcon()
Dim hIcon As Long
On Error Resume Next
If mhWndForm <> 0 Then
Err.Clear
If msIconPath = "" Then
hIcon = 0
ElseIf Dir(msIconPath) = "" Then
hIcon = 0
ElseIf Err.Number <> 0 Then
hIcon = 0
ElseIf Not mbIcon Then
hIcon = ExtractIcon(0, msIconPath, 0)
Else
hIcon = 0
End If
SendMessage mhWndForm, WM_SETICON, True, hIcon
SendMessage mhWndForm, WM_SETICON, False, hIcon
End If
End Sub
Prontinho espero ter ajudado, hááá não deixe de acompanhar com a sua planilha. Espero ter ajudado.
Duvida
Aproveito para agradecer pelas ajudas que tenho recebido neste fórum.
MUITO OBRIGADO
Melo
Josielgestor.com.br