|
-
Jun 30th, 2002, 08:21 PM
#1
Thread Starter
Fanatic Member
Making program look professional?
Hey, I'm wanting to make my program look more professional & USERPROOF! Here's what I want to do:
The following code populates a listview. I want to have another form with a progress bar that progresses as the list populates, while locking the form the listview is on so the user can't mess with it. Then when the progress bar reaches 100%, that form should close and turn vbModal off so the user can use the main form again. Hope this makes sense. I've never done this so I'm unsure on how to implement it. Any help is extremely appreciated.
I need the progress bar form to be on while the following event is occuring:
VB Code:
For x = 0 To File1.ListCount - 1
fname = File1.Path & "\" & File1.List(x)
'Get the MP3 info
ReadID3Info fname 'Read Id3v1.1 information
CMp3info.FileName = fname 'Get mp3info such as bitrate
Set i = ListView1.ListItems.Add(, , File1.List(x))
i.SubItems(1) = RTrim(GetID3.Artist)
i.SubItems(2) = RTrim(GetID3.Songname)
i.SubItems(3) = RTrim(GetID3.Album)
i.SubItems(4) = RTrim(GetID3.Track)
i.SubItems(5) = RTrim(GetID3.Genre)
i.SubItems(6) = Format(FileLen(fname) / 1000000, "#0.00")
i.SubItems(7) = CMp3info.Frequency
i.SubItems(8) = CMp3info.BitRate
strMins = Format(CMp3info.Duration \ 60, "#0")
strSecs = Format(CMp3info.Duration Mod 60, "0#")
strLength = strMins & ":" & strSecs
i.SubItems(9) = strLength
i.SubItems(10) = fname
DoEvents
Next
-
Jun 30th, 2002, 09:18 PM
#2
PowerPoster
assuming you want a zero to 100 progress bar, do this
VB Code:
frmProgress.Show ' or load it modal if that's what you want
frmProgress.ProgressBar1.Value = 0
For x = 0 To File1.ListCount - 1
fname = File1.Path & "\" & File1.List(x)
'Get the MP3 info
ReadID3Info fname 'Read Id3v1.1 information
CMp3info.FileName = fname 'Get mp3info such as bitrate
Set i = ListView1.ListItems.Add(, , File1.List(x))
i.SubItems(1) = RTrim(GetID3.Artist)
i.SubItems(2) = RTrim(GetID3.Songname)
i.SubItems(3) = RTrim(GetID3.Album)
i.SubItems(4) = RTrim(GetID3.Track)
i.SubItems(5) = RTrim(GetID3.Genre)
i.SubItems(6) = Format(FileLen(fname) / 1000000, "#0.00")
i.SubItems(7) = CMp3info.Frequency
i.SubItems(8) = CMp3info.BitRate
strMins = Format(CMp3info.Duration \ 60, "#0")
strSecs = Format(CMp3info.Duration Mod 60, "0#")
strLength = strMins & ":" & strSecs
i.SubItems(9) = strLength
i.SubItems(10) = fname
DoEvents
frmProgress.ProgressBar1.Value = 100 * (x / (File1.ListCount - 1))
Next x
unload frmProgress
-
Jun 30th, 2002, 09:25 PM
#3
PowerPoster
forgot to mention, set progress bar min to 0 and max to 100 (these are in the properties at design time, and are available at run-time as well)
-
Jun 30th, 2002, 09:26 PM
#4
The problem with having a modal form show the progress of a process on an other form is that when you call
the code on the other form will stop dead in it's tracks until you close the modal form.
-
Jun 30th, 2002, 09:36 PM
#5
Thread Starter
Fanatic Member
Two questions.........
Instead of using vbModal could I use that freeze window API? That just freezes the window allowing code to run in the background.
-
Jun 30th, 2002, 11:04 PM
#6
PowerPoster
MarkT's point is certainly a good one. I don't know anything about the "freeze window" thing, but I have another off-the-cuff idea which is this. Don't make the progress form modal, but while it's running, make the other form have .enabled=false
I'm not sure that works but the idea would be to allow your code to keep running but not allow user input of any kind to the form while the progress bar is on.
-
Jul 1st, 2002, 04:49 AM
#7
Addicted Member
You could also add the progress bar to the form itself instead of having another form open and set the enable property of the listview to false.
I think this will look more professional and user-friendly.
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
|