home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////////////////////////////////////
- // ATLVCL.CPP - Provides the connective tissue between
- // the ATL framework and VCL components.
- //
- // $Revision: 1.24.1.7 $
- //
- // Copyright (c) 1997, Borland International
- ///////////////////////////////////////////////////////////////////////////////
- #include <vcl.h>
- #pragma hdrstop
-
- #if !defined(__ATLVCL_H_)
- #include <atl\atlvcl.h>
- #endif
- #include <comconst.hpp>
- #include <axctrls.hpp>
- #include <tchar.h>
-
- // Externs
- // Pointer to save Initialization Procedure when using VCL
- // (CBuilder3 backward compatibility)
- //
- void* SaveInitProc = 0;
-
-
- // Helper used by IPersistStreamInit implementation to save component
- //
- void __fastcall SaveVCLComponentToStream(TComponent *vclInstance, LPSTREAM pStrm)
- {
- TPtr<TStream> pStream = new TOleStream(_di_IStream(pStrm));
- TPtr<TWriter> pWriter = new TWriter(pStream, 4096);
- pWriter->IgnoreChildren = true;
- pWriter->WriteDescendent(vclInstance, 0);
- }
-
-
- // Helper used by IPersistStreamInit implementation to load component
- //
- void __fastcall LoadVCLComponentFromStream(TComponent *vclInstance, LPSTREAM pStrm)
- {
- TPtr<TStream> pStream = new TOleStream(_di_IStream(pStrm));
- TPtr<TReader> pReader = new TReader(pStream, 4096);
- pReader->ReadRootComponent(vclInstance);
- }
-
-
- // Helper used by framework to create a reflector object
- //
- TWinControl* CreateReflectorWindow(HWND parent, Controls::TControl* Control)
- {
- return new TReflectorWindow(parent, Control);
- }
-
-
- // Register (or unregisters) Remote data module
- //
- HRESULT TRemoteDataModuleRegistrar::UpdateRegistry(bool bRegister)
- {
- HRESULT hr = TTypedComServerRegistrar::UpdateRegistry(bRegister);
-
- // Code specific to Remote Data Modules
- //
- if (&Forms::UpdateDataModuleRegistry != NULL)
- Forms::UpdateDataModuleRegistry(bRegister, AnsiString(LPCSTR(m_ClassIDstr)),
- AnsiString(LPCTSTR(m_ProgID)));
- return hr;
- }
-
-
- // Registers (or Unregisters) ActiveX Control
- //
- HRESULT TAxControlRegistrar::UpdateRegistry(bool Register)
- {
- HRESULT hres;
- if (Register)
- {
- // Call base first when registering
- //
- hres = TTypedComServerRegistrar::UpdateRegistry(Register);
-
- // Make registry entries
- //
- TCHAR key[_MAX_PATH];
- lstrcpy(key, m_ClassKey);
- LPTSTR pinsert = key + lstrlen(key);
-
- lstrcpy(pinsert, _T("\\MiscStatus"));
- CreateRegKey(key, _T(""), _T("0"));
-
- TCHAR misc[16];
- wsprintf(misc, _T("%d"), m_MiscFlags);
- lstrcpy(pinsert, _T("\\MiscStatus\\1"));
- CreateRegKey(key, _T(""), misc);
-
- lstrcpy(pinsert, _T("\\ToolboxBitmap32"));
- TCHAR mod[_MAX_PATH + 8];
- wsprintf(mod, _T("%s,%d"), LPCTSTR(m_ModuleName), m_BitmapID);
- CreateRegKey(key, _T(""), mod);
-
- lstrcpy(pinsert, _T("\\Control"));
- CreateRegKey(key, _T(""), _T(""));
-
- lstrcpy(pinsert, _T("\\Verb"));
- CreateRegKey(key, _T(""), _T(""));
-
- // Register Verbs
- //
- const OLEVERB *pVerb = m_Verbs;
- while (pVerb->lpszVerbName && *pVerb->lpszVerbName)
- {
- TCHAR szKey[_MAX_PATH];
- wsprintf(szKey, _T("%s\\Verb\\%d"), LPCTSTR(m_ClassKey), pVerb->lVerb);
-
- TCHAR szVerb[_MAX_PATH];
- wsprintf(szVerb, _T("%ls,%d,%d"), pVerb->lpszVerbName, pVerb->fuFlags, pVerb->grfAttribs);
-
- CreateRegKey(szKey, _T(""), szVerb);
-
- pVerb++;
- }
- }
- else
- {
- // Call base class to unregister
- // NOTE: Base class removes everything underneath \\CLSID\\<clsid> && \\<progid>\\
- //
- hres = TTypedComServerRegistrar::UpdateRegistry(Register);
- }
- return hres;
- }
-
- #if defined(USING_VCL)
- // AutomationTerminateProc (Backward compatiblity)
- //
- bool __fastcall AutomationTerminateProc()
- {
- return TComModule::AutomationTerminateProc();
- }
- #endif
-
-