Hi all another one tonight.
I have been trying to integrate a browser control on a window. With Pauls help that works ok, but I have been trying to get it to size with the window with a couple of problems.
The browser control with AWS_SIZE style sizes independently of the window. If I take the style away and try to use the browser class and OnSize(), the browser control will not size at all.
Is there any way to suppress the messages that the browser control processes so that the window class can manage them i.e for OnSize()
Regards Jeff :)
p.s I will get some code together to demonstrate if required.
Hi again some code to emphasize the AWS_SIZE point earlier.
Browser control created with AWS_SIZE will size indepently of the window, take the style away and it will not. Hover the mouse over the bottom right of the control.
Quotebrowse.Create(1,556,884,190,AWS_VISIBLE|AWS_CHILD|AWS_SIZE,0,"",win);
Regards Jeff :)
#include "webbrowser.inc"
class Cwin : CWindow
{
//virtual overrides used by our window
declare OnCreate(),int;
declare OnClose(),int;
declare OnSize(int nType,int cx,int cy),int;
int l,t,w,h,size,run;
}
Cwin::OnCreate(),int
{
CenterWindow();
size = 1;
run = 1;
return true;
}
Cwin::OnClose(),int
{
run = 0;
return true;
}
Cwin::OnSize(int nType,int cx,int cy),int
{
rect rc = GetClientRect();
l = rc.Left;
t = rc.Top;
w = rc.Right - rc.Left;
h = rc.Bottom - rc.Top;
return true;
}
global sub main()
{
Cwin win;
CWebBrowser browse;
win.Create(0,0,895,820,AWS_CAPTION|AWS_VISIBLE|AWS_BORDER|AWS_SYSMENU|AWS_AUTODRAW|AWS_SIZE,0,"RSS Demo",NULL);
browse.Create(1,556,884,190,AWS_VISIBLE|AWS_CHILD|AWS_SIZE,0,"",win);
browse.Navigate("http://www.ionicwind.com");
do
{
wait();
}until win.run = 0;
return;
//'win' is automatically closed here since the class destructor calls Destroy();
}
Move your CWebBrowser variable to the class as a member variable.
In CWin::OnSize you can then adjust the size of the browser to the client.
Browse.SetSize(rcClient.left,rcClient.top,rcClient.right,rcClient.bottom);
See the browser_test.src example program included with the installation.
QuoteMove your CWebBrowser variable to the class as a member variable.
Paul, can you expand on that, I dont quite understand? :-[
Regards Jeff
Nope! Still dont understand. I have been using browser_Test.src to learn about the browser control. Problem is I need a parent window with different embeded controls i.e. Listview + browser. browser_test is using the web browser as the main class.
Regards Jeff :'(
class Cwin : CWindow
{
//virtual overrides used by our window
declare OnCreate(),int;
declare OnClose(),int;
declare OnSize(int nType,int cx,int cy),int;
int l,t,w,h,size,run;
//ADD THIS AND REMOVE FROM main()
CWebBrowser browse;
}
//CHANGE THIS
Cwin::OnSize(int nType,int cx,int cy),int
{
rect rc = GetClientRect();
l = rc.Left;
t = rc.Top;
w = rc.Right - rc.Left;
h = rc.Bottom - rc.Top;
browse.SetSize(rc.left,rc.top,rc.right,rc.bottom)
return true;
}
I see that, do you also mean that you need a different place to create the browser?
Quotebrowse.Create(1,556,884,190,AWS_VISIBLE|AWS_CHILD,0,"",win);
This will fail in main() without the CWebBrowser variable. I tried OnCreate() but I think I'm going round in circles.
Jeff
win.browse.Create(....)
Browes is a member variable of win.
Thank you Paul. Now I certainly didnt know you could do that!! ;D
Regards Jeff
Think of it as a structure (UDT). Member variables in a class are essentially the same as the members of a UDT.
Thanks Paul. Is this a form of inheritance?
Dont worry about me I always ask stupid questions.
Regards Jeff :D
No, it's just a variable of a class. If you derived a class from CWin then you would inherit that variable in your new class.
Paul I have certainly a lot to learn.
Thanks again
Jeff :)