Description Error in MSDN about SETWINDOWLONGPTR and GETWINDOWLONGPTR functions

Source: Internet
Author: User

1 History of these two functions

Setwindowlongptr () and getwindowlongptr () are used to access specific blocks of data in the Window object, which is also used to replace SetWindowLong () and GetWindowLong (), which are obsolete APIs. The reason why the API is obsolete without the PTR end is that it cannot accommodate 64-bit platforms, and the problem with MSDN that this article points out is that it is not updated to accommodate the 64 platform.

2 where the error is

The following is an excerpt from the official MSDN website (January 13, 2015).

long_ptr WINAPI setwindowlongptr (_in_  hwnd HWND, _in_  int 
NIndex, _in_  long_ptr dwnewlong); 
nIndex   [in]

Type: int

The zero-based offset to the value to is set. Valid values is in the range zero through the number of bytes of extra window memory, minus the size of a integer. To set any other value, specify one of the following values.


To access the extra data for the Window object, the two functions must request additional bytes at registerclass () by Wndclass.cbwndextra. Parameter nindex refers to the reading and writing of sizeof (long_ptr) bytes from the nindex byte of an additional block of data when the function is used to read and write to the Window object. So whether it is legal depends on whether sizeof (LONG_PTR) bytes starting with nindex are all in the additional chunks of the form object. That is, 0 to (extra window memory)-sizeof (LONG_PTR). MSDN, however, simply writes it as a 0 to (extra window memory)-sizeof (int).

For 32-bit programs, sizeof (long_ptr) = = sizeof (int), the MSDN description is no problem. However, for a 64-bit program, sizeof (LONG_PTR) = 8, and sizeof (int) = 4, the two are no longer equal.

Perhaps the word integer in MSDN here refers to a platform-dependent integer, but most programmers will match the integer in this and the C + + language with Int. In this way, it will still cause a little trouble.

??

Description Error in MSDN about SETWINDOWLONGPTR and GETWINDOWLONGPTR functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.