Windows controls can be Unicode or ANSI, my question is what does it mean for a control to be in one of these two categories?
Is it the following (if I assume that the control is Unicode):
- The buffer for the control is in Unicode.
- WM_CHAR messages are sent as Unicode (e.g. 'A' is sent as 0x0041 and not as 0x41).
It means the window messages sent to the window procedure will be the ANSI or Unicode versions. For example a Unicode window will receive a
CREATESTRUCTW
inWM_CREATE
, while the ANSI windows will receive aCREATESTRUCTA
.This will apply to almost every window message containing string data.
Windows will internally marshal data accordingly. For example if you call the ANSI
SendMessageA(WM_SETTEXT, ...)
to a Unicode window, the window will receiveWM_SETTEXT
with a Unicode string.A window will be Unicode or ANSI depending on whether its class was registered with
RegisterClassExA
orRegisterClassExW
. You can test if a window is Unicode or not by callingIsWindowUnicode
.Some info about common controls, because that seems to be what you're talking about.
First of all, there is no problem with an ANSI window being the parent of a Unicode window. Also keep in mind that "controls" are just windows.
Common controls are always Unicode. The messages they receive will be in the native, Unicode, format. Of course you won't have visibility to this because it's all internal to the OS (exception: if you subclass a common control).
The messages you are typically dealing with will be sent to your window in the form of
WM_COMMAND
orWM_NOTIFY
. These messages are sent from common controls to their parent window (your window). They will respect your window being Unicode or ANSI like this:WM_NOTIFYFORMAT
message to ask if you prefer messages to be received in ANSI or Unicode (despite your window being Unicode or ANSI).IsWindowUnicode
to determine.So basically, you never need to know if a common control is Unicode or not, because 1) it always is, and 2) this question is only relevant as a matter of handling messages, which is internal to Windows, not your responsibility.
Your responsibility is to handle notifications coming from common controls to your own window. In this case the Unicode/ANSI-ness of your own window is all that matters.