首页 > 编程 > .NET > 正文

显示自定义动画鼠标或彩色图标(VB.net)

2024-07-10 13:00:43
字体:
来源:转载
供稿:网友
,欢迎访问网页设计爱好者web开发。 

'//
'//显示自定义动画鼠标或彩色图标
'//根据【孟子e章】的专栏c#代码 http://blog.csdn.net/net_lover/archive/2004/10/22/146575.aspx
'//

'imports system.runtime.interopservices
imports system.reflection
public class form1
    inherits system.windows.forms.form

#region " windows 窗体设计器生成的代码 "

    public sub new()
        mybase.new()

        '该调用是 windows 窗体设计器所必需的。
        initializecomponent()

        '在 initializecomponent() 调用之后添加任何初始化

    end sub

    '窗体重写 dispose 以清理组件列表。
    protected overloads overrides sub dispose(byval disposing as boolean)
        if disposing then
            if not (components is nothing) then
                components.dispose()
            end if
        end if
        mybase.dispose(disposing)
    end sub

    'windows 窗体设计器所必需的
    private components as system.componentmodel.icontainer

    '注意: 以下过程是 windows 窗体设计器所必需的
    '可以使用 windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    friend withevents savedlg as system.windows.forms.savefiledialog
    <system.diagnostics.debuggerstepthrough()> private sub initializecomponent()
        me.savedlg = new system.windows.forms.savefiledialog
        '
        'form1
        '
        me.autoscalebasesize = new system.drawing.size(6, 14)
        me.clientsize = new system.drawing.size(360, 213)
        me.name = "form1"
        me.text = "form1"

    end sub

#end region

    declare function loadcursorfromfile lib "user32" alias "loadcursorfromfilea" _
    (byval lpfilename as string) as intptr

    private sub form1_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load
        dim mycursor as new cursor(cursor.current.handle)
        'dinosau2.ani为windows自带的光标:
        dim colorcursorhandle as intptr = loadcursorfromfile("../dinosau2.ani")

        mycursor.gettype().invokemember("handle", bindingflags.public or _
        bindingflags.nonpublic or bindingflags.instance or bindingflags.setfield, _
        nothing, mycursor, new object() {colorcursorhandle}) '

        me.cursor = mycursor
    end sub

end class

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表