Mfccdc Demonstrates Viewport and Mapmode Use in MFC (195028)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++, 32-bit Editions 4.0
    • Microsoft Visual C++, 32-bit Editions 4.1
    • Microsoft Visual C++, 32-bit Enterprise Edition 4.2
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 4.2
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
    • Microsoft Visual C++ .NET (2002)
  • Microsoft Visual C++ .NET (2003)

This article was previously published under Q195028
NOTE: Microsoft Visual C++ .NET (2002) and Microsoft Visual C++ .NET (2003) support both the managed code model that is provided by the .NET Framework and the unmanaged native Windows code model. The information in this article applies to unmanaged Visual C++ code only.

SUMMARY

The Mfccdc sample demonstrates how to set the Mapmode, Viewport, and Window parameters, and draws a rectangle based on given logical coordinates; then, the sample calculates the resulting device units.

The sample shows how to use the following functions:
   SetMapMode()
   SetWindowExt()
   SetViewportExt()
   SetWindowOrg()
   SetViewportOrg()
   LPtoDP()
   NormalizeRect()
				

MORE INFORMATION

The following files are available for download from the Microsoft Download Center:

Visual C++ 6.0

The following file is available for download from the Microsoft Download Center:
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Visual C++ .NET

The following file is available for download from the Microsoft Download Center:
Release Date: June 25, 2002

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Steps to Run the Sample

Once the sample is running, parameters to the above-mentioned functions can be changed in a dialog box, which effectively updates the rectangle and the calculated device units.

REFERENCES

VC Online help - "CDC class members" and "Converting from Device Coordinates to Logical Coordinates."

Charles Petzold's book, "Programming Windows," ISBN 1-55615-264-7.

Modification Type:MinorLast Reviewed:8/9/2004
Keywords:kbfile kbGDI kbhowto KB195028 kbAudDeveloper