{"id":35953,"date":"2005-04-07T09:00:00","date_gmt":"2005-04-07T09:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/04\/07\/the-dialog-manager-part-8-custom-navigation-in-dialog-boxes\/"},"modified":"2005-04-07T09:00:00","modified_gmt":"2005-04-07T09:00:00","slug":"the-dialog-manager-part-8-custom-navigation-in-dialog-boxes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050407-00\/?p=35953","title":{"rendered":"The dialog manager, part 8: Custom navigation in dialog boxes"},"content":{"rendered":"<p>\nSome dialog boxes\ncontain custom navigation that goes beyond\nwhat\n<a HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/winui\/winui\/windowsuserinterface\/windowing\/dialogboxes\/dialogboxreference\/dialogboxfunctions\/isdialogmessage.asp\">\nthe <code>IsDialogMessage<\/code> function<\/a>\nprovides.\nFor example,\n<a HREF=\"http:\/\/msdn.microsoft.com\/library\/en-us\/shellcc\/platform\/commctls\/propsheet\/propsheet.asp\">\nproperty sheets<\/a>\nuse Ctrl+Tab and Ctrl+Shift+Tab to change pages within\nthe property sheet.\nRemember\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/04\/01\/404531.aspx\">\nthe core of the dialog loop<\/a>:<\/p>\n<pre>\nwhile (&lt;dialog still active&gt; &amp;&amp;\n       GetMessage(&amp;msg, NULL, 0, 0, 0)) {\n if (!IsDialogMessage(hdlg, &amp;msg)) {\n  TranslateMessage(&amp;msg);\n  DispatchMessage(&amp;msg);\n }\n}\n<\/pre>\n<p>\n(Or\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/04\/06\/405827.aspx\">\nthe modified version we created in part&nbsp;7<\/a>.)\n<\/p>\n<p>\nTo add custom navigation, just stick it in before\ncalling IsDialogMessage.\n<\/p>\n<pre>\nwhile (&lt;dialog still active&gt; &amp;&amp;\n       GetMessage(&amp;msg, NULL, 0, 0, 0)) {\n <font COLOR=\"blue\">if (msg.message == WM_KEYDOWN &amp;&amp;\n     msg.wParam == VK_TAB &amp;&amp;\n     GetKeyState(VK_CONTROL) &lt; 0) {\n  ... do custom navigation ...\n } else<\/font> if (!IsDialogMessage(hdlg, &amp;msg)) {\n  TranslateMessage(&amp;msg);\n  DispatchMessage(&amp;msg);\n }\n}\n<\/pre>\n<p>\nAfter retrieving a message, we check whether it was Ctrl+Tab\nbefore dispatching it or indeed even before letting\n<code>IsDialogMessage<\/code> see it.\nIf so, then treat it as a navigation key.\n<\/p>\n<p>\nNote that if you intend to have modeless dialogs controlled\nby this message loop, then your test needs to be a little\nmore focused, because you don&#8217;t want to pick off keyboard\nnavigation keys destined for the modeless dialog.\n<\/p>\n<pre>\nwhile (&lt;dialog still active&gt; &amp;&amp;\n       GetMessage(&amp;msg, NULL, 0, 0, 0)) {\n if (<font COLOR=\"blue\">(hdlg == msg.hwnd || IsChild(hdlg, msg.hwnd)) &amp;&amp;<\/font>\n     msg.message == WM_KEYDOWN &amp;&amp;\n     msg.wParam == VK_TAB &amp;&amp;\n     GetKeyState(VK_CONTROL) &lt; 0) {\n  ... do custom navigation ...\n } else if (!IsDialogMessage(hdlg, &amp;msg)) {\n  TranslateMessage(&amp;msg);\n  DispatchMessage(&amp;msg);\n }\n}\n<\/pre>\n<p>\nNext time, we&#8217;ll see another way of accomplishing this same task.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some dialog boxes contain custom navigation that goes beyond what the IsDialogMessage function provides. For example, property sheets use Ctrl+Tab and Ctrl+Shift+Tab to change pages within the property sheet. Remember the core of the dialog loop: while (&lt;dialog still active&gt; &amp;&amp; GetMessage(&amp;msg, NULL, 0, 0, 0)) { if (!IsDialogMessage(hdlg, &amp;msg)) { TranslateMessage(&amp;msg); DispatchMessage(&amp;msg); } } [&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-35953","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Some dialog boxes contain custom navigation that goes beyond what the IsDialogMessage function provides. For example, property sheets use Ctrl+Tab and Ctrl+Shift+Tab to change pages within the property sheet. Remember the core of the dialog loop: while (&lt;dialog still active&gt; &amp;&amp; GetMessage(&amp;msg, NULL, 0, 0, 0)) { if (!IsDialogMessage(hdlg, &amp;msg)) { TranslateMessage(&amp;msg); DispatchMessage(&amp;msg); } } [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/35953","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=35953"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/35953\/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=35953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=35953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=35953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}