The code below used to be perfect to C++Builder 6.0, but it is not compiling on RAD 10.4 Sydney. I am not familiar with OLE controls and its classes and methods. Can someone help me to make it work?
PogBrowser is a TCppWebBrowser.
void __fastcall TRelatPOG::ShowStream( TStream *stm )
{
try
{
if( !PogBrowser->Document )
{
PogBrowser->Navigate(L"about:blank");
while( PogBrowser->ReadyState != 4 )
Application->ProcessMessages();
}
IPersistStreamInit *psi;
TStreamAdapter *sa = new TStreamAdapter(stm,soReference);
if( sa )
{
if (SUCCEEDED(PogBrowser->Document->QueryInterface(IID_IPersistStreamInit,(void **)&psi)))
{
psi->InitNew();
psi->Load(*sa);// Compile error
psi->Release();
}
delete sa;
}
}
catch(Exception *E)
{
MessageDlg(String(E->ClassName()) + " ( " + E->Message + " )", mtError, TMsgDlgButtons() << mbOK, 0);
}
}
Once upon a time,
TStreamAdapter
used to implicitly convert toIStream*
, but now it implicitly converts to_di_IStream
instead (ieDelphiInterface<IStream>
).IPersistStreamInit::Save()
requiresIStream*
, thus requires 2 conversions (TStreamAdapter
->_di_IStream
->IStream*
), but C++ only allows 1 implicit conversion at a time.So, you need to cast the
TStreamAdapter
to_di_IStream
explicitly, which can then convert toIStream*
implicitly, eg:However, a better solution would be to let
_di_IStream
handle the lifetime of theTStreamAdapter
to begin with, eg: