home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / Atl / ATLVCL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  3.8 KB  |  141 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // ATLVCL.CPP - Provides the connective tissue between
  3. //              the ATL framework and VCL components.
  4. //
  5. // $Revision:   1.24.1.7  $
  6. //
  7. // Copyright (c) 1997, Borland International
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #include <vcl.h>
  10. #pragma hdrstop
  11.  
  12. #if !defined(__ATLVCL_H_)
  13. #include <atl\atlvcl.h>
  14. #endif
  15. #include <comconst.hpp>
  16. #include <axctrls.hpp>
  17. #include <tchar.h>
  18.  
  19. // Externs
  20. // Pointer to save Initialization Procedure when using VCL
  21. // (CBuilder3 backward compatibility)
  22. //
  23. void* SaveInitProc = 0;
  24.  
  25.  
  26. // Helper used by IPersistStreamInit implementation to save component
  27. //
  28. void __fastcall SaveVCLComponentToStream(TComponent *vclInstance, LPSTREAM pStrm)
  29. {
  30.   TPtr<TStream> pStream = new TOleStream(_di_IStream(pStrm)); 
  31.   TPtr<TWriter> pWriter = new TWriter(pStream, 4096);
  32.   pWriter->IgnoreChildren = true;
  33.   pWriter->WriteDescendent(vclInstance, 0);
  34. }
  35.  
  36.  
  37. // Helper used by IPersistStreamInit implementation to load component
  38. //
  39. void __fastcall LoadVCLComponentFromStream(TComponent *vclInstance, LPSTREAM pStrm)
  40. {
  41.   TPtr<TStream> pStream = new TOleStream(_di_IStream(pStrm)); 
  42.   TPtr<TReader> pReader = new TReader(pStream, 4096);
  43.   pReader->ReadRootComponent(vclInstance);
  44. }
  45.  
  46.  
  47. // Helper used by framework to create a reflector object
  48. //
  49. TWinControl* CreateReflectorWindow(HWND parent, Controls::TControl* Control)
  50. {
  51.   return new TReflectorWindow(parent, Control);
  52. }
  53.  
  54.  
  55. // Register (or unregisters) Remote data module
  56. //
  57. HRESULT TRemoteDataModuleRegistrar::UpdateRegistry(bool bRegister)
  58. {
  59.    HRESULT hr = TTypedComServerRegistrar::UpdateRegistry(bRegister);
  60.  
  61.    // Code specific to Remote Data Modules
  62.    //
  63.    if (&Forms::UpdateDataModuleRegistry != NULL)
  64.      Forms::UpdateDataModuleRegistry(bRegister, AnsiString(LPCSTR(m_ClassIDstr)), 
  65.                                                 AnsiString(LPCTSTR(m_ProgID)));
  66.    return hr;
  67. }
  68.  
  69.  
  70. // Registers (or Unregisters) ActiveX Control
  71. //
  72. HRESULT TAxControlRegistrar::UpdateRegistry(bool Register)
  73. {
  74.   HRESULT hres;
  75.   if (Register)
  76.   {
  77.     // Call base first when registering
  78.     //
  79.     hres = TTypedComServerRegistrar::UpdateRegistry(Register);
  80.    
  81.     // Make registry entries
  82.     //
  83.     TCHAR key[_MAX_PATH];
  84.     lstrcpy(key, m_ClassKey);
  85.     LPTSTR pinsert = key + lstrlen(key);
  86.  
  87.     lstrcpy(pinsert, _T("\\MiscStatus"));
  88.     CreateRegKey(key, _T(""), _T("0"));
  89.  
  90.     TCHAR misc[16];
  91.     wsprintf(misc, _T("%d"), m_MiscFlags);
  92.     lstrcpy(pinsert, _T("\\MiscStatus\\1"));
  93.     CreateRegKey(key, _T(""), misc);
  94.  
  95.     lstrcpy(pinsert, _T("\\ToolboxBitmap32"));
  96.     TCHAR mod[_MAX_PATH + 8];
  97.     wsprintf(mod, _T("%s,%d"), LPCTSTR(m_ModuleName), m_BitmapID);
  98.     CreateRegKey(key, _T(""),  mod);
  99.  
  100.     lstrcpy(pinsert, _T("\\Control"));
  101.     CreateRegKey(key,   _T(""), _T(""));
  102.  
  103.     lstrcpy(pinsert, _T("\\Verb"));
  104.     CreateRegKey(key,   _T(""), _T(""));
  105.    
  106.     // Register Verbs
  107.     //
  108.     const OLEVERB *pVerb = m_Verbs;
  109.     while (pVerb->lpszVerbName && *pVerb->lpszVerbName)
  110.     {
  111.       TCHAR szKey[_MAX_PATH];
  112.       wsprintf(szKey, _T("%s\\Verb\\%d"), LPCTSTR(m_ClassKey), pVerb->lVerb);
  113.  
  114.       TCHAR szVerb[_MAX_PATH];
  115.       wsprintf(szVerb, _T("%ls,%d,%d"), pVerb->lpszVerbName, pVerb->fuFlags, pVerb->grfAttribs);
  116.     
  117.       CreateRegKey(szKey, _T(""), szVerb);
  118.  
  119.       pVerb++;
  120.     }
  121.   }
  122.   else
  123.   {
  124.     // Call base class to unregister
  125.     // NOTE: Base class removes everything underneath \\CLSID\\<clsid> && \\<progid>\\
  126.     //
  127.     hres = TTypedComServerRegistrar::UpdateRegistry(Register);
  128.   }
  129.   return hres;
  130. }
  131.  
  132. #if defined(USING_VCL)
  133. // AutomationTerminateProc (Backward compatiblity)
  134. //
  135. bool __fastcall AutomationTerminateProc()
  136. {
  137.   return TComModule::AutomationTerminateProc();
  138. }
  139. #endif
  140.  
  141.