Click to See Complete Forum and Search --> : Activating two commands using same command button
Simonkale
July 15th, 2001, 08:05 AM
I need to open and close CD door using same command button. If cd door is close then eject it else close it. Like in Windows CD Player. Any ideas.
I know how to open or close the cd door but how do I check whether it is open or close?
Thanks,
Simon
Xanth Nomeda
July 20th, 2001, 06:21 PM
Maybe im off on this, but i belive your looking for
dim isOpen as (whatever the open/closecd functions return)
isOpen = openCD()
if isOpen = False(or whatever the negative return) then
openCD()
Else
closeCD()
End If
Just a shot in the dark without knowing the exact functions...
Xanth Nomeda
xnomeda@Nomeda.com
Simonkale
July 20th, 2001, 09:16 PM
I've almost done it. I tried to make it perfect but after several hours of hard work I simply couldn't. I've decided to have a look at it again at the end of the project. Since you are willing to work at it. I'll give my almost perfect code.
Add a class module and put these functions;
public Function EjectOpenCD()
'eject the CD door
mciSendString "set cd door open", 0, 0, 0
End Function
public Function EjectCloseCD()
'close the CD door
mciSendString "set cd door closed", 0, 0, 0
End Function
Add this in code of the form.
option Explicit
Dim snd as clsCDPlayer
Dim DoorOpen as Boolean
private Sub cmdEject_Click()
'eject/close CD door
If DoorOpen = true then
snd.EjectCloseCD
DoorOpen = false
Exit Sub
else
snd.EjectOpenCD
End If
DoorOpen = true
End Sub
private Sub Form_Load()
set snd = new clsCDPlayer 'clsCDPlayer = name of the class module
End Sub
This code works but there is a bug.
Open the cd door by clicking eject button in the CD-ROM itself. Now run the program(cdplayer) and click eject button to close the cd door. It won't close it unless you click it twice. Now the problem is how do I check whether the cd door is opened or not at form_load event.
Best of luck!
Simon
deghost
July 22nd, 2001, 02:56 PM
maybe try finding the right mci command string like status or info or monitor etc. you can find the help in msdn on the label of mci command strings
----------
The @host is everywhere!
----------
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.