#### Archived

This topic is now archived and is closed to further replies.

# Browser

This topic is 6621 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
You can make one thread to put your loop in and another thread to process windows stuff.

##### Share on other sites
How to do that in MFC???? Win32 okay, but MFC.....uuuuuuh.....I dunno.

Dance with me......

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

##### Share on other sites
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

##### Share on other sites
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;
}

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

##### Share on other sites
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

##### Share on other sites
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.

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.

##### Share on other sites
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

##### Share on other sites
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.

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)

##### Share on other sites
Hmmm...funny titles. Should it not be queen for felisandria? Hehehehe =) Happy New Year everybody =)

Best regards,
Sherman

##### Share on other sites
Yep, just like ZemeonE said, you want to use multiple threads. This is really easy to do. You would also want a new thread for each image, so that they can download at the same time.

##### Share on other sites
Okay, thanx to your input I implemented multithreading. I got some weird error messages, but solved that with static.....

Now...i stumbled across some weird problem.......and that is that the program terminates when it reaches the following line of code:

file is a CInternetFile

My code looks like:

CInternetSession session;CString Code = "Quering\r\n";CInternetFile  *file = NULL;try{	file = (CInternetFile*)session.OpenURL((char*)URL);}catch(CInternetException* pEx){	file = NULL;	pEx->Delete;}if(file){	Code += "Connection established.\r\n";	CString line;	file->SetReadBufferSize(4096);			while(TRUE)	{		if(file->ReadString(line) == FALSE) break;		Code += line + "\r\n";	}	file->Close();	delete file;}else{	Code += "No server has been found \r\n";}[/CODE]This code worked fine without multithreading, so I am wondering why it causes a termination of the program. I am quite confused about it.It says it exits with code(3)......Debugging doesn''t seem to help (me)...

Dance with me......

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

##### Share on other sites
Oh, also when I try to access the normal variabeles in my program.....like m_Code (which is a textbox)....it gives me an error like: (out of the head)

CMyProgram::m_Code Object has to point to class, struct, onion...

or something similar to that.......

Dance with me......

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

##### Share on other sites
Have you associated the correct variable type with your text box? Maybe it should be a control or something similar? Sorry I cannot help further as I am not too experienced at trouble-shooting MFC programs. I am into Win32 these days. =)

Best regards,
Sherman

##### Share on other sites
Looks like it is adios to the medieval world of Imperial Guards, Knights and Kings - back to plain old Dedicated, Zealot, etc.
Hehehehe =) What next? Private, Lieutenant, Captain, Admiral and so on? =) Very interesting indeed =) I am serious....this is fun =)

Best regards,
Sherman

##### Share on other sites
You can find more information on the browser stuff in MFC at [url]http://www.codeguru.com[/url]

##### Share on other sites
There is something obviously wrong with the message board. The URL hyperlinks do not work and the table length is too long in Netscape requiring us to scroll left and right. I certainly hope it can be rectified soon. Thanks.

Best regards,
Sherman