September 26, 2022, 07:03:24 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Browser Window in a Dialog?

Started by Bruce Peaslee, April 22, 2007, 05:23:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

I want to add text to a window on the fly, sort of like a log. I've been struggling with a RichEdit, but think it would be easier with a browser window. Is it possible to put one in a dialog? I can't get it to work.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

Should work, got the code that is giving you problems?
Ionic Wind Support Team

Bruce Peaslee

This is how I am I am trying it:

// Browser Control Test
#include "webbrowser.inc"

const D1_CLOSE = 1;

class dlg:CDialog
{
declare OnInitDialog(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
}

global sub main()
{
dlg d1;
d1.Create(0,0,300,202,0x80C80080,0,"Test",0);
d1.AddControl(CTDEFBUTTON,"Close",115,156,70,20,0x50000001,0x0,D1_CLOSE);
d1.DoModal();
return 0;
}



dlg::OnInitDialog(),int
{
CWebBrowser browser;
browser.Create(10,10,200,100,AWS_VISIBLE|AWS_BORDER,0,"",this);
CenterWindow();
return true;
}

dlg::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nID
{
case D1_CLOSE:
if(nNotifyCode = 0)
{
CloseDialog(IDOK);
}
}
return true;
}
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

You need either a class variable or dynamic one for the CWebBrowser object.  Think about this for a moment...

dlg::OnInitDialog(),int
{
   CWebBrowser browser;
   browser.Create(10,10,200,100,AWS_VISIBLE|AWS_BORDER,0,"",this);
   CenterWindow();
   return true;
}

OnInitDialog is a method subroutine that gets called when the dialog is created.  You are defining the CWebBrowser variable on the stack as a local variable.  That variable doesn't exist when the subroutine ends and will immediately close your browser window since the class destructor gets called when the variable goes out of scope.

Move that variable here:

class dlg:CDialog
{
   declare OnInitDialog(),int;
   declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
//member variables
        CWebBrowser browser;
}



Later,
Paul.
Ionic Wind Support Team

Bruce Peaslee

Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles