ActiveX Printing
Hello All,
I use FastReport to print my own ActiveX object. I want go get it's interface while printing/previewing and to change some properties. I put OLE object in FastReport and named it as "Ole1". Then I tried to use OnBeforePrint event and write a handler like this (IMyCtl is my object's interface):
void __fastcall TForm1::frReport1BeforePrint(TStringList *Memo,
TfrView *View)
{
TfrOLEView *pOleView = dynamic_cast<TfrOLEView*> (View);
if (pOleView)
{
IMyCtl *pCtl;
if (SUCCEEDED(pOleView->OleContainer->OleObjectInterface->QueryInterface(__uuidof(IMyCtl),(void**)&pCtl)) && pCtl)
{
pCtl->SomeProperty = 5;
ShowMessage(IntToStr(pCtl->SomeProperty));
pCtl->Release();
}
}
}
Everything was fine: QueryInterface succeeded, and SomeProperty was successfully changed (ShowMessage showed 5). But nothing happened in preview window: object there was not changed. Later I tried to put a call to user-defined function REFRESH_PROPERTIES() in OLE Memo, and write almost the same code in OnUserFunction:
TfrOLEView *pOleView = dynamic_cast<TfrOLEView*> (frReport1->FindObject("Ole1"));
if (pOleView)
...
and I got the same situation: property was successfully changed, but OLE object in Preview window looked unchanged. It seems, that I access a valid pointer to another object. What can I do? Should I write my own component - descendant of TfrOLEView and can anybody give me a sample? Or is there an easier way?
Thank you very much.
I use FastReport to print my own ActiveX object. I want go get it's interface while printing/previewing and to change some properties. I put OLE object in FastReport and named it as "Ole1". Then I tried to use OnBeforePrint event and write a handler like this (IMyCtl is my object's interface):
void __fastcall TForm1::frReport1BeforePrint(TStringList *Memo,
TfrView *View)
{
TfrOLEView *pOleView = dynamic_cast<TfrOLEView*> (View);
if (pOleView)
{
IMyCtl *pCtl;
if (SUCCEEDED(pOleView->OleContainer->OleObjectInterface->QueryInterface(__uuidof(IMyCtl),(void**)&pCtl)) && pCtl)
{
pCtl->SomeProperty = 5;
ShowMessage(IntToStr(pCtl->SomeProperty));
pCtl->Release();
}
}
}
Everything was fine: QueryInterface succeeded, and SomeProperty was successfully changed (ShowMessage showed 5). But nothing happened in preview window: object there was not changed. Later I tried to put a call to user-defined function REFRESH_PROPERTIES() in OLE Memo, and write almost the same code in OnUserFunction:
TfrOLEView *pOleView = dynamic_cast<TfrOLEView*> (frReport1->FindObject("Ole1"));
if (pOleView)
...
and I got the same situation: property was successfully changed, but OLE object in Preview window looked unchanged. It seems, that I access a valid pointer to another object. What can I do? Should I write my own component - descendant of TfrOLEView and can anybody give me a sample? Or is there an easier way?
Thank you very much.