J'ai un petit programme qui scrute les mails Outlook.
Dans le cas où l'expéditeur est connu, le programme m'avertit en affichant
un compteur de mails reçus ainsi que les sujets des mails. Tout marche.
Mais je voudrais que pour cet évènement, la fenêtre de ce programme passe au
1er plan devant les fenêtres des autres programmes un peu comme un pop-up.
Les Me.Show et autres AppActivate n'y font rien :-((
Sauriez-vous comment faire ?
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 teddy, teddy a écrit :
Bonjour,
J'ai un petit programme qui scrute les mails Outlook. Dans le cas où l'expéditeur est connu, le programme m'avertit en affichant un compteur de mails reçus ainsi que les sujets des mails. Tout marche.
Mais je voudrais que pour cet évènement, la fenêtre de ce programme passe au 1er plan devant les fenêtres des autres programmes un peu comme un pop-up.
Les Me.Show et autres AppActivate n'y font rien :-(( Sauriez-vous comment faire ?
Merci beaucoup pour vos idées. Teddy
Essaie :
Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long
SetForegroundWindow me.hWnd
Si cela ne suffit pas (fenêtre clignotante dans la barre de tâches sous XP) :
Option Explicit Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long 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 ShowWindow Lib "user32" _ (ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Const SW_RESTORE = 9 Private Const SW_SHOW = 5
[...] ForceForeGroundWindow Me.hWnd [...]
Public Sub ForceForeGroundWindow(ByVal newHwnd As Long) Dim ThreadID1 As Long, ThreadID2 As Long Dim lResult As Long
If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then lResult = AttachThreadInput(ThreadID1, ThreadID2, True) lResult = SetForegroundWindow(newHwnd) lResult = AttachThreadInput(ThreadID1, ThreadID2, True) Else lResult = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) Then lResult = ShowWindow(newHwnd, SW_RESTORE) Else lResult = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub
-- Cordialement,
Jacques.
Bonjour teddy,
teddy a écrit :
Bonjour,
J'ai un petit programme qui scrute les mails Outlook.
Dans le cas où l'expéditeur est connu, le programme m'avertit en affichant
un compteur de mails reçus ainsi que les sujets des mails. Tout marche.
Mais je voudrais que pour cet évènement, la fenêtre de ce programme passe au
1er plan devant les fenêtres des autres programmes un peu comme un pop-up.
Les Me.Show et autres AppActivate n'y font rien :-((
Sauriez-vous comment faire ?
Merci beaucoup pour vos idées.
Teddy
Essaie :
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
SetForegroundWindow me.hWnd
Si cela ne suffit pas (fenêtre clignotante dans la barre de tâches sous
XP) :
Option Explicit
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
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 ShowWindow Lib "user32" _
(ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Private Const SW_RESTORE = 9
Private Const SW_SHOW = 5
[...]
ForceForeGroundWindow Me.hWnd
[...]
Public Sub ForceForeGroundWindow(ByVal newHwnd As Long)
Dim ThreadID1 As Long, ThreadID2 As Long
Dim lResult As Long
If newHwnd = GetForegroundWindow() Then
Exit Sub
Else
ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0)
ThreadID2 = GetWindowThreadProcessId(newHwnd, 0)
If ThreadID1 <> ThreadID2 Then
lResult = AttachThreadInput(ThreadID1, ThreadID2, True)
lResult = SetForegroundWindow(newHwnd)
lResult = AttachThreadInput(ThreadID1, ThreadID2, True)
Else
lResult = SetForegroundWindow(newHwnd)
End If
If IsIconic(newHwnd) Then
lResult = ShowWindow(newHwnd, SW_RESTORE)
Else
lResult = ShowWindow(newHwnd, SW_SHOW)
End If
End If
End Sub
J'ai un petit programme qui scrute les mails Outlook. Dans le cas où l'expéditeur est connu, le programme m'avertit en affichant un compteur de mails reçus ainsi que les sujets des mails. Tout marche.
Mais je voudrais que pour cet évènement, la fenêtre de ce programme passe au 1er plan devant les fenêtres des autres programmes un peu comme un pop-up.
Les Me.Show et autres AppActivate n'y font rien :-(( Sauriez-vous comment faire ?
Merci beaucoup pour vos idées. Teddy
Essaie :
Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long
SetForegroundWindow me.hWnd
Si cela ne suffit pas (fenêtre clignotante dans la barre de tâches sous XP) :
Option Explicit Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long 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 ShowWindow Lib "user32" _ (ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Const SW_RESTORE = 9 Private Const SW_SHOW = 5
[...] ForceForeGroundWindow Me.hWnd [...]
Public Sub ForceForeGroundWindow(ByVal newHwnd As Long) Dim ThreadID1 As Long, ThreadID2 As Long Dim lResult As Long
If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then lResult = AttachThreadInput(ThreadID1, ThreadID2, True) lResult = SetForegroundWindow(newHwnd) lResult = AttachThreadInput(ThreadID1, ThreadID2, True) Else lResult = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) Then lResult = ShowWindow(newHwnd, SW_RESTORE) Else lResult = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub
-- Cordialement,
Jacques.
teddy
Je vais me pencher sur ces API car elles me semblent un peu obscures, mais je vais essayer de comprendre comment les utiliser.
Merci encore Jacques.
Ted
"Jacques93" a écrit dans le message de news: %23$
Bonjour teddy, teddy a écrit :
Bonjour,
J'ai un petit programme qui scrute les mails Outlook. Dans le cas où l'expéditeur est connu, le programme m'avertit en affichant un compteur de mails reçus ainsi que les sujets des mails. Tout marche.
Mais je voudrais que pour cet évènement, la fenêtre de ce programme passe au 1er plan devant les fenêtres des autres programmes un peu comme un pop-up.
Les Me.Show et autres AppActivate n'y font rien :-(( Sauriez-vous comment faire ?
Merci beaucoup pour vos idées. Teddy
Essaie :
Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long
SetForegroundWindow me.hWnd
Si cela ne suffit pas (fenêtre clignotante dans la barre de tâches sous XP) :
Option Explicit Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long 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 ShowWindow Lib "user32" _ (ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Const SW_RESTORE = 9 Private Const SW_SHOW = 5
[...] ForceForeGroundWindow Me.hWnd [...]
Public Sub ForceForeGroundWindow(ByVal newHwnd As Long) Dim ThreadID1 As Long, ThreadID2 As Long Dim lResult As Long
If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then lResult = AttachThreadInput(ThreadID1, ThreadID2, True) lResult = SetForegroundWindow(newHwnd) lResult = AttachThreadInput(ThreadID1, ThreadID2, True) Else lResult = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) Then lResult = ShowWindow(newHwnd, SW_RESTORE) Else lResult = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub
-- Cordialement,
Jacques.
Je vais me pencher sur ces API car elles me semblent un peu obscures, mais
je vais essayer de comprendre comment les utiliser.
Merci encore Jacques.
Ted
"Jacques93" <jacques@NoSpam> a écrit dans le message de news:
%23$vhjCj3FHA.2196@tk2msftngp13.phx.gbl...
Bonjour teddy,
teddy a écrit :
Bonjour,
J'ai un petit programme qui scrute les mails Outlook.
Dans le cas où l'expéditeur est connu, le programme m'avertit en
affichant un compteur de mails reçus ainsi que les sujets des mails. Tout
marche.
Mais je voudrais que pour cet évènement, la fenêtre de ce programme passe
au 1er plan devant les fenêtres des autres programmes un peu comme un
pop-up.
Les Me.Show et autres AppActivate n'y font rien :-((
Sauriez-vous comment faire ?
Merci beaucoup pour vos idées.
Teddy
Essaie :
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
SetForegroundWindow me.hWnd
Si cela ne suffit pas (fenêtre clignotante dans la barre de tâches sous
XP) :
Option Explicit
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
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 ShowWindow Lib "user32" _
(ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Private Const SW_RESTORE = 9
Private Const SW_SHOW = 5
[...]
ForceForeGroundWindow Me.hWnd
[...]
Public Sub ForceForeGroundWindow(ByVal newHwnd As Long)
Dim ThreadID1 As Long, ThreadID2 As Long
Dim lResult As Long
If newHwnd = GetForegroundWindow() Then
Exit Sub
Else
ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0)
ThreadID2 = GetWindowThreadProcessId(newHwnd, 0)
If ThreadID1 <> ThreadID2 Then
lResult = AttachThreadInput(ThreadID1, ThreadID2, True)
lResult = SetForegroundWindow(newHwnd)
lResult = AttachThreadInput(ThreadID1, ThreadID2, True)
Else
lResult = SetForegroundWindow(newHwnd)
End If
If IsIconic(newHwnd) Then
lResult = ShowWindow(newHwnd, SW_RESTORE)
Else
lResult = ShowWindow(newHwnd, SW_SHOW)
End If
End If
End Sub
Je vais me pencher sur ces API car elles me semblent un peu obscures, mais je vais essayer de comprendre comment les utiliser.
Merci encore Jacques.
Ted
"Jacques93" a écrit dans le message de news: %23$
Bonjour teddy, teddy a écrit :
Bonjour,
J'ai un petit programme qui scrute les mails Outlook. Dans le cas où l'expéditeur est connu, le programme m'avertit en affichant un compteur de mails reçus ainsi que les sujets des mails. Tout marche.
Mais je voudrais que pour cet évènement, la fenêtre de ce programme passe au 1er plan devant les fenêtres des autres programmes un peu comme un pop-up.
Les Me.Show et autres AppActivate n'y font rien :-(( Sauriez-vous comment faire ?
Merci beaucoup pour vos idées. Teddy
Essaie :
Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long
SetForegroundWindow me.hWnd
Si cela ne suffit pas (fenêtre clignotante dans la barre de tâches sous XP) :
Option Explicit Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long 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 ShowWindow Lib "user32" _ (ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Const SW_RESTORE = 9 Private Const SW_SHOW = 5
[...] ForceForeGroundWindow Me.hWnd [...]
Public Sub ForceForeGroundWindow(ByVal newHwnd As Long) Dim ThreadID1 As Long, ThreadID2 As Long Dim lResult As Long
If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then lResult = AttachThreadInput(ThreadID1, ThreadID2, True) lResult = SetForegroundWindow(newHwnd) lResult = AttachThreadInput(ThreadID1, ThreadID2, True) Else lResult = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) Then lResult = ShowWindow(newHwnd, SW_RESTORE) Else lResult = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub