在不使用PictureBox的情况下在MFC中插入图片 [英] insert picture in mfc without using picturebox

查看:115
本文介绍了在不使用PictureBox的情况下在MFC中插入图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我目前正在使用MFC对话框,我需要动态插入图片.
实际上,我不想使用已经提供的图片的拖放选项.这是静态方法,但是我需要通过代码指定一个区域,然后将图像加载到该区域.现在这是动态的,是我的要求.

需要紧急帮助.

谢谢.

Hy there,

I am currently working on MFC dialog, I need to insert pictures dynamically.
Actually I don''t want to use the drag drop option of picture already provided. This is static approach however I need to specify an area via code and than load image to that area. This would now be dynamic and my requirement.

Need help urgently.

Thanks.

推荐答案

使用CStatic控件.并更改其位图属性.
Use CStatic control. And change its property for bit map.


使用
Use the CBitmap[^] class to construct the image and draw into your view.


saybiz写道:

现在这是动态的,是我的要求.

This would now be dynamic and my requirement.


您仍然可以在对话框编辑器中使用图片控件.给它一个ID(在属性窗格的底部附近),例如IDC_PICTURE

现在,在代码中,您可以使用
GetDlgItem (IDC_PICTURE).

一旦有了手柄,就可以使用 SetWindowPos [ ^ ]或 MoveWindow [ ^ ]

如果将GetDlgItem返回的值转换为CStatic,则还可以使用该类中的函数来更改图片或其他任何内容.


You can use the picture control in the dialog editor still. Give it an ID (near the bottom of the properties pane), for example IDC_PICTURE

Now in the code you can get a handle of the picture control with GetDlgItem(IDC_PICTURE).

Once you have the handle, you can move or resize it with either SetWindowPos[^] or MoveWindow[^]

If you cast the value returned by GetDlgItem to CStatic you can also use the functions in that class to change the picture or anything else.

int width = 100;
int height = 75;
CStatic *pMyPicture = (CStatic *)GetDlgItem(IDC_PICTURE);
pMyPicture ->SetWindowPos(NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE); //Don't reorder control layering, and don't move the top left corner
//This example will only move the bottom right corner to resize


这篇关于在不使用PictureBox的情况下在MFC中插入图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆