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 / webimage / wimg.cpp < prev    next >
C/C++ Source or Header  |  1997-10-09  |  7KB  |  227 lines

  1. //=--------------------------------------------------------------------------=
  2. // WImg.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.  
  16. #define INITOBJECTS                // define the descriptions for our objects
  17.  
  18. #include "IPServer.H"
  19. #include "LocalSrv.H"
  20.  
  21.  
  22. #include "LocalObj.H"
  23. #include "CtrlObj.H"
  24. #include "Globals.H"
  25. #include "Util.H"
  26. #include "Resource.H"
  27.  
  28. #include "WImgCtl.H"
  29. #include "WImgPPG.H"
  30. #include "cathelp.H"
  31.  
  32. const IID IID_ICatRegister = {0x0002E012,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  33. const CATID CATID_SafeForScripting        = {0x7dd95801,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};
  34. const CATID CATID_SafeForInitializing    = {0x7dd95802,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};
  35.  
  36. // needed for ASSERTs and FAIL
  37. //
  38. SZTHISFILE
  39.  
  40. //=--------------------------------------------------------------------------=
  41. // our Libid.  This should be the LIBID from the Type library, or NULL if you
  42. // don't have one.
  43. //
  44. const CLSID *g_pLibid = &LIBID_WebImageObjects;
  45.  
  46.  
  47. //=--------------------------------------------------------------------------=
  48. // Localization Information
  49. //
  50. // We need the following two pieces of information:
  51. //    a. whether or not this DLL uses satellite DLLs for localization.  if
  52. //       not, then the lcidLocale is ignored, and we just always get resources
  53. //       from the server module file.
  54. //    b. the ambient LocaleID for this in-proc server.  Controls calling
  55. //       GetResourceHandle() will set this up automatically, but anybody
  56. //       else will need to be sure that it's set up properly.
  57. //
  58. const VARIANT_BOOL    g_fSatelliteLocalization =  FALSE;
  59. LCID            g_lcidLocale = MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT);
  60.  
  61.  
  62. //=--------------------------------------------------------------------------=
  63. // your license key and where under HKEY_CLASSES_ROOT_LICENSES it's sitting
  64. //
  65. const WCHAR g_wszLicenseKey [] = L"";
  66. const WCHAR g_wszLicenseLocation [] = L"";
  67.  
  68.  
  69. WNDPROC g_ParkingWindowProc = NULL;
  70.  
  71. //=--------------------------------------------------------------------------=
  72. // This Table describes all the automatible objects in your automation server.
  73. // See AutomationObject.H for a description of what goes in this structure
  74. // and what it's used for.
  75. //
  76. OBJECTINFO g_ObjectInfo[] = {
  77.     CONTROLOBJECT(WebImage),
  78.     PROPERTYPAGE(WebImageGeneral),
  79.     EMPTYOBJECT
  80. };
  81.  
  82. const char g_szLibName[] = "WebImage";
  83.  
  84. //=--------------------------------------------------------------------------=
  85. // IntializeLibrary
  86. //=--------------------------------------------------------------------------=
  87. // called from DllMain:DLL_PROCESS_ATTACH.  allows the user to do any sort of
  88. // initialization they want to.
  89. //
  90. // Notes:
  91. //
  92. void WINAPI InitializeLibrary
  93. (
  94.     void
  95. )
  96. {
  97.     // TODO: initialization here.  control window class should be set up in
  98.     // RegisterClassData.
  99. }
  100.  
  101. //=--------------------------------------------------------------------------=
  102. // UninitializeLibrary
  103. //=--------------------------------------------------------------------------=
  104. // called from DllMain:DLL_PROCESS_DETACH.  allows the user to clean up anything
  105. // they want.
  106. //
  107. // Notes:
  108. //
  109. void WINAPI UninitializeLibrary
  110. (
  111.     void
  112. )
  113. {
  114.     // TODO: uninitialization here.  control window class will be unregistered
  115.     // for you, but anything else needs to be cleaned up manually.
  116.     // Please Note that the Window 95 DLL_PROCESS_DETACH isn't quite as stable
  117.     // as NT's, and you might crash doing certain things here ...
  118. }
  119.  
  120.  
  121. //=--------------------------------------------------------------------------=
  122. // CheckForLicense
  123. //=--------------------------------------------------------------------------=
  124. // users can implement this if they wish to support Licensing.  otherwise,
  125. // they can just return TRUE all the time.
  126. //
  127. // Parameters:
  128. //    none
  129. //
  130. // Output:
  131. //    BOOL            - TRUE means the license exists, and we can proceed
  132. //                      FALSE means we're not licensed and cannot proceed
  133. //
  134. // Notes:
  135. //    - implementers should use g_wszLicenseKey and g_wszLicenseLocation
  136. //      from the top of this file to define their licensing [the former
  137. //      is necessary, the latter is recommended]
  138. //
  139. BOOL WINAPI CheckForLicense
  140. (
  141.     void
  142. )
  143. {
  144.     // TODO: decide whether or not your server is licensed in this function.
  145.     // people who don't want to bother with licensing should just return
  146.     // true here always.  g_wszLicenseKey and g_wszLicenseLocation are
  147.     // used by IClassFactory2 to do some of the licensing work.
  148.     //
  149.     return TRUE;
  150. }
  151.  
  152. //=--------------------------------------------------------------------------=
  153. // RegisterData
  154. //=--------------------------------------------------------------------------=
  155. // lets the inproc server writer register any data in addition to that in
  156. // any other objects.
  157. //
  158. // Output:
  159. //    BOOL            - false means failure.
  160. //
  161. // Notes:
  162. //
  163. BOOL WINAPI RegisterData
  164. (
  165.     void
  166. )
  167. {
  168.     HRESULT hr;
  169.  
  170.     hr = CreateComponentCategory(CATID_SafeForScripting, L"Controls that are safely scriptable");
  171.     hr = CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data");
  172.     hr = RegisterCLSIDInCategory(CLSID_WebImage, CATID_SafeForScripting);
  173.     hr = RegisterCLSIDInCategory(CLSID_WebImage, CATID_SafeForInitializing);
  174.     return TRUE;
  175. }
  176.  
  177. //=--------------------------------------------------------------------------=
  178. // UnregisterData
  179. //=--------------------------------------------------------------------------=
  180. // inproc server writers should unregister anything they registered in
  181. // RegisterData() here.
  182. //
  183. // Output:
  184. //    BOOL            - false means failure.
  185. //
  186. // Notes:
  187. //
  188. BOOL WINAPI UnregisterData
  189. (
  190.     void
  191. )
  192. {
  193.     HRESULT hr;
  194.  
  195.     hr = UnRegisterCLSIDInCategory(CLSID_WebImage, CATID_SafeForScripting);
  196.     hr = UnRegisterCLSIDInCategory(CLSID_WebImage, CATID_SafeForInitializing);
  197.     return TRUE;
  198. }
  199.  
  200. BOOL    WINAPI  CheckLicenseKey(LPWSTR wszCheckme)
  201. {
  202.     return TRUE;
  203. }
  204.  
  205. BSTR    WINAPI  GetLicenseKey(void)
  206. {
  207.     return NULL;
  208. }
  209.  
  210. //=--------------------------------------------------------------------------=
  211. // CRT stubs
  212. //=--------------------------------------------------------------------------=
  213. // these two things are here so the CRTs aren't needed. this is good.
  214. //
  215. // basically, the CRTs define this to suck in a bunch of stuff.  we'll just
  216. // define them here so we don't get an unresolved external.
  217. //
  218. // TODO: if you are going to use the CRTs, then remove this line.
  219. //
  220. // extern "C" int __cdecl _fltused = 1;
  221.  
  222. extern "C" int _cdecl _purecall(void)
  223. {
  224.   FAIL("Pure virtual function called.");
  225.   return 0;
  226. }
  227.