bilaloch
Messages postés556Date d'inscriptionlundi 6 octobre 2003StatutMembreDernière intervention31 octobre 2019
-
10 sept. 2007 à 14:45
bilaloch
Messages postés556Date d'inscriptionlundi 6 octobre 2003StatutMembreDernière intervention31 octobre 2019
-
10 sept. 2007 à 17:17
Bonjour à tous,
Je poste sur le forum à cause d'un petit problème que j'ai. En effet, je ne trouve pas d'APIs ou de fonctions me permettant d'agrandir une fenêtre présente sur la barre des tâches. J'utilise AppActivate mais je ne sais pourquoi, cela ne fonctionne pas pour les applications réduites. J'attends votre aide et vos idées avec impatience.
' DANS UNE FORM AVEC 3
CommandButton
'
Option Explicit
'
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWNORMAL As Long = 1
'
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
'
Dim lPID As Long
'
'
Private Sub Command1_Click()
lPID = Shell("notepad.exe", vbMinimizedFocus)
End Sub
Private Sub Command2_Click()
If lPID Then Call SetFocusToPID(lPID, SW_SHOWNORMAL)
End Sub
Private Sub Command3_Click()
If lPID Then Call SetFocusToPID(lPID, SW_SHOWMAXIMIZED)
End Sub
'
Private Function SetFocusToPID(ByVal lPID As Long, lFlag As Long) As Boolean
Dim lHwnd As Long
lHwnd = InstanceToWnd(lPID)
If lHwnd Then
Call ShowWindow(lHwnd, lFlag)
Call SetForegroundWindow(lHwnd)
SetFocusToPID = True
Else
SetFocusToPID = False
End If
End Function
Private Sub Form_Load()
Command1.Caption = "SHELL"
Command2.Caption = "NORMAL"
Command3.Caption = "MAXIMIZED"
End Sub
' DANS UN
MODULE
'http://www.codyx.org/snippet_recuperer-hwnd-handle-partir-pid-process-id_451.aspx
'
Option Explicit
Private Const GW_HWNDNEXT As Long = 2&
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As
Long
Private Declare Function GetParent 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 Declare Function GetWindowThreadProcessId Lib
"user32" (ByVal hwnd As Long, lpdwProcessId As Long) As
Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As
Long
'
Public Function InstanceToWnd(ByVal target_pid As Long) As Long 'API-Guid
Dim test_hwnd As Long, test_pid As Long, test_thread_id As
Long
test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
Do While test_hwnd <> 0&
If GetParent(test_hwnd) = 0& Then
test_thread_id = GetWindowThreadProcessId(test_hwnd,
test_pid)
If test_pid = target_pid Then
InstanceToWnd = test_hwnd
Exit Do
End If
End If
test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
Loop
End Function
++
PCPT [AFCK]
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
bilaloch
Messages postés556Date d'inscriptionlundi 6 octobre 2003StatutMembreDernière intervention31 octobre 20191 10 sept. 2007 à 15:54
En fait Dark, je n'ai que le PID du programme et non le hWnd de la fenêtre. C'est pourquoi tes deux APIs ne peuvent fonctionner. Cependant, si tu as une idée pour obtenir le hWnd à partir du PID, je suis preneur ^^ . Cela me servirait beaucoup.
cs_DARKSIDIOUS
Messages postés15814Date d'inscriptionjeudi 8 août 2002StatutMembreDernière intervention 4 mars 2013130 10 sept. 2007 à 16:00
Salut,
Aucune idée, mais ca doit être possible (de toute façon, avec uniquement le PID, tu peux vraiment pas faire grand chose, donc il doit bien y avoir une API pour énumérer les hwnd reliés à un processus !).
______________________________________
DarK Sidious
Vous n’avez pas trouvé la réponse que vous recherchez ?