home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / activexcontrol / basectl / card / card.cpp next >
C/C++ Source or Header  |  1997-10-05  |  7KB  |  213 lines

  1. //=--------------------------------------------------------------------------=
  2. // Card.Cpp
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995 - 1997 Microsoft Corporation.  All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // various routines et all that aren't in a file for a particular automation
  13. // object, and don't need to be in the generic ole automation code.
  14. //
  15. #define INITOBJECTS                // define the descriptions for our objects
  16.  
  17. #include "IPServer.H"
  18. #include "LocalSrv.H"
  19.  
  20.  
  21. #include "LocalObj.H"
  22. #include "CtrlObj.H"
  23. #include "Globals.H"
  24. #include "Util.H"
  25. #include "Resource.H"
  26.  
  27. #include "CardCtl.H"
  28. #include "CardPPG.H"
  29. #include "cathelp.H"
  30.  
  31. #include "carddraw.h"
  32.  
  33. // Control Globals
  34. //
  35. CRITICAL_SECTION drawCritSec;
  36. HBITMAP cardcacheMem[14*4+14];    // 4 suites * 14 cards + 14 card backs
  37.  
  38. const IID IID_ICatRegister = {0x0002E012,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  39. const CATID CATID_SafeForScripting = {0x7dd95801,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};
  40. const CATID CATID_SafeForInitializing = {0x7dd95802,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};
  41.  
  42. // needed for ASSERTs and FAIL
  43. //
  44. SZTHISFILE
  45.  
  46. //=--------------------------------------------------------------------------=
  47. // our Libid.  This should be the LIBID from the Type library, or NULL if you
  48. // don't have one.
  49. //
  50. const CLSID *g_pLibid = &LIBID_CardObjects;
  51.  
  52.  
  53. //=--------------------------------------------------------------------------=
  54. // Localization Information
  55. //
  56. // We need the following two pieces of information:
  57. //    a. whether or not this DLL uses satellite DLLs for localization.  if
  58. //       not, then the lcidLocale is ignored, and we just always get resources
  59. //       from the server module file.
  60. //    b. the ambient LocaleID for this in-proc server.  Controls calling
  61. //       GetResourceHandle() will set this up automatically, but anybody
  62. //       else will need to be sure that it's set up properly.
  63. //
  64. const VARIANT_BOOL    g_fSatelliteLocalization =  FALSE;
  65. LCID            g_lcidLocale = MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT);
  66.  
  67.  
  68. //=--------------------------------------------------------------------------=
  69. // your license key and where under HKEY_CLASSES_ROOT_LICENSES it's sitting
  70. //
  71. const WCHAR g_wszLicenseKey [] = L"";
  72. const WCHAR g_wszLicenseLocation [] = L"";
  73.  
  74.  
  75. WNDPROC g_ParkingWindowProc = NULL;
  76.  
  77. //=--------------------------------------------------------------------------=
  78. // This Table describes all the automatible objects in your automation server.
  79. // See AutomationObject.H for a description of what goes in this structure
  80. // and what it's used for.
  81. //
  82. OBJECTINFO g_ObjectInfo[] = {
  83.     CONTROLOBJECT(Card),
  84.     PROPERTYPAGE(CardGeneral),
  85.     EMPTYOBJECT
  86. };
  87.  
  88. const char g_szLibName[] = "ActiveXSDKCard";
  89.  
  90. //=--------------------------------------------------------------------------=
  91. // IntializeLibrary
  92. //=--------------------------------------------------------------------------=
  93. // called from DllMain:DLL_PROCESS_ATTACH.  allows the user to do any sort of
  94. // initialization they want to.
  95. //
  96. // Notes:
  97. //
  98. void WINAPI InitializeLibrary (void )
  99. {
  100.     InitializeCriticalSection( &drawCritSec );
  101. }
  102.  
  103. //=--------------------------------------------------------------------------=
  104. // UninitializeLibrary
  105. //=--------------------------------------------------------------------------=
  106. // called from DllMain:DLL_PROCESS_DETACH.  allows the user to clean up anything
  107. // they want.
  108. //
  109. // Notes:
  110. //
  111. void WINAPI UninitializeLibrary
  112. (
  113.     void
  114. )
  115. {
  116.     DeleteCriticalSection( &drawCritSec );
  117.  
  118.     for( int t = 0; t < sizeof(cardcacheMem)/sizeof(cardcacheMem[0]); t++ )
  119.         if( cardcacheMem[t] )
  120.             DeleteObject( cardcacheMem[t] );
  121. }
  122.  
  123.  
  124. //=--------------------------------------------------------------------------=
  125. // CheckForLicense
  126. //=--------------------------------------------------------------------------=
  127. // users can implement this if they wish to support Licensing.  otherwise,
  128. // they can just return TRUE all the time.
  129. //
  130. // Parameters:
  131. //    none
  132. //
  133. // Output:
  134. //    BOOL            - TRUE means the license exists, and we can proceed
  135. //                      FALSE means we're not licensed and cannot proceed
  136. //
  137. // Notes:
  138. //    - implementers should use g_wszLicenseKey and g_wszLicenseLocation
  139. //      from the top of this file to define their licensing [the former
  140. //      is necessary, the latter is recommended]
  141. //
  142. BOOL WINAPI CheckForLicense
  143. (
  144.     void
  145. )
  146. {
  147.     // TODO: decide whether or not your server is licensed in this function.
  148.     // people who don't want to bother with licensing should just return
  149.     // true here always.  g_wszLicenseKey and g_wszLicenseLocation are
  150.     // used by IClassFactory2 to do some of the licensing work.
  151.     //
  152.     return TRUE;
  153. }
  154.  
  155. //=--------------------------------------------------------------------------=
  156. // RegisterData
  157. //=--------------------------------------------------------------------------=
  158. // lets the inproc server writer register any data in addition to that in
  159. // any other objects.
  160. //
  161. // Output:
  162. //    BOOL            - false means failure.
  163. //
  164. // Notes:
  165. //
  166. BOOL WINAPI RegisterData
  167. (
  168.     void
  169. )
  170. {
  171.     HRESULT hr;
  172.  
  173.     hr = CreateComponentCategory(CATID_SafeForScripting, L"Controls that are safely scriptable");
  174.     hr = CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data");
  175.     hr = RegisterCLSIDInCategory(CLSID_Card, CATID_SafeForScripting);
  176.     hr = RegisterCLSIDInCategory(CLSID_Card, CATID_SafeForInitializing);
  177.     return TRUE;
  178. }
  179.  
  180. //=--------------------------------------------------------------------------=
  181. // UnregisterData
  182. //=--------------------------------------------------------------------------=
  183. // inproc server writers should unregister anything they registered in
  184. // RegisterData() here.
  185. //
  186. // Output:
  187. //    BOOL            - false means failure.
  188. //
  189. // Notes:
  190. //
  191. BOOL WINAPI UnregisterData
  192. (
  193.     void
  194. )
  195. {
  196.     HRESULT hr;
  197.  
  198.     hr = UnRegisterCLSIDInCategory(CLSID_Card, CATID_SafeForScripting);
  199.     hr = UnRegisterCLSIDInCategory(CLSID_Card, CATID_SafeForInitializing);
  200.     return TRUE;
  201. }
  202.  
  203. BOOL WINAPI      CheckLicenseKey(LPWSTR wszCheckme)
  204. {
  205.     return TRUE;
  206. }
  207.  
  208. BSTR WINAPI      GetLicenseKey(void)
  209. {
  210.     return NULL;
  211. }
  212.  
  213.