Home > Back-end >  How will the visual components encapsulation for Activex controls? Urgent please
How will the visual components encapsulation for Activex controls? Urgent please

Time:09-24

Need to be a non visual controls (and similar) TTable function encapsulation for Activex controls,
(here I am to imitate this tutorial http://blog.csdn.net/jaminwm/article/details/463953)
Is not familiar to c + + builder, groping his lane, according to the search example, imitating the experiment will TTable encapsulated as Activex controls, steps are as follows:

(1) open the bcb6, open the File/New/ActiveX projects page, select the ActiveX Library;
While they continue to add, open the File/New/ActiveX properties page, select Automation Object, named TMyTable
I don't know how to speak TTable classes encapsulate there,
Hope I can help take a look at, to achieve specific encapsulation methods!
In TMyTableImpl h, I originally thought, let this class inherits TTable class directly, but not
TMyTableImpl. H file:

//MYTABLEIMPL. H: Declaration of the TMyTableImpl

# # ifndef MyTableImplH
# define MyTableImplH

# define ATL_APARTMENT_THREADED
#include

# include "Project1_TLB. H"
#include
#include
#include
#include
#include
#include

/////////////////////////////////////////////////////////////////////////////
//TMyTableImpl Implements IMyTable, default interface of MyTable
//ThreadingModel: Apartment
//Dual Interface: TRUE
//Event Support: FALSE
//the Default ProgID: Project1 MyTable
//Description:
/////////////////////////////////////////////////////////////////////////////
The class ATL_NO_VTABLE TMyTableImpl:
Public CComObjectRootEx ,
Public CComCoClassPublic IDispatchImpl{
Public:
TMyTableImpl ()
{
}

//Data informs the when registering Object
//
DECLARE_THREADING_MODEL (otApartment);
DECLARE_PROGID (" Project1. MyTable ");
DECLARE_DESCRIPTION (" ");

//Function invoked to register (UN) object
//
The static HRESULT WINAPI UpdateRegistry (BOOL bRegister)
{
TTypedComServerRegistrarT
RegObj (GetObjectCLSID (), GetProgID (), the GetDescription ());
Return regObj. UpdateRegistry (bRegister);
}


BEGIN_COM_MAP (TMyTableImpl)
COM_INTERFACE_ENTRY (IMyTable)
COM_INTERFACE_ENTRY2 (IDispatch, IMyTable)
END_COM_MAP ()

//IMyTable
Public:

STDMETHOD (set_Active (VARIANT_BOOL Param1));
STDMETHOD (set_DatabaseName (BSTR Param1));
STDMETHOD (Open ());
STDMETHOD (Close ());
STDMETHOD (set_TableName (BSTR Param1));
STDMETHOD (get_Active (VARIANT_BOOL * Value));
Private:
TTable * m_Table;
};

# endif//MyTableImplH


TMyTableImpl. CPP file
//MYTABLEIMPL: Implementation of TMyTableImpl (CoClass: MyTable, Interface: IMyTable)

#include
# pragma hdrstop
#include
# include "MYTABLEIMPL. H"

/////////////////////////////////////////////////////////////////////////////
//TMyTableImpl
# pragma package (smart_init)
STDMETHODIMP TMyTableImpl: : set_Active (VARIANT_BOOL Param1)
{
Try
{
//m_Table - & gt; Active=Param1;

M_Table - & gt; Active=Param1;
}
The catch (Exception & amp; E)
{
Return the Error (e.M essage. C_str (), IID_IMyTable);
}
Return S_OK.
};


STDMETHODIMP TMyTableImpl: : set_DatabaseName (BSTR Param1)
{
Try
{
//m_Table - & gt; DatabaseName=Param1;


M_Table - & gt; DatabaseName="db. MDB";
}
The catch (Exception & amp; E)
{
Return the Error (e.M essage. C_str (), IID_IMyTable);
}
Return S_OK.
};


STDMETHODIMP TMyTableImpl: : Open ()
{
M_Table - & gt; The Open ();
}


STDMETHODIMP TMyTableImpl: : Close ()
{
M_Table - & gt; Close ();
}


STDMETHODIMP TMyTableImpl: : set_TableName (BSTR Param1)
{
Try
{
//m_Table - & gt; TableName=Value;

M_Table - & gt; TableName="tb_user";
}
The catch (Exception & amp; E)
{
Return the Error (e.M essage. C_str (), IID_IMyTable);
}
Return S_OK.
};





STDMETHODIMP TMyTableImpl: : get_Active (VARIANT_BOOL * Value)
{
Try
{
* Value=https://bbs.csdn.net/topics/m_Table-> Active;
}
The catch (Exception & amp; E)
{
Return the Error (e.M essage. C_str (), IID_IMyTable);
}
Return S_OK.
};


CodePudding user response:

The control is new,

CodePudding user response:

reference 1st floor wewaa response:
control is a new,

Where should the new comes out, I am in where the interface methods, with TAB TTable *=new TTable (NULL), an error when using,

CodePudding user response:

Control well, to add to the component panel of BCB ide, so that it can be directly in the designer brought in,

CodePudding user response:

Top hope someone to help!

CodePudding user response:

Abandoning the ActiveX, this technology is not worth learning,
  • Related