Let's learn winapi (14)

3 Name: Anonymous Techie : 2021-11-09 07:45 ID:Heaven

Learned that there are very similar functions in winapi, SetWindowLong and SetWindowLongPtr. SetWindowLong is the older one, but it works only with long (32-bit) numbers, and SetWindowLongPtr works with 32-bit numbers on 32-bit systems and 64-bit numbers on 64-bit systems. Actually, header looks something like that:

#ifdef _WIN64
...
#else
#define SetWindowLongPtrA SetWindowLongA
#define SetWindowLongPtrW SetWindowLongW
#endif

and it is literally an alias on 32bit computers.

I fear that this function alone may cause my program to not work correctly, if I run 32-bit program on 64-bit computer. I have code like this

edit_procedure_old = (WNDPROC)SetWindowLong(hEdit, GWL_WNDPROC, (addr)edit_procedure);

This will probably return garbage if the return value doesn't fit in 32 bits. Microsoft probably worked around it by placing all control procedures in a lower address, but I have no idea if they actually did it or not.

I think I will just make my own control instead, I don't like the default one anyway. Then I wouldn't need SetWindowLong.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: