home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / inole / cursors.c < prev    next >
C/C++ Source or Header  |  1995-05-03  |  4KB  |  148 lines

  1. /*
  2.  * CURSORS.C
  3.  * Buttons & Cursors
  4.  *
  5.  * Public functions to retrieve cursors.
  6.  *
  7.  * Copyright (c)1992-1995 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Microsoft
  10.  * Internet  :  kraigb@microsoft.com
  11.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  12.  */
  13.  
  14.  
  15. #include "inoledll.h"
  16.  
  17.  
  18. /*
  19.  * The +1 is because MAX is the highest allowable number and MIN is
  20.  * not necessarily zero.
  21.  */
  22. HCURSOR rgHCursors[IDC_NEWUICURSORMAX-IDC_NEWUICURSORMIN+1];
  23.  
  24.  
  25.  
  26. /*
  27.  * CursorsCache
  28.  * Internal
  29.  *
  30.  * Purpose:
  31.  *  Loads all the cursors available through NewUICursorLoad into
  32.  *  a global array.  This way we can clean up all the cursors without
  33.  *  placing the burden on the application.
  34.  *
  35.  * Parameters:
  36.  *  hInst           HANDLE of the DLL instance.
  37.  *
  38.  * Return Value:
  39.  *  None. If any of the LoadCursor calls fail, then the corresponding
  40.  *  array entry is NULL and NewUICursorLoad will fail. Better to fail
  41.  *  an app getting a cursor than failing to load the app just for
  42.  *  that reason; and app can attempt to load the cursor on startup if
  43.  *  it's that important, and fail itself.
  44.  */
  45.  
  46. void CursorsCache(HINSTANCE hInst)
  47.     {
  48.     UINT            i;
  49.  
  50.     for (i=IDC_NEWUICURSORMIN; i<=IDC_NEWUICURSORMAX; i++)
  51.         {
  52.         rgHCursors[i-IDC_NEWUICURSORMIN]=LoadCursor(hInst
  53.             , MAKEINTRESOURCE(i));
  54.         }
  55.     return;
  56.     }
  57.  
  58.  
  59.  
  60.  
  61. /*
  62.  * CursorsFree
  63.  * Internal
  64.  *
  65.  * Purpose:
  66.  *  Frees all the cursors previously loaded through CursorsCache.
  67.  *
  68.  * Parameters:
  69.  *  None
  70.  *
  71.  * Return Value:
  72.  *  None
  73.  */
  74.  
  75. void CursorsFree(void)
  76.     {
  77.     /*
  78.      * Note that since cursors are discardable resources and should
  79.      * not be used with DestroyCursor, there's nothing to do here.
  80.      * We still provide this API for compatibility and to maintain
  81.      * symmetry.
  82.      */
  83.     return;
  84.     }
  85.  
  86.  
  87.  
  88.  
  89.  
  90. /*
  91.  * UICursorLoad
  92.  * Public API
  93.  *
  94.  * Purpose:
  95.  *  Loads and returns a handle to one of the new standard UI cursors
  96.  *  contained in UITOOLS.DLL.  The application must not call
  97.  *  DestroyCursor on this cursor as it is managed by the DLL.
  98.  *
  99.  * Parameters:
  100.  *  iCursor         UINT index to the cursor to load which must be one
  101.  *                  of the following values:
  102.  *
  103.  *      IDC_RIGHTARROW    Right pointing standard arrow
  104.  *      IDC_CONTEXTHELP   Arrow with a ? (context help)
  105.  *      IDC_MAGNIFY       Magnifying glass for zooming
  106.  *      IDC_NODROP        Circle with a slash
  107.  *      IDC_TABLETOP      Small arrow pointing down
  108.  *
  109.  *      IDC_SMALLARROWS   Thin four-headed arrow
  110.  *      IDC_LARGEARROWS   Wide four-headed arrow
  111.  *      IDC_HARROWS       Horizontal two-headed arrow
  112.  *      IDC_VARROWS       Vertical two-headed arrow
  113.  *      IDC_NESWARROWS    Two-headed arrow pointing NE<->SW
  114.  *      IDC_NWSEHARROWS   Two-headed arrow pointing NW<->SE
  115.  *
  116.  *      IDC_HSIZEBAR      Horizontal two-headed arrow with
  117.  *                        a single vertical bar down the
  118.  *                        middle
  119.  *
  120.  *      IDC_VSIZEBAR      Vertical two-headed arrow with a
  121.  *                        single horizontal bar down the
  122.  *                        middle
  123.  *
  124.  *      IDC_HSPLITBAR     Horizontal two-headed arrow with
  125.  *                        split double vertical bars down the
  126.  *                        middle
  127.  *
  128.  *      IDC_VSPLITBAR     Vertical two-headed arrow with split
  129.  *                        double horizontal bars down the
  130.  *                        middle
  131.  *
  132.  * Return Value:
  133.  *  HCURSOR         Handle to the loaded cursor if successful, NULL
  134.  *                  if iCursor is out of range or the function could
  135.  *                  not load the cursor.
  136.  */
  137.  
  138. HCURSOR WINAPI UICursorLoad(UINT iCursor)
  139.     {
  140.     HCURSOR     hCur=NULL;
  141.  
  142.     if ((iCursor >= IDC_NEWUICURSORMIN)
  143.         && (iCursor <= IDC_NEWUICURSORMAX))
  144.         hCur=rgHCursors[iCursor-IDC_NEWUICURSORMIN];
  145.  
  146.     return hCur;
  147.     }
  148.