home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Multimedia Jumpstart 1.1a / CD_ROM.BIN / develpmt / examples / infobrws / src / utils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-15  |  28.6 KB  |  1,166 lines

  1. //     (C) Copyright Microsoft Corp. 1991.  All rights reserved.
  2. //
  3. //     You have a royalty-free right to use, modify, reproduce and 
  4. //     distribute the Sample Files (and/or any modified version) in 
  5. //     any way you find useful, provided that you agree that 
  6. //     Microsoft has no warranty obligations or liability for any 
  7. //     Sample Application Files which are modified. 
  8.  
  9.  
  10. /****************************************************************************
  11.  
  12.     MODULE    : Utils.c
  13.  
  14.     PURPOSE   : This module contains helper/utility functions for the application playvfw.
  15.  
  16.     FUNCTIONS :  
  17.                 ReadTextFileIntoEdit
  18.                 GetRandNumber123
  19.                 ExtractExtension
  20.                 StripSpaces
  21.                 ReturnCoor
  22.                 GetRealClientRect
  23.                 DrawRectOutsideButton
  24.                 PlayVFWPaint  
  25.                 Cleanup
  26.                 Playback
  27.                 f256Capable
  28.                 fHiResCapable
  29.                 fVgaCapable
  30.  
  31.     COMMENTS  : 
  32.  
  33.     HISTORY   :
  34.  
  35. ****************************************************************************/
  36.  
  37. #include "windows.h"
  38. #include <stdlib.h>
  39. #include "playvfw.h"
  40. #include "proto.h"
  41. #include "mmsystem.h"
  42. #include <digitalv.h>
  43. #include <stdio.h>
  44. #include <time.h>
  45. #include <io.h>  
  46. #include <viewer.h>
  47.  
  48. /****************************************************************************
  49.  
  50.     FUNCTION    : ReadTextFileIntoEdit()
  51.  
  52.     PURPOSE   :  This function reads a text file specified in the ini file into an edit control.
  53.     
  54.     COMMENTS  : 
  55.  
  56.     HISTORY   : Created by Steven Molstad 8/1/93.
  57.  
  58. ****************************************************************************/ 
  59.  
  60. BOOL FAR PASCAL ReadTextFileIntoEdit()
  61. {
  62.      OFSTRUCT pof;
  63.      HANDLE hFile;
  64.      int nBytes;
  65.      int bytes;
  66.      LPSTR lpFileName;
  67.      HANDLE hFileName;
  68.      HANDLE hExeName;
  69.      HANDLE hBuffer;
  70.      LPSTR lpExeName;
  71.      LPSTR lpBuffer;
  72.      LPSTR lpTmpBuf;
  73.      int i;
  74.  
  75.      hFileName=GlobalAlloc(GHND,128);
  76.      hExeName=GlobalAlloc(GHND,10);
  77.      hBuffer=GlobalAlloc(GHND,80+1);
  78.      if (hFileName && hExeName && hBuffer)
  79.           {
  80.      lpFileName=GlobalLock(hFileName);
  81.      lpExeName=GlobalLock(hExeName);
  82.      lpBuffer=GlobalLock(hBuffer);
  83.      if(lpFileName && hExeName && hBuffer)
  84.            {
  85.         nBytes=GetModuleFileName(GetModuleHandle("playvfw.exe"),lpFileName,128);
  86.         if(nBytes)
  87.               {
  88.                ExtractExtension(lpFileName,lpExeName);
  89.  
  90.                if(!lstrlen(lpDevice1->szFileName))
  91.                 {
  92.                 MessageBox(hWndMain,"Text File Name is invalid","ERROR",MB_OK);
  93.                 return FALSE;
  94.                 }
  95.  
  96.                lstrcat(lpFileName,lpDevice1->szFileName);
  97.                hFile=OpenFile(lpFileName,&pof,OF_READWRITE);
  98.  
  99.                if (hFile==-1)
  100.                 {
  101.                 MessageBox(hWndMain,"Unable to open File","Check that text file exists",MB_OK);
  102.                 return FALSE;
  103.                 }
  104.  
  105.                _llseek (hFile,0L,0);
  106.  
  107.                bytes=_lread(hFile,lpBuffer,80);
  108.  
  109.                while(bytes==80)
  110.                  {
  111.                   lpTmpBuf=lpBuffer;
  112.  
  113.                   for(i=0;i<80;++i)
  114.                    ++lpTmpBuf;
  115.  
  116.                   *lpTmpBuf='\0';
  117.  
  118.                   
  119.                   SendMessage(hWndEdit,EM_REPLACESEL,0,(LONG)lpBuffer);
  120.                   bytes=_lread(hFile,lpBuffer,80);
  121.  
  122.                   }
  123.  
  124.             if (bytes>0)
  125.                 {
  126.                   lpTmpBuf=lpBuffer;
  127.  
  128.                   for(i=0;i<bytes;++i)
  129.                    ++lpTmpBuf;
  130.  
  131.                   *lpTmpBuf='\0';
  132.  
  133.                 SendMessage(hWndEdit,EM_REPLACESEL,0,(LONG)lpBuffer);
  134.                 }
  135.                }// if nBytes
  136.           else
  137.               {
  138.               MessageBox(hWndMain,"couldn't get pathname","ERROR",MB_OK);
  139.               return FALSE;
  140.               }
  141.            }// if global lock
  142.     else
  143.            {
  144.            MessageBox(hWndMain,"Global Lock Failed","ERROR",MB_OK);
  145.            return FALSE;
  146.            }
  147.     }// if global alloc
  148.      else
  149.     {
  150.     MessageBox(hWndMain,"Global Alloc failed","ERROR",MB_OK);
  151.     return FALSE;
  152.     }
  153.      return TRUE;
  154. }
  155.  
  156. /****************************************************************************
  157.  
  158.     FUNCTION    : GetRandNumber123()
  159.  
  160.     PURPOSE   : This function retrieves a random number using the C runtime and returns it.
  161.     
  162.     COMMENTS  : 
  163.  
  164.     HISTORY   : Created by Steven Molstad 8/1/93.
  165.  
  166. ****************************************************************************/ 
  167.  
  168. int FAR PASCAL GetRandNumber123()
  169. {
  170.  
  171.  
  172.  
  173.    /* Seed the random number generator with current time so that
  174.     * the numbers will be different every time we run.
  175.     */
  176.    srand( (unsigned)time( NULL ) );
  177.  
  178.    /* Display 10 numbers. */
  179.    
  180.     return (rand() % 3)+1;
  181.  
  182. }
  183.  
  184.  
  185. // lpFileName will be of the form "c:\stuff\"
  186. /****************************************************************************
  187.  
  188.     FUNCTION    : ExtractExtension(LPSTR,LPSTR)
  189.  
  190.     PURPOSE   : This function takes a full path name and executable and truncates off the executable
  191.                 name.  i.e. c:\stuff\playvfw.exe passes back c:\stuff\.
  192.     
  193.     COMMENTS  : 
  194.  
  195.     HISTORY   :
  196.  
  197. ****************************************************************************/ 
  198.  
  199.  
  200. BOOL FAR PASCAL ExtractExtension(lpFileName,lpExeName)
  201. LPSTR lpFileName;
  202. LPSTR lpExeName;
  203. {
  204.        LPSTR lpF;
  205.        LPSTR lpFTemp;
  206.        LPSTR lpETemp;
  207.        HANDLE hTempExe;
  208.        LPSTR lpTempExe;
  209.        LPSTR lpE2Temp;
  210.  
  211.        lpF=lpFileName;
  212.  
  213.        // set the pointer to the end of the string.
  214.  
  215.        while (*lpF!='\0')
  216.       {
  217.       lpFTemp++;
  218.       lpF++;
  219.       }
  220.  
  221.        // if the string is empty return an error;
  222.  
  223.        if (lpF!=lpFileName)
  224.         lpF--;
  225.  
  226.        // scan back for a period in the file name, throwing out the extension.
  227.  
  228.        while ((*lpF!='.') && (lpF!=lpFileName) && (*lpF!='\\'))
  229.         lpF--;
  230.  
  231.        // incorrect the file didn't have a path or an extension.
  232.  
  233.        if (lpF==lpFileName)
  234.       {
  235.       MessageBox(hWndMain,"Invalid File Extension","ERROR",MB_OK);
  236.       return FALSE;
  237.       }
  238.  
  239.        // if we didn't find a period there mustn't have been an extension. Reset
  240.        // to end of string.  Otherwise skip the period.
  241.  
  242.        if(*lpF=='\\')
  243.         lpF=lpFTemp;
  244.        else
  245.         lpF--;
  246.  
  247.        // scan string until a \ is found.
  248.  
  249.        hTempExe=GlobalAlloc(GHND,128);
  250.        if (hTempExe)
  251.       {
  252.        lpTempExe=GlobalLock(hTempExe);
  253.        if (lpTempExe)
  254.            {
  255.         // set up a third party variable.
  256.  
  257.         lpETemp=lpTempExe;
  258.  
  259.         // read the string backwards into the temporary variable.
  260.  
  261.         while ((*lpF!='\\') && (lpF!=lpFileName))
  262.             *lpETemp++=*lpF--;
  263.  
  264.         *lpETemp='\0';
  265.         lpETemp--;
  266.  
  267.         // reread the string backwards and place it into the Exe name
  268.         // variable in its correct (forward order).
  269.  
  270.         lpE2Temp=lpExeName;
  271.  
  272.         while (lpETemp!=lpTempExe)
  273.               *lpE2Temp++=*lpETemp--;
  274.  
  275.         // get the last character or the first character depending on how
  276.         // you look at it.
  277.  
  278.         *lpE2Temp++=*lpETemp;
  279.  
  280.         *lpE2Temp='\0';
  281.         }
  282.  
  283.          GlobalUnlock(hTempExe);
  284.          GlobalFree(hTempExe);
  285.         }
  286.        // if we are at the begining of the string and a \ was not found error.
  287.  
  288.  
  289.        if (lpF==lpFileName)
  290.       {
  291.       MessageBox(hWndMain,"Invalid File Extension","ERROR",MB_OK);
  292.       return FALSE;
  293.       }
  294.  
  295.        // increment one past the last backslash and add a null to terminate string.
  296.  
  297.        lpF++;
  298.        *lpF='\0';
  299.  
  300. return TRUE;
  301. }
  302.  
  303. /****************************************************************************
  304.  
  305.     FUNCTION    : StripSpaces(LPSTR)
  306.  
  307.     PURPOSE   :  This function takes a string and strips all spaces out of the string.
  308.     
  309.     COMMENTS  : 
  310.  
  311.     HISTORY   : Created by Steven Molstad 8/1/93.
  312.  
  313. ****************************************************************************/  
  314.  
  315. BOOL FAR PASCAL StripSpaces(lpBuffer)
  316. LPSTR lpBuffer;
  317. {
  318.     LPSTR lpNew;
  319.     LPSTR lpOld;
  320.  
  321.     lpNew=lpBuffer;
  322.     lpOld=lpBuffer;
  323.  
  324.     while (*lpNew!='\0')
  325.       if (*lpNew==' ')
  326.            lpNew++;
  327.       else
  328.            *lpOld++=*lpNew++;
  329.  
  330.    *lpOld='\0';
  331.  
  332. return TRUE;
  333. }  
  334.  
  335. /****************************************************************************
  336.  
  337.     FUNCTION    : ReturnCoor(lpBuff,lpPoints)
  338.  
  339.     PURPOSE   :   This function takes a string of points as 12,12,100,100 and breaks it into
  340.                   the appropriate x,y,dx,dy components of a points structure.  
  341.     
  342.     COMMENTS  : 
  343.  
  344.     HISTORY   :  Created by Steven Molstad 8/1/93
  345.  
  346. ****************************************************************************/ 
  347.  
  348. BOOL FAR PASCAL ReturnCoor(lpBuff,lpPoints)
  349. LPSTR lpBuff;
  350. LPRECT lpPoints;
  351. {
  352.      char szNum[10];
  353.      int  nCoor;
  354.      LPSTR lpPB;
  355.      LPSTR lpNum;
  356.  
  357.      lpPB=lpBuff;
  358.      lpNum=szNum;
  359.  
  360.      while ((*lpPB!='\0') && (*lpPB!=','))
  361.       *lpNum++=*lpPB++;
  362.  
  363.      if (*lpPB=='\0')
  364.       {
  365.       MessageBox(hWndMain,"incorrect position string","ERROR",MB_OK);
  366.       return FALSE;
  367.      }
  368.  
  369.      *lpNum='\0';
  370.  
  371.      nCoor=atoi(szNum);
  372.      lpPoints->left=nCoor;
  373.  
  374.      lpNum=szNum;
  375.      lpPB++;
  376.  
  377.      while ((*lpPB!='\0') && (*lpPB!=','))
  378.       *lpNum++=*lpPB++;
  379.  
  380.      if (*lpPB=='\0')
  381.       {
  382.       MessageBox(hWndMain,"incorrect position string","ERROR",MB_OK);
  383.       return FALSE;
  384.      }
  385.  
  386.      *lpNum='\0';
  387.  
  388.      nCoor=atoi(szNum);
  389.      lpPoints->top=nCoor;
  390.  
  391.      lpNum=szNum;
  392.      lpPB++;
  393.  
  394.      while ((*lpPB!='\0') && (*lpPB!=','))
  395.       *lpNum++=*lpPB++;
  396.  
  397.      if (*lpPB=='\0')
  398.       {
  399.       MessageBox(hWndMain,"incorrect position string","ERROR",MB_OK);
  400.       return FALSE;
  401.      }
  402.  
  403.      *lpNum='\0';
  404.  
  405.      nCoor=atoi(szNum);
  406.      lpPoints->right=nCoor;
  407.  
  408.      lpNum=szNum;
  409.      lpPB++;
  410.  
  411.      while ((*lpPB!='\0') && (*lpPB!=','))
  412.       *lpNum++=*lpPB++;
  413.  
  414.      if (*lpPB==',')
  415.       {
  416.       MessageBox(hWndMain,"incorrect position string","ERROR",MB_OK);
  417.       return FALSE;
  418.      }
  419.  
  420.      *lpNum='\0';
  421.  
  422.      nCoor=atoi(szNum);
  423.      lpPoints->bottom=nCoor;
  424.  
  425.  return TRUE;
  426. }
  427.  
  428. /****************************************************************************
  429.  
  430.     FUNCTION    : GetRealClientRect(HWND,HWND,LPRECT)
  431.  
  432.     PURPOSE   :   This function takes a rect structure and returns client coordinates in that structure.  It
  433.                   also takes the child and parent that you want relative coordinates for.  The child being
  434.                   relative to the client area of the parent vs the upper left hand corner of the screen.
  435.     
  436.     COMMENTS  : 
  437.  
  438.     HISTORY   : Created by Steven Molstad 8/1/93.
  439.  
  440. ****************************************************************************/ 
  441.  
  442. BOOL FAR PASCAL GetRealClientRect(hWndChild,hWndParent,lpWinRect)
  443. HWND hWndChild;
  444. HWND hWndParent;
  445. LPRECT lpWinRect;
  446. {
  447.  
  448. POINT ptUpperLeft;
  449. POINT ptLowerRight;
  450.  
  451.       GetWindowRect(hWndChild,lpWinRect);
  452.  
  453.  
  454.       ptUpperLeft.x=lpWinRect->left;
  455.       ptUpperLeft.y=lpWinRect->top;
  456.       ptLowerRight.x=lpWinRect->right;
  457.       ptLowerRight.y=lpWinRect->bottom;
  458.  
  459.       ScreenToClient(hWndParent,&ptLowerRight);
  460.       ScreenToClient(hWndParent,&ptUpperLeft);
  461.  
  462.       lpWinRect->left=ptUpperLeft.x;
  463.       lpWinRect->top=ptUpperLeft.y;
  464.       lpWinRect->right=ptLowerRight.x;
  465.       lpWinRect->bottom=ptLowerRight.y;
  466.  
  467. return TRUE;
  468.  
  469. }
  470.  
  471. /****************************************************************************
  472.  
  473.     FUNCTION    : DrawRectOutsideButton(HWND,RECT)
  474.  
  475.     PURPOSE   : This function draws a rectangle around an owner draw button who's rectangular area is 
  476.                 specified by WinRect.  hWnd is the window handle to the parent.
  477.     
  478.     COMMENTS  : 
  479.  
  480.     HISTORY   :
  481.  
  482. ****************************************************************************/ 
  483.  
  484. BOOL FAR PASCAL DrawRectOutsideButton(hWnd,WinRect)
  485. HWND hWnd;
  486. RECT WinRect;
  487.  
  488. {
  489. HDC hWinDC;
  490. HPEN hWinPen;
  491. HPEN hPenOld;
  492.  
  493.       hWinDC=GetDC(hWnd);
  494.  
  495.       hWinPen=CreatePen(PS_SOLID,4,RGB(0,0,0));
  496.       hPenOld=SelectObject(hWinDC,hWinPen);
  497.  
  498.       Rectangle(hWinDC,WinRect.left-2,WinRect.top-2,WinRect.right+2,WinRect.bottom+2);
  499.  
  500.       SelectObject(hWinDC,hPenOld);
  501.       DeleteObject(hWinPen);
  502.  
  503.       ReleaseDC(hWnd,hWinDC);
  504.  
  505. return TRUE;
  506. }
  507.  
  508. /****************************************************************************
  509.  
  510.     FUNCTION    : PlayVFWPaint( HDC )
  511.  
  512.     PURPOSE   :  This procedure is no longer used but was called whenever the application needed to 
  513.                  paint the client area.
  514.     
  515.     COMMENTS  : 
  516.  
  517.     HISTORY   :   Created by Steven Molstad 6/1/93.
  518.  
  519. ****************************************************************************/ 
  520.  
  521. void PlayVFWPaint( hDC )
  522. HDC hDC;
  523. {
  524.     
  525.      //HDC hdc;
  526.      HDC hdcMemory;
  527.      HBITMAP hbmpMyBitmap, hbmpOld;
  528.      BITMAP bm;
  529. // Set the Background color to black.
  530.  
  531.      SetBkColor(hDC,RGB(255,255,255)); 
  532.      
  533.     
  534.      if (bIsPage0)
  535.           {
  536.            hbmpMyBitmap = LoadBitmap(hInst, "vgalogo4");
  537.            GetObject(hbmpMyBitmap, sizeof(BITMAP), &bm);
  538.  
  539.            //hdc = GetDC(hwnd);
  540.            hdcMemory = CreateCompatibleDC(hDC);
  541.            hbmpOld = SelectObject(hdcMemory, hbmpMyBitmap);
  542.  
  543.            BitBlt(hDC, 0, 0, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCCOPY);
  544.            SelectObject(hdcMemory, hbmpOld);
  545.  
  546.            DeleteDC(hdcMemory);
  547.  
  548.            //ReleaseDC(hwnd, hdc);
  549.            }
  550. return;
  551. }
  552.  
  553. /****************************************************************************
  554.  
  555.     FUNCTION    : LoadPalette()
  556.  
  557.     PURPOSE   : This procedure is no longer used but is usefull code to load a palette and retieve the
  558.                 handle to that palette.
  559.                 
  560.     
  561.     COMMENTS  : 
  562.  
  563.     HISTORY   :   Create by Steven Molstad 6/1/93.
  564.  
  565. ****************************************************************************/ 
  566.  
  567. BOOL FAR PASCAL LoadPalette()
  568. {
  569.      HFILE hfReadWriteFile;
  570.     
  571.         
  572.      
  573.      int bytes;
  574.      HANDLE hBuff;
  575.      LPLOGPALETTE lpBuff;   
  576.      HANDLE hLogPal;
  577.      LPLOGPALETTE lpLogPal;
  578.      UINT palsize;
  579.      
  580.      hfReadWriteFile=_lopen("palette.pal",READ);
  581.      
  582.      if (hfReadWriteFile == HFILE_ERROR)    
  583.          {
  584.            MessageBox(hWndMain,"Cannot find file palette.pal","ERROR",MB_OK);
  585.           return FALSE;
  586.           }           
  587.           
  588.        /* Allocate a buffer for file I/O. */
  589.  
  590.        hBuff=GlobalAlloc(GHND, sizeof(LOGPALETTE));   
  591.        
  592.        if (hBuff)      
  593.              {
  594.              lpBuff=(LPLOGPALETTE)GlobalLock(hBuff); 
  595.              
  596.              if (lpBuff)
  597.                   {            
  598.                    _llseek(hfReadWriteFile,20,0);
  599.                    bytes=_lread(hfReadWriteFile, lpBuff, sizeof(LOGPALETTE));
  600.                    
  601.         //
  602.        //allocate memory for the logical palette including the array of
  603.        //palette entries
  604.        //          
  605.        
  606.                    palsize = sizeof(LOGPALETTE) + (sizeof (PALETTEENTRY) * lpBuff->palNumEntries);
  607.                    
  608.                    hLogPal =  GlobalAlloc( GHND, palsize );        
  609.                    
  610.                    if(hLogPal)
  611.                         {                            
  612.                          lpLogPal=(LPLOGPALETTE)GlobalLock(hLogPal);
  613.                          if (lpLogPal)
  614.                               {
  615.                     
  616.                     
  617.                                _llseek(hfReadWriteFile,20,0);                                        
  618.                    
  619.                                bytes=_lread(hfReadWriteFile,lpLogPal,palsize);
  620.  
  621.                                //
  622.                                //create the palette
  623.                                //       
  624.                     
  625.                                hPal = CreatePalette((LPLOGPALETTE)lpLogPal);
  626.                          //{
  627.                          // SelectPalette(hDC, hPal, FALSE);
  628.                          // RealizePalette(hDC);
  629.                          //}
  630.                                                    
  631.                                GlobalUnlock(hBuff);
  632.                                GlobalFree(hBuff);  
  633.                    
  634.                               }                 
  635.                           else
  636.                               {
  637.                                MessageBox(hWndMain,"Global Lock Failed in Palette stuff","ERROR",MB_OK);
  638.                                return FALSE;
  639.                                }    
  640.                                
  641.                           GlobalUnlock(hLogPal);
  642.                           GlobalFree(hLogPal);    
  643.                          }      
  644.                          
  645.                         else
  646.                               {
  647.                                MessageBox(hWndMain,"Global Alloc Failed in Palette stuff","ERROR",MB_OK);
  648.                                return FALSE;
  649.                                }   
  650.                   }
  651.              }                         
  652.        /* Free the buffer and close the files. */
  653.  
  654.               _lclose(hfReadWriteFile);
  655.              
  656.        
  657. return TRUE;
  658. }
  659.  
  660.  
  661.  
  662.  
  663. /****************************************************************************
  664.  
  665.     FUNCTION  : Cleanup(void)
  666.  
  667.     PURPOSE   : This function does the cleanup work for the application.  It takes care of freeing all
  668.                 window handles and cursors.
  669.     
  670.     COMMENTS  : 
  671.  
  672.     HISTORY   :  Created by Steven Molstad 8/15/93.
  673.  
  674. ****************************************************************************/
  675.  
  676. BOOL FAR PASCAL Cleanup(void)
  677. {               
  678.  
  679.      if (VWRGlobal)
  680.         {
  681.          VwrQuit(VWRGlobal);
  682.          VWRGlobal=0;
  683.          }
  684.          
  685.      FreeDevices(hWndMain);
  686.      
  687.      
  688.      
  689.      if (hWndButtonBar)
  690.            DestroyWindow(hWndButtonBar);
  691.      
  692.      if (lpDevice1->hWnd)
  693.             DestroyWindow(lpDevice1->hWnd);
  694.                          
  695.      if (lpDevice2->hWnd)                    
  696.             DestroyWindow(lpDevice2->hWnd);
  697.             
  698.      if (lpDevice3->hWnd)
  699.             DestroyWindow(lpDevice3->hWnd);
  700.             
  701.      if (lpDevice4->hWnd)
  702.             DestroyWindow(lpDevice4->hWnd);
  703.             
  704.      if (lpDevice5->hWnd)
  705.             DestroyWindow(lpDevice5->hWnd);
  706.             
  707.      if (lpDevice6->hWnd)
  708.             DestroyWindow(lpDevice6->hWnd);
  709.             
  710.      if (lpDevice7->hWnd)
  711.             DestroyWindow(lpDevice7->hWnd);
  712.             
  713.      if (lpDevice8->hWnd)
  714.             DestroyWindow(lpDevice8->hWnd);
  715.             
  716.      if (lpDevice9->hWnd)
  717.             DestroyWindow(lpDevice9->hWnd);  
  718.     
  719.      SetCursor(hHelloCursor);
  720.  
  721.      DestroyCursor(lpDevice1->hCursor);
  722.      DestroyCursor(lpDevice2->hCursor);
  723.      DestroyCursor(lpDevice3->hCursor);
  724.      DestroyCursor(lpDevice4->hCursor);
  725.      DestroyCursor(lpDevice5->hCursor);
  726.      DestroyCursor(lpDevice6->hCursor);
  727.  
  728.  
  729.      GlobalUnlock(hDevice1);
  730.      GlobalFree(hDevice1);
  731.  
  732.      GlobalUnlock(hDevice2);
  733.      GlobalFree(hDevice2);
  734.  
  735.      GlobalUnlock(hDevice3);
  736.      GlobalFree(hDevice3);
  737.  
  738.      GlobalUnlock(hDevice4);
  739.      GlobalFree(hDevice4);
  740.  
  741.      GlobalUnlock(hDevice5);
  742.      GlobalFree(hDevice5);
  743.  
  744.      GlobalUnlock(hDevice6);
  745.      GlobalFree(hDevice6);
  746.  
  747.      GlobalUnlock(hDevice7);
  748.      GlobalFree(hDevice7);
  749.  
  750.      GlobalUnlock(hDevice8);
  751.      GlobalFree(hDevice8);  
  752.     
  753.      GlobalUnlock(hDevice9);
  754.      GlobalFree(hDevice9); 
  755.     
  756.      DestroyWindow(hWndMain);   
  757.      return TRUE;
  758. }  
  759.  
  760. /****************************************************************************
  761.  
  762.     FUNCTION  : Playback(WORD, HWND)
  763.  
  764.     PURPOSE   :  This function plays back a Video and Audio file when the cursor is placed over the
  765.                  corresponding owner draw button.  
  766.     
  767.     COMMENTS  : 
  768.  
  769.     HISTORY   : Created by Steven Molstad 6/1/93.
  770.  
  771. ****************************************************************************/
  772.  
  773. BOOL FAR PASCAL Playback(wParam,hOld)
  774. WORD wParam;                     
  775. HANDLE hOld;
  776. {             
  777.  
  778.      if(wParam==lpDevice1->hWnd)
  779.            {                   
  780.             if (hOld!=wParam)
  781.                  {
  782.                   if(bIsPage1)
  783.                         SetCursor(lpDevice1->hCursor);
  784.         
  785.                    if (!lpDevice1->bAudioPlaying)                        
  786.                         StopAllWaveFiles();             
  787.              
  788.              
  789.                    if(!lpDevice1->bVideoPlaying)
  790.                          {
  791.  
  792.                           SeekAllToStart(); 
  793.                           
  794.                           if (lpDevice1->bPlayVideo)
  795.                                 PlayVFWFile(hWndMain,lpDevice1->hWnd,lpDevice1->wDeviceID);
  796.                                 
  797.                            if (lpDevice1->bPlayAudio)     
  798.                                PlayWaveFile(lpDevice1->wAudioDeviceID);    
  799.                   
  800.  
  801.                           lpDevice1->bVideoPlaying=TRUE;      
  802.                           lpDevice1->bAudioPlaying=TRUE;  
  803.                  
  804.  
  805.                           //break;
  806.                          }
  807.                    hOld=wParam;
  808.                    }      
  809.  
  810.         return TRUE;
  811.         }
  812.  
  813.       if(wParam==lpDevice2->hWnd)
  814.            {   
  815.             if (hOld!=wParam)
  816.                  {             
  817.                          
  818.                   if(bIsPage1)   
  819.                         SetCursor(lpDevice2->hCursor); 
  820.              
  821.                   if (!lpDevice2->bAudioPlaying)                        
  822.                         StopAllWaveFiles();    
  823.                   
  824.                   if(!lpDevice2->bVideoPlaying)
  825.                         {
  826.               
  827.                   
  828.                          SeekAllToStart();
  829.                   
  830.                          if (lpDevice2->bPlayVideo)
  831.                               PlayVFWFile(hWndMain,lpDevice2->hWnd,lpDevice2->wDeviceID);  
  832.                               
  833.                          if (lpDevice2->bPlayAudio)       
  834.                                PlayWaveFile(lpDevice2->wAudioDeviceID);
  835.  
  836.                          lpDevice2->bVideoPlaying=TRUE;  
  837.                          lpDevice2->bAudioPlaying=TRUE;
  838.                  
  839.                          //break;
  840.                          }    
  841.                          
  842.                    hOld=wParam;      
  843.                   }
  844.         return TRUE;
  845.         }                
  846.         
  847.  
  848.       if(wParam==lpDevice3->hWnd)
  849.            {                   
  850.             if (hOld!=wParam)
  851.                  {
  852.                   if(bIsPage1)
  853.                         SetCursor(lpDevice3->hCursor);
  854.           
  855.                   if (!lpDevice3->bAudioPlaying)                        
  856.                         StopAllWaveFiles();     
  857.           
  858.                   if(!lpDevice3->bVideoPlaying)
  859.                         {
  860.                
  861.                  
  862.                          SeekAllToStart();
  863.  
  864.                 
  865.                          if (lpDevice3->bPlayVideo)
  866.                                PlayVFWFile(hWndMain,lpDevice3->hWnd,lpDevice3->wDeviceID); 
  867.                           
  868.                          if (lpDevice3->bPlayAudio)        
  869.                               PlayWaveFile(lpDevice3->wAudioDeviceID);
  870.  
  871.                          lpDevice3->bVideoPlaying=TRUE;
  872.                          lpDevice3->bAudioPlaying=TRUE;
  873.                  
  874.                          //break;
  875.                          }     
  876.                          
  877.                    hOld=wParam;      
  878.                   }       
  879.  
  880.         return TRUE;
  881.         }
  882.  
  883.       if(wParam==lpDevice4->hWnd)
  884.            {                     
  885.             if (hOld!=wParam)
  886.                  {
  887.                   if(bIsPage1)
  888.                        SetCursor(lpDevice4->hCursor); 
  889.              
  890.                   if (!lpDevice4->bAudioPlaying)                        
  891.                        StopAllWaveFiles();       
  892.               
  893.                   if(!lpDevice4->bVideoPlaying)
  894.                        {
  895.               
  896.                  
  897.                         SeekAllToStart();
  898.  
  899.                 
  900.                         if (lpDevice4->bPlayVideo)
  901.                               PlayVFWFile(hWndMain,lpDevice4->hWnd,lpDevice4->wDeviceID);\
  902.                                  
  903.                         if (lpDevice4->bPlayAudio)        
  904.                               PlayWaveFile(lpDevice4->wAudioDeviceID);
  905.  
  906.                         lpDevice4->bVideoPlaying=TRUE;
  907.                         lpDevice4->bAudioPlaying=TRUE;
  908.                   
  909.                  
  910.                         //break;
  911.                        }
  912.                    hOld=wParam;    
  913.                   }
  914.  
  915.         return TRUE;
  916.         }               
  917.         
  918.  
  919.       if(wParam==lpDevice5->hWnd)
  920.            {
  921.             if (hOld!=wParam)
  922.                  {
  923.                  if(bIsPage1)
  924.                       SetCursor(lpDevice5->hCursor);     
  925.              
  926.                  if (!lpDevice5->bAudioPlaying)                        
  927.                       StopAllWaveFiles();        
  928.  
  929.                  if(!lpDevice5->bVideoPlaying)
  930.                       {
  931.                
  932.                        SeekAllToStart();
  933.  
  934.                        if (lpDevice5->bPlayVideo)
  935.                             PlayVFWFile(hWndMain,lpDevice5->hWnd,lpDevice5->wDeviceID);  
  936.                             
  937.                        if (lpDevice5->bPlayAudio)       
  938.                              PlayWaveFile(lpDevice5->wAudioDeviceID);
  939.  
  940.                        lpDevice5->bVideoPlaying=TRUE; 
  941.                        lpDevice5->bAudioPlaying=TRUE;
  942.                   
  943.                        //break;
  944.                        }
  945.                   hOld=wParam;     
  946.                  }
  947.  
  948.         return TRUE;
  949.         }
  950.  
  951.       if(wParam==lpDevice6->hWnd)
  952.            {  
  953.             if (hOld!=wParam)
  954.                  { 
  955.                  
  956.                   if(bIsPage1)
  957.                        SetCursor(lpDevice6->hCursor);
  958.         
  959.                   if (!lpDevice6->bAudioPlaying)                        
  960.                        StopAllWaveFiles();   
  961.         
  962.                   if(!lpDevice6->bVideoPlaying)
  963.                         {
  964.               
  965.                          SeekAllToStart();
  966.                   
  967.                          if (lpDevice6->bPlayVideo)
  968.                                PlayVFWFile(hWndMain,lpDevice6->hWnd,lpDevice6->wDeviceID);
  969.                          
  970.                          if (lpDevice6->bPlayAudio)        
  971.                               PlayWaveFile(lpDevice6->wAudioDeviceID);
  972.  
  973.                          lpDevice6->bVideoPlaying=TRUE; 
  974.                          lpDevice6->bAudioPlaying=TRUE;     
  975.                   
  976.                  
  977.                          //break;
  978.                         }
  979.                         
  980.                    hOld=wParam;
  981.                   }            
  982.                    
  983.            return TRUE;
  984.            }
  985.  
  986.       if(wParam==hWndMain)
  987.            {    
  988.             if (hOld!=wParam)
  989.                  {
  990.                    SeekAllToStart();   
  991.                    StopAllWaveFiles();
  992.                    SetCursor(hHelloCursor); 
  993.                    hOld=wParam;
  994.                   }     
  995.                   
  996.             return TRUE;
  997.            }
  998. return FALSE;           
  999. }
  1000.  
  1001. /****************************************************************************
  1002.  
  1003.     FUNCTION   : fVgaCapable
  1004.  
  1005.     PARAMETERS : void
  1006.  
  1007.     PURPOSE    : Determines if the system includes at least a VGA
  1008.  
  1009.     CALLS      : WINDOWS
  1010.            GetDC
  1011.            GetDeviceCaps
  1012.            ReleaseDC
  1013.  
  1014.     RETURNS    : BOOL  -  TRUE if VGA, FALSE if !VGA
  1015.  
  1016.     MESSAGES   : none
  1017.  
  1018.     COMMENTS   :
  1019.  
  1020.     HISTORY    :     
  1021.  
  1022. ****************************************************************************/
  1023.  
  1024.  
  1025. BOOL PASCAL fVgaCapable(void)
  1026. {
  1027.       //get screen device context
  1028.     HDC     hdc = GetDC(NULL);
  1029.  
  1030.       //is screen res. less then 640 x 480?
  1031.     if ((GetDeviceCaps(hdc, HORZRES) != 640) ||
  1032.     (GetDeviceCaps(hdc, VERTRES) != 480))
  1033.     {
  1034.     ReleaseDC(NULL, hdc);
  1035.       //if yes, then not VGA
  1036.     return FALSE;
  1037.     }
  1038.     else
  1039.     {
  1040.     ReleaseDC(NULL, hdc);
  1041.       //if no, then VGA
  1042.     return TRUE;
  1043.     }
  1044. }
  1045.  
  1046. /****************************************************************************
  1047.  
  1048.     FUNCTION   : fHiRes
  1049.  
  1050.     PARAMETERS : void
  1051.  
  1052.     PURPOSE    : Determines if the system is running in at least a 1024 X 768
  1053.  
  1054.     CALLS      : WINDOWS
  1055.            GetDC
  1056.            GetDeviceCaps
  1057.            ReleaseDC
  1058.  
  1059.     RETURNS    : BOOL  -  TRUE if HiRes, FALSE if !HiRes
  1060.  
  1061.     MESSAGES   : none
  1062.  
  1063.     COMMENTS   :
  1064.  
  1065.     HISTORY    :     
  1066.  
  1067. ****************************************************************************/
  1068.  
  1069.  
  1070. BOOL PASCAL fHiResCapable(void)
  1071. {
  1072.       //get screen device context
  1073.     HDC     hdc = GetDC(NULL);
  1074.  
  1075.       //is screen res. less then 1024 X 768?
  1076.     if ((GetDeviceCaps(hdc, HORZRES) < 1024) ||
  1077.     (GetDeviceCaps(hdc, VERTRES) < 768))
  1078.     {
  1079.     ReleaseDC(NULL, hdc);
  1080.       //if yes, then not HiRes
  1081.     return FALSE;
  1082.     }
  1083.     else
  1084.     {
  1085.     ReleaseDC(NULL, hdc);
  1086.       //if no, then HiRes
  1087.     return TRUE;
  1088.     }
  1089. }
  1090.  
  1091. /****************************************************************************
  1092.  
  1093.     FUNCTION   : f256Capable
  1094.  
  1095.     PARAMETERS : void
  1096.  
  1097.     PURPOSE    : determines if the screen dc is capable of at least 8bpp
  1098.  
  1099.     CALLS      : WINDOWS
  1100.            GetDC
  1101.            GetDeviceCaps
  1102.            ReleaseDC
  1103.  
  1104.     RETURNS    : number of wave output devices found
  1105.  
  1106.     MESSAGES   : none
  1107.  
  1108.     COMMENTS   : first checks to see if MMSYSTEM is loaded.  So it works
  1109.          in 3.0 as well as 3.1
  1110.  
  1111.     HISTORY    :     
  1112.  
  1113. ****************************************************************************/
  1114.  
  1115.  
  1116. BOOL PASCAL f256Capable(void)
  1117. {
  1118.       //get screen device context
  1119.     HDC     hdc = GetDC(NULL);
  1120.  
  1121.       //is the screen dc capable of at least 8bpp?
  1122.     if ((GetDeviceCaps(hdc, NUMCOLORS) >= 256) ||
  1123.     (GetDeviceCaps(hdc, BITSPIXEL) >= 8))
  1124.     {
  1125.     ReleaseDC(NULL, hdc);
  1126.       //at least 8bpp
  1127.     return TRUE;
  1128.     }
  1129.     else
  1130.     {
  1131.     ReleaseDC(NULL, hdc);
  1132.       //less than 8bpp
  1133.     return FALSE;
  1134.     }
  1135. }
  1136.  
  1137. /****************************************************************************
  1138.  
  1139.     FUNCTION   : fNTRunning
  1140.  
  1141.     PARAMETERS : void
  1142.  
  1143.     PURPOSE    : determins if application is running under NT.
  1144.  
  1145.     CALLS      : WINDOWS
  1146.                  GetWinFlags
  1147.  
  1148.     RETURNS    : TRUE if running under NT
  1149.  
  1150.     MESSAGES   : none
  1151.  
  1152.     COMMENTS   : 
  1153.  
  1154.     HISTORY    :     
  1155.  
  1156. ****************************************************************************/
  1157.  
  1158.  
  1159. BOOL PASCAL fNTRunning(void)
  1160. {
  1161.      if (GetWinFlags()&WF_WINNT)
  1162.           return TRUE;
  1163.      else 
  1164.           return FALSE;         
  1165.  
  1166. }