Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can the lpClassName parameter of CreateWindowEx be optional

Tags:

windows

winapi

According to MSDN, the lpClassName parameter of CreateWindowEx is optional.

lpClassName [in, optional]

However, the documentation makes no mention of what it means to pass NULL. What's more, if NULL is passed, then there is no way for the window manager to find a window procedure for the new window.

So, is the documentation wrong? Or is it correct and there is some scenario where NULL is a valid value for lpClassName?

like image 382
David Heffernan Avatar asked Oct 02 '22 03:10

David Heffernan


1 Answers

The lpClassName parameter to CreateWindowEx is declared to be an LPCTSTR but it can actually be either a pointer to a string or a class atom returned by RegisterClass or RegisterClassEx.

Ideally the type annotation would specify precisely what's allowed for this parameter, but I guess the annotation language doesn't have a way of describing the types of things that don't match their declared type.

The best they could do is declare it as optional to indicate that the string might not be valid.

like image 144
arx Avatar answered Oct 09 '22 02:10

arx