Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Visual basic form
Message
De
15/07/2002 11:50:28
 
 
À
15/07/2002 10:31:24
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00678677
Message ID:
00678721
Vues:
11
In VB, there's no way; you can achieve this only with API functions. Here is sample code; put on the form two buttons (Command1 disables close button, Command2 re-enables it), paste code and test it.
Private Const CS_NOCLOSE = &H200
Private Const GCL_STYLE = (-26)
Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Sub Command1_Click()
  Dim style As Long
  style = GetClassLong(hwnd, GCL_STYLE)
  SetClassLong hwnd, GCL_STYLE, style Or CS_NOCLOSE
  Refresh
End Sub

Private Sub Command2_Click()
  Dim style As Long
  style = GetClassLong(hwnd, GCL_STYLE)
  SetClassLong hwnd, GCL_STYLE, style And (Not CS_NOCLOSE)
  Refresh
End Sub
CAUTION: This code modifies the class, from which VB creates its form. I.e. ALL FORMS INTO THE PROJECT WILL HAVE DISABLED CLOSE BUTTON UNTIL YOU RESTART VB OR RE-ENABLE CLOSE BUTTON!!!

Plamen Ivanov
MCSD .NET Early Achiever and MCAD .NET Charter Member (VB .NET/SQL Server 2000)
MCSD (VB 6.0/SQL Server 2000)

VB (.NET) - what other language do you need in the whole Universe?...

Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform