Why is the SetWindowLong function made in two versions: A and W?

Participant 41 Reputation points
2021-01-03T14:02:52.113+00:00

Why is the SetWindowLong function made in two versions: A and W?
This function does not use text, why is the version made for the A and for the W?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,585 questions
0 comments No comments
{count} votes

Accepted answer
  1. RLWA32 45,236 Reputation points
    2021-01-03T15:22:15.75+00:00

    Window messages are not always identical for unicode/non-unicode builds. So a window procedure handles one or the other. For example, there are A/W versions for DispatchMessage.

    Subclassing using SetWindowLong (32-bit) /SetWindowLongPtr (64-bit) needs to address these differences. I think this is made clear by the discussion here - What are these strange values returned from GWLP_WNDPROC?

    2 people found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. David Lowndes 4,711 Reputation points
    2021-01-03T15:15:46.577+00:00

    Almost all Windows APIs that have string parameters have both A & W versions.
    Windows was originally only single/multi-byte characters, but when Windows NT adopted Unicode, it had both A & W versions to accommodate old MBCS applications.
    I believe that under NT (and later) the A versions convert MBCS to Unicode and call the W versions.

    0 comments No comments

  2. Participant 41 Reputation points
    2021-01-03T15:19:47.613+00:00

    DavidLowndes-6766, the SetWindowLong function has no string parameters. All parameters are numeric.

    0 comments No comments

  3. Participant 41 Reputation points
    2021-01-03T17:03:46.797+00:00

    RLWA32, It is clear, it means for something it is needed.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.