Comment puis-je forcer une fenêtre à passer au premier plan quand je passe
de « Windowstate=1 » à « Windowstate=0 », déclancher par un évènement
« Timer » alors qu’il y déjà a une fenêtre d’un autre programme en plein
écran.
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Jacques93
Bonjour Le vent, Le vent de l''''est a écrit :
Bonjours,
Comment puis-je forcer une fenêtre à passer au premier plan quand je passe de « Windowstate=1 » à « Windowstate=0 », déclancher par un évènement « Timer » alors qu’il y déjà a une fenêtre d’un autre programme en plein écran.
Ce n'est peut être pas la meilleure idée, dans la mesure où ce genre de comportement peut pertuber l'utilisateur, mais bon, c'est toi qui voie, tu peux essayer ceci :
Private Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hWnd As Long, lpdwProcessId As Long) As Long Private Declare Function AttachThreadInput Lib "user32" _ (ByVal idAttach As Long, ByVal idAttachTo As Long, _ ByVal fAttach As Long) As Long Private Declare Function IsIconic Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function GetForegroundWindow Lib "user32" _ () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _ Optional bRestoreIconic As Boolean = False) Dim ThreadID1 As Long, ThreadID2 As Long Dim X As Long
' Nouveau comportement de SetForeGroundWindow ' La fenêtre à activer doit appartenir au Thread appelant If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then X = AttachThreadInput(ThreadID1, ThreadID2, True) X = SetForegroundWindow(newHwnd) X = AttachThreadInput(ThreadID1, ThreadID2, True) Else X = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) And bRestoreIconic = True Then X = ShowWindow(newHwnd, SW_RESTORE) Else X = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub
Private Sub Timer1_Timer() [...] If Me.WindowState = 0 Then ForceForeGroundWindow Me.hWnd End If End Sub
-- Cordialement,
Jacques.
Bonjour Le vent,
Le vent de l''''est a écrit :
Bonjours,
Comment puis-je forcer une fenêtre à passer au premier plan quand je passe
de « Windowstate=1 » à « Windowstate=0 », déclancher par un évènement
« Timer » alors qu’il y déjà a une fenêtre d’un autre programme en plein
écran.
Ce n'est peut être pas la meilleure idée, dans la mesure où ce genre de
comportement peut pertuber l'utilisateur, mais bon, c'est toi qui voie,
tu peux essayer ceci :
Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function AttachThreadInput Lib "user32" _
(ByVal idAttach As Long, ByVal idAttachTo As Long, _
ByVal fAttach As Long) As Long
Private Declare Function IsIconic Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" _
() As Long
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _
Optional bRestoreIconic As Boolean = False)
Dim ThreadID1 As Long, ThreadID2 As Long
Dim X As Long
' Nouveau comportement de SetForeGroundWindow
' La fenêtre à activer doit appartenir au Thread appelant
If newHwnd = GetForegroundWindow() Then
Exit Sub
Else
ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0)
ThreadID2 = GetWindowThreadProcessId(newHwnd, 0)
If ThreadID1 <> ThreadID2 Then
X = AttachThreadInput(ThreadID1, ThreadID2, True)
X = SetForegroundWindow(newHwnd)
X = AttachThreadInput(ThreadID1, ThreadID2, True)
Else
X = SetForegroundWindow(newHwnd)
End If
If IsIconic(newHwnd) And bRestoreIconic = True Then
X = ShowWindow(newHwnd, SW_RESTORE)
Else
X = ShowWindow(newHwnd, SW_SHOW)
End If
End If
End Sub
Private Sub Timer1_Timer()
[...]
If Me.WindowState = 0 Then
ForceForeGroundWindow Me.hWnd
End If
End Sub
Comment puis-je forcer une fenêtre à passer au premier plan quand je passe de « Windowstate=1 » à « Windowstate=0 », déclancher par un évènement « Timer » alors qu’il y déjà a une fenêtre d’un autre programme en plein écran.
Ce n'est peut être pas la meilleure idée, dans la mesure où ce genre de comportement peut pertuber l'utilisateur, mais bon, c'est toi qui voie, tu peux essayer ceci :
Private Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hWnd As Long, lpdwProcessId As Long) As Long Private Declare Function AttachThreadInput Lib "user32" _ (ByVal idAttach As Long, ByVal idAttachTo As Long, _ ByVal fAttach As Long) As Long Private Declare Function IsIconic Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function GetForegroundWindow Lib "user32" _ () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _ Optional bRestoreIconic As Boolean = False) Dim ThreadID1 As Long, ThreadID2 As Long Dim X As Long
' Nouveau comportement de SetForeGroundWindow ' La fenêtre à activer doit appartenir au Thread appelant If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then X = AttachThreadInput(ThreadID1, ThreadID2, True) X = SetForegroundWindow(newHwnd) X = AttachThreadInput(ThreadID1, ThreadID2, True) Else X = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) And bRestoreIconic = True Then X = ShowWindow(newHwnd, SW_RESTORE) Else X = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub
Private Sub Timer1_Timer() [...] If Me.WindowState = 0 Then ForceForeGroundWindow Me.hWnd End If End Sub
-- Cordialement,
Jacques.
Le vent de l''''est
-- ALCEDO
"Jacques93" a écrit :
Bonjour Le vent, Le vent de l''''est a écrit : > Bonjours, > > Comment puis-je forcer une fenêtre à passer au premier plan quand je passe > de « Windowstate=1 » à « Windowstate=0 », déclancher par un évènement > « Timer » alors qu’il y déjà a une fenêtre d’un autre programme en plein > écran. >
Ce n'est peut être pas la meilleure idée, dans la mesure où ce genre de comportement peut pertuber l'utilisateur, mais bon, c'est toi qui voie, tu peux essayer ceci :
Private Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hWnd As Long, lpdwProcessId As Long) As Long Private Declare Function AttachThreadInput Lib "user32" _ (ByVal idAttach As Long, ByVal idAttachTo As Long, _ ByVal fAttach As Long) As Long Private Declare Function IsIconic Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function GetForegroundWindow Lib "user32" _ () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _ Optional bRestoreIconic As Boolean = False) Dim ThreadID1 As Long, ThreadID2 As Long Dim X As Long
' Nouveau comportement de SetForeGroundWindow ' La fenêtre à activer doit appartenir au Thread appelant If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then X = AttachThreadInput(ThreadID1, ThreadID2, True) X = SetForegroundWindow(newHwnd) X = AttachThreadInput(ThreadID1, ThreadID2, True) Else X = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) And bRestoreIconic = True Then X = ShowWindow(newHwnd, SW_RESTORE) Else X = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub
Private Sub Timer1_Timer() [...] If Me.WindowState = 0 Then ForceForeGroundWindow Me.hWnd End If End Sub
-- Cordialement,
Jacques.
Merci Jacques pour cet extrait de code. Pour ce qui est de perturber l'utilisateur, c'est voulu, le programme est un contrôle d'accès à clés "DALLAS".(brièvement) Même si le gardien joue au "Solitaire" il doit voir ce qui se passe !
--
ALCEDO
"Jacques93" a écrit :
Bonjour Le vent,
Le vent de l''''est a écrit :
> Bonjours,
>
> Comment puis-je forcer une fenêtre à passer au premier plan quand je passe
> de « Windowstate=1 » à « Windowstate=0 », déclancher par un évènement
> « Timer » alors qu’il y déjà a une fenêtre d’un autre programme en plein
> écran.
>
Ce n'est peut être pas la meilleure idée, dans la mesure où ce genre de
comportement peut pertuber l'utilisateur, mais bon, c'est toi qui voie,
tu peux essayer ceci :
Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function AttachThreadInput Lib "user32" _
(ByVal idAttach As Long, ByVal idAttachTo As Long, _
ByVal fAttach As Long) As Long
Private Declare Function IsIconic Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" _
() As Long
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _
Optional bRestoreIconic As Boolean = False)
Dim ThreadID1 As Long, ThreadID2 As Long
Dim X As Long
' Nouveau comportement de SetForeGroundWindow
' La fenêtre à activer doit appartenir au Thread appelant
If newHwnd = GetForegroundWindow() Then
Exit Sub
Else
ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0)
ThreadID2 = GetWindowThreadProcessId(newHwnd, 0)
If ThreadID1 <> ThreadID2 Then
X = AttachThreadInput(ThreadID1, ThreadID2, True)
X = SetForegroundWindow(newHwnd)
X = AttachThreadInput(ThreadID1, ThreadID2, True)
Else
X = SetForegroundWindow(newHwnd)
End If
If IsIconic(newHwnd) And bRestoreIconic = True Then
X = ShowWindow(newHwnd, SW_RESTORE)
Else
X = ShowWindow(newHwnd, SW_SHOW)
End If
End If
End Sub
Private Sub Timer1_Timer()
[...]
If Me.WindowState = 0 Then
ForceForeGroundWindow Me.hWnd
End If
End Sub
--
Cordialement,
Jacques.
Merci Jacques pour cet extrait de code. Pour ce qui est de perturber
l'utilisateur, c'est voulu, le programme est un contrôle d'accès à clés
"DALLAS".(brièvement) Même si le gardien joue au "Solitaire" il doit voir ce
qui se passe !
Bonjour Le vent, Le vent de l''''est a écrit : > Bonjours, > > Comment puis-je forcer une fenêtre à passer au premier plan quand je passe > de « Windowstate=1 » à « Windowstate=0 », déclancher par un évènement > « Timer » alors qu’il y déjà a une fenêtre d’un autre programme en plein > écran. >
Ce n'est peut être pas la meilleure idée, dans la mesure où ce genre de comportement peut pertuber l'utilisateur, mais bon, c'est toi qui voie, tu peux essayer ceci :
Private Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hWnd As Long, lpdwProcessId As Long) As Long Private Declare Function AttachThreadInput Lib "user32" _ (ByVal idAttach As Long, ByVal idAttachTo As Long, _ ByVal fAttach As Long) As Long Private Declare Function IsIconic Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function GetForegroundWindow Lib "user32" _ () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _ Optional bRestoreIconic As Boolean = False) Dim ThreadID1 As Long, ThreadID2 As Long Dim X As Long
' Nouveau comportement de SetForeGroundWindow ' La fenêtre à activer doit appartenir au Thread appelant If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then X = AttachThreadInput(ThreadID1, ThreadID2, True) X = SetForegroundWindow(newHwnd) X = AttachThreadInput(ThreadID1, ThreadID2, True) Else X = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) And bRestoreIconic = True Then X = ShowWindow(newHwnd, SW_RESTORE) Else X = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub
Private Sub Timer1_Timer() [...] If Me.WindowState = 0 Then ForceForeGroundWindow Me.hWnd End If End Sub
-- Cordialement,
Jacques.
Merci Jacques pour cet extrait de code. Pour ce qui est de perturber l'utilisateur, c'est voulu, le programme est un contrôle d'accès à clés "DALLAS".(brièvement) Même si le gardien joue au "Solitaire" il doit voir ce qui se passe !