home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / m / m003_1 / sdk_win.ddi / SAMPLE / DLLMUSIC / DLLMUSIC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-17  |  23.8 KB  |  700 lines

  1. /****************************************************************************
  2.  
  3.     PROGRAM: DLLMusic.c
  4.  
  5.     PURPOSE: DLLMusic template for Sound Blaster applications
  6.  
  7.     FUNCTIONS:
  8.  
  9.     WinMain () - calls initialization function, processes message loop
  10.     InitApplication () - initializes window data and registers window
  11.     InitInstance () - saves instance handle and creates main window
  12.     MainWndProc () - processes messages
  13.     About () - processes messages for "About" dialog box
  14.  
  15.     COMMENTS:
  16.  
  17.         Windows can have several copies of your application running at the
  18.         same time. The variable hInst keeps track of which instance this
  19.         application is so that processing will be to the correct window.
  20.  
  21. ****************************************************************************/
  22.  
  23. #include "windows.h"            /* required for all Windows applications */
  24. #include "dllmusic.h"           /* specific to this program              */
  25. #include <sndblst.h>
  26.  
  27. WORD    wDLLVersion;            /* verion number of DLL                  */
  28. WORD    wSoundBlasterMsg;       /* Sound Blaster message                 */
  29. LPSTR   lpCardName;             /* name of Sound Blaster card            */
  30. HANDLE  hInst;                  /* current instance                      */
  31. HANDLE  hMusicMem;              /* handle of allocated memory            */
  32. LPSTR   lpBuffer;               /* buffer to hold voice data             */
  33. HWND    hWnd;                   /* main window handle.                   */
  34. int     wTempoValue=100;        /* tempo value                           */
  35. int     wTransposeValue=0;      /* transpose value                       */
  36. WORD    wMusicStatus=0;         /* music status                          */
  37.  
  38. /****************************************************************************
  39.  
  40.     FUNCTION: WinMain (HANDLE, HANDLE, LPSTR, int)
  41.  
  42.     PURPOSE: calls initialization function, processes message loop
  43.  
  44.     COMMENTS:
  45.  
  46.         Windows recognizes this function by name as the initial entry point 
  47.         for the program.  This function calls the application initialization 
  48.         routine, if no other instance of the program is running, and always 
  49.         calls the instance initialization routine.  It then executes a message 
  50.         retrieval and dispatch loop that is the top-level control structure 
  51.         for the remainder of execution. The loop is terminated when a WM_QUIT
  52.         message is received, at which time this function exits the application 
  53.         instance by returning the value passed by PostQuitMessage(). 
  54.  
  55.         If this function must abort before entering the message loop, it 
  56.         returns the conventional value NULL.  
  57.  
  58. ****************************************************************************/
  59.  
  60. int PASCAL WinMain (hInstance, hPrevInstance, lpCmdLine, nCmdShow)
  61. HANDLE hInstance;                /* current instance             */
  62. HANDLE hPrevInstance;            /* previous instance            */
  63. LPSTR lpCmdLine;                 /* command line                 */
  64. int nCmdShow;                     /* show-window type (open/icon) */
  65. {
  66.     MSG msg;                     /* message                      */
  67.  
  68.     if (!hPrevInstance)               /* Other instances of app running?   */
  69.     if (!InitApplication (hInstance)) /* Initialize shared things          */
  70.         return (FALSE);               /* Exits if unable to initialize     */
  71.  
  72.     /* Perform initializations that apply to a specific instance */
  73.  
  74.     if (!InitInstance (hInstance, nCmdShow))
  75.         return (FALSE);
  76.  
  77.     if ((wDLLVersion = sbcGetDLLVersion ()) == NULL)
  78.         return (FALSE);
  79.  
  80.     if ((lpCardName = sbcGetCardName ()) == NULL)
  81.         return (FALSE);
  82.  
  83.     wSoundBlasterMsg = RegisterWindowMessage ((LPSTR) "SoundBlaster");
  84.  
  85.     /* Acquire and dispatch messages until a WM_QUIT message is received. */
  86.  
  87.     while (GetMessage (&msg,     /* message structure                      */
  88.         NULL,                    /* handle of window receiving the message */
  89.         NULL,                    /* lowest message to examine              */
  90.         NULL))                   /* highest message to examine             */
  91.     {
  92.         TranslateMessage (&msg); /* Translates virtual key codes           */
  93.         DispatchMessage (&msg);  /* Dispatches message to window           */
  94.     }
  95.  
  96.     sbcTerminateDLL ();
  97.  
  98.     return (msg.wParam);        /* Returns the value from PostQuitMessage */
  99. }
  100.  
  101.  
  102. /****************************************************************************
  103.  
  104.     FUNCTION: InitApplication (HANDLE)
  105.  
  106.     PURPOSE: Initializes window data and registers window class
  107.  
  108.     COMMENTS:
  109.  
  110.         This function is called at initialization time only if no other 
  111.         instances of the application are running.  This function performs 
  112.         initialization tasks that can be done once for any number of running 
  113.         instances.  
  114.  
  115.         In this case, we initialize a window class by filling out a data 
  116.         structure of type WNDCLASS and calling the Windows RegisterClass() 
  117.         function.  Since all instances of this application use the same window 
  118.         class, we only need to do this when the first instance is initialized.  
  119.  
  120. ****************************************************************************/
  121.  
  122. BOOL InitApplication (hInstance)
  123. HANDLE hInstance;                       /* current instance                   */
  124. {
  125.     WNDCLASS  wc;
  126.  
  127.     /* Fill in window class structure with parameters that describe the       */
  128.     /* main window.                                                           */
  129.  
  130.     wc.style         = NULL;             /* Class style(s).                    */
  131.     wc.lpfnWndProc   = MainWndProc;      /* Function to retrieve messages for  */
  132.                                          /* windows of this class.             */
  133.     wc.cbClsExtra    = 0;                /* No per-class extra data.           */
  134.     wc.cbWndExtra    = 0;                /* No per-window extra data.          */
  135.     wc.hInstance     = hInstance;        /* Application that owns the class.   */
  136.     wc.hIcon         = LoadIcon (hInstance, "dllmusic");
  137.     wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
  138.     wc.hbrBackground = GetStockObject(WHITE_BRUSH); 
  139.     wc.lpszMenuName  = "DLLMusicMenu";   /* Name of menu resource in .RC file. */
  140.     wc.lpszClassName = "DLLMusicWClass"; /* Name used in call to CreateWindow. */
  141.  
  142.     /* Register the window class and return success/failure code. */
  143.  
  144.     return (RegisterClass (&wc));
  145.  
  146. }
  147.  
  148.  
  149. /****************************************************************************
  150.  
  151.     FUNCTION:  InitInstance (HANDLE, int)
  152.  
  153.     PURPOSE:  Saves instance handle and creates main window
  154.  
  155.     COMMENTS:
  156.  
  157.         This function is called at initialization time for every instance of 
  158.         this application.  This function performs initialization tasks that 
  159.         cannot be shared by multiple instances.  
  160.  
  161.         In this case, we save the instance handle in a static variable and 
  162.         create and display the main program window.  
  163.         
  164. ****************************************************************************/
  165.  
  166. BOOL InitInstance (hInstance, nCmdShow)
  167.     HANDLE          hInstance;          /* Current instance identifier.       */
  168.     int             nCmdShow;           /* Param for first ShowWindow() call. */
  169. {
  170.     /* Save the instance handle in static variable, which will be used in  */
  171.     /* many subsequence calls from this application to Windows.            */
  172.  
  173.     hInst = hInstance;
  174.  
  175.     /* Create a main window for this application instance.  */
  176.  
  177.     hWnd = CreateWindow
  178.     (
  179.         "DLLMusicWClass",               /* See RegisterClass() call.          */
  180.         "DLLMUSIC Sample Application",  /* Text for window title bar.         */
  181.         WS_OVERLAPPEDWINDOW,            /* Window style.                      */
  182.         CW_USEDEFAULT,                  /* Default horizontal position.       */
  183.         CW_USEDEFAULT,                  /* Default vertical position.         */
  184.         CW_USEDEFAULT,                  /* Default width.                     */
  185.         CW_USEDEFAULT,                  /* Default height.                    */
  186.         NULL,                           /* Overlapped windows have no parent. */
  187.         NULL,                           /* Use the window class menu.         */
  188.         hInstance,                      /* This instance owns this window.    */
  189.         NULL                            /* Pointer not needed.                */
  190.     );
  191.  
  192.     /* If window could not be created, return "failure" */
  193.  
  194.     if (!hWnd)
  195.         return (FALSE);
  196.  
  197.     /* Make the window visible; update its client area; and return "success" */
  198.  
  199.     ShowWindow (hWnd, nCmdShow);   /* Show the window                        */
  200.     UpdateWindow (hWnd);           /* Sends WM_PAINT message                 */
  201.     return (TRUE);                 /* Returns the value from PostQuitMessage */
  202.  
  203. }
  204.  
  205. /****************************************************************************
  206.  
  207.     FUNCTION: MainWndProc (HWND, unsigned, WORD, LONG)
  208.  
  209.     PURPOSE:  Processes messages
  210.  
  211.     MESSAGES:
  212.  
  213.     WM_COMMAND    - application menu (About dialog box)
  214.     WM_DESTROY    - destroy window
  215.  
  216.     COMMENTS:
  217.  
  218.     To process the IDM_ABOUT message, call MakeProcInstance() to get the
  219.     current instance address of the About() function.  Then call Dialog
  220.     box which will create the box according to the information in your
  221.     dllmusic.rc file and turn control over to the About() function.  When
  222.     it returns, free the intance address.
  223.  
  224. ****************************************************************************/
  225.  
  226. long FAR PASCAL MainWndProc (hWnd, message, wParam, lParam)
  227. HWND hWnd;                    /* window handle                   */
  228. unsigned message;             /* type of message                 */
  229. WORD wParam;                  /* additional information          */
  230. LONG lParam;                  /* additional information          */
  231. {
  232.     PAINTSTRUCT ps;
  233.     FARPROC lpProcAbout;      /* pointer to the "About" function */
  234.  
  235.     switch (message)
  236.     {
  237.         case WM_PAINT:
  238.             BeginPaint (hWnd, &ps);
  239.             EndPaint (hWnd, &ps);
  240.             DisplayMusicFlag (wMusicStatus);
  241.             DisplayTransposeValue (wTransposeValue);
  242.             DisplayTempoValue (wTempoValue);
  243.             break;
  244.         case WM_COMMAND:       /* message: command from application menu */
  245.             switch (wParam)
  246.             {
  247.                 case IDM_ABOUT:
  248.                     lpProcAbout = MakeProcInstance (About, hInst);
  249.                     DialogBox(hInst,         /* current instance         */
  250.                         "AboutBox",          /* resource to use          */
  251.                         hWnd,                /* parent handle            */
  252.                         lpProcAbout);        /* About() instance address */
  253.                     FreeProcInstance (lpProcAbout);
  254.                     break;
  255.                 case IDM_START:
  256.                     PlayMusicProcess ();
  257.                     break;
  258.                 case IDM_STOP:
  259.                     StopMusicProcess ();
  260.                     break;
  261.                 case IDM_PAUSE:
  262.                     PauseMusicProcess ();
  263.                     break;
  264.                 case IDM_CONTINUE:
  265.                     ContinueMusicProcess ();
  266.                     break;
  267.                 case IDM_TRANSPOSE_UP:
  268.                     TransposeMusic (1);
  269.                     break;
  270.                 case IDM_TRANSPOSE_DOWN:
  271.                     TransposeMusic (-1);
  272.                     break;
  273.                 case IDM_TEMPO_UP:
  274.                     ChangeMusicTempo (10);
  275.                     break;
  276.                 case IDM_TEMPO_DOWN:
  277.                     ChangeMusicTempo (-10);
  278.                     break;
  279.                 case IDM_FADE_IN:
  280.                     SetFading (100);
  281.                     break;
  282.                 case IDM_FADE_OUT:
  283.                     SetFading (0);
  284.                     break;
  285.                 default:          /* Lets Windows process it         */
  286.                     return (DefWindowProc (hWnd, message, wParam, lParam));
  287.             }
  288.             break;
  289.         case WM_DESTROY:          /* message: window being destroyed */
  290.             PostQuitMessage(0);
  291.             break;
  292.  
  293.         default:
  294.             if (message == wSoundBlasterMsg)
  295.             {
  296.                 switch (wParam)
  297.                 {
  298.                     case SBM_CALLBACK:
  299.                         sbcCallBack (lParam);
  300.                         break;
  301.                     case SBM_MUS_FLAG:
  302.                         switch (HIWORD (lParam))
  303.                         {
  304.                             case MP_PLAY_MEMMIDI:
  305.                                 wMusicStatus = LOWORD (lParam);
  306.                                 DisplayMusicFlag (wMusicStatus);
  307.                                 if (LOWORD (lParam) == 0)
  308.                                 {
  309.                                     musCloseDevice ();
  310.                                     ReleaseMemory ();
  311.                                 }
  312.                                 break;
  313.                         }
  314.                         break;
  315.                 }
  316.             }
  317.             else                  /* Passes it on if unproccessed    */
  318.             {
  319.                 return (DefWindowProc(hWnd, message, wParam, lParam));
  320.             }
  321.     }
  322.     return (NULL);
  323. }
  324.  
  325. /****************************************************************************
  326.  
  327.     FUNCTION: LoadMusicFile ()
  328.  
  329.     PURPOSE: Load a midi file into memory
  330.  
  331. ****************************************************************************/
  332.  
  333. HANDLE LoadMusicFile ()
  334. {
  335.     HANDLE        hFile ;
  336.     OFSTRUCT    os;
  337.     LONG        lFileLen ;
  338.     HANDLE      hMusicMem;
  339.     LPSTR       lpMidiBuffer;
  340.  
  341.     if (hFile = OpenFile ("demo.mid", &os,OF_READ))
  342.     {
  343.         lFileLen = _llseek (hFile, 0L, 2) ;
  344.         _llseek (hFile, 0L, 0);
  345.         hMusicMem = GlobalAlloc (GMEM_MOVEABLE, lFileLen);
  346.         if (lpMidiBuffer = GlobalLock (hMusicMem))
  347.         {
  348.             _lread (hFile, lpMidiBuffer, 0xFFFF) ;
  349.             GlobalUnlock (hMusicMem);
  350.             wTempoValue = 100;
  351.             DisplayTempoValue (wTempoValue);
  352.             wTransposeValue = 0;
  353.             DisplayTransposeValue (wTransposeValue);
  354.         }
  355.         else
  356.         {
  357.             MessageBeep (0);
  358.             MessageBox (hWnd, "Cannot allocate memory", "Error...",
  359.                         MB_ICONEXCLAMATION | MB_OK);
  360.         }
  361.         _lclose (hFile);
  362.     }
  363.     else
  364.     {
  365.         hMusicMem = NULL;
  366.         MessageBeep (0);
  367.         MessageBox (hWnd, "Cannot open music file", "Error...",
  368.                     MB_ICONEXCLAMATION | MB_OK);
  369.     }
  370.     return hMusicMem;
  371. }
  372.  
  373. /****************************************************************************
  374.  
  375.     FUNCTION: ReleaseMemory ()
  376.  
  377.     PURPOSE: Return allocated memory block to windows
  378.  
  379. ****************************************************************************/
  380.  
  381. void ReleaseMemory ()
  382. {
  383.     GlobalPageUnlock (HIWORD (lpBuffer));
  384.     GlobalUnWire (hMusicMem);
  385.     GlobalFree (hMusicMem);
  386. }
  387.  
  388. /****************************************************************************
  389.  
  390.     FUNCTION: PlayMusicProcess ()
  391.  
  392.     PURPOSE: Start music playback
  393.  
  394. ****************************************************************************/
  395.  
  396. void PlayMusicProcess ()
  397. {
  398.     WORD wReturnCode;
  399.  
  400.     if (wReturnCode = musOpenDevice (hWnd))
  401.         DisplayErrorCode (wReturnCode);
  402.     else
  403.     {
  404.         if (hMusicMem = LoadMusicFile ())
  405.         {
  406.             lpBuffer = GlobalWire (hMusicMem);
  407.             GlobalPageLock (HIWORD (lpBuffer));
  408.             if (wReturnCode = musPlayMemMidi (lpBuffer))
  409.             {
  410.                 musCloseDevice ();
  411.                 ReleaseMemory ();
  412.                 DisplayErrorCode (wReturnCode);
  413.             }
  414.         }
  415.     }
  416. }
  417.  
  418. /****************************************************************************
  419.  
  420.     FUNCTION: StopMusicProcess ()
  421.  
  422.     PURPOSE: Stop current active music process
  423.  
  424. ****************************************************************************/
  425.  
  426. void StopMusicProcess ()
  427. {
  428.     WORD wReturnValue;
  429.  
  430.     if (wReturnValue = musStopMusic ())
  431.         DisplayErrorCode (wReturnValue);
  432. }
  433.  
  434. /****************************************************************************
  435.  
  436.     FUNCTION: PauseMusicProcess ()
  437.  
  438.     PURPOSE: Pause current active music process
  439.  
  440. ****************************************************************************/
  441.  
  442. void PauseMusicProcess ()
  443. {
  444.     WORD wReturnValue;
  445.  
  446.     if (wReturnValue = musPauseMusic ())
  447.         DisplayErrorCode (wReturnValue);
  448. }
  449.  
  450. /****************************************************************************
  451.  
  452.     FUNCTION: ContinueMusicProcess ()
  453.  
  454.     PURPOSE: Continue previously paused music process
  455.  
  456. ****************************************************************************/
  457.  
  458. void ContinueMusicProcess ()
  459. {
  460.     WORD wReturnValue;
  461.  
  462.     if (wReturnValue = musContinueMusic ())
  463.         DisplayErrorCode (wReturnValue);
  464. }
  465.  
  466. /****************************************************************************
  467.  
  468.     FUNCTION: DisplayErrorCode (WORD)
  469.  
  470.     PURPOSE: Display error code
  471.  
  472. ****************************************************************************/
  473.  
  474. void DisplayErrorCode (error)
  475. WORD error;
  476. {
  477.     char szTmpBuf[20];
  478.  
  479.     wsprintf (szTmpBuf, "Error code = %d", error);
  480.     MessageBeep (0);
  481.     MessageBox (NULL, szTmpBuf, "Error...", MB_ICONINFORMATION | MB_OK);
  482. }
  483.  
  484. /****************************************************************************
  485.  
  486.     FUNCTION: DisplayMusicFlag (WORD)
  487.  
  488.     PURPOSE: Display status of music process
  489.  
  490. ****************************************************************************/
  491.  
  492. void DisplayMusicFlag (mus_status)
  493. WORD mus_status;
  494. {
  495.     HDC hDC;
  496.     int x, y;
  497.     char szText[64];
  498.  
  499.     if (mus_status)
  500.     {
  501.         EnableMenuItem (GetMenu (hWnd), IDM_START, MF_DISABLED | MF_GRAYED);
  502.         EnableMenuItem (GetMenu (hWnd), IDM_STOP, MF_ENABLED);
  503.     }
  504.     else
  505.     {
  506.         EnableMenuItem (GetMenu (hWnd), IDM_START, MF_ENABLED);
  507.         EnableMenuItem (GetMenu (hWnd), IDM_STOP, MF_DISABLED | MF_GRAYED);
  508.     }
  509.     wsprintf (szText, "Music Flag           = %04x    ", mus_status);
  510.     hDC = GetDC (hWnd);
  511.     x = GetDeviceCaps (hDC, LOGPIXELSX)*2.75;
  512.     y = GetDeviceCaps (hDC, LOGPIXELSY)*0.25;
  513.     TextOut (hDC, x, y, szText, strlen (szText));
  514.     ReleaseDC (hWnd, hDC);
  515. }
  516.  
  517. /****************************************************************************
  518.  
  519.     FUNCTION: ChangeMusicTempo (int)
  520.  
  521.     PURPOSE: Increase or decrease tempo
  522.  
  523. ****************************************************************************/
  524.  
  525. void ChangeMusicTempo (wChangeValue)
  526. int wChangeValue;
  527. {
  528.     wTempoValue += wChangeValue;
  529.  
  530.     if (wTempoValue > 400)
  531.         wTempoValue = 400;
  532.     else
  533.     {
  534.         if (wTempoValue < 25)
  535.             wTempoValue = 25;
  536.     }
  537.  
  538.     DisplayTempoValue (wTempoValue);
  539.     musChangeTempo (wTempoValue);
  540. }
  541.  
  542. /****************************************************************************
  543.  
  544.     FUNCTION: DisplayTempoValue (int)
  545.  
  546.     PURPOSE: Display tempo value
  547.  
  548. ****************************************************************************/
  549.  
  550. void DisplayTempoValue (wTempoValue)
  551. int wTempoValue;
  552. {
  553.     HDC hDC;
  554.     int x, y;
  555.     char szText[64];
  556.  
  557.     wsprintf (szText, "Tempo value        = %d    ", wTempoValue);
  558.     hDC = GetDC (hWnd);
  559.     x = GetDeviceCaps (hDC, LOGPIXELSX)*2.75;
  560.     y = GetDeviceCaps (hDC, LOGPIXELSY)*0.65;
  561.     TextOut (hDC, x, y, szText, strlen (szText));
  562.     ReleaseDC (hWnd, hDC);
  563. }
  564.  
  565. /****************************************************************************
  566.  
  567.     FUNCTION: TransposeMusic (int)
  568.  
  569.     PURPOSE: Transpose melody up or down
  570.  
  571. ****************************************************************************/
  572.  
  573. void TransposeMusic (wSemiTone)
  574. int wSemiTone;
  575. {
  576.     wTransposeValue += wSemiTone;
  577.  
  578.     if (wTransposeValue > 24)
  579.         wTransposeValue = 24;
  580.     else
  581.     {
  582.         if (wTransposeValue < -24)
  583.             wTransposeValue = -24;
  584.     }
  585.  
  586.     DisplayTransposeValue (wTransposeValue);
  587.     musTransposeNote (wTransposeValue);
  588. }
  589.  
  590. /****************************************************************************
  591.  
  592.     FUNCTION: DisplayTransposeValue (int)
  593.  
  594.     PURPOSE: Display transpose value
  595.  
  596. ****************************************************************************/
  597.  
  598. void DisplayTransposeValue (wTransposeValue)
  599. int wTransposeValue;
  600. {
  601.     HDC hDC;
  602.     int x, y;
  603.     char szText[64];
  604.  
  605.     wsprintf (szText, "Transpose value  = %d    ", wTransposeValue);
  606.     hDC = GetDC (hWnd);
  607.     x = GetDeviceCaps (hDC, LOGPIXELSX)*2.75;
  608.     y = GetDeviceCaps (hDC, LOGPIXELSY)*0.45;
  609.     TextOut (hDC, x, y, szText, strlen (szText));
  610.     ReleaseDC (hWnd, hDC);
  611. }
  612.  
  613. /****************************************************************************
  614.  
  615.     FUNCTION: SetFading (WORD)
  616.  
  617.     PURPOSE: Increase or decrease volume in steps
  618.  
  619. ****************************************************************************/
  620.  
  621. void SetFading (wFinalValue)
  622. WORD wFinalValue;
  623. {
  624.     WORD wReturnCode;
  625.  
  626.     if (wReturnCode = musFadeMusic (-1, wFinalValue, 5, 5))
  627.         DisplayErrorCode (wReturnCode);
  628. }
  629.  
  630. /****************************************************************************
  631.  
  632.     FUNCTION: About (HWND, unsigned, WORD, LONG)
  633.  
  634.     PURPOSE:  Processes messages for "About" dialog box
  635.  
  636.     MESSAGES:
  637.  
  638.     WM_INITDIALOG - initialize dialog box
  639.     WM_COMMAND    - Input received
  640.  
  641.     COMMENTS:
  642.  
  643.     No initialization is needed for this particular dialog box, but TRUE
  644.     must be returned to Windows.
  645.  
  646.     Wait for user to click on "Ok" button, then close the dialog box.
  647.  
  648. ****************************************************************************/
  649.  
  650. BOOL FAR PASCAL About (hDlg, message, wParam, lParam)
  651. HWND hDlg;                                /* window handle of the dialog box */
  652. unsigned message;                         /* type of message                 */
  653. WORD wParam;                              /* message-specific information    */
  654. LONG lParam;
  655. {
  656.     HDC     hDC;
  657.     HDC     hMemoryDC;
  658.     char    szTmpBuf[128];
  659.     BITMAP  Bitmap;
  660.     HBITMAP hBmSBLogo;
  661.     HBITMAP hOldBitmap;
  662.  
  663.     switch (message)
  664.     {
  665.         case WM_INITDIALOG:           /* message: initialize dialog box */
  666.             wsprintf (szTmpBuf, "Hardware Card: %s", lpCardName);
  667.             SetDlgItemText (hDlg, IDT_CARDNAME, szTmpBuf);
  668.             wsprintf (szTmpBuf, "DLL Version: %d.%02d", HIBYTE (wDLLVersion),
  669.                                                         LOBYTE (wDLLVersion));
  670.             SetDlgItemText (hDlg, IDT_DLLVERSION, szTmpBuf);
  671.             return (TRUE);
  672.  
  673.         case WM_COMMAND:                      /* message: received a command */
  674.             if (wParam == IDOK                /* "OK" box selected?          */
  675.                     || wParam == IDCANCEL)    /* System menu close command?  */
  676.             {
  677.                 EndDialog (hDlg, TRUE);       /* Exits the dialog box        */
  678.                 return (TRUE);
  679.             }
  680.             break;
  681.         case WM_PAINT:
  682.             hBmSBLogo = LoadBitmap (hInst, "sbct");
  683.             GetObject (hBmSBLogo, sizeof (BITMAP), (LPSTR) &Bitmap);
  684.             hDC = GetDC (hDlg);
  685.             hMemoryDC = CreateCompatibleDC (hDC);
  686.             hOldBitmap = SelectObject (hMemoryDC, hBmSBLogo);
  687.             if (hOldBitmap)
  688.             {
  689.                 BitBlt (hDC, 3, 3, Bitmap.bmWidth, Bitmap.bmHeight,
  690.                         hMemoryDC, 0, 0, SRCCOPY);
  691.                 SelectObject (hMemoryDC, hOldBitmap);
  692.             }
  693.             DeleteDC (hMemoryDC);
  694.             ReleaseDC (hDlg, hDC);
  695.             DeleteObject (hBmSBLogo);
  696.             break;
  697.     }
  698.     return (FALSE);                  /* Didn't process a message    */
  699. }
  700.