Free project Details and Project Source Code Form All Computer Students...... Collection of Information about Programming Languages

Thursday, June 26, 2008

Introducing Visual Studio 97






Introducing Visual Studio 97: A Well-stocked Toolbox for Building Distributed Apps


Your Ad Here

Visual Studio 97 to the Rescue

Microsoft® Visual Studio™ 97 goes a long way toward providing you with a well-stocked toolbox to help you complete your development projects. Visual Studio targets developers and teams that create dynamic Web-based applications or other distributed applications. Visual Studio takes all of Microsoft's development tools, adds a rich set of new tools for creating Web content, and ties it all together with comprehensive documentation. Even if you're not creating distributed applications but you use two or more Microsoft developer products, you'll probably find Visual Studio suits you. (If you use only one tool, don't stop reading—each of the tools in Visual Studio is also available separately. And you might find another tool that would make your life easier.)

In this article, I'll give you a quick overview of what Visual Studio is all about. It's a big product, so don't expect every detail of every tool to be covered here. I'm going to focus on the new tools released for the first time in Visual Studio and the new features of tools you've probably seen before. Watch Microsoft Systems Journal and Microsoft Interactive Developer (MIND) for more in-depth articles about individual tools.

Why Visual Studio?

Visual Studio specifically targets developers of distributed, client-server Web applications (see the sidebar, Building Distributed Applications with Components). It provides all the tools you need to create and maintain each tier of the multitier application architecture. Many of the improvements to existing Microsoft developer products are aimed directly at simplifying the creation or use of ActiveX components. A full complement of tools is provided to create HTML-based presentation layers in addition to the more traditional Windows®-based application programming tools. A comprehensive set of data management tools helps with the routine creation and maintenance of the underlying databases.

A second target of Visual Studio is the corporate client-server application. The same basic architecture applies to both types of applications. Corporate applications tend to focus a little more on the database side of things, though, and the Visual Studio Enterprise Edition contains even more tools for creating large-scale database and transaction-processing applications.

What's in the Box?

Visual Studio 97 comes in two editions, Professional Edition and Enterprise Edition. Figure 1 lists the contents of each edition. As you can see, the Enterprise Edition focuses more on database development than the Professional Edition. The first thing you'll notice is that Visual Studio is big, very big. The beta-2 Enterprise Edition I worked with came on five jam-packed CDs.

Figure 1 Visual Studio 97 Contents


Product

Hard Drive Space

Included in

Min

Max

Professional Edition

Enterprise Edition

Visual Basic 5.0 Professional Edition

30MB

220MB

x

Visual Basic 5.0 Enterprise Edition

35MB

345MB

x

Visual C++ 5.0 Professional Edition

50MB*

274MB

x

Visual C++ 5.0 Enterprise Edition

50MB*

293MB

x

Visual J++ 1.1 Professional Edition

35MB

55MB

x

x

Visual InterDev 1.0

37MB

52MB

x

x

Visual FoxPro 5.0

15MB

190MB

x

x

MSDN Library

10MB

1GB

x

x

SQL Server 6.5 Developer Edition

80MB

95MB

x

Transaction Server 1.0 Developer Edition

11MB

23MB

x

Visual SourceSafe 5.0

8MB

16MB

x

* Typical install

The best decision anyone made for Visual Studio was to put all the documentation on a single CD. The Microsoft Developer Network (MSDN) Library CD provides one-stop shopping for technical information about the Visual Studio tools. In addition to the product documentation, the CD contains a snapshot of the Microsoft KnowledgeBase, a collection of thousands of articles created by Microsoft technical support specialists.

Augmenting the MSDN Library CD will be Visual Studio Online, a Web site devoted to the Visual Studio toolset. Product and documentation updates, new samples, and helpful technical articles will appear here first. Visual Studio tools even have Help menu items that take you directly to their respective home pages.

Installation

Be prepared to set aside a significant amount of time—and disk space—to install Visual Studio. Figure 1 shows you the minimum and maximum hard disk space requirements for each component of Visual Studio. You don't have to install all the components on the same drive, but most apps will need to install files into the Windows system directory. You can reduce the amount of disk space needed by accessing the documentation and sample code from the CD.

The beta-2 version I worked with took a long time to install because the main Visual Studio install program simply triggers each tool's individual install program. In a couple of cases, the installation program requires a reboot to finish installing some files, which means that after you reboot, you need to start up the Visual Studio install program again and work your way through to the screen that lists the individual components you can install (see Figure 2). However, each individual installation program did what it was supposed to.

Once everything is installed, you'll see that your Start menu has a lot of new items. Each individual application makes its own start menu entry, and some common tools appear on multiple menus. (Unfortunately, these tools are also installed in multiple places on your hard drive.) Some applications create their Start menu entries in the user-specific menu and others create their entries in the menu common to all users. I would like to see better coordination between the different application setup programs when creating Start menu entries and installing common tools. I expect this to be much improved in the retail release.

I must admit that after installing the Visual Studio beta 2, I was feeling a little negative toward the product. Installing it took too long and used too much hard drive space. But once I actually starting working with the tools, my whole attitude changed. Believe me, the tools are worth the wait.

Let's take a look at each of the tools that comes with Visual Studio. First, I'll look at the language tools. They primarily provide a development environment for a programming language—Visual Basic, Visual FoxPro™, Visual C++®, and Visual J++™. After I look at the languages, I'll go over the Web content authoring tools that make up Visual InterDev™. Finally, I'll take a brief look at the enterprise tools—Visual SourceSafe™, Microsoft SQL Server™, and Microsoft Transaction Server.

Visual Basic 5.0

Visual Basic is Microsoft's RAD tool for Windows programmers. Visual Basic uses a graphical, forms-based approach to application development. The typical way to write a program in Visual Basic is to create a form, drag and drop components onto the form, set properties for the form and its components, and add application-specific code to handle events. It sounds simple, but you can write some very powerful applications this way.

The great thing about Visual Basic is that it hides most of the gory details of Windows-based programming and lets you focus on your application-specific functionality. Pretty much every service you use in a Visual Basic program is provided by an ActiveX component. Once you've learned how to use one component in Visual Basic, using any other component is simply a matter of learning how its object model—its properties, methods, and events—works.

If you've used Visual Basic before, one of the first things you'll notice is that Visual Basic 5.0 has a new integrated development environment (IDE). Figure 3 shows the IDE just after a new control project has been created. Unfortunately, this IDE is not the same one that other tools in Visual Studio use. The IDEs are becoming more similar, but there are still differences in their capabilities that may catch you by surprise if you move back and forth between them.

The Visual Basic 5.0 IDE now has a traditional Windows MDI look. If you don't like this, you can switch back to SDI mode from the ToolsOptions command. Windows and toolbars can float or be docked to each other or to the edge of the screen. The IDE is very flexible so that you can organize things for maximum productivity. The IDE even lets you open multiple projects simultaneously—critical for debugging projects with user-created controls. If the features provided by the IDE aren't sufficient, you can create add-ins to extend it.

The IDE code editor has some new features that you'll soon wish were in every product you use, including List Properties/Methods, which presents a dropdown list of properties available for that control, and Auto Quick Info, which displays the syntax for statements and functions. Complete Word fills in the rest of the word you are typing once you have entered enough characters for Visual Basic to identify the word you want. Parameter Info (see Figure 4) shows a popup in the Code window that contains information about the parameters of the initial function or statement. Quick Info provides the syntax for a variable, function, statement, method, or procedure selected in the Code window.

In addition to the IDE changes, Visual Basic now provides a native code compiler. Earlier versions of Visual Basic compiled applications into p-code, which required a runtime interpreter that reduced application performance. The native code compiler lets you compile your apps down to Intel-native instructions. You can even optimize for specific processors, including the Pentium and Pentium Pro. Whether you compile your app to native code or p-code, you still need to ship the Visual Basic runtime files, but native code applications will run much faster. (Even though compiling to native code generates machine code, the machine code still needs to make some calls to helper routines that live within the Visual Basic runtime.)

Visual Basic 5.0 Enterprise Edition provides enhanced client/server database development features. Remote Data Objects (RDO) has been improved to include local cursor support, optimized batch updates, and direct access to ODBC data sources without going through the Jet engine. You can now create standalone connection and query objects. A Connection Designer is provided to help create these objects at design time and a Data Form Wizard automatically generates forms used to manage database information. Integrated T-SQL debugging lets you verify stored procedures executing on a Microsoft SQL Server database.

With version 5.0, Visual Basic also expands its capabilities to encompass ActiveX component creation. Visual Basic 4.0 was able to create Automation servers, which are a type of component, but did not support more powerful component features. Visual Basic 5.0 lets you create components that raise events, support data binding, support licensing, have property pages, and are Internet-aware. Visual Basic can create several types of components, including Automation components (that Visual Basic calls ActiveX Code components), ActiveX controls, and ActiveX Documents.

All ActiveX components in Visual Basic are defined by creating class modules. Creating an Automation component isn't much more complicated than defining your object's data and implementing a few procedures. Visual Basic takes care of all the goo to turn a class module into an Automation dual interface. Using the new Implements feature, classes can even support any Automation-compliant interface already defined in a type library. You define events in your class module using the Event keyword, and raise events using the RaiseEvent keyword. Clients use the new WithEvents keyword to indicate that they want to handle events from a particular object, then implement event handlers just as they would for any other event.

Using the Enterprise Edition, you can mark your components for unattended execution, which means they have no user interface. When you do this, the components can be used in multithreaded environments. In-process components (DLLs) marked for unattended execution support the COM apartment threading model. Out-of-process components (EXEs) marked for unattended execution will allocate object instances across multiple threads for better scalability as instances are created.

The Enterprise Edition also provides full support for deploying components remotely. Remote Automation (RA) was originally developed for Visual Basic 4.0 Enterprise Edition and extends OLE Automation so that it works across machine boundaries. It is compatible with and can be replaced by Distributed COM (DCOM). However, there are some situations when RA is more appropriate than DCOM. In particular, you need to use RA if you want to support 16-bit clients, since there is no DCOM support for 16-bit Windows. Fortunately, you don't need to write your applications any differently to use RA or DCOM. In fact, Microsoft supplies configuration utilities that you can use to switch between RA and DCOM: the Remote Automation Manager (AUTMGR32), and the Remote Automation Connection Manager (RACMGR32).

Visual Basic 5.0 makes ActiveX control creation incredibly easy. You can either combine existing controls into a new component or create a component from scratch. Either way, you use a special kind of object, called a UserControl, as the basis for your ActiveX control. Once you've added any constituent controls to the UserControl, you use the ActiveX Control Interface Wizard to specify which properties, methods, and events your composite control will expose to clients. You can create property pages for your control using the PropertyPage Wizard.

The major limitation to the Visual Basic 5.0 control creation features is that the controls you create are single-threaded. In addition, I didn't see any support for windowless controls. But if you can live with these restrictions, Visual Basic now provides a great way to create powerful, lightweight controls. If you'd like to know more, take a look at Guy and Henry Eddon's articles in the February and March 1997 issues of MSJ.

Using another special object called a UserDocument, you can create ActiveX Documents as easily as you design a form. When you create an ActiveX Document in Visual Basic, you add controls to a UserDocument instead of adding them to a Form. In fact, Visual Basic provides a wizard for converting ordinary apps into ActiveX Documents: the ActiveX Document Migration Wizard. This wizard converts the project type to ActiveX Document DLL or EXE and adds a UserDocument to the project. It then copies a form's properties, controls, and the code behind the controls to the UserDocument object, and migrates form event handlers to the UserDocument equivalents.

ActiveX Documents created with Visual Basic are a little different than other ActiveX Documents you may have encountered. Visual Basic ActiveX Documents are roughly equivalent to Visual Basic forms that can only be hosted in ActiveX Document containers—you can't run them as standalone applications. ActiveX Documents are typically activated by accessing a file. When you create an ActiveX Document project in Visual Basic, it generates a file with a .VDP extension. This is a structured storage file containing the CLSID of the ActiveX Document that should be launched, and any persistent properties exposed by the document. However, the emphasis in Visual Basic seems to be related more to making a Visual Basic application run within a document container such as Internet Explorer than on the "persisted" data (contrast this with Word, where the emphasis is clearly on the persistent document).

Once you've created a component, you'll need to distribute it to your clients. Visual Basic provides a Setup Wizard to help you with all the packaging issues associated with distributing applications and components. The wizard has been enhanced in version 5.0 to support distribution via the Internet. It also supports installation of remote server components using either DCOM or RA.

Visual FoxPro 5.0

Visual FoxPro is a relational database system that provides powerful query and reporting capabilities as well as visual design tools for generating forms, queries, and reports (see Figure 5). Originally based on the dBase language, Visual FoxPro has evolved to include a complete object-oriented programming environment. The IDE offers multiuser project and database management support, including visual tools for designing tables, queries, and views. Visual FoxPro is fully integrated with source code control products such as Visual SourceSafe.

Like Visual Basic, Visual FoxPro provides a graphical forms designer. Your forms can contain built-in FoxPro controls or ActiveX controls. Builders and designers help you configure control properties. Using Visual FoxPro class libraries, you can even create new controls, either from scratch or by customizing existing Visual FoxPro classes. Numerous wizards are provided to help you create applications quickly. An Application Wizard generates a skeleton app for you. The Report Wizard generates professional-looking reports. There's even a Web Wizard to generate Web pages to query and display database records.

In addition to accessing data via the Visual FoxPro database engine, you can access any ODBC data source from a Visual FoxPro-based application. This makes Visual FoxPro a useful tool for creating front-ends for distributed applications. You can even develop your app against a Visual FoxPro database, then upsize the database to run on SQL Server or Oracle databases.

Visual FoxPro also provides limited support for creating Automation servers, which can be deployed locally or remotely using RA. (Visual FoxPro provides the same RA management tools as the Enterprise Editions of Visual Basic and Visual C++.) These servers are single-threaded and cannot fire events. However, even with these limitations, you may find Visual FoxPro to be a useful tool for creating middle-tier business objects—particularly those that interact with data management services.

Developer Studio

Developer Studio is the IDE used by the rest of the tools included with Visual Studio—Visual C++, Visual J++, and Visual InterDev—as well as the MSDN Library. Developer Studio consists of a shell that various packages can be plugged into. A package typically corresponds to a language such as Visual C++, or a tool such as Visual InterDev or NuMega's BoundsChecker. The shell provides standard functionality that all packages can use. With this plug-in approach, new packages are automatically integrated into Developer Studio as soon as they are installed on your system.

If you've used Developer Studio in the past, Developer Studio 97 will look familiar. Appearances can be deceiving, though. Developer Studio has some interesting new features.

Developer Studio uses project workspaces to help you organize your work. Workspaces include projects and your preferences for how project information appears on the screen. Projects organize the files required to create specific targets. One workspace can contain multiple projects (independent or interdependent) and projects can be nested. You can also create projects using different Developer Studio packages. For example, a single workspace might contain pages for a Web site created using Visual InterDev, a Visual C++ project to create a custom server-side object, and a Visual J++ project to create a client-side applet (see Figure 6).

Although the project management user interface looks similar to previous versions, there have been several improvements. A single dialog is used to create new workspaces, projects, and files, instead of the separate project and file dialogs used in earlier versions of Developer Studio. When you create a new file, you can select the project or workspace you want to add it to. Developer Studio is now an ActiveX Document host, which means you can view any ActiveX Document, such as a Word document or Microsoft Excel worksheet, within the IDE. You can also add ActiveX Documents to your projects. This is handy for keeping track of specifications, project plans, and so on. All this additional flexibility requires new project and workspace file formats—project files now have the extension DSP rather than MAK or BLD, and project workspace files now have the extension DSW rather than MDP.

Sharing project workspace files is a problem that has plagued development teams using Developer Studio since its inception. Microsoft has finally managed to eliminate all machine-specific information from the workspace files so that everyone on your team can use the same workspace without needing exactly the same directory configuration. Machine-specific information is now stored in a workspace options file (OPT). You share the workspace and project files among team members, but each team member has his or her own options files.

Developer Studio is also Internet-aware. You can use a new InfoViewer (based on the Internet Explorer WebBrowser control) or your own Web browser to view Web pages within the IDE. When a URL appears in a window, clicking on the URL takes you right to the Web page. The Help menu includes a new item, Microsoft on the Web, that connects you to important developer sites on http://www.microsoft.com/, including Visual Studio Online.

Perhaps the most interesting new feature of the Developer Studio IDE is that it exposes a rich Automation object model that can be manipulated from within Developer Studio by using VBScript macros or DLLs called add-ins. Of course, Automation can also be used to control Developer Studio from other applications too.

VBScript macros are procedures containing VBScript commands. You cannot pass any parameters to VBScript macros. Macros can be created by recording keystrokes which are automatically converted to VBScript, or by writing the VBScript code yourself.

One of the things I like to put in every source file I create is a comment block with Visual SourceSafe keywords. Visual SourceSafe takes care of updating the file name, last revision date, and so on. Manually adding this block in every file is a pain though, so I wrote a VBScript macro to handle this task. It figures out what type of file is active and inserts a standard comment block above the current selection. The macro, InsertVSSHeader, is shown in Figure 7, MYMACROS.DSM. After assigning the macro to an available keystroke, adding a header is a piece of cake.

'------------------------------------------------------------------------------'FILE DESCRIPTION: MYMACROS.DSM
'------------------------------------------------------------------------------
'This is a modification of the FileType function in the sample macros'Return value: 0 Unknown file type' 1 C related file, this includes .c, .cpp, .cxx, .h, .hpp, .hxx' 2 Java related file, this includes .jav, .java' 3 ODL style, .odl, .idl' 4 Resource file, .rc, .rc2' 5 StyleSheet file: .css' 6 HTML style file, this includes .html, And .htm' 7 VBS style, .dsm' 8 Def style, .def' 9 ASP file: .asp, .asa'USE: pass this function the document that you wish to get information forFunction FileType (ByVal doc) ext = doc.Name FileType = 0 pos = Instr(ext, ".") if pos > 0 then Do While pos <> 1 ext = Mid(ext, pos, Len(ext) - pos + 1) pos = Instr(ext, ".") Loop ext = LCase(ext) end if If ext = ".rc" Or ext = ".rc2" Then FileType = 4 ElseIf ext = ".css" Then FileType = 5 ElseIf ext = ".asp" Or ext = ".asa" Then FileType = 9 ElseIf doc.Language = dsCPP Then FileType = 1 ElseIf doc.Language = dsJava Then FileType = 2 ElseIf doc.Language = dsIDL Then FileType = 3 ElseIf doc.Language = dsHTML_IE3 Or doc.Language = dsHTML_IE2 Or _ doc.Language = dsHTML_RFC1866 Then FileType = 6 ElseIf doc.Language = dsVBSMacro Then FileType = 7 ElseIf ext = ".def" Then FileType = 8 Else FileType = 0 End IfEnd Function
Sub InsertVSSHeader()'DESCRIPTION: This macro adds a comment block with Visual SourceSafe keywords' at the insertion point.
Asterisk = Asc("*") Dash = Asc("-")
OpenComment = "" 'Language specific token to open a comment block CloseComment = "" 'Language specific token to close a comment block LineComment = "" 'Language specific token for each line in a comment block
'Make sure the active document is a text window If ActiveDocument.Type = "Text" Then TypeOfFile = FileType(ActiveDocument)
'Figure out what comment tokens to use If TypeOfFile > 0 And TypeOfFile < 5 Then 'C/C++, Java, IDL, and Resource Files OpenComment = "/*" + String(63, Asterisk) CloseComment = String(63, Asterisk) + "*/" LineComment = vbTab ElseIf TypeOfFile = 5 Or TypeOfFile = 6 Then 'HTML and StyleSheet Files OpenComment = "<!--" + String(61, Dash) CloseComment = String(62, Dash) + "-->" LineComment = vbTab ElseIf TypeOfFile = 7 Then 'VBS Files OpenComment = "'" + String(64, Dash) CloseComment = "'" + String(64, Dash) LineComment = vbTab + "'" ElseIf TypeOfFile = 8 Then 'DEF Files OpenComment = ";" + String(64, Dash) CloseComment = ";" + String(64, Dash) LineComment = ";" + vbTab ElseIf typeOfFile = 9 Then 'ASP Files OpenComment = "<%" + vbLf + vbTab + "'" + String(59, Dash) CloseComment = vbTab + "'" + String(59, Dash) + vbLf + "%>" LineComment = vbTab + "'" End If
If TypeOfFile = 0 Then 'Unrecognized File MsgBox("Unable to add comment header. Unrecognized file type") Else 'Position the comment block above the current selection ActiveDocument.Selection.StartOfLine
'Add comment block with one assignment statement so it 'can be removed with a single Undo command. ActiveDocument.Selection = _ OpenComment + vbLf + _ LineComment + "$Logfile:$" + vbLf + _ LineComment + "$Author:$" + vbLf + _ LineComment + "$Modtime:$" + vbLf + _ LineComment + vbLf + _ LineComment + "$Nokeywords$" + vbLf + _ CloseComment + vbLf + vbLf End If
End IfEnd Sub

Developer Studio add-ins can be written in Visual C++, Visual Basic, or other languages that can create in-process Automation servers. Add-ins can contain multiple commands to be added to Developer Studio, as well as the code to connect these commands to toolbar buttons and key sequences. A wizard is provided to help you start writing an add-in using Visual C++. Sample add-ins provide standard code you can cut and paste into your own add-ins.

VBScript macros are easier to create than add-ins, but they're not as versatile. Macros can only access the Developer Studio object model. Add-ins, on the other hand, can access all the resources of your system—including other object models. This is a significant difference. For example, if you want to read information from a text file during your processing, you would need to go through major contortions in VBScript, which has no file system commands of its own.

The Developer Studio editors haven't been ignored. Many user-interface improvements make locating and maintaining your resources and source code easier. In particular, syntax coloring is now available for many languages—C++, Java™, VBScript, IDL/ODL, SQL, and several variants of HTML. Take a look at the "What's New in Visual Studio" topic in the online help for the highlights.

You'll also see a more functional WizardBar and Class View. Early versions of these tools were tied to Visual C++. Now any language package can use them (Visual C++ and Visual J++ do). Class View and WizardBar complement each other: Class View lets you see all the classes in all the projects in the current workspace, while WizardBar shows you a single class within the active project. Unlike Class View, WizardBar tracks where you are in the source editor to display context-sensitive class information. For Visual C++, WizardBar extends the functionality of the dialog editor, making it easy to add event handling code for your dialogs. Class View and WizardBar both have a convenient way to add properties and methods to your classes; this has been extended to support editing COM interfaces or dispinterfaces defined in IDL or ODL files. If you're using the ActiveX Template Library (ATL) or MFC, this even creates a stub function in the appropriate H and CPP files.

Developer Studio, like MSDN, uses an online documentation system called InfoViewer, now based on Microsoft Internet Explorer. Documentation is stored in InfoViewer title files, which have the extension .IVT, and are compressed HTML files. Although the implementation of InfoViewer has changed, I did not see any major change in functionality—you can still do full-text searches across titles, define information subsets, create bookmarks, print complete books, access sample code, and so on.

The new InfoViewer is Internet-aware, and topics may contain links to Internet Web sites. The docs can even be incrementally updated over the Internet. If you click on a link to a Web site, an Internet connection will be established. You can also enter a URL into the listbox on the InfoViewer toolbar. InfoViewer Internet navigation uses the Internet Explorer options, and they must be set before an Internet connection can be completed.

Visual C++ 5.0

You'll have to dig to find most of the updates from previous versions of Visual C++. Not that the changes are insubstantial, they're just not as visible as a new IDE.

On the compiler front, there have been updates to better conform with the C++ standard. Visual C++ 5.0 now supports the keywords bool, explicit, false, mutable, true, and typename. This will undoubtedly thrill the C++ gurus, but may cause you C++ programmers grief if you've used these words for your own purposes. Visual C++ 5.0 also ships with an ANSI Standard C++ library that conforms to the working paper produced by the Stockholm meeting of July 1996. There have been some changes to the compiler options you can use as well. If you're upgrading from a previous version of Visual C++, I'd suggest looking at the "What's New" section of the documentation to see if any of these changes will affect your app.

In an intriguing move, Microsoft has added special support for COM to the Visual C++ compiler itself. This support simplifies creating COM clients—for instance, applications or other components that use ActiveX components. Microsoft has added a new preprocessor keyword, #import, which is essentially #include for type libraries. When you import a type library into your C++ code, the preprocessor reads the type library, creates a C++ header file describing the included COM interfaces as C++ classes, and creates a second header file containing the implementation of these classes. You can read more about the compiler support for COM in George Shepherd's article in this issue of MSJ.

If you prefer to work at a slightly higher level of abstraction, Visual C++ includes two class libraries. MFC is an established framework for Windows-based application development and ActiveX control creation. The ActiveX Template Library (ATL) is a relatively new library designed specifically for creating small, fast ActiveX components.

There have been a few updates to MFC since version 4.2b, primarily for Internet and database support. ActiveX Documents written in MFC now support all the features required for hosting in both Internet Explorer and Office Binder. MFC also supports asynchronous URL monikers. On the database front, MFC supports DAO 3.5 and ODBC 3.0. It supports binding simple and complex data controls to any ActiveX data control, including the Remote Data Control shipped with Visual C++ Enterprise Edition.

Previous versions of MFC were able to create Automation components, ActiveX controls, and ActiveX Documents. You won't see any major changes here. Components can support apartment model threading, but cannot be free-threaded. Unlike Visual Basic, MFC does provide support for windowless controls. However, MFC doesn't support dual interfaces directly.

ATL takes a radically different approach from MFC. It focuses on one thing—creating small, fast ActiveX components. (For more information see "Developing and Deploying ActiveX Web Components: A Tools Overview" by Michael T. McKeown and Mary Kirtland, MIND, April 1997.) Early versions of ATL only had built-in support for only the most basic COM functionality. With ATL 2.0, the ability to create ActiveX controls was added. Visual C++ 5.0 ships with ATL 2.1, which offers better integration with the Developer Studio IDE and wizards to create more kinds of objects. (You'll also see significantly smaller components when you compile with Visual C++ 5.0, due to better code-generation optimizations.)

Of all the tools included with Visual Studio, ATL offers the most flexibility in creating components. It supports all COM threading models and lets you build components as DLLs, EXEs, or services. Unlike MFC, ATL supports dual interfaces. And since ATL is a C++ template library, all code gets included in your component—no runtime DLL is required. ATL uses templates and multiple inheritance to implement objects. If you're not comfortable with these C++ features, you may find using ATL rough going. However, the wizards provided are a great help in creating the basic framework for your component and adding object classes to it. Figure 8 shows the ATL Object Wizard.

Visual C++ 5.0 Enterprise Edition provides better SQL support than earlier Visual C++ versions. A Data View pane in the project workspace window simplifies working with ODBC data sources. The text editor color-codes SQL statements to help reduce syntax and spelling errors. Combined with the Data View's ability to generate skeletal triggers and stored procedures, this helps you create SQL scripts and procedures. The integrated SQL debugger helps track down errors in your stored procedures.

In addition to working directly with SQL or using MFC to work with DAO or ODBC, you can use data controls that ship with Visual C++ 5.0 to connect to local or remote databases. These controls also ship with Visual Basic 5.0. (See Figure 9 for a list of the controls that are available.) You can bind the MSDataList, MSDataCombo, Data Bound Grid, Masked Edit, and Calendar controls to the Remote Data control. When you do this, data accessed by the Remote Data Control is displayed in the data-bound control. This helps you write Visual C++-based apps that can view and maintain database records. Remote Data Objects is used to manipulate the data control. When you insert the control into your project, Visual C++ automatically creates the C++ class framework for manipulating the control.

Control Type

Files

Remote Data

MSRDC32.OCXMSRDO32.DLL

Apex Data-Bound Grid

DBGRID32.OCXGRDKRN32.DLL

Microsoft Masked Edit

MSMASK32.OCX

MSDataList

DBLIST32.OCX

MSDataCombo

DBLIST32.OCX

Calendar

MSACAL70.OCX

Visual J++ 1.1

Visual J++ is Microsoft's Java development tool. Like Visual C++, Visual J++ uses Developer Studio as its IDE. Figure 10 shows a debugging session in progress. Note that the debugger disassembly window shows the bytecodes being executed.

Visual J++ has wizards to help you generate the generic parts of your Java applets and applications. The Applet Wizard generates a starting framework that will run as both an applet and an application. You can elect to have the wizard provide multithreading support, animations, mouse event handlers, and more—it will even generate a sample HTML page for testing the operation as an applet.

Java applets use Abstract Windowing Toolkit (AWT) code to specify UI elements such as menus and dialogs. Instead of writing this code by hand, you can use graphical resource editors in the IDE to create your UI elements and store them in a resource template file. You then use the Java Resource Wizard to convert that file into the appropriate Java code.

Microsoft's reference implementation of the Java Virtual Machine (VM) integrates Java and ActiveX. Using Visual J++, you can build components with Java and expose their functionality as COM interfaces. You can also write client applications and higher-level components in Java that glue together existing ActiveX components. The Java Type Library Wizard is used to create Java classes that interface with the ActiveX components described by a type library. (Sounds a lot like Visual C++ #import, doesn't it?) Take a look at the March 1997 Visual Programmer column in MSJ and "Understanding the Java/COM Integration Model," by Guy and Henry Eddon, MIND, April 1997 to learn more about Java/COM integration.

The Web Content Tools—Visual InterDev 1.0

Visual InterDev (formerly Internet Studio) is a complete set of tools for creating dynamic, data-driven, Web applications for the Internet and intranet. With Visual InterDev, you can edit static content files, create, manage, and work with ODBC databases and connect them to your Web application, add client and server-side scripting to HTML pages using VBScript or JScript™, and manage multi-user Web projects.

When you create your Web application with Visual InterDev, you work with a Web, which is the actual set of files out on the Web server, and a project, which is the working directory and files located on your development machine. Visual InterDev includes Web project wizards that create the working directory on the development machine, create project and workspace files, create (if necessary) and configure the Web on a Web server, and create a set of starter files for the Web. Multiple developers can work on the same site and multiple projects can point at the same Web. Visual InterDev lets you decide whether multiuser projects should permit free-for-all changes or should use source control. When source control is enabled, file locking on the Web server is used to prevent multiple users from changing files.

To create HTML, you can use the Developer Studio text editor, the FrontPage WYSIWYG HTML editor, or any other editor you might prefer. To activate your Web page, you add controls and scripting. The editors make it extremely easy to add controls to your pages. If you're not a VBScript or JScript™ guru, Visual InterDev supplies a Script Wizard that provides limited point and click client-side scripting support. Visual InterDev keeps track of the relationships between Web files and can update links when you move a file. A Link View tool lets you see the connections between your Web pages graphically. Figure 11 shows the link view and FrontPage™ editor in action.

Visual InterDev's strength is its support for creating data-driven applications using Microsoft Active Server Pages. (For more information about Active Server Pages, take a look at my article, "Writing a Smart Server Application with Denali," MIND, December 1996.) Data-driven Active Server Pages tend to have a lot of code, much of which is the same no matter what database is accessed or how the data is displayed—the ideal scenario for a wizard. That's exactly what Visual InterDev provides: wizards to generate common code for Active Server Pages. Visual InterDev also provides something called Web Designers that help you create and initialize instances of server-side controls in your Active Server Pages. Using these designers is a little disconcerting if you are editing your pages in text mode because a visual editor is displayed. The Visual InterDev designers don't really make a compelling case for using them—it's faster to type in the little bit of code they generate than it is to use the designer, and the handwritten code is easier to read. For complex server-side objects such as the data command control, a design-time interface would be extremely handy.

Once you've got some content, Visual InterDev lets you test it out in your browser (Internet Explorer by default) from within the IDE using the Preview command. This is important for Active Server Pages, which must be run from the Web server to generate the client-side content; you can't just open up the file and expect to see what Web clients will see. You can also test alternate browsers using the Browse With command—very handy. The text editor's syntax coloring is a helpful addition to actual testing in multiple browsers. You can select different versions of HTML to control syntax coloring, and unrecognized tags show up in a different color.

Visual InterDev includes Visual Data Tools to help manage your application databases. The tools include a graphical Query Designer and Database Designer. If you've used Microsoft Access and Query, these tools will look familiar. Database Designer helps you create, edit, and delete Microsoft SQL Server 6.5 database objects. Query Designer helps you construct SQL statements to query or update databases.

Visual InterDev also includes several tools for creating and managing multimedia content. Image Composer is a sprite-based image editor. To create images in Image Composer, you take existing images (sprites), apply various imaging effects, and put the images together to form a composition. These images can then be saved in standard image formats that Web browsers understand. Music Producer is a program you can use to create music. You specify information such as tempo, key, style, mood, and instruments, and Music Producer generates an original composition for you. This works better for some types of music than others: the compositions Music Producer generated for me tended to be heavy on the rhythm section and light on the melody (think about the electronic organ demonstrations at your local mall and you'll get the idea). But if you need background sounds for your Web site and can't compose your own, Music Producer is the answer.

Finally, Visual InterDev includes a tool for keeping track of media. If you've ever wasted half an hour trying to locate that way-cool bullet that would be absolutely perfect for your new Web page, or ended up with half a dozen applets cluttering the screen while picking out background images and sounds, you'll appreciate Media Manager. Media Manager is so seamlessly integrated into the Windows shell that, if it weren't for the startup screen that automatically loads with Windows, you might never realize it's there. Although you might think Media Manager is just for graphics, audio, and video files, you can actually keep track of many kinds of files with it. All you need to do is create a Media Manager directory (by right-clicking on a directory and selecting "Convert to a Media Manager folder," or by selecting NewMedia Manager folder) and start adding files to it. Figure 12 shows a Media Manager view of some audio files. Media Manager also keeps track of file properties—both those it understands automatically in supported file types and any annotations you add yourself—so that it can provide enhanced file find capabilities.

Visual InterDev is a powerful, full-featured tool for creating and managing Web content, and I've obviously just hit the highlights here. For more details, take a look at the March 1997 MIND.

The Enterprise Tools

Visual Studio 97 Enterprise Edition includes Developer Editions of Microsoft SQL Server 6.5 and Microsoft Transaction Server 1.0. Developer editions are full-fledged copies of the respective products with restricted licenses that prohibit deployment of your applications. This lets you develop and test your applications within your development team, for example, before handing the app over to your IS manager for company-wide deployment. Your team can work on its own private database server, without affecting production applications—and without purchasing a production copy of SQL Server or Transaction Server.

If you're not familiar with Microsoft Transaction Server (formerly codenamed Viper), it provides development tools and runtime services for building high-performance, scalable applications with transactioning.

The Visual Studio Enterprise Edition also includes the latest version of Visual SourceSafe, Microsoft's source code management tool. It is fully integrated with the Visual Studio tools, and with Microsoft Access and Microsoft FrontPage. Visual SourceSafe is a project-oriented version control system for tracking changes to any type of file. As you can see in Figure 13, Visual SourceSafe provides a hierarchical view of your project files. Development team members can share files, modify them independently, and merge changes or revert to earlier versions if necessary. Like most version control systems, you can add comments about the file you are checking in or out, then later review the file's history. A separate administration program lets you control who has access to which files.

Perhaps the most interesting new feature of Visual SourceSafe version 5.0 for Visual Studio users is its Web site management feature. To create a Web site, you collect a set of files and check them into a Visual SourceSafe project. Designating the project as a Web site project using the Administrator program enables several useful features: Check Hyperlinks, which looks for invalid links on your site, Create Site Map, which creates a map of all the Web pages on your site, and Deploy, which moves an entire project onto a designated Web server.

Summing Up

Microsoft's aim in creating Visual Studio 97 is to provide you the tools you need to develop applications that integrate the best of the Internet and the best of client/server computing—applications that can be built once and deployed everywhere.

ActiveX components are central to Microsoft's distributed applications architecture. While there are thousands of ready-to-use components you can purchase, at some point you'll probably want to write your own. Visual Studio 97 provides a multitude of options for creating components. Each tool optimizes for different scenarios and has different constraints (see Figure 14). Instead of forcing you to use a one-size-fits-all tool to create your components, Visual Studio 97 gives you the flexibility to use the tool that best meets the needs of your development project. And since ActiveX is language-neutral, the components will work together regardless of how they were developed.

Figure 14 Visual Studio Tools ActiveX Component Authoring Comparison


Capability

Visual Basic

Visual FoxPro

Visual J++

Visual C++

ATL

MFC

ActiveX Components

Automation

x

x

x

x

x

Dual Interface

x

x

x

Events

x

x

x

UI Controls

x

x

x

Windowless Controls

x

x

Internet-Aware Controls

x

x

x

ActiveX Documents

x

x

x

Threading Models

Single Threaded

x

x

x

x

Apartment Model

x*

x

x

Free Threaded

x

Both (Apt. + Free)

x

x

Packaging

In-Process

x

x

x

x

x

Executable

x

x

x†

x

x

Service

x

* Only in Enterprise Edition when component marked as unattended (no UI)

† Using surrogate application

Building Distributed Applications with Components

A distributed application is nothing more than an app that runs on more than one machine. The most common reason for writing a distributed app is to give multiple clients the ability to create or access data from a common set of stored data. These applications are also known as client-server applications. Figure A shows the architecture of a typical, multitier client-server application. This general architecture can be applied to traditional client-server apps as well as to Web-based apps. (Web apps are client-server applications, after all.) Well-designed multitier architectures partition software into reusable parts, or components, that can be easily adapted to changing business needs.

A front-end or presentation tier provides the user interface, and is typically created using a rapid application development (RAD) tool. The presentation layer accesses business objects that perform actions such as validating user input or calculating output based on business rules. The business objects communicate with data management services that know how to access data servers. By separating presentation, business logic, and data access code into discrete components with well-defined, narrow interfaces, developers can create reusable, maintainable, and scalable code. Any tier can be modified easily to meet changing requirements without affecting the rest of the app.

When it comes time to deploy an application that uses a tiered architecture, components are installed wherever it makes the most sense for the application's needs. For example, two important requirements for most applications are a responsive user interface and minimal network traffic. So, you'll typically see the presentation layer installed on each client's machine and data management services deployed near the data they access. Business objects can be installed on client machines, data servers, or any other machines, depending on the application and the environment it's used in.

What makes this architecture work is an underlying infrastructure that lets components work together without regard to their physical location. Developers write only the components. These components can then be glued together in any way, shape, or form, depending on the business need. Components can be reused in a variety of applications that can be deployed anywhere. The applications can be standalone, single-user applications or complex enterprise solutions. Although components may need to be tuned for specific performance scenarios, the fundamental notion of what it means to write a component remains unchanged.

The Component Object Model

In the Microsoft universe, the infrastructure that enables objects to work together is the Component Object Model (COM), the cornerstone of the ActiveX™ technologies. COM is a widely used technology that provides a binary standard for component interoperability. "Binary standard" means that components can be written in and used from most any language—you aren't tied into a single development language or tool. "Widely used" means that there are literally thousands of components available today that you can purchase for use in your applications. These components range from simple user interface widgets to complex data analysis tools.

COM takes care of all the murky details required to make objects work together, regardless of where these objects are located. Neither the developer of a component nor the developer of the application that uses the component needs to worry about where the component code is located. This gives you an enormous amount of flexibility when it's time to deploy your application.

COM objects communicate with each other and with client applications by using an interface. An interface is essentially a specification for some well-defined behavior. Any object that claims it supports a particular interface agrees to provide the specified behavior. A client that uses the interface doesn't need to worry about the specifics of how a particular object implements the interface; it just knows that the object provides the specified services. Objects can support any number of interfaces.

Objects that support COM are called ActiveX components, or ActiveX controls. The features required of an ActiveX component are simple: support the fundamental COM interface, IUnknown, and know how to register yourself with the operating system.

Admittedly, if this is all a component did, it would be pretty boring, so components add their own unique functionality by implementing additional interfaces. Some interfaces are generic and—either by themselves or in conjunction with other interfaces—provide behaviors that can be implemented by many components. Other interfaces are specific to a single component and are known as custom interfaces.

Components that implement certain generic interfaces are often referred to by special names. For example, components that implement the IDispatch interface are called Automation components. Automation components expose properties, methods, and events to client applications via IDispatch interfaces or a combination of IDispatch and custom interfaces known as a dual interface. Information about interfaces and components can be stored in a type library. Development tools can use this information at design time to determine what features a particular component exposes.

An ActiveX control is an Automation component that provides some user interface and is designed to be used in the context of a data form. There are a number of additional interfaces UI controls use to communicate with control container applications.

Another type of specialized component is called an ActiveX Document. ActiveX Documents support an additional set of interfaces that let them work with ActiveX Document containers to display a viewport into your document's data. Unlike normal components, ActiveX Documents are displayed full-frame within document hosts such as Internet Explorer or Office Binder. When an ActiveX Document is viewed, its menus are merged with the host's menus, giving the user the sense that he or she is working with your application rather than the host. Microsoft Word docs and Microsoft Excel worksheets are examples of ActiveX Documents.

Active Content

To create distributed applications, you purchase or create a bunch of components and glue them together, either into higher-level components or into a front-end application that interacts with the user. Web applications that target the Internet or intranets are created the same way; the only difference is the type of glue you use. Web applications use HTML for their user interfaces, and glue components together using a scripting language such as Visual Basic® for Scripts (VBScript) or JavaScript. The combination of HTML, components, and scripting is often called active content. Just like other distributed applications, Web applications can be distributed over multiple machines. The HTML and possibly some components run on each client machine. Other components and data access services are likely to run only on the server side. The client and server communicate with each other using standard Internet protocols, typically HTTP.


No comments:

Free Hit Counter