pinje
Messages postés129Date d'inscriptionvendredi 25 juillet 2003StatutMembreDernière intervention24 août 2006
-
12 avril 2006 à 12:00
mortalino
Messages postés6786Date d'inscriptionvendredi 16 décembre 2005StatutMembreDernière intervention21 décembre 2011
-
12 avril 2006 à 12:18
Bonjour a tous,
Je cherche a empecher la fermeture d'une Form en VB.NET version 2005.
Avec la version 2003 j'utilisais ca qui marchait tres bien, mais il veut pas sous 2005:
Private Sub FrmLayerEditor_Closing(ByVal sender As Object, ByVal eventArgs As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
eventArgs.Cancel = True
End Sub
Comment fait on pour empecher la fermeture d'une form sous vb 2005?
pinje
Messages postés129Date d'inscriptionvendredi 25 juillet 2003StatutMembreDernière intervention24 août 2006 12 avril 2006 à 12:04
C'est toujour quand on pose la question qu'on trouve...
Voici ce qui marche:
Private Sub FrmGISLayer_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = True
End Sub
mortalino
Messages postés6786Date d'inscriptionvendredi 16 décembre 2005StatutMembreDernière intervention21 décembre 201118 12 avril 2006 à 12:11
Salut !
Je ne te garantis pas que cette technique fonctionne en VB.net mais en VBA, c'est super, ça permet d'occulter la croix :
En haut, en déclaration de ta Form :
Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Puis dans l'initialize de ta Form :
Dim hwnd As Long
hwnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", Me.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
Seul bug qui peut apparaitre, c'est si tu changes le Texte du Caption de ta form, après chargement (suivant les besoins, ça peut arriver) dans ce cas, la croix revient.