May 08, 2024, 06:00:17 AM

News:

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


using browse.navigate in a different class

Started by Jeffers, June 10, 2006, 07:04:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jeffers

Hi all. Another Newbie question for you. I am experimenting with saperos splitter classes to build two child windows, each has a control, one a listview and another a browser. I need to use browse.navigate() in..

CLeftWin::OnNotify(int code,int nID,NMHDR *pnmhdr),int
{
CListView *pList = GetControl(LISTVIEW_1);
if(pList)
{
if(code = 0xFFFFFFFE)
{
//MessageBox(this,pList->GetItemText(*(NMLISTVIEW)pnmhdr.iItem,1),pList->GetItemText(*(NMLISTVIEW)pnmhdr.iItem,0));
link = pList->GetItemText(*(NMLISTVIEW)pnmhdr.iItem,2);
browse.Navigate(link);
}
}
}


and have the browser control navigate from a link where the control is created in

CRightWin::OnCreate(),int
{
browse.Create(1,1,890,545,AWS_VISIBLE|AWS_CHILD,0,"",this);
browse.Navigate("http://www.google.com");
}


Now I know the browser control works as browse.navigate command works in the class it was created, there are also no errors on compilation. How do I make the browse command point to the right control?

Full source attached.

Regards Jeff :)

Ionic Wind Support Team

When you derive a class from a base class you are creating a distinct new class.  Both of your windows are derived from the same base class but that doesn't mean they 'share' the same variable at the same time.

In other words each of your window has it's own separate 'browse' variable.  When you can browse.navigate in the left window you are not affecting the 'browse' variable in your right window and vice versa.

How can I state that clearer?...every class you derive from CSplitterContainer will have it's own distinct browser control.   What you want to do is move that variable to the real containing window (CRightWin)  And give a pointer to the browser to the left window.
Ionic Wind Support Team

Jeffers

Thanks paul. I understand how to place the variable, which I have done. How do you point the browser control to CLeftWin class? I know you can return a variable or pointer to the base class, but from there I am not sure how to complete it.

Still learning! Regards Jeff :)

Ionic Wind Support Team

Yes but did you understand what I said?  You have two 'browser' variables being created, not just one

Probably the simplest way to resolve it, whithout me rewriting the whole thing,  is to move the browser variable out of the base class and put it into the CRightWin class.  Then have a global pointer at the top of your source file.

CWebBrowser *gpBrowser;

Which gets set in CRightWin::Create

CRightWin::Create()
{
browse.Create(...
browse.Navigate(..
gpBrowser = &browser;
}

That way you can access the browser control from the left window.

gpBrowser->Navigate(...

Ionic Wind Support Team

Jeffers

Again thanks Paul. Works fine. My understanding increases every day.

Regards Jeff :D