SUMIR COM O "X" DA BORDA DO FORM

 Tópico anterior Próximo tópico Novo tópico

SUMIR COM O [�]X[�] DA BORDA DO FORM

VB / VBA

 Compartilhe  Compartilhe  Compartilhe
#1170 - 16/12/2003 09:58:59

USUARIO.EXCLUIDOS

Cadast. em:


Pessoal,
Ser que algum tem alguma funo que deixa invisvel o boto "x" da borda do form ?

Falow.


P.S. Quero fazer isso sem trocar a borda. Sem coloc-la como none...



Resposta escolhida #1173 - 16/12/2003 10:04:23

USUARIO.EXCLUIDOS

Cadast. em:


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 no meu, ele foi encontrado algures na Internet. Mas o que facto que funciona e isso, julgo, o que interessa.








 Tópico anterior Próximo tópico Novo tópico


Tópico encerrado, respostas não sao permitidas
Encerrado por WEBMASTER em 18/08/2009 10:03:45