Rendre le focus à une appli non vb

Résolu
cs_tistouille Messages postés 3 Date d'inscription jeudi 6 avril 2006 Statut Membre Dernière intervention 19 avril 2007 - 19 avril 2007 à 11:26
cs_tistouille Messages postés 3 Date d'inscription jeudi 6 avril 2006 Statut Membre Dernière intervention 19 avril 2007 - 19 avril 2007 à 14:06
Bonjour,

Je suis sur l'appli X et j'ai donc le focus dessus, un événement se produit suite à un timer dans mon appli en vb et prend du coup le focus mon appli vb prend le focus, je cherche à rendre le focus immédiatement à la fenetre de l'appli non vb précédenment active, une idée ?

Merci d'avance.

8 réponses

drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
19 avril 2007 à 13:45
Exemple:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Integer) As Integer

Dim hwnd As Ineger

hwnd = CInt(FindWindow(vbNullString, "TitreDeLaForm"))
SetForegroundWindow(hwnd), ----
(Coloration syntaxique automatique par Kenji)

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
3
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
19 avril 2007 à 11:48
Salut, regarde du côté des API setforgroundwindow et findwindow!

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0
cs_tistouille Messages postés 3 Date d'inscription jeudi 6 avril 2006 Statut Membre Dernière intervention 19 avril 2007
19 avril 2007 à 13:37
Je suis débutant, et la j'ai bien peur de ne pas voir comment faire :(
0
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
19 avril 2007 à 13:40
Fait tour sur www.allapi.net pour plus d'explication!

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
19 avril 2007 à 13:41
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

· lpClassName
Points to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpClassName; the high-order word must be zero.


· lpWindowName
Points to a null-terminated string that specifies the window name (the window’s title). If this parameter is NULL, all window names match.

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
19 avril 2007 à 13:41
Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long

· hWnd
Identifies the window that should be activated and brought to the foreground.

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
19 avril 2007 à 13:42
Attention les types Long sont à modifier en Integer en .Net!

 Drikce 06

Si la réponse vous convient: Réponse acceptée. Si la réponse vous convient pas:
0
cs_tistouille Messages postés 3 Date d'inscription jeudi 6 avril 2006 Statut Membre Dernière intervention 19 avril 2007
19 avril 2007 à 14:06
Merci bcp! Ca fonctionne parfaitement :)
0
Rejoignez-nous