VC uses gdiplus in Win32

Source: Internet
Author: User

1. In stdafx. h

Comment out # define win32_lean_and_mean
Or add # include <windows. h>

Visual Studio 2012 does not seem to need to be changed by default.


2. Locate a CPP file and add:

# Include <gdiplus. h>
Using namespace gdiplus;
# Pragma comment (Lib, "gdiplus. lib ")


3. Add at the top of the winmain Function

Ulong_ptr token;
Gdiplusstartupinput GSI;
Gdiplusstartup (& token, & GSI, 0 );

4. Add at the bottom of winmain
Gdiplusshutdown (token );

5.

Add in wndproc

Case wm_paint:
HDC = beginpaint (hwnd, & PS );
// Todo: add any drawing code here...
Onpaint (HDC );
Endpaint (hwnd, & PS );
Break;
---------------

Add drawing function
Void onpaint (HDC ){
Graphics g (HDC );
Gdiplus: Image IMG (L "img.jpg ");
Pen (color (233,24, 22 ));
G. drawimage (& IMG, pointf ());
G. drawline (& pen, 100,100 );

And so on.

From:

Http://hi.baidu.com/kikoqiu/item/2e60f12b4dd123f850fd87d3



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.