SetWindowLongPtr using DialogBoxParam?

While I was writing a C ++ program using the Win32 API, which would display a dialog box and then listen to the messages it created. At some point, I was interested in linking a piece of data with a dialog box. If I manually created a window and added a proc window, I would simply use SetWindowLongPtrit to set a GWLP_USERDATApointer to the associated data in the field . However, in this case, I created and displayed a window with DialogBoxParam, and it is unclear whether this function linked this data to its internal state. Since there was no description in MSDN of what would happen in this case, I decided to use a different approach to solve the problem.

My question is this: is it safe to use SetWindowLongPtrvalues ​​to overwrite GWLP_USERDATAin the window created DialogBoxParam?

+3
source share
1 answer

Technically, GWLP_USERDATA is designed to use the window class (base in the case of a subclass) to use. Since dialogs are a ready-made class, GWLP_USERDATA is intended for internal use, so dialogs provide the DWLP_USER field for use in using DialogProc.

However, be that as it may, all of the internal window classes supplied by Microsoft - EDIT, BUTTON, Dialog, etc., do not and cannot use GWLP_USERDATA for application compatibility purposes, therefore they are effectively available for using the application.

+2
source

Source: https://habr.com/ru/post/1783805/


All Articles