如何在ActiveX控件MFC中创建一个圆形按钮 [英] how to create a round button in ActiveX Control MFC

查看:71
本文介绍了如何在ActiveX控件MFC中创建一个圆形按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

i想在我的应用程序中创建一个圆形按钮-MFC ActiveX Control
项目ONCREATE中的


i已创建一个变量_button as CButton

我使用API​​ Create():

Hi all
i want to create a round button in my apps-MFC ActiveX Control
in the function ONCREATE of project
i have created a variable _button as CButton
and i use API Create():

_button.Create(_T("button view",WS_VISIABLE,CRect(15,15,20,10), this,1);



之后,在函数OnDraw


after, in the function OnDraw

_button.MoveWindow(rcBounds,TRUE);
pdc->FillRect(rcBounds,#color);
pdc->Ellipse(20,20,50,50);





但是,按钮显示的不是圆形按钮

可以帮助我

非常感谢



however, button is show not a round button
can help me
thank so much

推荐答案

所有魔术都通过一个重要的Windows API函数完成 SetWindowRgn

http:// msdn .microsoft.com / zh-CN / library / windows / desktop / dd145102%28v = vs.85%29.aspx [ ^ ]。



创建非矩形区域,并在已创建某个窗口的句柄时在某些HWND上调用此函数。这使得真正的非矩形窗口不仅在视觉上,而且可以通过鼠标命中观察到。不要把它与在DC剪辑区域上执行的技巧混在一起:它们只能提供一些视觉效果,但实际的窗口,通过鼠标命中测试,仍然是矩形的。



我找到了一本简短的手册,只是为了看看它涉及到什么: http://www.codeguru.com/cpp/wd/dislog/non-rectangulardialogs/article.php/c5037/Creating-Shaped-Windows-Using- Regions-with-Win32.htm [ ^ ]。



没有问题使用MFC进行操作,MFC与原始Windows API紧密结合并基于它。无论如何,控件的HWND窗口句柄总是可以访问。



-SA
All the magic is done via one important Windows API function SetWindowRgn:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd145102%28v=vs.85%29.aspx[^].

You create a non-rectangular region and call this function on some HWND when a handle of some window is already created. This make "real" non-rectangular window, not only visually, but observable via mouse hits. Don''t mix it up with tricks performed on DC clip regions: they only give some visual effect, but the actual window, by a mouse hit test, is still rectangular.

I found a short manual, just to see what''s involved: http://www.codeguru.com/cpp/w-d/dislog/non-rectangulardialogs/article.php/c5037/Creating-Shaped-Windows-Using-Regions-with-Win32.htm[^].

There is no a problem to do it with MFC, which is tightly coupled with raw Windows API and based on it. Anyway, HWND window handle for controls is always accessible.

—SA


这篇关于如何在ActiveX控件MFC中创建一个圆形按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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