zoukankan      html  css  js  c++  java
  • VC++6.0中使用GDI+绘图(转载)

    VC++6.0中使用GDI+绘图

    1.在VC++6.0中配置GDI+环境

    1.1 下载GDI+库

    VC++6.0中没有GDI+库。可以从http://www.crazy-bit.com/download/gdiplus.zip下载。

    1.2 拷贝GDI+文件

    将下载的文件解压。把include文件拷贝到VC安装目录的include目录下,最好将包含GDI+头文件的文件名重命名为GdiPlus。

    把lib文件中的GdiPlus.lib文件拷贝到VC安装目录的lib文件夹下。

    1.3 配置VC++6.0

    在你的VC++工程的Tools->Options->Directories中添加1.2步中的GdiPlus文件夹

    2. 绘图实例

    2.1 在stdafx.h中添加

    #ifndef ULONG_PTR
    #define ULONG_PTR unsigned long*
    #endif
    #include <GdiPlus.h>
    using namespace Gdiplus;

    2.2 在*app类中添加变量

    ULONG_PTR m_gdiplusToken;

    2.3 在InitInstance中初始化GDI+

    GdiplusStartupInput gdiplusStartupInput;
    GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);

    注意:一定要添加在 m_pMainWnd->ShowWindow(SW_SHOW);之前。

    2.4 在OnDraw中绘图

    Graphics graphics(pDC->m_hDC);

    Pen 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);
  • 相关阅读:
    Linux目录
    find命令
    107. Binary Tree Level Order Traversal II
    grep命令
    110. Balanced Binary Tree
    111. Minimum Depth of Binary Tree
    什么是泛型
    自动装箱与拆箱
    HDU 3001 Travelling (状压DP + BFS)
    POJ 3411 Paid Roads (状态压缩+BFS)
  • 原文地址:https://www.cnblogs.com/zhixing/p/1986602.html
Copyright © 2011-2022 走看看