{"id":99665,"date":"2018-09-06T07:00:00","date_gmt":"2018-09-06T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=99665"},"modified":"2019-03-13T00:29:34","modified_gmt":"2019-03-13T07:29:34","slug":"20180906-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20180906-00\/?p=99665","title":{"rendered":"What does it mean for a window to be Unicode?"},"content":{"rendered":"<p>The <code>Is&shy;Window&shy;Unicode<\/code> function reports whether the current window procedure expects Unicode window messages. What specifically does this mean? <\/p>\n<p>It means that messages like <code>WM_<\/code><code>CHAR<\/code> will report characters as Unicode code units rather than as ANSI code units. <\/p>\n<p>Okay, so what determines whether a window procedure receives Unicode messages? <\/p>\n<p>When a window is created, its initial window procedure comes from the class registration. If the class was registered with <code>Register&shy;Class[Ex]W<\/code>, then it is a Unicode window procedure; otherwise it was registered with <code>Register&shy;Class[Ex]A<\/code> and is an ANSI window procedure. <\/p>\n<p>If a window is subclassed with a function pointer, then the new window procedure is Unicode if it was set with <code>Set&shy;Window&shy;Long&shy;PtrW(GWLP_<\/code><code>WNDPROC)<\/code> and ANSI if it was set with <code>Set&shy;Window&shy;Long&shy;PtrA(GWLP_<\/code><code>WNDPROC)<\/code>. <\/p>\n<p>As we saw some time ago, <a HREF=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/\"><code>Get&shy;Window&shy;Long&shy;Ptr(GWLP_<\/code><code>WNDPROC)<\/code> returns a thunk<\/a> if you use the ANSI version but the current window procedure is Unicode, or vice versa. Suppose the window procedure is Unicode and you call <code>Get&shy;Window&shy;Long&shy;PtrA(GWLP_<\/code><code>WNDPROC)<\/code>. This will return you a thunk, and if you later set that thunk back as the window procedure with <code>Set&shy;Window&shy;Long&shy;PtrA(GWLP_<\/code><code>WNDPROC)<\/code>, then the original Unicode window procedure is restored, and the window is a Unicode window again. <\/p>\n<p>Note that calling <code>Set&shy;Window&shy;Long&shy;PtrA(GWLP_<\/code><code>WNDPROC)<\/code> can result in a window procedure that is Unicode. <\/p>\n<p>As a window message travels from one window procedure to another window procedure (via <code>Call&shy;Window&shy;Proc<\/code>), the character set may flip between Unicode and ANSI. The <code>Is&shy;Window&shy;Unicode<\/code> function tells you only about the window&#8217;s current window procedure. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The expected character set of the current window procedure.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-99665","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>The expected character set of the current window procedure.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=99665"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/99665\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=99665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=99665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=99665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}