{"id":6173,"date":"2012-11-05T07:00:00","date_gmt":"2012-11-05T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2012\/11\/05\/how-do-i-get-the-tabbed-dialog-effect-on-my-own-custom-tabbed-dialog\/"},"modified":"2012-11-05T07:00:00","modified_gmt":"2012-11-05T07:00:00","slug":"how-do-i-get-the-tabbed-dialog-effect-on-my-own-custom-tabbed-dialog","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20121105-00\/?p=6173","title":{"rendered":"How do I get the tabbed dialog effect on my own custom tabbed dialog?"},"content":{"rendered":"<p>\nCJ observed that the standard tabbed dialogs provide\nan effect on the tab pages and want to know\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2010\/04\/08\/9992117.aspx#9992799\">\nhow to get the tabbed dialog effect on custom dialogs<\/a>.\nfds242 noted this as well and wanted to know\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2010\/07\/20\/10040074.aspx#10040447\">\nwhy the automatic tabbed dialog effect doesn&#8217;t kick in\nuntil you put a static control on the child dialog box<\/a>.\n<\/p>\n<p>\nLet&#8217;s look at the first question first.\nTo get the tabbed dialog effect, you can call\n<code>Enable&shy;Theme&shy;Dialog&shy;Texture<\/code> with the\n<code>ETDT_ENABLE&shy;TAB<\/code> flag.\nThe best time to do this is in the\n<code>WM_INIT&shy;DIALOG<\/code> handler,\nbut you can also do it immediately\nafter the dialog has been created.\n(Basically, you want to do this before the dialog paints\nfor the first time, so as to avoid flicker.)\n<\/p>\n<p>\nHere&#8217;s a sample program that shows a dummy dialog with the\ntabbed dialog texture enabled.\n<\/p>\n<pre>\n\/\/ Hereby incorporated by reference:\n\/\/ dialog template and DlgProc function from <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2005\/08\/04\/447654.aspx\">this sample program<\/a>\n\/\/ Comctl32 version 6 manifest from <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2007\/05\/31\/2995284.aspx\">this sample program<\/a>\nint WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev,\n                   LPSTR lpCmdLine, int nShowCmd)\n{\n    return DialogBox(hinst, MAKEINTRESOURCE(1), 0, DlgProc);\n}\n<\/pre>\n<p>\nIf you run this program, you get the expected dialog box\nwithout the tabbed dialog effect.\nBut you can turn on the effect by calling the\n<code>Enable&shy;Theme&shy;Dialog&shy;Texture<\/code> function:\n<\/p>\n<pre>\n#include &lt;uxtheme.h&gt;\n case WM_INITDIALOG:\n  CheckRadioButton(hdlg, 100, 102, 100);\n  <font COLOR=\"blue\">EnableThemeDialogTexture(hdlg, ETDT_ENABLETAB);<\/font>\n  return TRUE;\n<\/pre>\n<p>\nNow, when you run the program, you get the tabbed dialog effect.\nIt looks kind of weird when it&#8217;s not in a tabbed dialog,\nbut presumably you&#8217;re going to put this dialog inside your own\ncustom tabbed dialog control, so everything will look right\nwhen it&#8217;s all finished.\n<\/p>\n<p>\nNow the second half of the question:\nWhy doesn&#8217;t the automatic tabbed dialog effect kick in\nuntil you put a static control on the child dialog box?\n<\/p>\n<p>\nIf you look closely at the\n<code>ETDT_ENABLE&shy;TAB<\/code> flag,\nyou&#8217;ll see that it&#8217;s really two flags:\n<code>ETDT_USE&shy;TAB&shy;TEXTURE<\/code> and\n<code>ETDT_ENABLE<\/code>.\nThe first flag says,\n&#8220;I would like to get the tab texture, if enabled&#8221;;\nthe second flag says &#8220;Enable it.&#8221;\nIn other words, in order to get the tab texture, the\ntab texture needs to be both <i>used<\/i> and <i>enabled<\/i>.\n<\/p>\n<p>\nOriginally,\n<code>ETDT_ENABLE&shy;TAB<\/code> was just a single bit.\nSetting the bit turned on the tab texture.\nBut it turns out that some programs didn&#8217;t look good with\nthe tab texture,\nand the common reason was that they created a dialog\nwith no standard controls at all and then did custom drawing all over it.\nTherefore, the algorithm for enabling the tab texture\nwas changed to the two-step version.\nThe property sheet manager turned on the\n<code>ETDT_USE&shy;TAB&shy;TEXTURE<\/code> flag,\nand the button and static controls turned on the\n<code>ETDT_ENABLE<\/code> flag.\nTherefore, if your property sheet page has a button or a static,\nthe second bit got turned on, and the tab texture became visible.\nOn the other hand, if you didn&#8217;t have any buttons or statics,\nthen the assumption is that you&#8217;re one of those programs that\ndoes custom dialog drawing, and the tab texture remains disabled.\n<\/p>\n<p>\nLet&#8217;s watch it in action:\n<\/p>\n<pre>\n1 DIALOGEX 32, 32, 200, 76\nSTYLE DS_MODALFRAME\nCAPTION \"Sample\"\nFONT 8, \"MS Shell Dlg\"\nBEGIN\n    \/\/ nothing!\nEND\nINT_PTR CALLBACK DlgProc(HWND hdlg, UINT uMsg,\n                         WPARAM wParam, LPARAM lParam)\n{\n switch (uMsg) {\n case WM_INITDIALOG:\n  return TRUE;\n }\n return FALSE;\n}\nint WINAPI WinMain(HINSTANCE hinst, HINSTANCE hinstPrev,\n                   LPSTR lpCmdLine, int nShowCmd)\n{\n PROPSHEETPAGE psp = { sizeof(psp) };\n psp.hInstance = hinst;\n psp.pszTemplate = MAKEINTRESOURCE(1);\n psp.pfnDlgProc = DlgProc2;\n PROPSHEETHEADER psh = { sizeof(psh) };\n psh.dwFlags = PSH_PROPSHEETPAGE;\n psh.nPages = 1;\n psh.ppsp = &amp;psp;\n return PropertySheet(&amp;psh);\n}\n<\/pre>\n<p>\nIf you run this program, you&#8217;ll see that there is no\ntabbed dialog texture.\nAs we saw earlier, the reason there is no tabbed dialog texture\nis that the system is afraid that you&#8217;re one of those programs\nthat custom-draws their dialog boxes, so it&#8217;s staying out of your way.\n<\/p>\n<p>\nBut add this line:\n<\/p>\n<pre>\n case WM_INITDIALOG:\n  <font COLOR=\"blue\">EnableThemeDialogTexture(hdlg, ETDT_ENABLETAB);<\/font>\n  return TRUE;\n<\/pre>\n<p>\nThe property sheet manager was afraid to give you that texture\nby default,\nbut adding that line just adds the texture manually.\n<\/p>\n<p>\nThis time, when you run the program,\nyou get the happy tabbed dialog texture\nbecause you added it explicitly.\n<\/p>\n<p>\nI will leave you to answer fds242&#8217;s final question:\n&#8220;Why do Windows Task Manager&#8217;s tab pages still have the\ngray background.&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CJ observed that the standard tabbed dialogs provide an effect on the tab pages and want to know how to get the tabbed dialog effect on custom dialogs. fds242 noted this as well and wanted to know why the automatic tabbed dialog effect doesn&#8217;t kick in until you put a static control on the child [&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-6173","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>CJ observed that the standard tabbed dialogs provide an effect on the tab pages and want to know how to get the tabbed dialog effect on custom dialogs. fds242 noted this as well and wanted to know why the automatic tabbed dialog effect doesn&#8217;t kick in until you put a static control on the child [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/6173","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=6173"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/6173\/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=6173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=6173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=6173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}