首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Win32Exception -类已存在

Win32Exception -类已存在
EN

Stack Overflow用户
提问于 2012-11-19 11:59:20
回答 1查看 707关注 0票数 1

我在产品代码中得到了Win32Exception -“类已经存在”。在我的演示项目中,相同的代码可以正常工作。会有什么问题呢?

代码语言:javascript
复制
Private Class MyClientWindow
    Inherits NativeWindow

    Public Sub New(ByVal parent As Form)

        Dim cp As CreateParams = New CreateParams()

        ' Fill in the CreateParams details.
        cp.Caption = "Parent Static Window"
        cp.ClassName = "Static"

        ' Set the position on the form
        cp.X = 0
        cp.Y = 0
        cp.Height = 0
        cp.Width = 0

        ' Specify the form as the parent.
        cp.Parent = parent.Handle

        ' Create as a child of the specified parent
        cp.Style = WS_CHILD Or WS_VISIBLE

        ' Create the actual window 
        Me.CreateHandle(cp)
    End Sub

End Class

System.ComponentModel.Win32Exception was unhandled by user code. 
ErrorCode=-2147467259,     
Message=Class already exists, 
NativeErrorCode=1410, 
StackTrace:
at System.Windows.Forms.NativeWindow.WindowClass.RegisterClass()
at System.Windows.Forms.NativeWindow.WindowClass.Create(String className, Int32 classStyle)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-21 10:59:44

将类名称从"Static“更改为"STATIC”seams才能工作。我在CreateParams.ClassName Property上找到了关于这方面的评论

若要从标准按钮控件派生,请将此ClassName属性设置为" Button "

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13447490

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档