cs_HeXoR
Messages postés165Date d'inscriptionmercredi 29 janvier 2003StatutMembreDernière intervention15 avril 2010
-
7 juil. 2008 à 11:41
bouv
Messages postés1411Date d'inscriptionmercredi 6 août 2003StatutMembreDernière intervention 3 mars 2019
-
7 juil. 2008 à 16:40
Bonjour, je précise un peu ma question : je souhaiterais enlever le statut de "TOPMOST" à une fenêtre contenue dans une autre application. En fait, elle est en "TOPMOST" seulement pour la dite application, pas pour toute les fenêtres en général. En d'autres termes, cette fenêtre bloque toute interaction (clique de souris, ...) avec la fenêtre principale de l'application.
Bien entendu, il est supposé que j'ai le Handle (hWnd) de la fenêtre.
J'ai essayé l'attribut "HWND_NOTOPMOST" avec l'API SetWindowText, mais hélas sans résultat.
bouv
Messages postés1411Date d'inscriptionmercredi 6 août 2003StatutMembreDernière intervention 3 mars 20191 7 juil. 2008 à 13:21
Tu te trompes d'API, il ne faut pas utiliser SetWindowText mais SetWindowPosition.
PLACE CE CODE DANS UN MODULE :
Option Explicit
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
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 Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'Pour le premier plan
Private Const Flags = 1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Public Enum WindowPositionConstants
[Window Top Always] = 0 'TOPMOST : TOUJOURS AU PREMIER PLAN
[Window Top Now] = 1 'FOREGROUND : PLACE AU PREMIER PLAN MAIS NE MAINTIENT PAS
[Window Normal] = 2 'NOTOPMOST : RETIRE LE STATUT TOPMOST
End Enum
Public Function SetWindowPosition(ByVal hWnd As Long, _
ByVal wPosition As WindowPositionConstants) As Long
Dim Success As Long
Dim rPOS As RECT
Select Case wPosition
Case [Window Top Always]
Call GetWindowRect(hWnd, rPOS)
Success = SetWindowPos(hWnd, HWND_TOPMOST, rPOS.Left, rPOS.Top, 0, 0, Flags)
Case [Window Top Now]
Success = SetForegroundWindow(hWnd)
Case [Window Normal]
Call GetWindowRect(hWnd, rPOS)
Success = SetWindowPos(hWnd, HWND_NOTOPMOST, rPOS.Left, rPOS.Top, 0, 0, Flags)
End Select
SetWindowPosition = Success
End Function
Tu peux ensuite utiliser la fonction SetWindowPosition avec le bon parametre pour faire ce que tu veux de ta fenêtre.
cs_HeXoR
Messages postés165Date d'inscriptionmercredi 29 janvier 2003StatutMembreDernière intervention15 avril 2010 7 juil. 2008 à 13:42
Salut à tous.
Rien à faire bouv, ta méthode ne semble pas fonctionner pour les fenêtres enfants (?). Elle ne marche que pour les fenêtres principales des applis. :(
Je pense que PCPT a raison, il faudrait un équivalent de VBMODAL
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 7 juil. 2008 à 14:00
avec çà on sera déja fixés....
Private Const GWL_STYLE As Long = -16
Private Const WS_DISABLED As Long = &H8000000
'
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As
Long
'
Public Function IsModal(ByVal lHandle As Long) As
Boolean
IsModal = ((GetWindowLong(lHandle, GWL_STYLE) And WS_DISABLED) =
WS_DISABLED)
End Function
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 7 juil. 2008 à 16:29
umm...
donc modale ou pas? ^^
si NON, çà revient au code de bouv : SetWindowPos avec HWND_NOTOPMOST<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
bouv
Messages postés1411Date d'inscriptionmercredi 6 août 2003StatutMembreDernière intervention 3 mars 20191 7 juil. 2008 à 16:40
Autre solution, le Modal est simulé avec la propriété Enabled de la fenêtre parent. On se retrouve parfois obligé de faire ainsi. Voir ma source si je suis pas clair.
Dans ce cas il faut mettre la propriété Enabled de la fenêtre parent = True.