|
-
Jan 26th, 2007, 07:47 AM
#1
-
Jan 26th, 2007, 08:38 AM
#2
Re: [2005] Showing another form
Can't you just call the show and hide method?
Form1.Show()
Form1.Hide()
-
Jan 26th, 2007, 08:47 AM
#3
-
Jan 26th, 2007, 09:25 AM
#4
Re: [2005] Showing another form
There is no need to call the visible properties in the for load.
Just change you Show and Hide functions to call
VB Code:
Private Sub ShowRead()
fRead.Show()
End Sub
Private Sub HideRead()
fRead.Hide()
End Sub
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Serial.IsOpen = True Then
Serial.Close()
End If
Index = 0
fRead.pbRead.Minimum = 0
fRead.pbRead.Maximum = 63
fRead.pbRead.Value = 0
Try
With Serial
.BaudRate = 9600
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
End With
Serial.Open()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
-
Jan 26th, 2007, 09:41 AM
#5
-
Jan 26th, 2007, 10:06 AM
#6
Re: [2005] Showing another form
Question, why are you using delegates to show the form? Why not just call the show method in your DataRecieved sub like so
VB Code:
Private Sub DataReceived( _
ByVal sender As Object, _
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
Handles Serial.DataReceived
If fRead.Visible = False Then
fRead.Show()
End If
fRead.pbRead.Invoke(New myDelegate(AddressOf ChangePB))
Tdata(Index) = Serial.ReadByte
Index += 1
If Index = 64 Then
Index = 0
Call Display()
End If
End Sub
-
Jan 26th, 2007, 10:15 AM
#7
-
Jan 28th, 2007, 07:42 PM
#8
-
Feb 21st, 2007, 02:58 PM
#9
-
Mar 5th, 2007, 03:41 PM
#10
-
Mar 5th, 2007, 05:21 PM
#11
Fanatic Member
Re: [2005] Showing another form
Here is something similiar out of an application that I have done.
My ShowProcessing.vb class
Code:
Imports System.ComponentModel
Public Class ShowProcessing
Implements IDisposable
Private _TextToDisplay As String
Private WithEvents _bw As New BackgroundWorker
#Region " IDisposable Support "
Private disposedValue As Boolean = False ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
End If
_bw.Dispose()
End If
Me.disposedValue = True
End Sub
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
#Region " Property Declarations "
Friend Property TextToDisplay() As String
Get
Return _TextToDisplay
End Get
Set(ByVal value As String)
_TextToDisplay = value
End Set
End Property
#End Region
Public Sub New()
_bw.WorkerSupportsCancellation = True
End Sub
Friend Sub StartProcessing()
_bw.RunWorkerAsync()
End Sub
Friend Sub StopProcessing()
_bw.CancelAsync()
End Sub
Private Sub _bw_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles _bw.DoWork
Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)
e.Result = DisplayForm(worker, _TextToDisplay, e)
End Sub
Private Function DisplayForm(ByVal worker As BackgroundWorker, ByVal inText As String, ByVal e As System.ComponentModel.DoWorkEventArgs) As Boolean
Dim frm As New frmProcessing
With frm
.Text = inText
.ShowDialog(worker, e)
.Dispose()
End With
End Function
End Class
My ProgressBar form:
Code:
Public Class frmProcessing
Private _worker As System.ComponentModel.BackgroundWorker
Private _e As System.ComponentModel.DoWorkEventArgs
Private Sub frmProcessing_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
_e.Cancel = True
End Sub
Private Sub frmProcessing_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
With ProgressBar1
.Minimum = 0
.Maximum = 100
.Value = 0
End With
With Timer1
.Interval = 500
.Start()
End With
Cursor = Cursors.WaitCursor
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If _worker.CancellationPending Then
Me.Close()
End If
If ProgressBar1.Value = 100 Then
ProgressBar1.Value = 0
Else
ProgressBar1.Value += 1
End If
End Sub
Public Overloads Function ShowDialog(ByVal worker As System.ComponentModel.BackgroundWorker, ByVal e As System.ComponentModel.DoWorkEventArgs) As System.Windows.Forms.DialogResult
_worker = worker
_e = e
MyBase.ShowDialog()
End Function
End Class
My.Settings.Signature = String.Empty
-
Mar 5th, 2007, 05:24 PM
#12
Fanatic Member
Re: [2005] Showing another form
The example above is shown by FormA when it starts a SQL Stored Procedure that takes about 5 minutes to run. I just wanted the user to understand that it was still working.
That should give you a push in the right direction.
PS - Why all of the Delegates in your code? Is there something I am missing?
My.Settings.Signature = String.Empty
-
Mar 6th, 2007, 05:40 PM
#13
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|