Salve, stavo continuando un vecchio progetto in .net ma sono incappato in questo problema che mi ha lasciato perplesso. Semplicemente trovandomi in un form1(esempio), cliccando un bottone doveva nascondermi il form1 e mostrarmi il form2. Il form2 appare ma il form1 non si nasconde; lasci qui il "source code" anche se sono due stringhe...
Private Sub btn_dir_Click(sender As Object, e As EventArgs) Handles bnt_dir.Click
Me.Hide()
DirectoryForm.Show()
P.S. Ho notato che sempre nello stesso progetto, ma in altri form questo problema non accade, e in questo form dove e' avvenuto cio' non si chiude nemmeno con
Me.close()
. E' come se si chiudesse e poi si riaprisse contemporaneamente.
Grazie a tutti.
Form1:
Public Class HomeForm
#Region "MoveForm"
Const WM_NCHITTEST As Integer = &H84
Const HTCLIENT As Integer = &H1
Const HTCAPTION As Integer = &H2
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_NCHITTEST
MyBase.WndProc(m)
If m.Result = IntPtr.op_Explicit(HTCLIENT) Then m.Result = IntPtr.op_Explicit(HTCAPTION)
Case Else
MyBase.WndProc(m)
End Select
End Sub
#End Region
#Region "Move Panel"
Dim drag As Boolean
Dim mousex As Integer
Dim mousey As Integer
Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
drag = True
mousex = Cursor.Position.X - Me.Left 'Sets variable mousex
mousey = Cursor.Position.Y - Me.Top 'Sets variable mousey
End Sub
Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
If drag Then
Me.Top = Cursor.Position.Y - mousey
Me.Left = Cursor.Position.X - mousex
End If
End Sub
Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
drag = False
End Sub
#End Region
#Region "Move Panel2"
Private Sub Panel2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel2.MouseDown
drag = True
mousex = Cursor.Position.X - Me.Left 'Sets variable mousex
mousey = Cursor.Position.Y - Me.Top 'Sets variable mousey
End Sub
Private Sub Panel2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel2.MouseMove
If drag Then
Me.Top = Cursor.Position.Y - mousey
Me.Left = Cursor.Position.X - mousex
End If
End Sub
Private Sub Panel2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel2.MouseUp
drag = False
End Sub
#End Region
Private Sub btn_home_min_Click(sender As Object, e As EventArgs) Handles btn_home_min.Click
Me.WindowState = WindowState.Minimized
End Sub
Private Sub btn_dir_Click(sender As Object, e As EventArgs) Handles bnt_dir.Click
Me.Hide()
DirectoryForm.Show()
End Sub
Private Sub btn_home_close_Click(sender As Object, e As EventArgs) Handles btn_home_close.Click
Application.ExitThread()
End Sub
Private Sub HomeForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
Form2:
Public Class DirectoryForm
Private Sub btn_home_min_Click(sender As Object, e As EventArgs) Handles btn_direc_min.Click
Me.WindowState = FormWindowState.Minimized
End Sub
Private Sub btn_home_close_Click(sender As Object, e As EventArgs) Handles btn_home_close.Click
Me.Close()
HomeForm.Show()
End Sub
End Class