|
-
Apr 30th, 2004, 05:00 PM
#1
Thread Starter
Fanatic Member
Form will not show until sub has completed. [SOLVED]
Ok, got rid of all the headaches in the search algorithm I used, it shows the startup form, but I have another form with a progress bar on it, and that won't show until the algorithm has completed its routine.
VB Code:
Sub ScanFolder(FolderSpec)
Dim thisFolder As Folder
Dim allFolders As Folders
Dim thisFile As File
Dim allFiles As Files
Dim lstItem As ListItem
Set fso = New FileSystemObject
If Not FolderSpec = "D" Then
Set thisFolder = fso.GetFolder(FolderSpec & "\")
Else
Set thisFolder = fso.GetFolder(FolderSpec & ":")
End If
Set allFolders = thisFolder.SubFolders
For Each thisFolder In allFolders
Set allFiles = thisFolder.Files
If allFiles.Count > 0 Then
For Each thisFile In allFiles
Set lstItem = frmMain.lvwVolumes.ListItems.Add(, , thisFile.Name)
lstItem.SubItems(1) = thisFile.Size
Next
End If
Set allFiles = Nothing
ScanFolder thisFolder.Path
DoEvents
Next
Set thisFolder = Nothing
Set allFolders = Nothing
Set rs = Nothing
Set fso = Nothing
Exit Sub
End Sub
And here's where I call the form.
VB Code:
Sub ProcessDeviceChange(wParam As Long, lParam As Long)
Dim DBHdr As DEV_BROADCAST_HDR
Dim DBVol As DEV_BROADCAST_VOLUME
CopyMemory DBHdr, ByVal lParam, LenB(DBHdr)
If wParam = DBT_DEVICEARRIVAL Then
If DBHdr.dbch_devicetype = DBT_DEVTYP_VOLUME Then
CopyMemory DBVol, ByVal lParam, LenB(DBVol)
If (DBVol.dbcv_flags And DBTF_MEDIA) = DBTF_MEDIA Then
frmSetup.Show
End If
End If
End If
End Sub
Last edited by hothead; Apr 30th, 2004 at 06:23 PM.
-
Apr 30th, 2004, 06:15 PM
#2
So Unbanned
Uhm... I don't see where you call ScanFolder... nor the progress bar code. If you call this from fom_load, that may be the problem. Try form_activate instead.
-
Apr 30th, 2004, 06:19 PM
#3
Thread Starter
Fanatic Member
Thanks, that worked.
Yes, I was calling it from Form_Load
VB Code:
Private Sub Form_Load()
Dim drv As Drive
CenterForm Me
Set fso = New FileSystemObject
For Each drv In fso.Drives
If drv.DriveType = CDRom Then
If drv.IsReady = True Then
ScanFolder drv.DriveLetter
Else
Exit Sub
End If
End If
Next
For i = 1 To frmMain.lvwVolumes.ListItems.Count
TotalCDSize = TotalCDSize + frmMain.lvwVolumes.ListItems(i).SubItems(1)
Next i
For i = 1 To frmMain.lvwVolumes.ListItems.Count
BytesProcessed = BytesProcessed + frmMain.lvwVolumes.ListItems(i).SubItems(1)
pbrProgress.Value = BytesProcessed / TotalCDSize
Next i
Set fso = Nothing
End Sub
Moving it to Form_Activate worked.
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
|