欢迎光临
我们一直在努力

ToolBar的模样自己画(四)-.NET教程,评论及其它

建站超值云服务器,限时71元/月

 

几个gdi绘图函数功能的封装,有一定通用性,有些是我平时自己就喜欢用的模块。

private function newmyhdc(dhdc as long, w as long, h as long, optional bm as long) as memhdc
    with newmyhdc
        .hdc = createcompatibledc(dhdc)
        if bm = 0 then
            .bmp = createcompatiblebitmap(dhdc, w, h)
        else
            .bmp = bm
        end if
        .obm = selectobject(.hdc, .bmp)
    end with
end function
private function delmyhdc(myhdc as memhdc, optional nobmp as boolean) as memhdc
    with myhdc
        if .hdc <> 0 then
            selectobject .hdc, .obm
            if nobmp = false then deleteobject .bmp
            deletedc .hdc
        end if
    end with
end function
private sub drawploy3(hdc as long, rcdrop as rect, up as boolean)
    画下拉菜单的小三角形
    dim ploy(2) as pointl
    dim hbrush as long, holdbrush as long
    dim hpen as long, holdpen as long
    with rcdrop
        if up then
            .left = .left – 1
            .right = .right – 1
            .top = .top – 1
            .bottom = .bottom – 1
            hbrush = createsolidbrush(m_lngtexthicolor)
            hpen = createpen(ps_solid, 1, m_lngtexthicolor)
        else
            hbrush = createsolidbrush(m_lngtextcolor)
            hpen = createpen(ps_solid, 1, m_lngtextcolor)
        end if
        holdpen = selectobject(hdc, hpen)
        holdbrush = selectobject(hdc, hbrush)
        ploy(0).x = (.left + .right – 5) \ 2
        ploy(0).y = (.top + .bottom) \ 2
        ploy(1).x = ploy(0).x + 4
        ploy(1).y = ploy(0).y
        ploy(2).x = ploy(0).x + 2
        ploy(2).y = ploy(0).y + 2
    end with
    polygon hdc, ploy(0), 3
    selectobject hdc, holdpen
    selectobject hdc, holdbrush
    deleteobject hpen
    deleteobject hbrush
end sub
private sub geticonsize(hicon as long)
    取得图像列表框图标的大小
    dim bm as bitmap, bi as iconinfo
    geticoninfo hicon, bi
    getobj bi.hbmcolor, len(bm), bm
    deleteobject bi.hbmcolor
    deleteobject bi.hbmmask
    mlngiconwidth = bm.bmwidth
    mlngiconheight = bm.bmheight
end sub
private sub drawrect(hdc as long, rc as rect, state as long, optional isdrop as boolean)
    dim hpen as long
    if (state > 0 or isdrop) and m_lngbrdstyle > 3 then
        hpen = createpen(ps_solid, 1, m_lngbrdcolor)
        if isdrop then rc.left = rc.left – 1
        framerect hdc, rc, hpen
        if isdrop then rc.left = rc.left + 1
        deleteobject hpen
        exit sub
    end if
    select case state
        case 0  普通状态
            select case m_lngbrdstyle
                case 1
                    if isdrop then drawedge hdc, rc, bdr_outer, bf_rect or bf_flat
                case 2
                    drawedge hdc, rc, bdr_raisedouter, bf_rect
                case 3
                    drawedge hdc, rc, edge_raised, bf_rect
            end select
        case 1  高亮状态
            select case m_lngbrdstyle
                case 0
                    drawedge hdc, rc, bdr_raisedinner, bf_rect
                case 1, 2, 3
                    drawedge hdc, rc, edge_raised, bf_rect
            end select
        case 2  按下状态
            select case m_lngbrdstyle
                case 0
                    drawedge hdc, rc, bdr_sunkenouter, bf_rect
                case 1
                    drawedge hdc, rc, bdr_sunkeninner, bf_rect
                case 2, 3
                    drawedge hdc, rc, edge_sunken, bf_rect
            end select
    end select
end sub

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ToolBar的模样自己画(四)-.NET教程,评论及其它
分享到: 更多 (0)