Use GDI + graphic functions in vc6.0

Source: Internet
Author: User

A class provided by a group in the. net environment to replace the GDI graphic functions. In the future, the GDI graphic functions will be gradually replaced.

If you use the gdi + graphic function in vc6.0, follow these steps:

1. download the following rarfile and copy the uplodes and Lib files to the uplodes and Lib folders in the vc directory.

2. Create a new project (taking the winsdk framework as an example, the same is true for mfc)

Add the following code to the StdAfx. h header file:

// Added header file
# Include <comdef. h> // initialize the comport.

# Ifndef ULONG_PTR
# Define ULONG_PTR unsigned long *
# Include "GdiPlus. h"
Using namespace Gdiplus;
# Endif
// End

3. Add in program Initialization

// Two variables used by gdi +
GdiplusStartupInput m_gdiplusStartupInput;
ULONG_PTR m_pGdiToken;
// Load gdi +
GdiplusStartup (& m_pGdiToken, & m_gdiplusStartupInput, NULL );

4. Add it before exiting the program

// Uninstall gdi +
GdiplusShutdown (m_pGdiToken );

5. Add gdiplus. lib to Project> stting> Link> Object/libary.

After completing the steps above, we can use GDI + in the program. Please try it first!

Display a transparent string

Graphics mygraphics (hdc); // create a Graphics object
SolidBrush brush (Color (0,255, 0,); // create a brush. The first item is transparency. The last three items are RGB values.
FontFamily fontFamily (L "Latha"); select a font
Font font (& fontFamily, 1, FontStyleRegular, UnitInch );
PointF pointF (5, 5 );

Mygraphics. DrawString (L "Hello Word! ",-1, & font, pointF, & brush );

Or display a jpg image.

Graphics imgraphics (hdc );
Image image (L "001.jpg ");
Imgraphics. DrawImage (& image, 0, 0 );

Upload 001.jpg to the project directory
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.