mfc CFileDialog类

知识点:
CFileDialog类
SetBitmap
LoadImage
动态显示图片

一、CFileDialog类
构造函数
CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR 
lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | 
OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL );

参数
bOpenFileDialog
TRUE:打开,FALSE,保存
lpszDefExt
缺省文件扩展名,如果用户在文件名编辑框中不包含扩展名,则lpszDefExt定义的扩展名自动加到文件名后。如果为NULL,则不添加扩展名。
lpszFileName
默认要打开的文件名
dwFlags
对话框标志
  OFN_HIDEREADONLY //打开时,隐藏只读复选框
   FN_OVERWRITEPROMPT //保存时 文件存在则显示一个提示框
   OFN_READONLY //打开时, 显示 只读复选框
lpszFilter
文件扩展名列表 如:
"位图bitmap (*.bmp)|*.bmp|文本文件(*.txt)|*.txt|All Files (*.*)|*.*||";
pParentWnd
指定一个父窗口地址


二、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



三、LoadImage函数
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
);



//载入文件里的图片
 hbp=(HBITMAP)LoadImage(NULL,fileName,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE) ;
//载入资源里的图片
 hbp=(HBITMAP)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDB_BITMAP2),IMAGE_BITMAP,0,0,LR_DEFAULTSIZE) ;
//图片大小缩放
 hbp=(HBITMAP)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDB_BITMAP2),IMAGE_BITMAP,33,221,0) ;


//释放资源
Resource    释放资源函数
Bitmap    DeleteObject

Cursor    DestroyCursor

Icon    DestroyIcon

 

转载于:https://www.cnblogs.com/whzym111/p/6225298.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值