bohanl01
October 8, 2003, 21:26:37
I am trying to script the ActiveX Server from visual c++, I've added the ocx to the project and generated the corresponding .cpp .h wrapper object.
After some tinkering, it compiled. However, I haven't been sucessful in calling any of the object's functions from my program.
How would I go about the implementaion of this. Any suggestions. Examples.
Do you have any sample code in c++ of this?
bohanl01
October 13, 2003, 19:46:39
The following code is where I'm at I've gotten it will compile and run but it crashes on the saves and loads. Can anyone see if there is a problem with the way I'm going about this?
THANKS
CiRISConverterDlg dlg;
m_pMainWnd = &dlg;
TRACE (" before constructor\n" );
IDispatch* m_pDispApp;
if (SUCCEEDED(CoInitialize(NULL)))
{
/*
CLSID clsid;
CLSIDFromProgID(L"TX.TextControl.LicManager", &clsid);
// Create an instance of the Word application and obtain the pointer
// to the application's IUnknown interface
IUnknown* pUnk;
HRESULT hr = ::CoCreateInstance( clsid, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**) &pUnk);
if (FAILED(hr))
{
TRACE("Error in creating Word application instance\n");
return -1;
}
// Query IUnknown to retrieve a pointer to the IDispatch interface
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&m_pDispApp);
*/
Tx4oleLib::ILicManagerPtr lic(__uuidof(Tx4oleLib::TXLicenseManager));
// Tx4oleLib::ILicManagerPtr lic(m_pDispApp);
TRACE (" after constructor\n" );
Tx4oleLib::_DTX4OLEPtr textControl(__uuidof(Tx4oleLib::TXTextControl));
textControl->EnableAutomationServer();
VARIANT variant1;
VARIANT variant2;
VariantInit(&variant1);
VariantInit(&variant2);
variant1.vt = VT_I8;
variant1.lVal = 0;
variant2.vt = VT_I4;
variant2.intVal = 12;
TRACE (" before Load\n" );
// textControl->Load("c:\\test.rtf", variant1, variant2);
TRACE (" After Load\n" );
textControl->ViewMode = 1;
textControl->PageHeight = 16837;
textControl->PageWidth = 11906;
textControl->PageMarginL = 567;
textControl->PageMarginB = 567;
textControl->PageMarginT = 567;
textControl->PageMarginR = 567;
LPCTSTR csTemp = "demo.pdf";
//textControl->CTXTextControl();
textControl->Text = "The quick brown fox jumps over the lazy dog.";
textControl->Save ( csTemp, variant1, variant2 );
}