SUMIR COM O "X" DA BORDA DO FORM

USUARIO.EXCLUIDOS 16/12/2003 09:58:59
#1170
Pessoal,
Será que alguém tem alguma função que deixa invisível o botão "x" da borda do form ?

Falow.


P.S. Quero fazer isso sem trocar a borda. Sem colocá-la como none...
USUARIO.EXCLUIDOS 16/12/2003 10:04:23
#1173
Resposta escolhida
Aí vai um exemplo:

This code shows how to disable the X-button on a form, to keep the user from closing a form that way. Ok, now I hear you saying that this can be done by simply setting the ControlBox property to false. Yes, but this can only be done at design time. This code allows you to disable the close button from code.


Call DisableX(MyForm)

MyForm is the name of the form you want to disable the X-button on.


Put the following code in a bas module
'//*********************************//'
Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long

Public Const MF_BYPOSITION = &H400&
Public Const MF_DISABLED = &H2&

Public Sub DisableX(Frm As Form)
Dim hMenu As Long, nCount As Long

'Get handle to system menu
hMenu = GetSystemMenu(Frm.hwnd, 0)

'Get number of items in menu
nCount = GetMenuItemCount(hMenu)

'Remove last item from system menu (last item is 'Close')
Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)

'Redraw menu
DrawMenuBar Frm.hwnd

End Sub

Como deve calcular este exemplo não é meu, ele foi encontrado algures na Internet. Mas o que é facto é que funciona e isso, julgo, é o que interessa.




Tópico encerrado , respostas não são mais permitidas