在 VC6 中使用 GdiPlus-使用
下面用 VC6 来写一个 GdiPlus 的 Demo 工程
Step1:新建一个名为 Demo_GdiPlus 的 MFC AppWizard(exe) 工程
操作步骤:
(1)主菜单File->New...,选择 Projects 选项卡;
(2)在工程类型列表中选中 MFC AppWizard(exe);
(3)Project name 填入 Demo_GdiPlus,按 OK 进入下一页;
(4)选择单文档(Single document)类型的程序框架,按 Finish 完成工程创建工作。
Step2:添加头文件声明
在 StdAfx.h 中添加以下代码:
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
typedef unsigned long ULONG_PTR, *PULONG_PTR;
#include <gdiplus.h>
using namespace Gdiplus;
#pragma comment (lib, "GdiPlus.lib")
Step3:在 CDemo_GdiPlusApp 中增加成员变量 m_gdiplusToken,并在构造函数中进行初始化
{
private:
ULONG_PTR m_gdiplusToken;
// …… ……
};
CDemo_GdiPlusApp::CDemo_GdiPlusApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
m_gdiplusToken = NULL;
}
Step4:添加安装和卸载 GdiPlus 的代码
通过 ClassWizard 在 CDemo_GdiPlusApp 中增加成员函数
virtual BOOL InitInstance();
virtual int ExitInstance();
// .cpp 中的实现
BOOL CDemo_GdiPlusApp::InitInstance()
{
// 加载 GdiPlus
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
// …… ……
}
int CDemo_GdiPlusApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
// 卸载 GdiPlus
if (m_gdiplusToken)
Gdiplus::GdiplusShutdown(m_gdiplusToken);
return CWinApp::ExitInstance();
}
Step5:找到 CDemo_GdiPlusView::OnDraw() 函数,在里面添加一段 GdiPlus 的绘图代码
{
CDemo_GdiPlusDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
Graphics graphics(pDC->GetSafeHdc());
// Pen can also be constructed using a brush or another pen. There is a second parameter - a width which defaults to 1.0f
Pen blue (Color(255, 0, 0, 255));
Pen red (Color(255, 255, 0, 0));
int y = 256;
for (int x = 0; x < 256; x += 5)
{
graphics.DrawLine(&blue, 0, y, x, 0);
graphics.DrawLine(&red, 256, x, y, 256);
y -= 5;
}
}
编译运行,Demo 程序完成。留住这个 Demo 程序,今后我们会利用它进行更加深入的 GdiPlus 学习。
在 VC6 中使用 GdiPlus-使用的更多相关文章
- 在VC6中使用ogre进行游戏开发
微软公司开发的visual c++6.0堪称史上最易用.最成熟的开发工具.vc6以其小巧.轻便赢得了程序员的喜爱,以至于在VS大行其道的时代,很多程序员仍然使用vc6作为开发工具,vc6的欢迎性可见一 ...
- VC6中创建Qt工程的创建
文章来源:http://blog.sina.com.cn/s/blog_64d015c10100sf1o.html 本文主要介绍怎么创建可以在VC6中编译的QT工程.本文所采用环境为VC++6.0+Q ...
- [转载]VC6中的文件后缀
VC文件扩展名 .APS:存放二进制资源的中间文件,VC把当前资源文件转换成二进制格式,并存放在APS文件中,以加快资源装载速度. .BMP:位图资源文件. .BSC:浏览信息文件,由浏览信息维护工具 ...
- 在VC6中基于dll开发插件用于各种图片显示(BMP/TGA/JPG/GIF/PNG/TIF/ICO/WMF/EMF/...)
一.图片显示 图片显示的方法: 1. 直接写程序 2. 第3方库 3. 调用COM组件的IPicture接口 4. 使用MFC的CPictureHolder类 5. 使用GDI+的CImag ...
- STLport在vc6中的集成
STLport的下载 http://sourceforge.net/projects/stlport/ STLport的编译 * 试验环境 : win7x64sp1 + vc6sp6* 打开控制台窗口 ...
- vc6中向vs2010迁移的几个问题
vc6版本支持的库编译:CJ60lib 1. 用vs2010打开CJ60库的源码的dsw,强制打开 (1)设置项目属性的语言 因为,如果代码字符的编码集不一样,则会出现函数冲定义,参数冲突等问题,这可 ...
- VC6中函数点go to definition报告the symbol XXX is undefined
删除Debug中的bsc文件,再重建所有文件即可,在该函数处点击go to definition会提示重建.bsc文件,如果不行,多操作几次.
- vc6中向vs2010迁移的几个问题(2)
1. 库文件的迁移 参考:http://www.cnblogs.com/icmzn/p/6724969.html 2. 其他项目中的可能遇到的问题: 2.1 无法打开包括文件:“fstream.h”: ...
- vc6中关于“新建”
1.windows api 编程:新建→工程→Win32 Application→一个空工程→新建→文件→C++ Source File2.windows mfc 编程:新建→工程→MFC AppWi ...
随机推荐
- Smarty模板学习
1.基本语法 所有的smarty模板标签都被加上了定界符.默认情况下是 { 和},但它们是可被改变的. 在smarty里,所有定界符以外的内容都是静态输出的,或者称之为不可改变.当smarty遇到了模 ...
- js-jQuery对象与dom对象相互转换
http://blog.csdn.net/jueshengtianya/article/details/8823091 核心提示:jquery选择器得到的jquery对象和标准的 javascri ...
- EOF的一点注记
int ch; while( (ch = getchar()) != EOF ) { putchar(ch); } 执行程序,输入:we are the,然后回车.运行结果如下: [purple@lo ...
- Java集合框架(三)
Map Map集合:该集合存储键值对,一对一对的往里存,而且要保证键的唯一性. Map |------HashTable:底层是哈希表数据结构,不可以存入null键null值.该集合是线程同步的.J ...
- http://www.cnblogs.com/draem0507/archive/2013/02/01/2889317.html
http://www.cnblogs.com/draem0507/archive/2013/02/01/2889317.html
- Bootstrap下拉菜单dropdown-menu
1.步骤 (1)要做为下拉菜单的li增加class="dropdown" (2)为li中文字添加超链接<a data-toggle="dropdown" ...
- VCC、VDD、VEE、VSS等有关电源标注的区别
Almost all integrated circuits (ICs) have at least two pins which connect to the power rails of the ...
- Delphi操作XML的几个博客
http://www.cnblogs.com/acuier 整整十几篇,省得我自己研究,学一下就可以了. http://www.cnblogs.com/del/category/113561.htm ...
- 改变dijit的长度的心得
改变dijit的长度要进入到里面改 如dijit/form/Select (以table的方式来组合控件) 改变的时候,先找到dijitButtonContent 然后在后面样式文件里写就可以了 ...
- SSIS ->> 通过Checkoints实现SSIS的包重启(Package Restartability Fullfilled By Checkoints)
Checkpoints是实现SSIS包重载的基础.它的原理是把当前运行环境的配置.变量以及到了包运行到哪一步和哪一步失败这些信息写入到一个文件中.而且有一点很重要,Checkpoint只发生在Cont ...