Visual Basic - Cargar un Formulario por Encima de Otro

Life is soft - evento anual de software empresarial
 
Vista:

Cargar un Formulario por Encima de Otro

Publicado por Ruben (38 intervenciones) el 14/02/2005 18:34:21
Hola Gente!:

Mi caso es el siguiente:

Tengo un Form1, que viene a ser el formulario principal de la aplicación.
Tengo por ahí, otro formulario, llamado Form2, que es una pantalla de login (o acceso).

Lo que pretendo es que al cargar la aplicación, se cargue el Form1 bloqueado (eso lo tengo ya), y que por encima de este formulario, salga el Form2, quedando Form2 por encima de Form1.

Lo que me hace actualmente la aplicación es cargar el Form1, dejarlo en primero plano, y siempre por detrás de Form1 me sale Form2, cuando debería ser al revés.

¿Como puedo solucionar esto sin tener que recurrir a los formulario MDI?

Gracias de antemano.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Cargar un Formulario por Encima de Otro

Publicado por ChaRLinux (25 intervenciones) el 14/02/2005 19:16:47
esto va en el primer formulario
Option Explicit

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
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOZORDER = &H4
Const SWP_NOREDRAW = &H8
Const SWP_NOACTIVATE = &H10
Const SWP_FRAMECHANGED = &H20
Const SWP_SHOWWINDOW = &H40
Const SWP_HIDEWINDOW = &H80
Const SWP_NOCOPYBITS = &H100
Const SWP_NOOWNERZORDER = &H200
Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Const HWND_TOP = 0
Const HWND_BOTTOM = 1
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Private Sub Command1_Click()
Dim i
i = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
Form2.Show vbModal
End Sub

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:esto va en el segundo formulario

Publicado por ChaRLinux (25 intervenciones) el 14/02/2005 19:18:11
en el segundo formulario

Option Explicit

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
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOZORDER = &H4
Const SWP_NOREDRAW = &H8
Const SWP_NOACTIVATE = &H10
Const SWP_FRAMECHANGED = &H20
Const SWP_SHOWWINDOW = &H40
Const SWP_HIDEWINDOW = &H80
Const SWP_NOCOPYBITS = &H100
Const SWP_NOOWNERZORDER = &H200
Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Const HWND_TOP = 0
Const HWND_BOTTOM = 1
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Private Sub Form_Load()
Dim i
i = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

End Sub
espero te sirva
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:esto va en el segundo formulario

Publicado por Rubén (38 intervenciones) el 14/02/2005 20:21:07
Excelente.

Me ha quedado mejor incluso de lo que pretendía.

Muchas Gracias!.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar