Processing Messages for a CD Player Graphic Button

The following code fragment illustrates a message-handling procedure for a CD player window. This example demonstrates synchronization of a graphic button and control of a CD player.

  CD_Player_Message_Proc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  {
      switch (msg)  {
        ...
        case WM_CONTROL:

        /* If the Music Scan GraphicButton sent the notification...   */
            if (SHORT1FROMMP(mp1) == ID_MUSIC_SCAN) {

               switch (SHORT2FROMMP(mp1)) {  /* type of notification */

                  case GBN_BUTTONHILITE:  /* button held down */
                     CD_Music_Scan_Start (...);
                     break;

                  case GBN_BUTTONUP:      /* button released */
                     CD_Music_Scan_Stop (...);
                     break;
                  ...
               }
            ...
            }
            ...
            break;
        ...
     }
  }

When the music scan button on a physical CD player is held down, it allows the listener to hear the music played at an accelerated rate. In the example shown in the previous figure, the effect of the message procedure is similar. If the user holds the mouse button down and the pointer is over the Music Scan graphic button, the CD_Music_Scan_Start function is called. If the mouse button is released, or the pointer is removed from the Music Scan graphic button, then the CD_Music_Scan_Stop function is called.


[Back: Two-State Graphic Button]
[Next: Secondary Windows]