Use GDI + plotting in VC ++ 6.0

Source: Internet
Author: User

Use GDI + plotting in VC ++ 6.0

1. Configure the GDI + Environment in VC ++ 6.0

1.1 download the GDI + Library

There is no GDI + Library in VC ++ 6.0. FromHttp://www.crazy-bit.com/download/gdiplus.zipDownload.

1.2 copy the GDI + File

Decompress the downloaded file. Copy the include file to the include directory of the VC installation directory. It is recommended that you rename the file name containing the GDI + header file to gdiplus.

Copy the gdiplus. Lib file in the Lib file to the Lib folder in the VC installation directory.

1.3 configure VC ++ 6.0

Add the gdiplus folder in step 1 to tools> Options> directories of your VC ++ project.

2. Drawing instance

2.1 Add in stdafx. h

# Ifndef ulong_ptr
# Define ulong_ptr unsigned long *
# Endif
# Include <gdiplus. h>
Using namespace gdiplus;

2.2 Add a variable to * app class

Ulong_ptr m_gdiplustoken;

2.3 initialize GDI + in initinstance

Gdiplusstartupinput;
Gdiplusstartup (& m_gdiplustoken, & gdiplusstartupinput, null );

Note: Be sure to add it before m_pmainwnd-> showwindow (sw_show.

2.4 draw in ondraw

Graphics graphics (PDC-> m_hdc );

Pen (color (50,255, 0,255), 15 );
Pen. setdashstyle (dashstyledash );
Pen. setstartcap (linecaproundanchor );
Pen. setendcap (linecaparrowanchor );

graphics. drawline (& pen, 20, 20,300,100);
graphics. drawline (& pen, 300,100,600,100);

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.