' NO NECESITAS UN PANEL, CHECA ESTO
' ASUMIENDO QUE ABRISTE UN PROYECTO NUEVO
' ANTES DE ABRIR EL CODIGO DEL FORM
' EN EL EXPLORADOR CAMBIA EL NOMBRE DE DISEÑO A TU FORMULARIO, DE Form1 A Form0
' Y ACEPTA QUE CAMBIE TODA LA REFERENCIA DEL PROYECTO CON ESE NOMBRE
' LUEGO AGREGA A TU Form0 QUE ES EL DE INICIO TRES BOTONES (Button1, Button2, Button3) Y OPCIONALMENTE UN Button4 PARA INVERTIR EL ARREGLO
' Y EN EL EXPLORADOR AGREGA TRES FORMULARIOS MAS A TU PROYECTO (Form1, Form2, Form3)
' FINALMENTE COPIA ESTE CODIGO EN TU Form0 TAL COMO SE VE ABAJO
Option Strict On
Public Class Form0
Public SOLO_UNO As Boolean = False ' CAMBIANDO (SOLO_UNO = True) SE VERA SOLO UNO DE LOS TRES FORMULARIOS (CASO DEL Button4)
WithEvents FRM1 As New Form, FRM2 As New Form, FRM3 As New Form
Private Sub Form0_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = ""
Me.BackColor = Color.White
Me.SizeGripStyle = SizeGripStyle.Show
Me.Button1.Text = "Form1"
Me.Button2.Text = "Form2"
Me.Button3.Text = "Form3"
INICIO()
End Sub
Private Sub INICIO()
FRM1 = Form1
FRMS(FRM1)
FRM2 = Form2
FRMS(FRM2)
FRM3 = Form3
FRMS(FRM3)
End Sub
Dim L As Integer = 25, T As Integer = 40, W As Integer = 650, H As Integer = 300 ' POSICION INICIAL (LEFT, TOP) Y DIMENSIONES (WIDTH, HEIGHT) DE CADA FORM
Private Sub FRMS(ByVal FRMX As Form)
FRMX.TopLevel = False
FRMX.ControlBox = False ' SI ESTA PROPIEDAD ES (False) NO HABRA BOTONES TRADICIONALES, Y TENDRAS QUE PONER LOS PROPIOS COMO SE MUESTRA AL FINAL
FRMX.Text = ""
FRMX.Location = New Point(L, T)
FRMX.BackColor = Color.Gainsboro
If SOLO_UNO = False Then
FRMX.FormBorderStyle = FormBorderStyle.Sizable
FRMX.SizeGripStyle = SizeGripStyle.Show
FRMX.Size = New Size(W, H)
Else
FRMX.FormBorderStyle = FormBorderStyle.None
FRMX.SizeGripStyle = SizeGripStyle.Hide
FRMX.Size = New Size(Me.Width - 65, Me.Height - 115)
FRMX.Anchor = CType((AnchorStyles.Left + AnchorStyles.Top + AnchorStyles.Right + AnchorStyles.Bottom), AnchorStyles)
End If
Controls.Add(FRMX)
End Sub
' AQUI SE MUESTRA COMO ABRIR CADA FORMULARIO CON EL PROCESO BUTTONS ABAJO MENCIONADO
Dim FRM As New Form
Private Sub BUTTONS_Click(sender As Object, e As EventArgs) Handles _
Button1.Click, Button2.Click, Button3.Click, Button4.Click
Dim CTRL As Control = CType(sender, Control)
Select Case CTRL.Name
Case Button1.Name
FRM = FRM1 : FRM.Show() : FRM.BringToFront()
Case Button2.Name
FRM = FRM2 : FRM.Show() : FRM.BringToFront()
Case Button3.Name
FRM = FRM3 : FRM.Show() : FRM.BringToFront()
' Y SI DURANTE EL TIEMPO DE EJECUCION QUIERES INVERTIR EL ARREGLO
Case Button4.Name
FRM1.Close()
FRM2.Close()
FRM3.Close()
If SOLO_UNO = False Then
SOLO_UNO = True
Else
SOLO_UNO = False
End If
INICIO()
End Select
End Sub
' MOVIMIENTO DEL Form0
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Declare Auto Function ReleaseCapture Lib "user32.dll" () As Boolean
Private Sub Form_MouseDown_1(ByVal sender As Object, ByVal e As MouseEventArgs) Handles _
Me.MouseDown, FRM1.MouseDown, FRM2.MouseDown, FRM3.MouseDown
If SOLO_UNO = True Then
If e.Button = MouseButtons.Left Then
Const WM_NCLBUTTONDOWN As Integer = &HA1
Const HT_CAPTION As Integer = &H2
ReleaseCapture()
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
End If
End If
End Sub
Private Sub Form_MouseDown_2(ByVal sender As Object, ByVal e As MouseEventArgs) Handles _
Me.MouseDown
If SOLO_UNO = False Then
If e.Button = MouseButtons.Left Then
Const WM_NCLBUTTONDOWN As Integer = &HA1
Const HT_CAPTION As Integer = &H2
ReleaseCapture()
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0)
End If
End If
End Sub
' AQUI UNA CONFIRMACION PARA EL CIERRE DE ESTE FORM QUE ES EL PRINCIPAL
Private Sub Form0_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Dim RESP As Integer = MsgBox("Confirme Salir del Programa", MsgBoxStyle.YesNo)
If RESP = vbYes Then
Else
e.Cancel = True
End If
End Sub
End Class
'' Y PARA TERMINAR, AGREGA ESTOS PROCEDIMIENTOS AL CODIGO DE TUS OTROS FORMULARIOS (Form1, Form2, Form3)
'WithEvents LBL As New Label
'Private Sub Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' If Form0.SOLO_UNO = False Then
' Controls.Add(LBL)
' LBL.Font = New Font("Consolas", 11.5, FontStyle.Regular) : LBL.BackColor = Me.BackColor : LBL.ForeColor = Color.DimGray
' LBL.AutoSize = True : LBL.Text = " X "
' LBL.Location = New Point(CInt(Me.Width - LBL.Width * 1.45), 0)
' LBL.Anchor = CType(AnchorStyles.Right + AnchorStyles.Top, AnchorStyles)
' LBL.Visible = True
' End If
' For Each CTRL1 As Control In Me.Controls
' AddHandler CTRL1.MouseClick, AddressOf Form_BringToFront
' For Each CTRL2 As Control In CTRL1.Controls
' AddHandler CTRL2.MouseClick, AddressOf Form_BringToFront
' For Each CTRL3 As Control In CTRL2.Controls
' AddHandler CTRL3.MouseClick, AddressOf Form_BringToFront
' Next
' Next
' Next
'End Sub
'Private Sub Form_BringToFront()
' Me.BringToFront()
'End Sub
'Private Sub LBL_MouseMove(sender As Object, e As MouseEventArgs) Handles LBL.MouseMove
' LBL.BackColor = Color.Red : LBL.ForeColor = Color.White
' LBL.BorderStyle = BorderStyle.FixedSingle
' Application.DoEvents()
' Threading.Thread.Sleep(200)
' LBL.BorderStyle = BorderStyle.None
' LBL.BackColor = Me.BackColor : LBL.ForeColor = Color.DimGray
'End Sub
'Private Sub LBL_MouseDown(sender As Object, e As MouseEventArgs) Handles LBL.MouseDown
' If e.Button = MouseButtons.Left Then
' Me.Visible = False
' Application.DoEvents()
' End If
'End Sub
'Dim Xobj As Single, Yobj As Single
'Dim Xfrm As Single, Yfrm As Single
'Dim TM As Boolean = False
'Dim SNR As Control
'Sub Mueve_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
' If e.Button = MouseButtons.Left Then
' SNR = CType(sender, Control)
' SNR.BringToFront()
' Xobj = e.X
' Yobj = e.Y
' TM = True
' Application.DoEvents()
' End If
'End Sub
'Sub Mueve_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
' If e.Button = MouseButtons.Left Then
' If TM = True Then
' SNR = CType(sender, Control)
' Xfrm = e.X + SNR.Left
' Yfrm = e.Y + SNR.Top
' SNR.Left = CInt(Xfrm - Xobj)
' SNR.Top = CInt(Yfrm - Yobj)
' Application.DoEvents()
' End If
' End If
'End Sub
'Sub Mueve_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
' If e.Button = MouseButtons.Left Then
' TM = False
' Application.DoEvents()
' End If
'End Sub