Search code examples
winapiwindow

cbClsExtra and cbWndExtra


I want more detailed information about cbClsExtra and cbWndExtra WNDCLASSEX members that are used in RegisterClassEx winapi.

MSDN says that this members can be used to set size of extra bytes that will be allocated for class and for each window instance accordingly.

MSDN says

The system initializes the bytes to zero.

1) Does this mean that bytes are initialized with zero value or system allocates zero (none) bytes by default?

2) The most important question is how to use this extra bytes (provide examples please with winapi used) and how they are used most common?

Thanks in advance.


Solution

  • Does this mean that bytes are initialized with zero value or system allocates zero (none) bytes by default?

    initialization is always done on variables, so it means to sets the allocated extra memory to 0.

    The most important question is how to use this extra bytes (provide examples please with winapi used) and how they are used most common?

    The only way to do this is via the GetClassLongPtr and GetWindowLongPtr functions, these functions are simple enough to not need examples (call Get* to get the value, and Set* set set the value, passing either the class ATOM or window HWND).