天天看點

【VS2013中使用GDI+繪圖】

MFC操作Excel的類

http://download.csdn.net/detail/bigtree_mfc/8101757

MFC為工具欄添加下拉按鈕

http://download.csdn.net/detail/bigtree_mfc/8196895

VS2013中使用GDI+繪圖和VC6.0不同,在VC6.0中能繪出的圖像在VS2013中不會顯示,原因就是在VS2013中需要添加初始化GDI+;

繪圖

對話框視圖類中:(繪圖部分大同小異,)

void **View::OnDraw(CDC *pDC)

{

//初始化部分

GdiplusStartupInput gdiplusStartupInput;

ULONG_PTR gdiplusToken;

GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

HDC hdc = pDC->m_hDC;

using namespace Gdiplus;

Graphics graphics(hdc);

graphics.SetSmoothingMode(SmoothingModeAntiAlias);

Pen newPen(Color(0, 255, 255), 2);

graphics.DrawLine(&newPen, 0, 0, 500, 500);

}

注:頂部添加GDI+定義注意要4行全部添加

#pragma once

#include <GdiPlus.h>

#pragma comment(lib, "GdiPlus.lib")

using namespace Gdiplus;

效果:

【VS2013中使用GDI+繪圖】

繼續閱讀