TCppWebBrowser generates access violation....


2003-09-09 01:56:38 AM
cppbuilder61
I have following code which creates a TCppWebBrowser and works just
fine....
class TForm1 : public TForm
{
__published: // IDE-managed Components
TLabel *Label1;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TCppWebBrowser *MyWebBrowser = new TCppWebBrowser(this);
MyWebBrowser->TOleControl::Parent = NULL;
MyWebBrowser->Visible=false;
MyWebBrowser->Offline=false;
MyWebBrowser->Silent=true;
// Code continues....
}
//---------------------------------------------------------------------------
So far, so good. But since I had written a lot of code which works
with the TCppWebBrowser component I decided to make a seperate class
out of it.
Do note that I do not need a visible TCppWebBrowser component. I just
retrieve a file from the internet in it and then access the content of
the TCppWebBrowser (the HTML-source) to do some stuff.
So I created a separate class called CheckVersion :
//---------------------------------------------------------------------------
class CheckVersion
{
public: // User declarations
void RetrieveCurrentVersionFromServer(String URL_Location);
};
//---------------------------------------------------------------------------
void CheckVersion::RetrieveCurrentVersionFromServer(String
URL_Location)
{
TCppWebBrowser *MyWebBrowser = new TCppWebBrowser(this);
MyWebBrowser->TOleControl::Parent = NULL;
MyWebBrowser->Visible=false;
MyWebBrowser->Offline=false; <========= This line crashes with an
access violation
MyWebBrowser->Silent=true;
// Code continues....
}
//---------------------------------------------------------------------------
And in my main form I create an instance of this class.
CheckVersion MyCheckVersion;
When I press the form-button I just call a function from the
MyCheckVersion-instance...
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
MyCheckVersion.RetrieveCurrentVersionFromServer("http:\\dvdplusid.cdfreaks.com");
}
//---------------------------------------------------------------------------
Even though the code is identical to the code at the very top (except
that it is now split into 2 classes) it will crash everytime.
MyWebBrowser->Offline=false; <========= This line crashes with an
access violation
A little voice is telling me that the 'this' in "= new
TCppWebBrowser(this)" perhaps might have something to do with it but I
can't figure out any alternatives to try.....
Any ideas why ? I'm totally lost and any help is much appreciated.....