如何使用Visual C创建在Win32 API的一个圆形/圆形按钮++ [英] how to create a round/circular button in win32 API using visual c++

查看:834
本文介绍了如何使用Visual C创建在Win32 API的一个圆形/圆形按钮++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个窗口(WIN32 API)在Visual C ++应用程序。我不使用MFC。我要创建位图图像圆/圆形按钮。我的应用程序有一个skined视图。任何一个可以帮助我实现这个任务。先谢谢了。

I have a Window (win32 API) Application in visual c++. I am not using MFC. I have to create a round/circular button with bitmap image. My application have a skined view. Can any one help me out in achieving this task. Thanks in advance.

推荐答案

按钮的窗口。您可以创建一个CreateWindow的或函数CreateWindowEx呼叫按钮:

Buttons are windows. You can create a button with the CreateWindow or CreateWindowEx call:

-http://msdn.microsoft.com/en-us/library/ms632680(VS.85)的.aspx

-http://msdn.microsoft.com/en-us/library/ms632680(VS.85).aspx

当您创建按钮,窗口,确保你通过BS_OWNDERDRAW风格:

When you create your button window ensure that you pass the BS_OWNDERDRAW style:

-http://msdn.microsoft.com/en-us/library/bb775951(VS.85)的.aspx

-http://msdn.microsoft.com/en-us/library/bb775951(VS.85).aspx

这将告诉按钮WM_DRAWITEM消息发送到您的按钮'WNDPROC:

That will tell the button to send WM_DRAWITEM messages to your buttons' WNDPROC:

-http://msdn.microsoft.com/en-us/library/bb775923(V = VS.85)的.aspx

-http://msdn.microsoft.com/en-us/library/bb775923(v=VS.85).aspx

在您的按钮'WNDPROC你会处理WM_DRAWITEM消息和油漆根据在DRAWITEMSTRUCT的信息您收到的按钮在lParam中的指针。

In your buttons' WNDPROC you would handle the WM_DRAWITEM message and paint your button according to the information in the DRAWITEMSTRUCT received as a pointer in lParam.

要呈现一个位图任何东西,但你长方形需要提供1位掩码位图的大小,你希望呈现按钮所处的位图一样。该位掩码有,你想在你的按钮位图的像素在屏幕上设定的位。不显示在按钮位图的像素必须是黑色。 BITBLT您的掩码位图使用AND运算符,然后在屏幕上或您的按钮位图。当然,你需要考虑的各种按钮状态(通常是一个按钮只有两种状态。)

To render a bitmap as anything but rectangular you will need to provide a 1-bit bitmask bitmap the same size as the bitmap you wish to render for your button. The bitmask has bits set where you want the pixels in your button bitmap to be set on the screen. The pixels in your button bitmap that do not display need to be black. Bitblt your bitmask bitmap to the screen with the AND operator then OR your button bitmap. Of course you will need to account for the various button states (normally a push button is only two states.)

我可能混合在上面的解释黑/白或设置/取消位,但和/或按位(SRCAND / SRCPAINT)光栅操作是您要acheive怎样才是正确的操作。

I may have mixed the black/white or set/unset bits in the explanation above, but the AND / OR bitwise (SRCAND/SRCPAINT) Raster Operations are the correct operations for what you are trying to acheive.

-http://msdn.microsoft.com/en-us/library/aa930997.aspx

-http://msdn.microsoft.com/en-us/library/aa930997.aspx

希望有所帮助。

这篇关于如何使用Visual C创建在Win32 API的一个圆形/圆形按钮++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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