nntoolkit_ocx.cpp

来自「C++BUILDER与MATLAB实现混合编程源代码」· C++ 代码 · 共 131 行

CPP
131
字号
// ************************************************************************ //
// WARNING                                                                    
// -------                                                                    
// The types declared in this file were generated from data read from a       
// Type Library. If this type library is explicitly or indirectly (via        
// another type library referring to this type library) re-imported, or the   
// 'Refresh' command of the Type Library Editor activated while editing the   
// Type Library, the contents of this file will be regenerated and all        
// manual modifications will be lost.                                         
// ************************************************************************ //

// C++ TLBWRTR : $Revision:   1.151.1.0.1.27  $
// File generated on 2005-9-30 17:31:22 from Type Library described below.

// ************************************************************************  //
// Type Lib: C:\2NSOFTPF\nnToolKit\nnToolKit_1_0.dll (1)
// LIBID: {33624A11-28E1-48B6-B235-18A83A91747F}
// LCID: 0
// Helpfile: 
// HelpString: nnToolKit 1.0 Type Library
// DepndLst: 
//   (1) v2.0 stdole, (C:\WINDOWS\system32\StdOle2.tlb)
//   (2) v1.0 MWComUtil, (C:\2NSOFTPF\nnToolKit\bin\win32\mwcomutil.dll)
// Errors:
//   Hint: TypeInfo 'nnToolKit' changed to 'nnToolKit_'
//   Error creating palette bitmap of (TnnToolKit) : Server C:\2NSOFTPF\nnToolKit\nnToolKit_2_0.dll contains no icons
// ************************************************************************ //

#include <vcl.h>
#pragma hdrstop

#include <olectrls.hpp>
#include <oleserver.hpp>
#if defined(USING_ATL)
#include <atl\atlvcl.h>
#endif

#include "nnToolKit_OCX.h"

#if !defined(__PRAGMA_PACKAGE_SMART_INIT)
#define      __PRAGMA_PACKAGE_SMART_INIT
#pragma package(smart_init)
#endif

namespace Nntoolkit_tlb
{

InnToolKitPtr& TnnToolKit::GetDefaultInterface()
{
  if (!m_DefaultIntf)
    Connect();
  return m_DefaultIntf;
}

_di_IUnknown __fastcall TnnToolKit::GetDunk()
{
  _di_IUnknown diUnk;
  if (m_DefaultIntf) {
    IUnknownPtr punk = m_DefaultIntf;
    diUnk = LPUNKNOWN(punk);
  }
  return diUnk;
}

void __fastcall TnnToolKit::Connect()
{
  if (!m_DefaultIntf) {
    _di_IUnknown punk = GetServer();
    m_DefaultIntf = punk;
    if (ServerData->EventIID != GUID_NULL)
      ConnectEvents(GetDunk());
  }
}

void __fastcall TnnToolKit::Disconnect()
{
  if (m_DefaultIntf) {
    
    if (ServerData->EventIID != GUID_NULL)
      DisconnectEvents(GetDunk());
    m_DefaultIntf.Reset();
  }
}

void __fastcall TnnToolKit::BeforeDestruction()
{
  Disconnect();
}

void __fastcall TnnToolKit::ConnectTo(InnToolKitPtr intf)
{
  Disconnect();
  m_DefaultIntf = intf;
  if (ServerData->EventIID != GUID_NULL)
    ConnectEvents(GetDunk());
}

void __fastcall TnnToolKit::InitServerData()
{
  static Oleserver::TServerData sd;
  sd.ClassID = CLSID_nnToolKit_;
  sd.IntfIID = __uuidof(InnToolKit);
  sd.EventIID= GUID_NULL;
  ServerData = &sd;
}


};     // namespace Nntoolkit_tlb


// *********************************************************************//
// The Register function is invoked by the IDE when this module is 
// installed in a Package. It provides the list of Components (including
// OCXes) implemented by this module. The following implementation
// informs the IDE of the OCX proxy classes implemented here.
// *********************************************************************//
namespace Nntoolkit_ocx
{

void __fastcall PACKAGE Register()
{
  // [1]
  TComponentClass cls_svr[] = {
                              __classid(Nntoolkit_tlb::TnnToolKit)
                           };
  RegisterComponents("ActiveX", cls_svr,
                     sizeof(cls_svr)/sizeof(cls_svr[0])-1);
}

};     // namespace Nntoolkit_ocx

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?