Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegisterClass failed: class already exits

Tags:

windows

winapi

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?

like image 802
user963241 Avatar asked Sep 03 '10 19:09

user963241


1 Answers

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.

like image 192
ChrisF Avatar answered Oct 17 '22 20:10

ChrisF