695 698




Visual Basic 6 Black Book:Visual Basic And The Internet: Web Browsing, Email, HTTP, FTP, And DHTML
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive To access the contents, click the chapter and section titles. Visual Basic 6 Black Book (Publisher: The Coriolis Group) Author(s): Steven Holzner ISBN: 1576102831 Publication Date: 08/01/98 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  














Previous
Table of Contents
Next




Chapter 21Visual Basic And The Internet: Web Browsing, Email, HTTP, FTP, And DHTML


If you need an immediate solution to:
Creating A Web Browser
Specifying URLs In A Web Browser
Adding Back And Forward Buttons To A Web Browser
Adding Refresh, Home, And Stop Buttons To A Web Browser
Creating DHTML Pages
Adding Text To DHTML Pages
Adding Images To DHTML Pages
Adding HTML Controls To DHTML Pages
Adding ActiveX Controls To DHTML Pages
Adding Tables To DHTML Pages
Adding Hyperlinks To DHTML Pages
Using MAPI Controls To Support Email
Sending Email From Visual Basic
Reading Email In Visual Basic
Using The Internet Transfer Control For FTP And HTTP Operations
Handling FTP Operations In Visual Basic
Handling HTTP Operations In Visual Basic

In Depth
In this chapter, we’ll see how to create a Web browser, create a dynamic HTML page (DHTML), and work with email and the HTTP and FTP protocols. Not surprisingly, these are all hot topics in Visual Basic.

Creating A Web Browser
If you have the Microsoft Internet Explorer installed, you can build Web browsers using Visual Basic. Microsoft has packaged the Internet Explorer in a control, the WebBrowser control, and we’ll be able to use that control to create a Web browser in this chapter that supports such browser functionality as Back, Forward, Home, Stop, and Refresh buttons. We’ll also let the user specify what URL to navigate to with a combo box—as well as keeping track of recently visited URLs in that combo box.

Building a Web browser can be a worthwhile project in itself, but another popular use of the WebBrowser control is to add a Web browser to your existing program for added power. In fact, you can use the WebBrowser control to open ActiveX documents (as we did in Chapter 20) in a way that makes them look like a seamless part of the program—even though that document may have come from the Internet.
Creating A Dynamic HTML Page
Dynamic HTML is the new, although amorphous, Web page standard (that is, Netscape and Microsoft think of dynamic HTML as entirely different things). The Microsoft standard for DHTML makes all the tags in a Web page active elements in the sense that they have properties you can change at runtime, as well as events like Click. The DirectAnimation and DirectShow Internet Explorer packages are part of Microsoft DHTML as well.
Visual Basic can write dynamic HTML—in fact, you can now use Visual Basic as an HTML editor, adding text, images, hyperlinks, and tables. We’ll see how to do that in this chapter. There’s more here too. You can add ActiveX controls directly to your Web pages when designing them in the DHTML Designer. We’ll see how to create Web pages using that designer and how to test them out in the Internet Explorer immediately, from Visual Basic.
Working With Email
Visual Basic includes support for working with email as well. That support is based on the Microsoft Exchange utility that’s installed with Windows (and usually appears on the Windows desktop as the Inbox icon). In this chapter, we’ll see how to connect Visual Basic to the Microsoft Exchange to handle email. To do that, we’ll use the ActiveX MAPI controls (Messaging Applications Programming Interface) that come with Visual Basic.

To connect to the email system, you create a new MAPI session using the MAPISession control. When the session is created, you use the MAPIMessages control to work with individual messages. Note that these controls are interfaces to the Microsoft Exchange package, which means that we’ll be using that package to send and receive email.
Using FTP
FTP (File Transfer Protocol) is a very popular Internet protocol for, as its name implies, transferring files. Visual Basic has good support for FTP work, and that support is contained in the Visual Basic Internet transfer control. That control has two approaches to working with FTP. You can use the OpenURL method to easily download a file from an FTP site. In addition, you can execute standard FTP commands with the control’s Execute method. Using Execute, you can make use of the standard FTP commands like CD, GET, CLOSE, QUIT, SEND, and so on.
Using HTTP
HTTP (Hypertext Transfer Protocol) is the protocol on which the World Wide Web is based. As most programmers know, this is the protocol used for Web pages on the Internet. Because we’re going to build a functioning Web browser in this chapter, you may wonder why we want to work with the HTTP protocol directly. The answer is that although Web browsers do indeed download and display Web pages, there’s a lot more you can do with the HTTP protocol. When you download a file using the Internet transfer control’s OpenURL method, you get access to the file’s HTML directly, which is important if you want to interpret that HTML in a way different from how the Internet Explorer would. You can also use that control’s Execute method to execute HTTP commands directly.
You can even write your own Web browser or use emerging Web languages like XML (Extended Markup Language). XML, intended to be a successor to HTML, allows you to create your own markup tags in a well-defined way, on a document-by-document basis. When reading those tags, it’s up to the browser to interpret them, and you can write such XML browser programs in Visual Basic.

TIP:  Microsoft has made an XML parser available on its Web site in two versions: a Java version and a Visual C++ version. (Its URL keeps changing, though, so search the site for “XML parser”.) This parser breaks XML documents down tag by tag in a way that makes reading XML documents more systematic. You can connect the Visual C++ version to Visual Basic if you place your Visual C++ code in a dynamic link library that Visual Basic can link in, but the Visual C++ parser is so complex to use that it may not be worth the bother. One aspect of the Microsoft parser is, however, very useful: it can tell you if an XML document meets the XML specification for being valid and well formed.

Besides using the Internet transfer control’s OpenURL method, you can also use the Execute method to execute such common HTTP commands as GET, POST, and PUT.
That’s it for the overview of Visual Basic and the Internet for the moment—it’s time to turn to our Immediate Solutions.



Previous
Table of Contents
Next






Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.



Wyszukiwarka

Podobne podstrony:
698,17,artykul
69825
www mediweb pl?ta print php id=695
69814
SC75216AGF 695
69813
695 697
www mediweb pl?ta print php id=698
69815
695 696
README (695)

więcej podobnych podstron