Discussion:
CExplorer in Child Dialog
(too old to reply)
Gold Panther
2008-03-12 18:54:50 UTC
Permalink
I have a main dialog. On that dialog there is a button that brings up
a new dialog that should have a web browser on it. The new dialog
fails, because the control has not been created yet as stated by the
commented MS code:

"not an OLE control (not yet, at least)."

I happened upon a post or website talking about acquiring a license
for the control to create it dynamically. I figured since the dialog
is created dynamically that that means the web browser is probably
considered dynamically created. I tried doing the following:

CLSID stuff = m_webBrowser.GetClsid();

if(SUCCEEDED( hr = CoGetClassObject( m_webBrowser.GetClsid(),
CLSCTX_ALL, NULL,
IID_IClassFactory2, (LPVOID *)&pClassFactory )) )
{
LICINFO license;

if( SUCCEEDED(pClassFactory->GetLicInfo( &license )) )
{
if( SUCCEEDED(pClassFactory->RequestLicKey( 0, &bstrLicense )) )
{
if( bstrLicense == NULL )
{
EndDialog( 1 );
}
else
{
m_webBrowser.Create( NULL, WS_VISIBLE, CRect(0, 0, 200, 200 ),
this, IDC_EXPLORER1,
NULL, NULL, bstrLicense );
SysFreeString( bstrLicense );
}
}
else
{
EndDialog( 1 );
}
}
else
{
EndDialog( 1 );
}
}
else
{
EndDialog( 1 );
}

The call to CoGetClassObject fails with a CLASS_E_CLASSNOTAVAILABLE.
The variable "stuff" recognizes the CLSID while debugging as the CLSID
for the Microsoft Web Browser. After this license attempt, I have
just beat my head against a wall. How would I go about doing what I
want to do? What am I doing wrong? Thanks for responses.
Sheng Jiang[MVP]
2008-03-14 16:28:05 UTC
Permalink
use CWnd::CreateControl instead.
--
Sheng Jiang
Microsoft MVP in VC++
Post by Gold Panther
I have a main dialog. On that dialog there is a button that brings up
a new dialog that should have a web browser on it. The new dialog
fails, because the control has not been created yet as stated by the
"not an OLE control (not yet, at least)."
I happened upon a post or website talking about acquiring a license
for the control to create it dynamically. I figured since the dialog
is created dynamically that that means the web browser is probably
CLSID stuff = m_webBrowser.GetClsid();
if(SUCCEEDED( hr = CoGetClassObject( m_webBrowser.GetClsid(),
CLSCTX_ALL, NULL,
IID_IClassFactory2, (LPVOID *)&pClassFactory )) )
{
LICINFO license;
if( SUCCEEDED(pClassFactory->GetLicInfo( &license )) )
{
if( SUCCEEDED(pClassFactory->RequestLicKey( 0, &bstrLicense )) )
{
if( bstrLicense == NULL )
{
EndDialog( 1 );
}
else
{
m_webBrowser.Create( NULL, WS_VISIBLE, CRect(0, 0, 200, 200 ),
this, IDC_EXPLORER1,
NULL, NULL, bstrLicense );
SysFreeString( bstrLicense );
}
}
else
{
EndDialog( 1 );
}
}
else
{
EndDialog( 1 );
}
}
else
{
EndDialog( 1 );
}
The call to CoGetClassObject fails with a CLASS_E_CLASSNOTAVAILABLE.
The variable "stuff" recognizes the CLSID while debugging as the CLSID
for the Microsoft Web Browser. After this license attempt, I have
just beat my head against a wall. How would I go about doing what I
want to do? What am I doing wrong? Thanks for responses.
Gold Panther
2008-03-17 14:03:37 UTC
Permalink
On Mar 14, 11:28 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
use CWnd::CreateControl instead.
--
Sheng Jiang
Is obtaining the license still necessary? What I am asking is this:
are you telling me to replace m_webBrowser.Create with
m_webBrowser.CreateControl? If so, I do not even make it to there for
that to be a problem. I can not seem to obtain the license.
Sheng Jiang[MVP]
2008-03-17 15:53:33 UTC
Permalink
I mean instead the whole string
see CMySampleView::Create in http://support.microsoft.com/kb/236312
--
Sheng Jiang
Microsoft MVP in VC++
"Gold Panther" <***@yahoo.com> wrote in message news:aba660a7-6331-413e-8b4e-***@d62g2000hsf.googlegroups.com...
On Mar 14, 11:28 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
use CWnd::CreateControl instead.
--
Sheng Jiang
Is obtaining the license still necessary? What I am asking is this:
are you telling me to replace m_webBrowser.Create with
m_webBrowser.CreateControl? If so, I do not even make it to there for
that to be a problem. I can not seem to obtain the license.
Gold Panther
2008-03-17 20:07:21 UTC
Permalink
On Mar 17, 10:53 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
I mean instead the whole string
see  CMySampleView::Create inhttp://support.microsoft.com/kb/236312
--
Sheng Jiang
I looked at and tried to implement the idea in the kb. Once again, I
ran into problems dealing with the window not existing yet. I did
notice that the example was on a document/view architecture. My
application is dialog-based only. Could this be causing the problem?
Sheng Jiang[MVP]
2008-03-19 15:51:21 UTC
Permalink
For dialogs put your initialization code after CDialog::OnInitDialog.
--
Sheng Jiang
Microsoft MVP in VC++
"Gold Panther" <***@yahoo.com> wrote in message news:5dc75c69-16eb-4669-bd7d-***@d62g2000hsf.googlegroups.com...
On Mar 17, 10:53 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
I mean instead the whole string
see CMySampleView::Create inhttp://support.microsoft.com/kb/236312
--
Sheng Jiang
I looked at and tried to implement the idea in the kb. Once again, I
ran into problems dealing with the window not existing yet. I did
notice that the example was on a document/view architecture. My
application is dialog-based only. Could this be causing the problem?
Gold Panther
2008-03-20 16:35:13 UTC
Permalink
I tried creating the control within OnInitDialog. The debugger
complains that the web browser is already attached to the window.
What would cause the control to already be attached but not be an OLE
control yet? I'm not entirely sure of that answer. That is where the
problem began in the first place. When I tried to use the control,
the debugger complained that it was not a control yet. This was
happening during and after OnInitDialog. I came across forums talking
about the license issue, but I could not get that to work either. Why
can I not get the web browser to work on this child dialog? A
separate instance of one works on the main dialog already.

On Mar 19, 10:51 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
For dialogs put your initialization code after CDialog::OnInitDialog.
--
Sheng Jiang
Post by Sheng Jiang[MVP]
I mean instead the whole string
see CMySampleView::Create inhttp://support.microsoft.com/kb/236312
--
Sheng Jiang
Sheng Jiang[MVP]
2008-03-21 19:09:37 UTC
Permalink
Place a static control as the placeholder, destroy the window and create the
web browser in its place. If you want the web browser to fill the client
area of the dialog, take a look at the source code of CDHtmlDialog.
--
Sheng Jiang
Microsoft MVP in VC++
"Gold Panther" <***@yahoo.com> wrote in message news:bc4dc0b7-c112-4a3d-ac88-***@k13g2000hse.googlegroups.com...
I tried creating the control within OnInitDialog. The debugger
complains that the web browser is already attached to the window.
What would cause the control to already be attached but not be an OLE
control yet? I'm not entirely sure of that answer. That is where the
problem began in the first place. When I tried to use the control,
the debugger complained that it was not a control yet. This was
happening during and after OnInitDialog. I came across forums talking
about the license issue, but I could not get that to work either. Why
can I not get the web browser to work on this child dialog? A
separate instance of one works on the main dialog already.

On Mar 19, 10:51 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
For dialogs put your initialization code after CDialog::OnInitDialog.
--
Sheng Jiang
Post by Sheng Jiang[MVP]
I mean instead the whole string
see CMySampleView::Create inhttp://support.microsoft.com/kb/236312
--
Sheng Jiang
Gold Panther
2008-03-24 15:34:33 UTC
Permalink
The following is how I interpreted what you said to do:

RECT rect;
TCHAR tszName[MAX_PATH];
CLSID const wbClsid
= { 0x8856F961, 0x340A, 0x11D0, { 0xA9, 0x6B, 0x0, 0xC0, 0x4F,
0xD7, 0x5, 0xA2 } };

this->GetWindowTextW(tszName, MAX_PATH);
CWnd* plblPlaceHolder = this->GetDlgItem( IDC_STATIC_PLACEHOLDER );
plblPlaceHolder->GetWindowRect( &rect );
plblPlaceHolder->DestroyWindow();

if(!CreateControl( wbClsid, tszName, WS_VISIBLE | WS_CHILD, rect,
this, AFX_IDW_PANE_FIRST ))
{
return -1;
}

Is this a misrepresentation of your suggestion? This code dies in the
call to CreateControl in occcont.cpp on an assert of the call IsWindow
at line 926. My code excerpt is included in OnInitDialog.

On Mar 21, 2:09 pm, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
Place a static control as the placeholder, destroy the window and create the
web browser in its place. If you want the web browser to fill the client
area of the dialog, take a look at the source code of CDHtmlDialog.
--
Sheng Jiang
I tried creating the control within OnInitDialog.  The debugger
complains that the web browser is already attached to the window.
What would cause the control to already be attached but not be an OLE
control yet?  I'm not entirely sure of that answer.  That is where the
problem began in the first place.  When I tried to use the control,
the debugger complained that it was not a control yet.  This was
happening during and after OnInitDialog.  I came across forums talking
about the license issue, but I could not get that to work either.  Why
can I not get the web browser to work on this child dialog?  A
separate instance of one works on the main dialog already.
On Mar 19, 10:51 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
For dialogs put your initialization code after CDialog::OnInitDialog.
--
Sheng Jiang
Post by Sheng Jiang[MVP]
I mean instead the whole string
see CMySampleView::Create inhttp://support.microsoft.com/kb/236312
--
Sheng Jiang
- Show quoted text -
Sheng Jiang[MVP]
2008-03-26 15:42:55 UTC
Permalink
Is the webbrowser already created or attatched to a control via DDX? If
attatched, what kind of control is it?
--
Sheng Jiang
Microsoft MVP in VC++
"Gold Panther" <***@yahoo.com> wrote in message news:fccb0b0e-a1b2-4b34-91dd-***@m44g2000hsc.googlegroups.com...
The following is how I interpreted what you said to do:

RECT rect;
TCHAR tszName[MAX_PATH];
CLSID const wbClsid
= { 0x8856F961, 0x340A, 0x11D0, { 0xA9, 0x6B, 0x0, 0xC0, 0x4F,
0xD7, 0x5, 0xA2 } };

this->GetWindowTextW(tszName, MAX_PATH);
CWnd* plblPlaceHolder = this->GetDlgItem( IDC_STATIC_PLACEHOLDER );
plblPlaceHolder->GetWindowRect( &rect );
plblPlaceHolder->DestroyWindow();

if(!CreateControl( wbClsid, tszName, WS_VISIBLE | WS_CHILD, rect,
this, AFX_IDW_PANE_FIRST ))
{
return -1;
}

Is this a misrepresentation of your suggestion? This code dies in the
call to CreateControl in occcont.cpp on an assert of the call IsWindow
at line 926. My code excerpt is included in OnInitDialog.

On Mar 21, 2:09 pm, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
Place a static control as the placeholder, destroy the window and create the
web browser in its place. If you want the web browser to fill the client
area of the dialog, take a look at the source code of CDHtmlDialog.
--
Sheng Jiang
I tried creating the control within OnInitDialog. The debugger
complains that the web browser is already attached to the window.
What would cause the control to already be attached but not be an OLE
control yet? I'm not entirely sure of that answer. That is where the
problem began in the first place. When I tried to use the control,
the debugger complained that it was not a control yet. This was
happening during and after OnInitDialog. I came across forums talking
about the license issue, but I could not get that to work either. Why
can I not get the web browser to work on this child dialog? A
separate instance of one works on the main dialog already.
On Mar 19, 10:51 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
For dialogs put your initialization code after CDialog::OnInitDialog.
--
Sheng Jiang
Post by Sheng Jiang[MVP]
I mean instead the whole string
see CMySampleView::Create inhttp://support.microsoft.com/kb/236312
--
Sheng Jiang
in- Hide quoted text -
Post by Sheng Jiang[MVP]
- Show quoted text -
Gold Panther
2008-03-26 21:07:53 UTC
Permalink
Originally it is attached via DDX. It is of type CExplorer. When I
took some of your suggestions, I obviously had to comment out the DDX
macros.

On Mar 26, 10:42 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
Is the webbrowser already created or attatched to a control via DDX? If
attatched, what kind of control is it?
--
Sheng Jiang
Sheng Jiang[MVP]
2008-03-26 23:22:09 UTC
Permalink
The CExplorer DDX is no longer nevessary.
--
Sheng Jiang
Microsoft MVP in VC++
"Gold Panther" <***@yahoo.com> wrote in message news:6143891e-9715-4b4d-bb8b-***@n77g2000hse.googlegroups.com...
Originally it is attached via DDX. It is of type CExplorer. When I
took some of your suggestions, I obviously had to comment out the DDX
macros.

On Mar 26, 10:42 am, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
Is the webbrowser already created or attatched to a control via DDX? If
attatched, what kind of control is it?
--
Sheng Jiang
Gold Panther
2008-03-27 12:53:34 UTC
Permalink
When is it no longer necessary? Are you talking about in general or
after implementing your suggestions? If the latter, please notice
that in the third sentence of my last response I addressed that I
commented out the DDX macros when implementing your ideas. So, are
you speaking in general?

On Mar 26, 6:22 pm, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
The CExplorer DDX is no longer nevessary.
--
Sheng Jiang
Sheng Jiang[MVP]
2008-03-28 15:43:39 UTC
Permalink
No, in this case, you need to ensure the control is not attatched to a
dialog control via DDX before creating manually.
--
Sheng Jiang
Microsoft MVP in VC++
"Gold Panther" <***@yahoo.com> wrote in message news:450219f5-5d07-492d-92d8-***@q78g2000hsh.googlegroups.com...
When is it no longer necessary? Are you talking about in general or
after implementing your suggestions? If the latter, please notice
that in the third sentence of my last response I addressed that I
commented out the DDX macros when implementing your ideas. So, are
you speaking in general?

On Mar 26, 6:22 pm, "Sheng Jiang[MVP]"
Post by Sheng Jiang[MVP]
The CExplorer DDX is no longer nevessary.
--
Sheng Jiang
Loading...