Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Cutting Edge Direct 3D Programming
(Publisher: The Coriolis Group)
Author(s): Stan Trujillo
ISBN: 1576100502
Publication Date: 11/01/96

Bookmark It

Search this book:
 
Previous Table of Contents Next


Chapter 1
A Quick Introduction To Visual C++

  What Is Visual C++?
  What Is MFC?
  Programming For Windows
  Using The ClassWizard
  Using The AppWizards
  Using The Direct3D AppWizard

Since the release of Windows 3.0, hordes of programmers have migrated to Windows from other platforms. Many Windows programmers started with DOS and discovered that programming for Windows is very different. To make matters worse, there were no function libraries, class frameworks, or visual tools to ease the pain of transition.

Things have changed a lot. Visual C++ is an amazing tool that combines a powerful class framework with visual tools that take the drudgery out of designing resources such as dialogs and menus. Visual C++’s ClassWizard allows you to add functions to your project with the press of a button. Visual C++’s AppWizard constructs ready-to-compile projects, giving you a solid starting place whenever you start a new application.

As great as Visual C++ is, however, you still have to be a programmer to use it, and you have to understand some basics about Windows programming. In this chapter, you will learn how to use Visual C++ to create complete applications and easily modify them. You will also learn how to create complete Direct3D applications in this chapter.

It’s not a complete Visual C++ tutorial, but it should be enough to get you started if you have some programming background.

Developer Studio

Visual C++ is a set of tools for Windows application development. The flagship Visual C++ tool is Developer Studio. You can use Developer Studio to create minimal applications, add functionality to existing programs, and create or edit resources such as menus, dialogs, and icons. Developer Studio is also a complete compiler, debugger, and editor. Figure 1.1 shows the Visual C++ Developer Studio.


Figure 1.1  The Visual C++ Developer Studio.

The Windows SDK vs. MFC

The Windows SDK (Software Development Kit) is a set of functions, structures, and macros that allow programmers to write applications for Windows. The SDK, in some form or another, has been with Windows since Windows 1.0 (yes, there was a Windows 1.0). Written in C, the SDK is known for being hard to work with. Because the SDK isn’t object-oriented, it is difficult to extend and forces the programmer to deal with every possible detail of Windows programming. The Windows SDK is included with Visual C++, but in a way, you’re missing the point if you restrict yourself to SDK programming. The real heart of Visual C++ is MFC.

MFC (Microsoft Foundation Classes) is a C++ class library that insulates programmers from the details of the Windows SDK. Microsoft named MFC appropriately. MFC is indeed a foundation; a set of low-level, flexible objects that can be extended to serve just about any purpose. Many of the MFC classes are merely thin wrappers around Windows SDK constructs. By themselves, the MFC classes are not particularly impressive or useful, but their extensibility is remarkable. MFC is also included with Visual C++.

Event-Driven Programming

The most fundamental difference between Windows and DOS programming is that Windows is event-driven. This means that virtually everything that happens in Windows happens in response to a message or event (in this discussion, we use the terms message and event interchangeably).

In DOS, you are given an entry point, a place in your program that DOS will execute when your program is started. The DOS entry point is the main() function. DOS calls your main() function and your program does whatever it needs to do. You don’t return out of main() until your program is finished. Once main() returns, DOS shuts down your program.

The WinMain Function

A Windows program also has an entry point: the WinMain() function. WinMain() is a function that you write and that Windows calls when your application starts. Unlike the DOS main() function, however, WinMain() must perform certain tasks. A typical WinMain function initializes data structures, creates a window, and then runs a message pump, which is a loop that continually checks to see if new messages are available. If so, the pump retrieves each message and dispatches it. A typical message pump looks like this:

while ( GetMessage( &msg, NULL, 0, 0 ) )
{
    TranslateMessage( &msg );
    DispatchMessage( &msg );
}

GetMessage, TranslateMessage, and DispatchMessage are all functions supplied by the Windows SDK. Messages can be posted by applications or by Windows itself. These messages can be notifications that the system palette has changed, that a key has been pressed, the mouse has moved, and so on. Eventually, the pump translates and dispatches a WM_QUIT message, which signals the program to terminate.


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.