C++/MFC-Picture Control
来源:互联网 发布:宽带网络套餐 编辑:程序博客网 时间:2024/05/13 05:56
Picture Control属于Cstatic类
能显示三种类型的图片:
Bitmap:位图(.bmp)
Cursor:光标(.cur)
Icon:图标(.icon)
一、Picture Control 控件类
CStatic::
SetBitmap
Specifies a bitmap to be displayed in the static control.
GetBitmap
Retrieves the handle of the bitmap previously set with SetBitmap.
SetIcon
Specifies an icon to be displayed in the static control.
GetIcon
Retrieves the handle of the icon previously set with SetIcon.
SetCursor
Specifies a cursor image to be displayed in the static control.
GetCursor
Retrieves the handle of the cursor image previously set with SetCursor.
SetEnhMetaFile
Specifies an enhanced metafile to be displayed in the static control.
GetEnhMetaFile
Retrieves the handle of the enhanced metafile previously set with SetEnhMetaFile
二、加载图片
注意:加载不同类型的图片时,picture control 控件的type属性中应改为相应的类型
Type:Etched Horz水平蚀刻线条
Type:Etched Vert垂真蚀刻线条
Type:Rectangle实心矩形
Type:Bitmap位图
Type:Icon 图标
Type:Enhanced Metafile 增强图元 支持wmf格式图片
Type:Owner Draw 自绘图
Color:颜色
Black:黑
Gray:灰色
White:白色
Etched:蚀刻
2.1LoadImage函数
HANDLE LoadImage( HINSTANCE hinst, // handle of the instance containing the image LPCTSTR lpszName, // name or identifier of image UINT uType, // type of image int cxDesired, // desired width int cyDesired, // desired height UINT fuLoad // load flags);
2.2从文件中载入
//载入文件里(即通过CFileDialog打开)的图片 文件中的第一个参数一般为空,路径,类型,宽,高, 默认大小 HBITMAP hbp=(HBITMAP)LoadImage( NULL, fileName, IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE|LR_LOADFROMFILE) ;
2.3从资源中载入
具体的可以看:
VS2010/MFC编程入门之二十七(常用控件:图片控件Picture Control)
//载入资源里的图片 hbp=(HBITMAP)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDB_BITMAP2),IMAGE_BITMAP,0,0,LR_DEFAULTSIZE) ;
2.4图片缩放
//图片大小缩放 hbp=(HBITMAP)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDB_BITMAP2),IMAGE_BITMAP,33,221,0) ;
三、释放资源
Bitmap
DeleteObject
Cursor
DestroyCursor
Icon
DestroyIcon
例:
HCURSOR hbp=(HCURSOR)LoadImage( NULL, fileName, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE|LR_LOADFROMFILE) ;DestroyCursor(hbp);
- C++/MFC-Picture Control
- mfc- Picture control显示图片
- MFC Picture Control显示图片
- MFC--图片控件Picture Control
- 【MFC】picture control改变背景图片
- MFC控件(12):Picture Control
- MFC 动态创建Picture Control
- MFC图片控件Picture Control
- mfc图片自适应picture control
- MFC 使用picture control 加载图片
- MFC中Picture Control如何添加图片
- 改变MFC picture control控件背景色
- MFC中Picture Control如何添加图片
- MFC的picture control响应鼠标操作
- VC++ 6.0 MFC Picture Control Usage
- MFC中Picture Control如何添加图片
- 6.MFC Picture Control控件的使用.
- MFC用Picture Control显示图像
- Android JNI(五)————JNI_JNI函数编码风格(C风格与C++风格)
- 鸟哥Linux学习之——查找
- mha 日常检查维护
- 06-图1 列出连通集 (25分)
- Json
- C++/MFC-Picture Control
- 使用Quartz实现任务调度
- 给自己的博客领养一些小宠物--增加趣味性的小插件
- 找到一本不错的Linux电子书,附《Linux就该这么学》章节目录。
- int、long和long long的区别
- 子段求和
- Jenkins Android 集成
- VTK: 拾取方式的三种实现
- 学习Postgres 数据导入导出工具架构及源码