RegisterClass 失败:类已经存在 [英] RegisterClass failed: class already exits

查看:45
本文介绍了RegisterClass 失败:类已经存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我第二次创建子窗口时,

When I create a child window for the second time,

if (!::RegisterClass(&hwClass))
{
    throw std::runtime_error("RegisterClass failed!");
}

它抛出一个异常,该类已经存在.但是子窗口类在子窗口被销毁时被删除:

It throws an exception that the class already exists. but the child window class was deleted when the child window was destroyed at:

WM_DESTROY:
{
   delete this;  //destroy child class
}

如果我评论预期错误,它会起作用.这是否意味着我不需要再次注册课程?

It works if I comment the expection error. does that mean I don't need to register a class again?

推荐答案

来自 UnregisterClass 文档,其中指出:

From the UnregisterClass documentation, which states:

在调用此函数之前,应用程序必须销毁使用指定类创建的所有窗口.

Before calling this function, an application must destroy all windows created with the specified class.

表示销毁窗口不会取消注册类.

Indicates that destroying the windows doesn't unregister the class.

这篇关于RegisterClass 失败:类已经存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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