
MCI Control Gets Into a Tizzy - Done Events Not Being Generated
I'm writing a program (VB 4.0 Win 3.11) that uses a multimedia MCI
Control to play WAVe and MIDi files. The program uses two forms. The
main (frmMain) form displays a digital clock and is used to load sound
schedules and display the status of the file currently playing. This
form also has a menu control on it.
The second form (frmEditGroup) has the MCI control on it. It is loaded
when the Edit|Edit Group menu command is selected from the main form
using the statement: frmEditGroup.Show. I can play all of my files
just fine, and Done events are generated as expected when the program
is run for the first time. However, when I exit the program, and then
run it again, no DONE events are generated. The only way to get the
done events generated is to shut VB down and restart it.
This is how I exit the program:
While on the second form (the one with the MCI control) I click the
Exit button. This causes the following statement to be executed:
frmEditGroup.Hide, thus preserving variables related to that form, and
returning me to the main form.
On the main form, I click on File|Exit. The following lines of code
are executed:
frmEditGroup.MMControl1.Wait = True
frmEditGroup.MMControl1.Command = "Close"
Close
End
When I run the program again, the MCI_Done events don't get generated.
Am I not managing the MCI resources properly. These actions obviously
put the MCI control in a state of confusion.
Please also note that if you click the stop button on the VB tool-bar
or if you double-click the control menu bar on the main form as a
means to end the program, the MCI control gets confused here as well.
I would almost expect this to happen though, because I don't have any
code in the forms unload event that would take care of the MCI
control. Also, I would have thought that when you re-start a program,
the MCI control would be initialized to some default behaviour. but
instead it seems to retain old values.
After the problem occurred, I started playing with notify and wait
properties, but the control ignores them. Also, as stated above, the
program runs as expected the first time through, so I must have these
properties set correctly.
If anyone has any clues as to what is taking place here, I would
appreciate it very much if you would pass them along. Thanks.
Regards,
Michael E. Floyd
Saint John, NB Canada
P.S. After writing this note, I put a frmEditGroup.Unload statement
in my main form's Unload event. Now, the File|Exit command should
close the media player, and then the main form's unload event should
unload frmEditGroup. Without unloading the second form, the programs
resources are chewing up memory (at least in EXE version).
Unfortunately, it didn't help me.