我想做一个圆形的按钮,但是在圆形外的地方也能响应事件,怎样使响应范围只在圆形中(WMP就是这样)?

解决方案 »

  1.   

    我有一个图形界面的程序,要的话,拿EMAIL来~~
      

  2.   

    用Create开头的一个API函数,绘制
    然后用另一个api函数将绘制的几部分合并
    实在抱歉,具体的函数名,忘了
      

  3.   

    Option ExplicitPrivate Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
    Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Sub Form_Resize()
    Const RGN_DIFF = 4Dim outer_rgn As Long
    Dim inner_rgn As Long
    Dim combined_rgn As Long
    Dim wid As Single
    Dim hgt As Single
    Dim border_width As Single
    Dim title_height As Single    If WindowState = vbMinimized Then Exit Sub
        
        ' Create the regions.
        wid = ScaleX(Width, vbTwips, vbPixels)
        hgt = ScaleY(Height, vbTwips, vbPixels)
        outer_rgn = CreateRectRgn(0, 0, wid, hgt)
        
        border_width = (wid - ScaleWidth) / 2
        title_height = hgt - border_width - ScaleHeight
        inner_rgn = CreateRectRgn( _
            wid * 0.25, hgt * 0.25, _
            wid * 0.75, hgt * 0.75)    ' Subtract the inner region from the outer.
        combined_rgn = CreateRectRgn(0, 0, 0, 0)
        CombineRgn combined_rgn, outer_rgn, _
            inner_rgn, RGN_DIFF
        
        ' Restrict the window to the region.
        SetWindowRgn hWnd, combined_rgn, True    DeleteObject combined_rgn
        DeleteObject inner_rgn
        DeleteObject outer_rgn
    End Sub
    这是一个中间带方洞的窗体,你改一改即可。
      

  4.   

    普通按钮,创建圆形区域后用 setwindowrgn设定这个圆形区域为按钮的窗体区域.用过setwindowrgn后不能再对按钮的区域做任何操作.
      

  5.   

    似乎在哪里见过椭圆按钮的源码,到Vbden/vbgood找找看
      

  6.   

    小弟很菜.有一个很笨拙的方法....
    要是你做的按钮不多的话.可以试一试.说起来也不是什么秘密.大家都知道.呵呵你可以用label控件或者配合画图控件做出鼠标move事件的显示状态....
    或者直接点:用picture控件.配合图片效果更为显著...
      

  7.   

    轻松搞掂按钮众多效果!
    看看效果:
    http://www.oklong.net/sdbutton.htm
    下载吧:http://www.oklong.net/download/sdflatbtn.ocx