Browser

Started by
15 comments, last by CJ 24 years, 3 months ago
Who can give me information how an internet-browser is made? (I use MFC for this)

Especially the following parts:
1) loading the site.....I have a loop now, but it takes some time before the loop is finished, and in the meanwhile, nothing can be done. How to make it a way so it can always get the HTML code, and do the normal windows-things at the same time? (I know how to grab HTML code).
2) The graphics, how did they ever get all the graphics this smooth????? good colors, images shown where they want them. Did they do that with SDI????? HOW???????

Any additional information necessary to make a browser would be appreciated

------------------
Dance with me......

http://members.xoom.com/CJdeVos/index.htm

Advertisement
You can make one thread to put your loop in and another thread to process windows stuff.
How to do that in MFC???? Win32 okay, but MFC.....uuuuuuh.....I dunno.

Dance with me......

http://members.xoom.com/CJdeVos/index.htm

You might want to take a look at CHtmlView, which is the MFC way of doing web displays and has several relatively spiffy features to save you some work.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
To elaborate a little on felisandria''s recommendation of using the CHtmlView Class: First, create a SDI application using the AppWizard. Accept the default settings presented by the AppWizard but choose the Internet Explorer Rebars and specify that the CHtmlView as the base class for your view class. Wow! If you just followed those easy steps, you will find that you have a working web browser once you compile and run your application just by working with the AppWizard.

To add navigation functionality, just add a new member function to the CMainFrame class - return type: void, access: public and name: OnEnterURL. Edit the function:

void CMainFrame::OnEnterURL()
{
CString sURL;
m_wndDlgBar.GetDlgItem(IDC_URL)->GetWindowText(sAddress);
((CWebBrowseView*)GetActiveView())->Navigate(sAddress);
}

Then, using your graphical editor, add a edit box and specify its ID as IDC_URL.

Next, add the message map entry between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP. Add this line after }}AFX_MSG_MAP: ON_COMMAND(IDOK, OnEnterURL).

That should be it. When you enter your URL into the edit box, you will be able to navigate to the site of your choice. I may have missed explaining about a few variables there but you get the idea =)

Best regards,
Sherman
hitw@crosswinds.net
http://hitw.spedia.net
(website down temporarily)

Edited by - sherman on 1/1/00 12:43:31 PM
_________________ Best regards, Sherman Chin Director Sherman3D (Malaysia) Sdn Bhd www.Sherman3D.com www.AlphaKimori.com
Hmmmm...thank you!!

Anyway...I''d rather make something like that myself, instead of using CHTMLView. I already have some enhanced features implemented. very different than a normal browser would do.
I didn''t really ask for some more explanation about how to use CHTMLView because that is quite obvious, thanks anyway...

Dance with me......

http://members.xoom.com/CJdeVos/index.htm

Well, the Netscape browser currently has opened it''s source files, so you can take a peek inside that.

Other than that, from what I understand this is how the thread structure of the current generation of browsers works:

There are two basic threads call one worker and the other one user interface. When you request a web page, worker spawns a new thread. Call this thread html thread.

html thread then opens a connection to the server and starts downloading the page into a buffer that it shares with worker thread. As html thread downloads it, worker thread parses the document. When worker thread determines something needs to be inlined such as an image, it spawns a new thread that downloads the new object. When worker thread determines that enough of the document has been downloaded to be displayed, it passes a handle to the data to the user-interface thread.

The user-interface thread then renders the html document as best it can with whatever data it has at the time. The key to the current series of browsers is that they attempt to render without receiving complete information. Older browsers (such as the original mosiac) wouldn''t render without having downloaded the whole document, image and all.
I never worked with multiple threads.....but I have an understanding of what is done in a browser now.

Can anybody show me a short bit of source of how to make an extra thread and use it someway???? I would appreciate that very much....

it''s sometjhing with the MESSAGE_MAPS thing, and I know you can only have a maximum of 64 threads, but.....uhm.....how.

Thank you

Dance with me......

http://members.xoom.com/CJdeVos/index.htm

I am not sure whether I am on the mark but here goes:

1. Add a new member variable to your document class. Specify the variable type as CWinThread* and name it something like m_pMyThreads[5] - assuming you want to create 5 threads.

2. When you want to activate your thread in your code, just type: m_pMyThreads[nCount] = AfxBeginThread(ThreadFunc, (LPVOID)&m_MyParameter);
where nCount is your looping variable (values 0 to 4) and m_MyParameter is the parameter you wish to pass to your Thread function.

3. Finally create your thread function. To do this, add a new member function to your document class. You can declare it something like ThreadFunc(LPVOID pParam) where pParam is the argument of which to receive your m_MyParameter that was mentioned earlier. Important: Check the static check box for the ThreadFunc otherwise the compiler will report an error at the AfxBeginThread().

I know it is really basic but I really hope that helps.

Best regards,
Sherman
hitw@crosswinds.net
http://hitw.spedia.net
(website temporarily down)
_________________ Best regards, Sherman Chin Director Sherman3D (Malaysia) Sdn Bhd www.Sherman3D.com www.AlphaKimori.com
Hmmm...funny titles. Should it not be queen for felisandria? Hehehehe =) Happy New Year everybody =)

Best regards,
Sherman
_________________ Best regards, Sherman Chin Director Sherman3D (Malaysia) Sdn Bhd www.Sherman3D.com www.AlphaKimori.com

This topic is closed to new replies.

Advertisement