IonicWind Software

Aurora Compiler => GUI => Topic started by: Bruce Peaslee on April 22, 2007, 05:23:25 PM

Title: Browser Window in a Dialog?
Post by: Bruce Peaslee on April 22, 2007, 05:23:25 PM
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.
Title: Re: Browser Window in a Dialog?
Post by: Ionic Wind Support Team on April 22, 2007, 07:48:50 PM
Should work, got the code that is giving you problems?
Title: Re: Browser Window in a Dialog?
Post by: Bruce Peaslee on April 23, 2007, 09:53:19 AM
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;
}
Title: Re: Browser Window in a Dialog?
Post by: Ionic Wind Support Team on April 23, 2007, 03:47:53 PM
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.
Title: Re: Browser Window in a Dialog?
Post by: Bruce Peaslee on April 23, 2007, 04:07:45 PM
Duh...

Thanks, Paul.