Página 1 de 1

Retirar o botão X do formulário na versão 64 bits

Enviado: 17 Out 2020 às 09:08
por batistathor
bom dia ,
estou tentando desenvolver um programa de vendas no excel ,sendo que o meu código para remover o botão x do formulario so funciona na versão 32 bits
gostaria de converte esse codigo para 64 bits

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) 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 DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Sub removeCaption(objForm As Object)
Dim lStyle As Long
Dim hMenu As Long
Dim mhWndForm As Long

If Val(Application.Version) < 9 Then
mhWndForm = FindWindow("ThunderXFrame", objForm.Caption) 'XL97
Else
mhWndForm = FindWindow("ThunderDFrame", objForm.Caption) 'XL2000+
End If

lStyle = GetWindowLong(mhWndForm, -16)
lStyle = lStyle And Not &HC00000
SetWindowLong mhWndForm, -16, lStyle
DrawMenuBar mhWndForm

End Sub

Re: Retirar o botão X do formulário na versão 64 bits

Enviado: 17 Out 2020 às 14:17
por fcarlosc2018
Boa-tarde

Tente assim:

Public Declare Function >> altere para >> Public Declare PtrSafe Function
Private Declare Function >> altere para >> Private Declare PtrSafe Function

Não fiz nenhum teste porque meu Office é 32 bits, mas acredito que resolva.

Att,
Francisco

Re: Retirar o botão X do formulário na versão 64 bits

Enviado: 17 Out 2020 às 17:12
por gfranco
Amigo,
veja se atende: