[已解决]设置圆形按钮的背景图像 [英] [Solved] Setting background image for round button

查看:79
本文介绍了[已解决]设置圆形按钮的背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在创建了一个圆形按钮,如何将位图图像设置为圆形按钮的背景

在此先感谢...

i have created a round button now how to set bitmap image as background for a round button

Thanks in advance...

推荐答案

您尝试过这些吗?
http://stackoverflow.com/questions/2047470/how- to-add-bitmap-image-to-buttons-in-mfc [ http://www.ucancode.net/faq/Visual-C-Example- Bitmap-Button-CButton.htm [ ^ ]

是的,这将适用于普通形状的按钮,但是我让所有者绘制了圆形按钮

如果这是所有者绘制按钮,则表示您的绘画代码位于OnPaint中.因此,您只需要加载位图(从磁盘或资源)并在OnPaint处理程序中绘制即可.看看:
从文件中绘制位图:
http://www.ucosoft.com/how-to-draw- bitmap-from-a-bmp-file.html [ ^ ]
从资源中绘制位图:
http://www.ucancode.net/faq/CBitmap.htm [CBitmapButton,因此,如果不使用该位图,则必须使用BitBlt.
Did you try these?
http://stackoverflow.com/questions/2047470/how-to-add-bitmap-image-to-buttons-in-mfc[^]
http://www.ucancode.net/faq/Visual-C-Example-Bitmap-Button-CButton.htm[^]

ys, this will work for normal shaped button, but i have owner draw round shaped button

If this is an owner draw button, it means your painting code is in OnPaint. So you just need to load your bitmap (from disk or from resource) and draw it in your OnPaint handler. Have a look to:
Draw bitmap from file:
http://www.ucosoft.com/how-to-draw-bitmap-from-a-bmp-file.html[^]
Draw bitmap from resource:
http://www.ucancode.net/faq/CBitmap.htm[^]

-------------

If overriding OnPaint doesn''t work, try with OnEraseBkgnd. This function is called whenever the background needs to be repainted: you will have a CDC pointer as a parameter and can use the BitBlt function with it.

Whatever message you handle to draw your bitmap, you will have to draw it with BitBlt (or same family, like StretchBlt). The only "magical" way to draw a bitmap directly on a button with MFC is to use CBitmapButton, so if you don''t use that one, you will have to use BitBlt.


这篇关于[已解决]设置圆形按钮的背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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