Bonjour/soir,
L'article suivant de la FAQ pourra t'aider:
http://faq.vb.free.fr/index.php?questionP
Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne possèdent
pas de propriété hwnd.
Voici un contournement:
'Dans un module:
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or
SWP_NOSIZE
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long,
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx
Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
lpClassName As String, ByVal lpWindowName As String) As Long
Public Function SetTopMostWindow(WindowTitle As String, Topmost As
As Long
Dim hWnd As Long
hWnd = FindWindow(vbNullString, WindowTitle)
If hWnd Then
If Topmost = True Then
SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0,
Flags)
Else
SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0,
0, Flags)
End If
End If
End Function
'Dans la userform:
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal x As Single, ByVal y As Single)
If Button = VBA.vbKeyLButton Then
SetTopMostWindow Me.Caption, True 'Active au click gauche
ElseIf Button = VBA.vbKeyRButton Then
SetTopMostWindow Me.Caption, False 'Désactive au click droit
End If
End Sub
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
"John Fuss" a écrit dans le message de
news:
> Bonjour,
>
> j'ai réalisé une macro qui pilote une application avec Shell(),
> AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
> pendant le pilotage de l'application pour afficher les opérations
> réalisées. SendKeys() envoi des frappes claviers à l'application qui
> a le focus.. Comment puis-je faire pour que ma UserForm soit tjrs
> visible mais sans prise de focus ?
>
> Merci d'avance.
>
> John Fuss
Bonjour/soir,
L'article suivant de la FAQ pourra t'aider:
http://faq.vb.free.fr/index.php?questionP
Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne possèdent
pas de propriété hwnd.
Voici un contournement:
'Dans un module:
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or
SWP_NOSIZE
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long,
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx
Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
lpClassName As String, ByVal lpWindowName As String) As Long
Public Function SetTopMostWindow(WindowTitle As String, Topmost As
As Long
Dim hWnd As Long
hWnd = FindWindow(vbNullString, WindowTitle)
If hWnd Then
If Topmost = True Then
SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0,
Flags)
Else
SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0,
0, Flags)
End If
End If
End Function
'Dans la userform:
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal x As Single, ByVal y As Single)
If Button = VBA.vbKeyLButton Then
SetTopMostWindow Me.Caption, True 'Active au click gauche
ElseIf Button = VBA.vbKeyRButton Then
SetTopMostWindow Me.Caption, False 'Désactive au click droit
End If
End Sub
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
"John Fuss" <newskob650@yahoo.fr> a écrit dans le message de
news:O9cR5Z6aDHA.3360@tk2msftngp13.phx.gbl
> Bonjour,
>
> j'ai réalisé une macro qui pilote une application avec Shell(),
> AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
> pendant le pilotage de l'application pour afficher les opérations
> réalisées. SendKeys() envoi des frappes claviers à l'application qui
> a le focus.. Comment puis-je faire pour que ma UserForm soit tjrs
> visible mais sans prise de focus ?
>
> Merci d'avance.
>
> John Fuss
Bonjour/soir,
L'article suivant de la FAQ pourra t'aider:
http://faq.vb.free.fr/index.php?questionP
Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne possèdent
pas de propriété hwnd.
Voici un contournement:
'Dans un module:
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or
SWP_NOSIZE
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long,
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx
Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
lpClassName As String, ByVal lpWindowName As String) As Long
Public Function SetTopMostWindow(WindowTitle As String, Topmost As
As Long
Dim hWnd As Long
hWnd = FindWindow(vbNullString, WindowTitle)
If hWnd Then
If Topmost = True Then
SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0,
Flags)
Else
SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0,
0, Flags)
End If
End If
End Function
'Dans la userform:
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal x As Single, ByVal y As Single)
If Button = VBA.vbKeyLButton Then
SetTopMostWindow Me.Caption, True 'Active au click gauche
ElseIf Button = VBA.vbKeyRButton Then
SetTopMostWindow Me.Caption, False 'Désactive au click droit
End If
End Sub
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
"John Fuss" a écrit dans le message de
news:
> Bonjour,
>
> j'ai réalisé une macro qui pilote une application avec Shell(),
> AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
> pendant le pilotage de l'application pour afficher les opérations
> réalisées. SendKeys() envoi des frappes claviers à l'application qui
> a le focus.. Comment puis-je faire pour que ma UserForm soit tjrs
> visible mais sans prise de focus ?
>
> Merci d'avance.
>
> John Fuss
J'en viens à l'instant. Merci bcp
John Fuss.
"François Picalausa" a écrit dans le message de
> Bonjour/soir,
>
> L'article suivant de la FAQ pourra t'aider:
> http://faq.vb.free.fr/index.php?questionP
>
> Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne
> pas de propriété hwnd.
> Voici un contournement:
>
> 'Dans un module:
>
> Private Const SWP_NOMOVE = &H2
> Private Const SWP_NOSIZE = &H1
> Private Const SWP_NOACTIVATE = &H10
> Private Const SWP_SHOWWINDOW = &H40
> Private Const HWND_TOPMOST = -1
> Private Const HWND_NOTOPMOST = -2
> Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or
> SWP_NOSIZE
>
> Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long,
> ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal
As
> Long, ByVal cy As Long, ByVal wFlags As Long) As Long
> Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal
> lpClassName As String, ByVal lpWindowName As String) As Long
>
> Public Function SetTopMostWindow(WindowTitle As String, Topmost As
Boolean)
> As Long
> Dim hWnd As Long
> hWnd = FindWindow(vbNullString, WindowTitle)
> If hWnd Then
> If Topmost = True Then
> SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0,
0,
> Flags)
> Else
> SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0,
> 0, Flags)
> End If
> End If
> End Function
>
>
> 'Dans la userform:
> Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As
> Integer, ByVal x As Single, ByVal y As Single)
> If Button = VBA.vbKeyLButton Then
> SetTopMostWindow Me.Caption, True 'Active au click gauche
> ElseIf Button = VBA.vbKeyRButton Then
> SetTopMostWindow Me.Caption, False 'Désactive au click droit
> End If
> End Sub
>
> --
> François Picalausa (MVP VB)
> FAQ VB : http://faq.vb.free.fr
> MSDN : http://msdn.microsoft.com
>
>
> "John Fuss" a écrit dans le message de
> news:
> > Bonjour,
> >
> > j'ai réalisé une macro qui pilote une application avec Shell(),
> > AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
> > pendant le pilotage de l'application pour afficher les opérations
> > réalisées. SendKeys() envoi des frappes claviers à l'application qui
> > a le focus.. Comment puis-je faire pour que ma UserForm soit tjrs
> > visible mais sans prise de focus ?
> >
> > Merci d'avance.
> >
> > John Fuss
>
>
J'en viens à l'instant. Merci bcp
John Fuss.
"François Picalausa" <fpicalausa@chez.com> a écrit dans le message de
egAVOj6aDHA.1272@TK2MSFTNGP12.phx.gbl...
> Bonjour/soir,
>
> L'article suivant de la FAQ pourra t'aider:
> http://faq.vb.free.fr/index.php?questionP
>
> Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne
> pas de propriété hwnd.
> Voici un contournement:
>
> 'Dans un module:
>
> Private Const SWP_NOMOVE = &H2
> Private Const SWP_NOSIZE = &H1
> Private Const SWP_NOACTIVATE = &H10
> Private Const SWP_SHOWWINDOW = &H40
> Private Const HWND_TOPMOST = -1
> Private Const HWND_NOTOPMOST = -2
> Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or
> SWP_NOSIZE
>
> Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long,
> ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal
As
> Long, ByVal cy As Long, ByVal wFlags As Long) As Long
> Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal
> lpClassName As String, ByVal lpWindowName As String) As Long
>
> Public Function SetTopMostWindow(WindowTitle As String, Topmost As
Boolean)
> As Long
> Dim hWnd As Long
> hWnd = FindWindow(vbNullString, WindowTitle)
> If hWnd Then
> If Topmost = True Then
> SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0,
0,
> Flags)
> Else
> SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0,
> 0, Flags)
> End If
> End If
> End Function
>
>
> 'Dans la userform:
> Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As
> Integer, ByVal x As Single, ByVal y As Single)
> If Button = VBA.vbKeyLButton Then
> SetTopMostWindow Me.Caption, True 'Active au click gauche
> ElseIf Button = VBA.vbKeyRButton Then
> SetTopMostWindow Me.Caption, False 'Désactive au click droit
> End If
> End Sub
>
> --
> François Picalausa (MVP VB)
> FAQ VB : http://faq.vb.free.fr
> MSDN : http://msdn.microsoft.com
>
>
> "John Fuss" <newskob650@yahoo.fr> a écrit dans le message de
> news:O9cR5Z6aDHA.3360@tk2msftngp13.phx.gbl
> > Bonjour,
> >
> > j'ai réalisé une macro qui pilote une application avec Shell(),
> > AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
> > pendant le pilotage de l'application pour afficher les opérations
> > réalisées. SendKeys() envoi des frappes claviers à l'application qui
> > a le focus.. Comment puis-je faire pour que ma UserForm soit tjrs
> > visible mais sans prise de focus ?
> >
> > Merci d'avance.
> >
> > John Fuss
>
>
J'en viens à l'instant. Merci bcp
John Fuss.
"François Picalausa" a écrit dans le message de
> Bonjour/soir,
>
> L'article suivant de la FAQ pourra t'aider:
> http://faq.vb.free.fr/index.php?questionP
>
> Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne
> pas de propriété hwnd.
> Voici un contournement:
>
> 'Dans un module:
>
> Private Const SWP_NOMOVE = &H2
> Private Const SWP_NOSIZE = &H1
> Private Const SWP_NOACTIVATE = &H10
> Private Const SWP_SHOWWINDOW = &H40
> Private Const HWND_TOPMOST = -1
> Private Const HWND_NOTOPMOST = -2
> Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or
> SWP_NOSIZE
>
> Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long,
> ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal
As
> Long, ByVal cy As Long, ByVal wFlags As Long) As Long
> Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal
> lpClassName As String, ByVal lpWindowName As String) As Long
>
> Public Function SetTopMostWindow(WindowTitle As String, Topmost As
Boolean)
> As Long
> Dim hWnd As Long
> hWnd = FindWindow(vbNullString, WindowTitle)
> If hWnd Then
> If Topmost = True Then
> SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0,
0,
> Flags)
> Else
> SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0,
> 0, Flags)
> End If
> End If
> End Function
>
>
> 'Dans la userform:
> Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As
> Integer, ByVal x As Single, ByVal y As Single)
> If Button = VBA.vbKeyLButton Then
> SetTopMostWindow Me.Caption, True 'Active au click gauche
> ElseIf Button = VBA.vbKeyRButton Then
> SetTopMostWindow Me.Caption, False 'Désactive au click droit
> End If
> End Sub
>
> --
> François Picalausa (MVP VB)
> FAQ VB : http://faq.vb.free.fr
> MSDN : http://msdn.microsoft.com
>
>
> "John Fuss" a écrit dans le message de
> news:
> > Bonjour,
> >
> > j'ai réalisé une macro qui pilote une application avec Shell(),
> > AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
> > pendant le pilotage de l'application pour afficher les opérations
> > réalisées. SendKeys() envoi des frappes claviers à l'application qui
> > a le focus.. Comment puis-je faire pour que ma UserForm soit tjrs
> > visible mais sans prise de focus ?
> >
> > Merci d'avance.
> >
> > John Fuss
>
>
Euhh, un pti pbl,
j'utilise VBA et ds le code j'ai remplacé Form par UserForm, et
UserForm n'a pas de propriété hwnd.
Comment puis-je faire ?
Merci
"John Fuss" a écrit dans le message de news:J'en viens à l'instant. Merci bcp
John Fuss.
"François Picalausa" a écrit dans le message
de news:Bonjour/soir,
L'article suivant de la FAQ pourra t'aider:
http://faq.vb.free.fr/index.php?questionP
Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne
possèdent pas de propriété hwnd.
Voici un contournement:
'Dans un module:
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or
SWP_NOMOVE Or SWP_NOSIZE
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As
Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As
Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As
Long
Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
String) As Long
Public Function SetTopMostWindow(WindowTitle As String, Topmost As
Boolean) As Long
Dim hWnd As Long
hWnd = FindWindow(vbNullString, WindowTitle)
If hWnd Then
If Topmost = True Then
SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0,
0, 0, 0, Flags)
Else
SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST,
0, 0, 0, 0, Flags)
End If
End If
End Function
'Dans la userform:
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift
As Integer, ByVal x As Single, ByVal y As Single)
If Button = VBA.vbKeyLButton Then
SetTopMostWindow Me.Caption, True 'Active au click gauche
ElseIf Button = VBA.vbKeyRButton Then
SetTopMostWindow Me.Caption, False 'Désactive au click droit
End If
End Sub
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
"John Fuss" a écrit dans le message de
news:Bonjour,
j'ai réalisé une macro qui pilote une application avec Shell(),
AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
pendant le pilotage de l'application pour afficher les opérations
réalisées. SendKeys() envoi des frappes claviers à l'application
qui a le focus.. Comment puis-je faire pour que ma UserForm soit
tjrs visible mais sans prise de focus ?
Merci d'avance.
John Fuss
Euhh, un pti pbl,
j'utilise VBA et ds le code j'ai remplacé Form par UserForm, et
UserForm n'a pas de propriété hwnd.
Comment puis-je faire ?
Merci
"John Fuss" <newskob650@yahoo.fr> a écrit dans le message de news:
uWEVFz6aDHA.2136@TK2MSFTNGP10.phx.gbl...
J'en viens à l'instant. Merci bcp
John Fuss.
"François Picalausa" <fpicalausa@chez.com> a écrit dans le message
de news: egAVOj6aDHA.1272@TK2MSFTNGP12.phx.gbl...
Bonjour/soir,
L'article suivant de la FAQ pourra t'aider:
http://faq.vb.free.fr/index.php?questionP
Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne
possèdent pas de propriété hwnd.
Voici un contournement:
'Dans un module:
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or
SWP_NOMOVE Or SWP_NOSIZE
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As
Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As
Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As
Long
Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
String) As Long
Public Function SetTopMostWindow(WindowTitle As String, Topmost As
Boolean) As Long
Dim hWnd As Long
hWnd = FindWindow(vbNullString, WindowTitle)
If hWnd Then
If Topmost = True Then
SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0,
0, 0, 0, Flags)
Else
SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST,
0, 0, 0, 0, Flags)
End If
End If
End Function
'Dans la userform:
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift
As Integer, ByVal x As Single, ByVal y As Single)
If Button = VBA.vbKeyLButton Then
SetTopMostWindow Me.Caption, True 'Active au click gauche
ElseIf Button = VBA.vbKeyRButton Then
SetTopMostWindow Me.Caption, False 'Désactive au click droit
End If
End Sub
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
"John Fuss" <newskob650@yahoo.fr> a écrit dans le message de
news:O9cR5Z6aDHA.3360@tk2msftngp13.phx.gbl
Bonjour,
j'ai réalisé une macro qui pilote une application avec Shell(),
AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
pendant le pilotage de l'application pour afficher les opérations
réalisées. SendKeys() envoi des frappes claviers à l'application
qui a le focus.. Comment puis-je faire pour que ma UserForm soit
tjrs visible mais sans prise de focus ?
Merci d'avance.
John Fuss
Euhh, un pti pbl,
j'utilise VBA et ds le code j'ai remplacé Form par UserForm, et
UserForm n'a pas de propriété hwnd.
Comment puis-je faire ?
Merci
"John Fuss" a écrit dans le message de news:J'en viens à l'instant. Merci bcp
John Fuss.
"François Picalausa" a écrit dans le message
de news:Bonjour/soir,
L'article suivant de la FAQ pourra t'aider:
http://faq.vb.free.fr/index.php?questionP
Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne
possèdent pas de propriété hwnd.
Voici un contournement:
'Dans un module:
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or
SWP_NOMOVE Or SWP_NOSIZE
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As
Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As
Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As
Long
Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
String) As Long
Public Function SetTopMostWindow(WindowTitle As String, Topmost As
Boolean) As Long
Dim hWnd As Long
hWnd = FindWindow(vbNullString, WindowTitle)
If hWnd Then
If Topmost = True Then
SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0,
0, 0, 0, Flags)
Else
SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST,
0, 0, 0, 0, Flags)
End If
End If
End Function
'Dans la userform:
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift
As Integer, ByVal x As Single, ByVal y As Single)
If Button = VBA.vbKeyLButton Then
SetTopMostWindow Me.Caption, True 'Active au click gauche
ElseIf Button = VBA.vbKeyRButton Then
SetTopMostWindow Me.Caption, False 'Désactive au click droit
End If
End Sub
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
"John Fuss" a écrit dans le message de
news:Bonjour,
j'ai réalisé une macro qui pilote une application avec Shell(),
AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
pendant le pilotage de l'application pour afficher les opérations
réalisées. SendKeys() envoi des frappes claviers à l'application
qui a le focus.. Comment puis-je faire pour que ma UserForm soit
tjrs visible mais sans prise de focus ?
Merci d'avance.
John Fuss
Bonjour/soir,
relis mon post en entier, il y a la solution ;-)
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
"John Fuss" a écrit dans le message de
news:O$
> Euhh, un pti pbl,
>
> j'utilise VBA et ds le code j'ai remplacé Form par UserForm, et
> UserForm n'a pas de propriété hwnd.
>
> Comment puis-je faire ?
>
> Merci
>
>
> "John Fuss" a écrit dans le message de news:
>
>> J'en viens à l'instant. Merci bcp
>>
>> John Fuss.
>>
>> "François Picalausa" a écrit dans le message
>> de news:
>>> Bonjour/soir,
>>>
>>> L'article suivant de la FAQ pourra t'aider:
>>> http://faq.vb.free.fr/index.php?questionP
>>>
>>> Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne
>>> possèdent pas de propriété hwnd.
>>> Voici un contournement:
>>>
>>> 'Dans un module:
>>>
>>> Private Const SWP_NOMOVE = &H2
>>> Private Const SWP_NOSIZE = &H1
>>> Private Const SWP_NOACTIVATE = &H10
>>> Private Const SWP_SHOWWINDOW = &H40
>>> Private Const HWND_TOPMOST = -1
>>> Private Const HWND_NOTOPMOST = -2
>>> Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or
>>> SWP_NOMOVE Or SWP_NOSIZE
>>>
>>> Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As
>>> Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As
>>> Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As
>>> Long
>>> Private Declare Function FindWindow Lib "user32" Alias
>>> "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
>>> String) As Long
>>>
>>> Public Function SetTopMostWindow(WindowTitle As String, Topmost As
>>> Boolean) As Long
>>> Dim hWnd As Long
>>> hWnd = FindWindow(vbNullString, WindowTitle)
>>> If hWnd Then
>>> If Topmost = True Then
>>> SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0,
>>> 0, 0, 0, Flags)
>>> Else
>>> SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST,
>>> 0, 0, 0, 0, Flags)
>>> End If
>>> End If
>>> End Function
>>>
>>>
>>> 'Dans la userform:
>>> Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift
>>> As Integer, ByVal x As Single, ByVal y As Single)
>>> If Button = VBA.vbKeyLButton Then
>>> SetTopMostWindow Me.Caption, True 'Active au click gauche
>>> ElseIf Button = VBA.vbKeyRButton Then
>>> SetTopMostWindow Me.Caption, False 'Désactive au click droit
>>> End If
>>> End Sub
>>>
>>> --
>>> François Picalausa (MVP VB)
>>> FAQ VB : http://faq.vb.free.fr
>>> MSDN : http://msdn.microsoft.com
>>>
>>>
>>> "John Fuss" a écrit dans le message de
>>> news:
>>>> Bonjour,
>>>>
>>>> j'ai réalisé une macro qui pilote une application avec Shell(),
>>>> AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
>>>> pendant le pilotage de l'application pour afficher les opérations
>>>> réalisées. SendKeys() envoi des frappes claviers à l'application
>>>> qui a le focus.. Comment puis-je faire pour que ma UserForm soit
>>>> tjrs visible mais sans prise de focus ?
>>>>
>>>> Merci d'avance.
>>>>
>>>> John Fuss
Bonjour/soir,
relis mon post en entier, il y a la solution ;-)
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
"John Fuss" <newskob650@yahoo.fr> a écrit dans le message de
news:O$PS746aDHA.1280@tk2msftngp13.phx.gbl
> Euhh, un pti pbl,
>
> j'utilise VBA et ds le code j'ai remplacé Form par UserForm, et
> UserForm n'a pas de propriété hwnd.
>
> Comment puis-je faire ?
>
> Merci
>
>
> "John Fuss" <newskob650@yahoo.fr> a écrit dans le message de news:
> uWEVFz6aDHA.2136@TK2MSFTNGP10.phx.gbl...
>> J'en viens à l'instant. Merci bcp
>>
>> John Fuss.
>>
>> "François Picalausa" <fpicalausa@chez.com> a écrit dans le message
>> de news: egAVOj6aDHA.1272@TK2MSFTNGP12.phx.gbl...
>>> Bonjour/soir,
>>>
>>> L'article suivant de la FAQ pourra t'aider:
>>> http://faq.vb.free.fr/index.php?questionP
>>>
>>> Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne
>>> possèdent pas de propriété hwnd.
>>> Voici un contournement:
>>>
>>> 'Dans un module:
>>>
>>> Private Const SWP_NOMOVE = &H2
>>> Private Const SWP_NOSIZE = &H1
>>> Private Const SWP_NOACTIVATE = &H10
>>> Private Const SWP_SHOWWINDOW = &H40
>>> Private Const HWND_TOPMOST = -1
>>> Private Const HWND_NOTOPMOST = -2
>>> Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or
>>> SWP_NOMOVE Or SWP_NOSIZE
>>>
>>> Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As
>>> Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As
>>> Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As
>>> Long
>>> Private Declare Function FindWindow Lib "user32" Alias
>>> "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
>>> String) As Long
>>>
>>> Public Function SetTopMostWindow(WindowTitle As String, Topmost As
>>> Boolean) As Long
>>> Dim hWnd As Long
>>> hWnd = FindWindow(vbNullString, WindowTitle)
>>> If hWnd Then
>>> If Topmost = True Then
>>> SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0,
>>> 0, 0, 0, Flags)
>>> Else
>>> SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST,
>>> 0, 0, 0, 0, Flags)
>>> End If
>>> End If
>>> End Function
>>>
>>>
>>> 'Dans la userform:
>>> Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift
>>> As Integer, ByVal x As Single, ByVal y As Single)
>>> If Button = VBA.vbKeyLButton Then
>>> SetTopMostWindow Me.Caption, True 'Active au click gauche
>>> ElseIf Button = VBA.vbKeyRButton Then
>>> SetTopMostWindow Me.Caption, False 'Désactive au click droit
>>> End If
>>> End Sub
>>>
>>> --
>>> François Picalausa (MVP VB)
>>> FAQ VB : http://faq.vb.free.fr
>>> MSDN : http://msdn.microsoft.com
>>>
>>>
>>> "John Fuss" <newskob650@yahoo.fr> a écrit dans le message de
>>> news:O9cR5Z6aDHA.3360@tk2msftngp13.phx.gbl
>>>> Bonjour,
>>>>
>>>> j'ai réalisé une macro qui pilote une application avec Shell(),
>>>> AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
>>>> pendant le pilotage de l'application pour afficher les opérations
>>>> réalisées. SendKeys() envoi des frappes claviers à l'application
>>>> qui a le focus.. Comment puis-je faire pour que ma UserForm soit
>>>> tjrs visible mais sans prise de focus ?
>>>>
>>>> Merci d'avance.
>>>>
>>>> John Fuss
Bonjour/soir,
relis mon post en entier, il y a la solution ;-)
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
"John Fuss" a écrit dans le message de
news:O$
> Euhh, un pti pbl,
>
> j'utilise VBA et ds le code j'ai remplacé Form par UserForm, et
> UserForm n'a pas de propriété hwnd.
>
> Comment puis-je faire ?
>
> Merci
>
>
> "John Fuss" a écrit dans le message de news:
>
>> J'en viens à l'instant. Merci bcp
>>
>> John Fuss.
>>
>> "François Picalausa" a écrit dans le message
>> de news:
>>> Bonjour/soir,
>>>
>>> L'article suivant de la FAQ pourra t'aider:
>>> http://faq.vb.free.fr/index.php?questionP
>>>
>>> Toutefois, si il s'agit bien d'un UserForm, VBA, les feuilles ne
>>> possèdent pas de propriété hwnd.
>>> Voici un contournement:
>>>
>>> 'Dans un module:
>>>
>>> Private Const SWP_NOMOVE = &H2
>>> Private Const SWP_NOSIZE = &H1
>>> Private Const SWP_NOACTIVATE = &H10
>>> Private Const SWP_SHOWWINDOW = &H40
>>> Private Const HWND_TOPMOST = -1
>>> Private Const HWND_NOTOPMOST = -2
>>> Private Const Flags = SWP_NOACTIVATE Or SWP_SHOWWINDOW Or
>>> SWP_NOMOVE Or SWP_NOSIZE
>>>
>>> Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As
>>> Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As
>>> Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As
>>> Long
>>> Private Declare Function FindWindow Lib "user32" Alias
>>> "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
>>> String) As Long
>>>
>>> Public Function SetTopMostWindow(WindowTitle As String, Topmost As
>>> Boolean) As Long
>>> Dim hWnd As Long
>>> hWnd = FindWindow(vbNullString, WindowTitle)
>>> If hWnd Then
>>> If Topmost = True Then
>>> SetTopMostWindow = SetWindowPos(hWnd, HWND_TOPMOST, 0,
>>> 0, 0, 0, Flags)
>>> Else
>>> SetTopMostWindow = SetWindowPos(hWnd, HWND_NOTOPMOST,
>>> 0, 0, 0, 0, Flags)
>>> End If
>>> End If
>>> End Function
>>>
>>>
>>> 'Dans la userform:
>>> Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift
>>> As Integer, ByVal x As Single, ByVal y As Single)
>>> If Button = VBA.vbKeyLButton Then
>>> SetTopMostWindow Me.Caption, True 'Active au click gauche
>>> ElseIf Button = VBA.vbKeyRButton Then
>>> SetTopMostWindow Me.Caption, False 'Désactive au click droit
>>> End If
>>> End Sub
>>>
>>> --
>>> François Picalausa (MVP VB)
>>> FAQ VB : http://faq.vb.free.fr
>>> MSDN : http://msdn.microsoft.com
>>>
>>>
>>> "John Fuss" a écrit dans le message de
>>> news:
>>>> Bonjour,
>>>>
>>>> j'ai réalisé une macro qui pilote une application avec Shell(),
>>>> AppActivate() & SendKeys(). J'aimerai pouvoir afficher une UserForm
>>>> pendant le pilotage de l'application pour afficher les opérations
>>>> réalisées. SendKeys() envoi des frappes claviers à l'application
>>>> qui a le focus.. Comment puis-je faire pour que ma UserForm soit
>>>> tjrs visible mais sans prise de focus ?
>>>>
>>>> Merci d'avance.
>>>>
>>>> John Fuss