Child dialog update problem

Help
dp
2005-09-11
2013-04-15
  • dp
    dp
    2005-09-11

    My main application is a dialog with several embedded child dialogs which are created manually in the on_initdialog message handler. These dialogs have the same position and size and are selected using the tab control.
    The problem goes with the list_ctrl control, which is located on one of these child dialogs. Sometimes it is not correctly redrawn after being overlapped by another window.
    It always happens for example when list_ctrl has input focus and I' switching to another application and then back to mine.
    If I change the style of the child dialog from "child" to "popup", this problem does not occur, but no keyboard navigation is possible in this case.

    Any help will be greatly appreciated.
    Dmitry

     
    • dp
      dp
      2005-09-12

      Figured this out myself. bring_to_top() does the trick.

       
      • John Torjo
        John Torjo
        2005-09-13

        Great! :)

        I assume you called it on the child dialog itself?
        If so, perhaps I should do this by default, when the tab control is shown.

        Do you have some trimmed down code to show this?
        (you can post it to the win32gui-code@lists.sourceforge.net mailing list)

         
        • dp
          dp
          2005-09-13

          The code is ugly and simple, but it works :) (and actually uses dialog on dialog feature)

          void MainDialog::OnTab()
          {
                 static int ctrls[] = {
                        IDD_TAB1_DIALOG,
                        IDD_TAB2_DIALOG,
                        IDD_TAB3_DIALOG };

                 int sel = child<tab_ctrl>(IDC_CATEGORY_TAB)->sel();
                 assert(sel >= 0 && sel < sizeof(ctrls)/sizeof(ctrls[0]));
                  for (int i = 0; i < sizeof(ctrls)/sizeof(ctrls[0]); i++) {
                       if (i == sel) {
                             child(ctrls[i])->show();
                             child(ctrls[i])->bring_to_top();
                       }
                       else
                             child(ctrls[i])->show(false);
                 }
          }

          P.S. Later I found a nice thing in the library - the tab_dialog class. Haven't used it yet, but it looks really cool! Thanks a lot!

           
          • John Torjo
            John Torjo
            2005-09-13

            Yes, tab_dialog seems to be the perfect thing for this scenario. You can also create the child dialogs at design time.

            Also, note that now you can use Resource Splitter, you don't have to cast each control every time you use it.

            Best,
            John