При регистрации класса окна можно задать параметр cbWndExtra
который будет показывать сколько дополнительно памяти выделить каждому окну
cbWndExtra
Type: int
The number of extra bytes to allocate following the window instance. The system initializes the bytes to zero. If an application uses WNDCLASS to register a dialog box created by using the CLASS directive in the resource file, it must set this member to DLGWINDOWEXTRA.
Здесь в последнем абзаце сказано, что для доступа к этой памяти нужно использовать SetWindowLong
The SetWindowLong function copies a value to the extra memory. The GetWindowLong function retrieves a value from the extra memory. The cbWndExtra member of the WNDCLASSEX structure specifies the amount of extra window memory to allocate. An application that does not use the memory must initialize cbWndExtra to zero.
Но из самого описания SetWindowLong
я не пойму как к этой памяти добраться. Все, что я вижу, так это констатация того факта, что память выделяется
Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASSEX structure used with the RegisterClassEx function.
Так как получить указатель на эту память? Если я правильно понимаю, то GWL_USERDATA - это отдельный участок памяти размером sizeof(LONG_PTR)
и он не зависит от cbWndExtra