home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / video / textout / drvproc.c next >
C/C++ Source or Header  |  1997-10-05  |  4KB  |  169 lines

  1. /**************************************************************************
  2.  *
  3.  *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4.  *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5.  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6.  *  PURPOSE.
  7.  *
  8.  *  Copyright (C) 1992 - 1997 Microsoft Corporation.  All Rights Reserved.
  9.  *
  10.  **************************************************************************/
  11. /****************************************************************************
  12.  *
  13.  *   drvproc.c
  14.  *
  15.  ***************************************************************************/
  16.  
  17. #include <windows.h>
  18. #include <windowsx.h>
  19. #include <mmsystem.h>
  20. #include <vfw.h>
  21.  
  22. #include "TxtOut.h"
  23.  
  24. HMODULE ghModule;
  25.  
  26. /***************************************************************************
  27.  *
  28.  * DriverProc The entry point for an installable driver.
  29.  *
  30.  ***************************************************************************/
  31.  
  32. LRESULT WINAPI DriverProc(
  33.     DWORD dwDriverID,
  34.     HDRVR hDriver,
  35.     UINT uiMessage,
  36.     LPARAM lParam1,
  37.     LPARAM lParam2)
  38. {
  39.     INSTINFO *pi = (INSTINFO *)(UINT)dwDriverID;
  40.  
  41.     switch (uiMessage)
  42.     {
  43.         case DRV_LOAD:
  44.             return (LRESULT) Load();
  45.  
  46.         case DRV_FREE:
  47.             Free();
  48.             return (LRESULT)1L;
  49.  
  50.         case DRV_OPEN:
  51.             // if being opened with no open struct, then return a non-zero
  52.             // value without actually opening
  53.             if (lParam2 == 0L)
  54.                 return 0xFFFF0000;
  55.  
  56.             return (LRESULT)(DWORD)(UINT)Open((ICOPEN FAR *) lParam2);
  57.  
  58.       case DRV_CLOSE:
  59.           if (dwDriverID != 0xFFFF0000)
  60.               Close(pi);
  61.  
  62.             return (LRESULT)1L;
  63.  
  64.         /*********************************************************************
  65.  
  66.             state messages
  67.  
  68.         *********************************************************************/
  69.  
  70.         case DRV_QUERYCONFIGURE: // configuration from drivers applet
  71.             return (LRESULT)0L;
  72.  
  73.         case DRV_CONFIGURE:
  74.             return DRV_OK;
  75.  
  76.         case ICM_CONFIGURE:
  77.             //
  78.             // return ICERR_OK if you will do a configure box, error otherwise
  79.             //
  80.             if (lParam1 == -1)
  81.                 return QueryConfigure(pi) ? ICERR_OK : ICERR_UNSUPPORTED;
  82.             else
  83.                 return Configure(pi, (HWND)lParam1);
  84.  
  85.         case ICM_ABOUT:
  86.             //
  87.             // return ICERR_OK if you will do a about box, error otherwise
  88.             //
  89.             if (lParam1 == -1)
  90.                 return QueryAbout(pi) ? ICERR_OK : ICERR_UNSUPPORTED;
  91.             else
  92.                 return About(pi, (HWND)lParam1);
  93.  
  94.         case ICM_GETSTATE:
  95.             return GetState(pi, (LPVOID)lParam1, (DWORD)lParam2);
  96.  
  97.         case ICM_SETSTATE:
  98.             return SetState(pi, (LPVOID)lParam1, (DWORD)lParam2);
  99.  
  100.         case ICM_GETINFO:
  101.             return GetInfo(pi, (ICINFO FAR *)lParam1, (DWORD)lParam2);
  102.  
  103.         /*********************************************************************
  104.  
  105.             draw messages
  106.  
  107.         *********************************************************************/
  108.  
  109.         case ICM_DRAW_QUERY:
  110.             return DrawQuery(pi, (LPVOID FAR *)lParam1);
  111.  
  112.         case ICM_DRAW_BEGIN:
  113.             return DrawBegin(pi,(ICDRAWBEGIN FAR *)lParam1, (DWORD)lParam2);
  114.  
  115.         case ICM_DRAW:
  116.             return Draw(pi,(ICDRAW FAR *)lParam1, (DWORD)lParam2);
  117.  
  118.         case ICM_DRAW_END:
  119.             return DrawEnd(pi);
  120.  
  121.         /*********************************************************************
  122.  
  123.             standard driver messages
  124.  
  125.         *********************************************************************/
  126.  
  127.         case DRV_DISABLE:
  128.         case DRV_ENABLE:
  129.             return (LRESULT)1L;
  130.  
  131.         case DRV_INSTALL:
  132.         case DRV_REMOVE:
  133.             return (LRESULT)DRV_OK;
  134.     }
  135.  
  136.     if (uiMessage < DRV_USER)
  137.         return DefDriverProc(dwDriverID, hDriver, uiMessage,
  138.             lParam1,lParam2);
  139.     else
  140.         return ICERR_UNSUPPORTED;
  141. }
  142.  
  143. /****************************************************************************
  144.  *
  145.  * DllMain Library initialization code.
  146.  *
  147.  ***************************************************************************/
  148. APIENTRY DllMain(HANDLE, DWORD, LPVOID);
  149. APIENTRY DllMain(
  150.     HANDLE hModule,
  151.     DWORD dwReason,
  152.     LPVOID lpReserved )
  153. {
  154.     switch( dwReason)
  155.     {
  156.         case DLL_PROCESS_ATTACH:
  157.             if(ghModule == NULL)
  158.                 ghModule = (HMODULE)hModule;
  159.             break;
  160.         case DLL_THREAD_ATTACH:
  161.             break;
  162.         case DLL_THREAD_DETACH:
  163.             break;
  164.         case DLL_PROCESS_DETACH:
  165.             break;
  166.     }
  167.     return TRUE;
  168. }
  169.