I read the documentation about CreateWindowEx
CreateWindowExA
CreateWindowExW
and they all are seem to be identical to each other.
if there is not difference why they all even exist?
CodePudding user response:
Firstly, CreateWindowEx
is a macro, which expands to either CreateWindowExA
or CreateWindowExW
based on whether UNICODE
has been defined. Many WinAPI functions work this way: they have a macro which switches between the appropriate functions based on UNICODE
, then have the A
and W
versions.
Now, the difference with the A
and W
versions is fairly simple.
The "A" version handles text based on Windows code pages, while the "W" version handles Unicode text.
-- Source: https://docs.microsoft.com/en-us/windows/win32/intl/code-pages
From Microsoft documentation:
The winuser.h header defines CreateWindowEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.