 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Nico Reinacher Guest
|
Posted: Sat Nov 29, 2003 3:46 pm Post subject: Derive TCppWebBrowser |
|
|
Hello!
I have problems to create a class derived from TCppWebBrowser (see code
example).
If the function "Navigate" executed in the "FormShow"-function, the
C++Builder 5 throw
an exception "EAccessViolation". Why?? How can I solve this problem?
Header file:
-----------
//--------------------------------------------------------------------------
-
#ifndef MainH
#define MainH
//--------------------------------------------------------------------------
-
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <shdocvw_ocx.h>
//--------------------------------------------------------------------------
-
class TIBrowser;
class TMainForm : public TForm
{
__published: // Von der IDE verwaltete Komponenten
void __fastcall FormShow(TObject *Sender);
private: // Anwender-Deklarationen
public: // Anwender-Deklarationen
TIBrowser *Browser;
__fastcall TMainForm(TComponent* Owner);
};
//--------------------------------------------------------------------------
-
extern PACKAGE TMainForm *MainForm;
//--------------------------------------------------------------------------
-
class TIBrowser : public TCppWebBrowser
{
public:
__fastcall TIBrowser(TComponent* Owner);
};
#endif
cpp-file:
--------
//--------------------------------------------------------------------------
-
#include <vcl.h>
#pragma hdrstop
#include "Main.h"
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
//--------------------------------------------------------------------------
-
__fastcall TMainForm::TMainForm(TComponent* Owner)
: TForm(Owner)
{
Browser = new TIBrowser(this); Browser->ParentWindow = Handle;
Browser->TOleControl::Parent = MainForm; Browser->Align = alClient;}
//--------------------------------------------------------------------------
-
__fastcall TIBrowser::TIBrowser(TComponent* Owner)
: TCppWebBrowser(Owner)
{
//TODO: Hier Ihren Quelltext einfügen
}
//--------------------------------------------------------------------------
-
void __fastcall TMainForm::FormShow(TObject *Sender)
{
Browser->Navigate( WideString("about:blank") );
}
//--------------------------------------------------------------------------
-
Thanks
Nico
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sun Nov 30, 2003 4:54 am Post subject: Re: Derive TCppWebBrowser |
|
|
"Nico Reinacher" <nico.reinacher (AT) t-online (DOT) de> wrote
| Quote: | If the function "Navigate" executed in the "FormShow"-function,
the C++Builder 5 throw an exception "EAccessViolation". Why??
|
An AV occurs when you try to access invalid memory. The form's OnShow event
can be triggered before the form is finished being initialized, so you are
probably trying to access the browser before it has even been instantiated
yet. Do you, by change, have the OldCreateOrder property set to true?
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|