RegisterClass error: class is already completed

When I create a child window a 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 removed when the child window was destroyed:

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

It works if I comment on the outcome error. Does this mean that I no longer need to register the class?

+5
source share
2 answers

From the UnregisterClassdocumentation that states:

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

Indicates that destroying windows does not unregister the class.

+5
source

Yes, you should not register the class again.

This is from MSDN:

, , .

Update: , , .

+1

All Articles