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.
Should work, got the code that is giving you problems?
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;
}
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.
Duh...
Thanks, Paul.