cs_yvesyves
Messages postés561Date d'inscriptionsamedi 10 janvier 2004StatutMembreDernière intervention11 octobre 2010
-
16 juil. 2008 à 21:43
cs_yvesyves
Messages postés561Date d'inscriptionsamedi 10 janvier 2004StatutMembreDernière intervention11 octobre 2010
-
17 juil. 2008 à 20:01
Bonjour,
Je voudrais rendre mon form invisible à son ouverture, c'est le formulaire principal de l'application. Je n'y suis pas arrivé. J'ai essayé de mettre Me.visible = false fans l'événement Load mais aucun effet.
cs_yvesyves
Messages postés561Date d'inscriptionsamedi 10 janvier 2004StatutMembreDernière intervention11 octobre 2010 16 juil. 2008 à 21:57
C'est pas bête comme idée mais le concepteur vs m'a crée un fichier applicationevents.vb et en commentaire ça parle de l'evenement startup déclenché avant la création du formulaire. On peut peut être y faire quelque chose nan?
Kevin.Ory
Messages postés840Date d'inscriptionmercredi 22 octobre 2003StatutMembreDernière intervention 7 janvier 200911 16 juil. 2008 à 22:24
Ce que tu peux faire c'est créer une "Sub Main" dans un module, et la spécifier comme routine de démarrage à la place du formulaire. Tu devra alors toi même gérer la fermeture du programme.
Mais sinon, impossible de faire autrement avec le formulaire de démarrage je pense. Il faut savoir que la méthode Load d'un contrôle (aussi bien pour une Form qu'un UserControl) est appelé lorsque le contrôle est affiché pour la 1ère fois.
En tout cas moi je met l'opacité à 0, et ça fonctionne parfaitement bien.
gillardg
Messages postés3275Date d'inscriptionjeudi 3 avril 2008StatutMembreDernière intervention14 septembre 20142 17 juil. 2008 à 00:20
il y a un moyen éssaie ceci :
Public
Class Form1
' If you just want the hot key, with no modifier
' use zero for the fsModifiers value (But this is a BAD IDEA).
Private
Const NoModKey
As
Integer = 0
' Modifier key constants
Private
Const MOD_ALT
As
Integer = 1
Private
Const MOD_CONTROL
As
Integer = 2
Private
Const MOD_SHIFT
As
Integer = 4
Private
Const MOD_WIN
As
Integer = 8
' Value indicating Windows Message is a hot key.
Protected
Friend
Const WM_HOTKEY
As
Integer = 786
' Unique ID for the atomic hot key.
Protected
Friend hotkeyID
As
Short
' Register hotkey
Protected
Friend
Declare
Function RegisterHotKey
Lib
"user32" (
ByVal hwnd
As IntPtr,
ByVal id
As
Integer,
ByVal fsModifiers
As
Integer,
ByVal vk
As Keys)
As
Integer
' Add global name for hotkey
Protected
Friend
Declare
Function GlobalAddAtomA
Lib
"kernel32" (
ByVal lpString
As
String)
As
Short
' Delete hotkey atom.
Protected
Friend
Declare
Function GlobalDeleteAtom
Lib
"kernel32" (
ByVal nAtom
As
Integer)
As
Short
' Unregister hotkey.
Protected
Friend
Declare
Function UnregisterHotKey
Lib
"user32" (
ByVal hwnd
As IntPtr,
ByVal id
As
Integer)
As
Integer
Private
Sub hotkey_Load()
' GlobalAddAtom adds the String to the System global
' atom table, and returns a unique number to identify
' it the atom table.hotkeyID = GlobalAddAtomA(
"GlobalHotKeyFor_MyUniqueAppName")
If hotkeyID = 0
ThenMessageBox.Show(
"Unable to generate the requested hotkey unique ID.",
"Error Making Hotkey ID")
Else
' Register the hot key combo used to show the form.
' I used Alt key modifier and the F1 key, Alt + F1,
' but you can use any key combo.
If RegisterHotKey(
Me.Handle, hotkeyID, MOD_ALT, Keys.F1) = 0
ThenMessageBox.Show(
"Unable to register the requested hotkey.",
"Error Registering Hotkey")
Else
'mettre la ligne suivante en commentaire pour la productionMessageBox.Show(
"The following Hotkey was registered for this application: " &
"Keys: Alt + F1",
"Hot Key Registered")
End
If
End
If
End
Sub
Private
Sub Form1_Closing(
ByVal sender
As
Object,
ByVal e
As System.ComponentModel.CancelEventArgs)
Handles
MyBase.Closing
' READ ME:
' You MUST unregister your Hot Key, or your application will leak memory.
If
Me.hotkeyID <> 0
ThenUnregisterHotKey(
Me.Handle, hotkeyID)
' Also delete the hot key atom. GlobalDeleteAtom(hotkeyID)
End
If
End
Sub
Protected
Overrides
Sub WndProc(
ByRef m
As System.Windows.Forms.Message)
' Check for our Windows Message Hotkey.
If m.Msg = WM_HOTKEY
Then
' Do something.
Me.Show()
Me.TopLevel =
True
End
If
' Return key messages to the application.
MyBase.WndProc(m)
End
Sub
Private
Sub Form1_Load(
ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles
MyBase.Load
Me.TopLevel =
False
' invisible dans la barre de taches et dans la liste des programmes ouverthotkey_Load()
End
SubEnd
Class
Les écologistes réclament une société propre les imbéciles nettoient