Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. modeless dialog in the client area of MDI-application

modeless dialog in the client area of MDI-application

Scheduled Pinned Locked Moved C / C++ / MFC
question
13 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Franken
    wrote on last edited by
    #1

    Hi everybody, I try to create a modeless dialog in the client area of a MDI application. It should display some data form the app class (not the document). When I create the dialog:

    pmyDlg = new CmyDialog;
    pmyDlg->Create(IDD_DIALOG_mydlg)
    pmyDlg->ShowWindow(SW_SHOW)

    it always appear on top of the application, not in the client area of the child frame. I tried things like pmyDlg->Create(IDD_DIALOG_mydlg, theApp.m_pMainWnd) to set a parent for this dialog but it was alway dragable over the whole desktop and was not restricted to the client area. Can someone send me a hint? Many thanks. Cheers, Frank.

    T M D 3 Replies Last reply
    0
    • F Franken

      Hi everybody, I try to create a modeless dialog in the client area of a MDI application. It should display some data form the app class (not the document). When I create the dialog:

      pmyDlg = new CmyDialog;
      pmyDlg->Create(IDD_DIALOG_mydlg)
      pmyDlg->ShowWindow(SW_SHOW)

      it always appear on top of the application, not in the client area of the child frame. I tried things like pmyDlg->Create(IDD_DIALOG_mydlg, theApp.m_pMainWnd) to set a parent for this dialog but it was alway dragable over the whole desktop and was not restricted to the client area. Can someone send me a hint? Many thanks. Cheers, Frank.

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      did you have a look at this[^] ?


      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      F 1 Reply Last reply
      0
      • T toxcct

        did you have a look at this[^] ?


        [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

        F Offline
        F Offline
        Franken
        wrote on last edited by
        #3

        yes, but it doesn't help me because Nishant Sivakumar suggest to use the desktop window as a parent for the modeless dialog. When I do this, the modeless dialog is even more independent of my application. What I want is a modeless dialog, which behaves like a MDIView but without the overhead of the document. It should be moveable only inside the client area of the application and not on the whole desktop.

        A M 2 Replies Last reply
        0
        • F Franken

          yes, but it doesn't help me because Nishant Sivakumar suggest to use the desktop window as a parent for the modeless dialog. When I do this, the modeless dialog is even more independent of my application. What I want is a modeless dialog, which behaves like a MDIView but without the overhead of the document. It should be moveable only inside the client area of the application and not on the whole desktop.

          A Offline
          A Offline
          Arman S
          wrote on last edited by
          #4

          Subclass your childview[of MDI] and create a child[WS_CHILD] dialog on it.

          -- ====== Arman

          1 Reply Last reply
          0
          • F Franken

            yes, but it doesn't help me because Nishant Sivakumar suggest to use the desktop window as a parent for the modeless dialog. When I do this, the modeless dialog is even more independent of my application. What I want is a modeless dialog, which behaves like a MDIView but without the overhead of the document. It should be moveable only inside the client area of the application and not on the whole desktop.

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            Franken wrote:

            What I want is a modeless dialog, which behaves like a MDIView but without the overhead of the document.

            yuck.

            Franken wrote:

            It should be moveable only inside the client area of the application and not on the whole desktop.

            double yuck. but I'm a good sport. Can't you create the modeless dialog with the MainFrame as a WS_CHILD of the main frame ? or something similar ? I think I remember that you can set of the dialog style to do this.


            Maximilien Lincourt Your Head A Splode - Strong Bad

            D F 2 Replies Last reply
            0
            • M Maximilien

              Franken wrote:

              What I want is a modeless dialog, which behaves like a MDIView but without the overhead of the document.

              yuck.

              Franken wrote:

              It should be moveable only inside the client area of the application and not on the whole desktop.

              double yuck. but I'm a good sport. Can't you create the modeless dialog with the MainFrame as a WS_CHILD of the main frame ? or something similar ? I think I remember that you can set of the dialog style to do this.


              Maximilien Lincourt Your Head A Splode - Strong Bad

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Maximilien wrote:

              ...the MainFrame as a WS_CHILD of the main frame ?

              :confused:


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              M 1 Reply Last reply
              0
              • M Maximilien

                Franken wrote:

                What I want is a modeless dialog, which behaves like a MDIView but without the overhead of the document.

                yuck.

                Franken wrote:

                It should be moveable only inside the client area of the application and not on the whole desktop.

                double yuck. but I'm a good sport. Can't you create the modeless dialog with the MainFrame as a WS_CHILD of the main frame ? or something similar ? I think I remember that you can set of the dialog style to do this.


                Maximilien Lincourt Your Head A Splode - Strong Bad

                F Offline
                F Offline
                Franken
                wrote on last edited by
                #7

                I also thought that it should be possible to set WS_CHILD style but haven't found a way to do this.

                1 Reply Last reply
                0
                • D David Crow

                  Maximilien wrote:

                  ...the MainFrame as a WS_CHILD of the main frame ?

                  :confused:


                  "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                  "Judge not by the eye but by the heart." - Native American Proverb

                  M Offline
                  M Offline
                  Maximilien
                  wrote on last edited by
                  #8

                  ok, that was bad! :doh:


                  Maximilien Lincourt Your Head A Splode - Strong Bad

                  1 Reply Last reply
                  0
                  • F Franken

                    Hi everybody, I try to create a modeless dialog in the client area of a MDI application. It should display some data form the app class (not the document). When I create the dialog:

                    pmyDlg = new CmyDialog;
                    pmyDlg->Create(IDD_DIALOG_mydlg)
                    pmyDlg->ShowWindow(SW_SHOW)

                    it always appear on top of the application, not in the client area of the child frame. I tried things like pmyDlg->Create(IDD_DIALOG_mydlg, theApp.m_pMainWnd) to set a parent for this dialog but it was alway dragable over the whole desktop and was not restricted to the client area. Can someone send me a hint? Many thanks. Cheers, Frank.

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    Do you want the MDIFrame window to be the parent or do you want to place the dialog in a MDIChild frame? Either way, the dialog needs to be a child and you need to specify the parent in the Create() call. You can set the child style in the resource editor, properties, style. Mark

                    "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                    F 1 Reply Last reply
                    0
                    • F Franken

                      Hi everybody, I try to create a modeless dialog in the client area of a MDI application. It should display some data form the app class (not the document). When I create the dialog:

                      pmyDlg = new CmyDialog;
                      pmyDlg->Create(IDD_DIALOG_mydlg)
                      pmyDlg->ShowWindow(SW_SHOW)

                      it always appear on top of the application, not in the client area of the child frame. I tried things like pmyDlg->Create(IDD_DIALOG_mydlg, theApp.m_pMainWnd) to set a parent for this dialog but it was alway dragable over the whole desktop and was not restricted to the client area. Can someone send me a hint? Many thanks. Cheers, Frank.

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #10

                      You could do something like:

                      BOOL CModelessDlg::OnInitDialog()
                      {
                      CDialog::OnInitDialog();

                      CRect rc;
                      GetWindowRect(rc);
                      m\_lWidth = rc.Width();
                      m\_lHeight = rc.Height();
                      
                      AfxGetMainWnd()->GetWindowRect(m\_rcParent);
                      
                      return TRUE;
                      

                      }

                      void CModelessDlg::OnMoving(UINT fwSide, LPRECT pRect)
                      {
                      CDialog::OnMoving(fwSide, pRect);

                      // keep the child's left edge inside the parent's right edge
                      pRect->left = min(pRect->left, m\_rcParent.right - m\_lWidth);
                      // keep the child's left edge inside the parent's left edge
                      pRect->left = max(pRect->left, m\_rcParent.left);
                      
                      // keep the child's top edge inside the parent's bottom edge
                      pRect->top  = min(pRect->top, m\_rcParent.bottom - m\_lHeight);
                      // keep the child's top edge inside the parent's top edge
                      pRect->top  = max(pRect->top, m\_rcParent.top);
                      
                      // keep the child's right edge inside the parent's right edge
                      pRect->right = min(pRect->right, m\_rcParent.right);
                      // keep the child's right edge inside the parent's left edge
                      pRect->right = max(pRect->right, m\_rcParent.left + m\_lWidth);
                      
                      // keep the child's bottom edge inside the parent's bottom edge
                      pRect->bottom = min(pRect->bottom, m\_rcParent.bottom);
                      // keep the child's bottom edge inside the parent's top edge
                      pRect->bottom = max(pRect->bottom, m\_rcParent.top + m\_lHeight);
                      

                      }

                      It works regardless of whether WS_POPUP or WS_CHILD is used. A parent can be specified or not.


                      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                      "Judge not by the eye but by the heart." - Native American Proverb

                      1 Reply Last reply
                      0
                      • M Mark Salsbery

                        Do you want the MDIFrame window to be the parent or do you want to place the dialog in a MDIChild frame? Either way, the dialog needs to be a child and you need to specify the parent in the Create() call. You can set the child style in the resource editor, properties, style. Mark

                        "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                        F Offline
                        F Offline
                        Franken
                        wrote on last edited by
                        #11

                        I set the style to child in the dialog editor properties and did the following during the creation of the dialog:

                        CMainFrame* pFrame = (CMainFrame*)GetMainWnd();
                        CChildFrame* pChild = (CChildFrame*)pFrame->GetActiveFrame();

                        CmyDlg* pDlg = new CmyDlg;
                        pDlg->Create(IDD_DIALOG_myDlg, pChild->GetParent());
                        pDlg->ShowWindow(SW_SHOW);

                        This is almost what I wanted but it shows some weird behaviour. When a region of the dialog is covered by another child window this region shows still the part of the child window even if I drag the dialog to another place. It only restores the correct dialog, when I resize the dialog. Is there somewhere a flag like redraw or something? Many thanks :), Frank.

                        M 2 Replies Last reply
                        0
                        • F Franken

                          I set the style to child in the dialog editor properties and did the following during the creation of the dialog:

                          CMainFrame* pFrame = (CMainFrame*)GetMainWnd();
                          CChildFrame* pChild = (CChildFrame*)pFrame->GetActiveFrame();

                          CmyDlg* pDlg = new CmyDlg;
                          pDlg->Create(IDD_DIALOG_myDlg, pChild->GetParent());
                          pDlg->ShowWindow(SW_SHOW);

                          This is almost what I wanted but it shows some weird behaviour. When a region of the dialog is covered by another child window this region shows still the part of the child window even if I drag the dialog to another place. It only restores the correct dialog, when I resize the dialog. Is there somewhere a flag like redraw or something? Many thanks :), Frank.

                          M Offline
                          M Offline
                          Mark Salsbery
                          wrote on last edited by
                          #12

                          hmm I'm not sure if there's different invalidation with MDI windows (which differ from other windows because they're controlled by an "MDICLIENT" class window). I have a feeling it's due to activation issues. Mixing a non-MDI child window in a MDI client window isn't necessarily going to work properly. I still think it's much easier to make the dialog a client window of a CMDIChildWnd frame. There shouldn't be any issues then. Mark

                          "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                          1 Reply Last reply
                          0
                          • F Franken

                            I set the style to child in the dialog editor properties and did the following during the creation of the dialog:

                            CMainFrame* pFrame = (CMainFrame*)GetMainWnd();
                            CChildFrame* pChild = (CChildFrame*)pFrame->GetActiveFrame();

                            CmyDlg* pDlg = new CmyDlg;
                            pDlg->Create(IDD_DIALOG_myDlg, pChild->GetParent());
                            pDlg->ShowWindow(SW_SHOW);

                            This is almost what I wanted but it shows some weird behaviour. When a region of the dialog is covered by another child window this region shows still the part of the child window even if I drag the dialog to another place. It only restores the correct dialog, when I resize the dialog. Is there somewhere a flag like redraw or something? Many thanks :), Frank.

                            M Offline
                            M Offline
                            Mark Salsbery
                            wrote on last edited by
                            #13

                            Here's some more info: Using the Multiple Document Interface[^] As you can see in the Window Procedure sections, the MDI windows use different default window procs so they can/will behave differently than normal parent/child windows. Mark

                            "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups