{"id":13743,"date":"2010-06-11T07:00:00","date_gmt":"2010-06-11T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/06\/11\/how-do-i-indicate-that-i-want-my-window-to-follow-right-to-left-layout-rules\/"},"modified":"2010-06-11T07:00:00","modified_gmt":"2010-06-11T07:00:00","slug":"how-do-i-indicate-that-i-want-my-window-to-follow-right-to-left-layout-rules","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20100611-00\/?p=13743","title":{"rendered":"How do I indicate that I want my window to follow right-to-left layout rules?"},"content":{"rendered":"<p>There are many ways, depending on how wide a scope you want.\n If there is one specific window that you want to follow right-to-left layout rules, then you pass the <code>WS_EX_LAYOUT&shy;RTL<\/code> extended window style when you create the window. This extended style is inherited by child windows, so once you set a top-level window to have right-to-left layout, all child windows will have it, too. To block the <code>WS_EX_LAYOUT&shy;RTL<\/code> extended style from being inherited by child windows, pass the <code>WS_EX_NO&shy;INHERIT&shy;LAYOUT<\/code> style when you create the parent window.\n <b>Sidebar<\/b>: If you&#8217;re calling the <code>Message&shy;Box<\/code> function, then you don&#8217;t directly control the styles of the top-level window. But there&#8217;s a weird back-channel way to specify that you want the message box dialog to have the <code>WS_EX_LAYOUT&shy;RTL<\/code> extended style: <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms645505(VS.85).aspx\"> Begin the <code>lpText<\/code> string with two U+200F characters<\/a>. Then again, instead of <code>Message&shy;Box<\/code> you should be using the <code>Task&shy;Dialog&shy;Indirect<\/code> function which not only lets you customize the text on the buttons, but also lets you pass the <code>TDF_RTL_LAYOUT<\/code> flag to indicate that you want the dialog to be laid out according to RTL rules. (And as an aid to porting, the <code>Task&shy;Dialog<\/code> and <code>Task&shy;Dialog&shy;Indirect<\/code> functions implicitly turn on the <code>TDF_RTL_LAYOUT<\/code> flag if they find that <code>pszContent<\/code> is a pointer to a string&mdash;not a <code>MAKE&shy;INT&shy;RESOURCE<\/code>&mdash;which begins with two U+200F characters.) <b>End sidebar<\/b>.&sup1;\n If you want right-to-left layout rules to apply to all top-level windows in your process, you have two choices. You can either do it programmatically or declaratively. (Similar to how you can specify DPI-awareness either <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms633543.aspx\"> programmatically or declaratively<\/a>.)\n The programmatic way is to call <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms633543.aspx\"> <code>Set&shy;Process&shy;Default&shy;Layout(LAYOUT_RTL)<\/code><\/a> from your application. The declarative way is to  <a href=\"http:\/\/msdn.microsoft.com\/en-us\/goglobal\/bb688119.aspx#EDC\"> insert two left-to-right marks (U+200E) at the beginning of the <i>File&shy;Description<\/i> version resource string of the executable<\/a>.\n Note that the caveats which apply to changing the process DPI awareness programmatically also apply to changing the default process layout programmatically: Code which calls <code>Get&shy;Process&shy;Default&shy;Layout<\/code> will see the default at the time of the call, even if some code later on calls <code>Set&shy;Process&shy;Default&shy;Layout<\/code> to change it.\n Note also that it really is the application&#8217;s call whether its default layout is left-to-right or right-to-left. A DLL shouldn&#8217;t decide on its own to change the process default layout, at least not without co&ouml;peration from that process. If you are a DLL and you want to create a specific window with right-to-left layout, you should use the <code>WS_EX_LAYOUT&shy;RTL<\/code> method so that your decision applies only to your DLL&#8217;s windows. (Otherwise you&#8217;re <a href=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2008\/12\/11\/9193695.aspx\"> using a global setting to manage a local problem<\/a>.)\n <b>Bonus chatter<\/b>: Why isn&#8217;t the default layout specified in the manifest like DPI-awareness? Because RTL support was added in Windows&nbsp;2000, which predated application manifests by several years. If the feature were invented today, the manifest would be a much better place for declaring it.\n <b>Update<\/b>\n &sup1; Commenter SCB pointed out that there is indeed a flag to specify that you want RTL layout on your message box: <code>MB_RTLREADING<\/code>. If that flag exists, then why also have the U+200F back-channel?<\/p>\n<p> Answer: So that translators can mark a string as requiring RTL treatment without having to go back and make code changes. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many ways, depending on how wide a scope you want. If there is one specific window that you want to follow right-to-left layout rules, then you pass the WS_EX_LAYOUT&shy;RTL extended window style when you create the window. This extended style is inherited by child windows, so once you set a top-level window to [&hellip;]<\/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-13743","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>There are many ways, depending on how wide a scope you want. If there is one specific window that you want to follow right-to-left layout rules, then you pass the WS_EX_LAYOUT&shy;RTL extended window style when you create the window. This extended style is inherited by child windows, so once you set a top-level window to [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/13743","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=13743"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/13743\/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=13743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=13743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=13743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}