在win32对话框中添加图像 [英] Adding image in a win32 dialog

查看:199
本文介绍了在win32对话框中添加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在此链接后创建了一个win32对话框: http://www.functionx.com/win32/Lesson02.htm [ ^ ]



它工作正常,一个小窗口按照描述进行。



现在我想在这个对话框中添加一个小图片,比如横幅图片类型;



任何人都可以告诉我如何我可以在这个窗口中添加它吗;



谢谢

Hi,

I have created an win32 dialog following this link:http://www.functionx.com/win32/Lesson02.htm[^]

and it is working fine and a small window is coming as described.

now I want to add an small image inside this this dialog, say a banner image type;

can any one give me idea how can I add it in this window;

thanks

推荐答案





请尝试下面的代码,



全局声明这些变量,以及WinProc中的代码()



Hi,

Try this code below,

declare these variables globally, and the code that follows inside WinProc()

HBITMAP bitmap;
HDC hdcMem;

	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		hdcMem = CreateCompatibleDC(hdc);
		SelectObject(hdcMem, bitmap);
		StretchBlt(
			hdc,
			0,
			0,
			1000,
			1000,
			hdcMem,
			0,
			0,
			1000,
			1000,
			SRCCOPY);
		
		EndPaint(hWnd, &ps);
		break;


	case WM_CREATE:
		bitmap=(HBITMAP)LoadImage(NULL,"C:\\Wallpaper.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
		break;





在我的例子中,我保留了C:\\Wallpaper.bmp中的图像文件,因此根据您的位置进行更改。



在apiStretchBlt内部给出适当的尺寸你的要求。



希望这会对你有所帮助。



再见。



In my example, i have kept a image file in "C:\\Wallpaper.bmp", so change as per your location.

Inside the api "StretchBlt" give appropriate dimensions as per your requirement.

Hope this will help you.

Bye.

这篇关于在win32对话框中添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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