Fixer fenetre en premier plan par rapport aux autres
lazarird
Messages postés4Date d'inscriptionsamedi 17 janvier 2004StatutMembreDernière intervention17 mai 2007
-
27 sept. 2005 à 19:25
cboulas
Messages postés2641Date d'inscriptionmercredi 2 juin 2004StatutMembreDernière intervention 8 janvier 2014
-
27 sept. 2005 à 21:54
Bonjour,
je veux réaliser un programme dans lequel il y a deux form, et je veux que quand toutes les
deux sont à l'ecran la première est toujours au premier plan et je ne peux accéder à la
deuxième sans avoir fermé la première (comme si il s'agissait d'un message box)
j'ai essayé cette API mais elle ne semble pas marcher:
Public 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
PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 27 sept. 2005 à 20:01
salut,
VbModal est la meilleur solution.
mais pour info, l'API que tu utilises est correcte et fonctionne. elle n'empêche cependant pas la prise en main d'autres fenêtres.
' -----
' Form1
' -----
Private Sub Command1_Click()
Form2.Show
End Sub
' -----
' Form2
' -----
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub 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)
Private Sub Form_Activate()
'KPD-Team 1998
'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net
'Set the window position to topmost
SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Sub
jpleroisse
Messages postés1788Date d'inscriptionmardi 7 novembre 2000StatutMembreDernière intervention11 mars 200627 27 sept. 2005 à 20:01
Bonsoir,
Dans un Module:
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
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
Public Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) As Long