Private Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (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 Const MOSTRAR_VENTANA = 64 ' es el flag que vamos a meter... en hexadecimal es H40
' las constantes cuando el parámetro hWndInsertAfter utiliza constantes...
private enum enPosicionZ
ORDEN_NORMAL= -2
ORDEN_EN_LA_CIMA= -1
ORDEN_ENCIMA=0
ORDEN_DEBAJO=1
end enum
Private Type Rectangulo
X As Long
Y As Long
Ancho As Long
Alto As Long
End Type
Private p_OrdenZ As enPosicionZ
Private AreaF As Rectangulo
Friend Property Get OrdenZ() As enPosicionZ
OrdenZ = p_OrdenZ
End Property
Friend Property Let OrdenZ(ByVal oz As enPosicionZ)
If p_OrdenZ <> oz Then
If oz > -3 And oz < 2 Then
p_OrdenZ = oz
Call getRect
Call SetWindowPos(Me.hwnd, p_OrdenZ, AreaF.X, AreaF.Y, AreaF.Ancho, AreaF.Alto, MOSTRAR_VENTANA)
msgBox("Nuevo orden z: " & p_OrdenZ)
End If
End If
End Property
Private Sub Command1_Click()
Static n As Integer
n = n + 1
If n = 2 Then n = -2
OrdenZ = n
End Sub
' toma la posición y medidas actuales del Formulario
Private Function getRect()
AreaF.X = ScaleX(Me.Left, vbTwips, vbPixels) + 0 ' previsto para añadir alguna variable
AreaF.Y = ScaleY(Me.Top, vbTwips, vbPixels) + 0
AreaF.Ancho = ScaleX(Me.Width, vbTwips, vbPixels) + 0
AreaF.Alto = ScaleY(Me.Height, vbTwips, vbPixels) + 0
End Function