the cancel can be done with a doevents statement in the loop.
I do this with a batch image converter.
This is some sample code that gives the idea, but is dependent on other functions of course:
Public Sub ConvertImgCSandType(ByVal e As MtClickEventArgs, ByVal exts As String, ByVal colorSpace As
ImageManip.colorSpaces, ByVal imgExt As ImageManip.ImgExtensions)
Dim formStatus As New frmStatus
Try
Dim SelectedItems() As String = GeteFilteredFiles(e.SelectedItems, exts)
If Not SelectedItems Is Nothing Then
Dim useFolder As String = Path.GetDirectoryName(SelectedItems(0))
If IsFldrReadOnly(useFolder) = True Then
'see if user wants to create locally
If MsgBox("Folder is Read-Only, Create File on Desktop instead?", MsgBoxStyle.YesNo, "Question") =
MsgBoxResult.Yes Then
useFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
End If
End If
formStatus.Startup(SelectedItems.GetUpperBound(0) + 1)
'do items
Dim i As Integer = 0
While formStatus.Cancel = False And i < SelectedItems.GetUpperBound(0) + 1 '<---Loop starts here
If formStatus.CanFocus = True Then formStatus.OneMore()
ImageManip.ReColorImg(SelectedItems(i), colorSpace, useFolder, imgExt)
Application.DoEvents() '<--- do events here, this means check if other forms have been picked
i += 1
If formStatus.CanFocus = True Then formStatus.OneMoreDone()
End While
End If
Catch ex As Exception
End Try
If Not formStatus Is Nothing Then formStatus.FadeClose() 'formStatus.Close()
End Sub
the idea is to use a global var that the loop checks before continuing.
hbhlm <>
|>I want to write some code .net to batch-plot several drawings , and also during process, a dialog is avaible for user to cancel the plotting. Can anyone tell me where to find sample code related to plot in vb.net? Thanks.
James Maeding
Civil Engineer and Programmer
jmaeding - at - hunsaker - dotcom