CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1

    Activating two commands using same command button

    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


  2. #2
    Join Date
    Jul 2001
    Posts
    3

    Re: Activating two commands using same command button

    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
    [email protected]


  3. #3

    Re: Activating two commands using same command button

    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


  4. #4
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    Re: Activating two commands using same command button

    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!
    ----------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured