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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Pop Up loading message

Pop Up loading message

Scheduled Pinned Locked Moved C / C++ / MFC
question
29 Posts 4 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.
  • A acerunner316

    Called from yet another function belonging to the same class. I only have one class because everything have been in one dialog box until now.

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

    acerunner316 wrote:

    Called from yet another function belonging to the same class.

    OK, my point is, as long as you're not creating it in the class' WM_CREATE handler or OnInitDialog() override it should show. Are you creating the dialog, doing the processing, and destroying the dialog all in one function? If so, then you could try this: ... pLoadingDlg->Create(IDD_LOADING,this); Invalidate(FALSE); UpdateWindow(); ....do processing ...destroy dialog as usual

    A 1 Reply Last reply
    0
    • M Mark Salsbery

      acerunner316 wrote:

      Called from yet another function belonging to the same class.

      OK, my point is, as long as you're not creating it in the class' WM_CREATE handler or OnInitDialog() override it should show. Are you creating the dialog, doing the processing, and destroying the dialog all in one function? If so, then you could try this: ... pLoadingDlg->Create(IDD_LOADING,this); Invalidate(FALSE); UpdateWindow(); ....do processing ...destroy dialog as usual

      A Offline
      A Offline
      acerunner316
      wrote on last edited by
      #20

      Yes i am creating, processing and destroying all in one function. But on different calls of the function. Therefore, the pointer to CLoading has to be static. I've tried your new node, it works! But the dialog box is created in the upper left corner of the main dialog box. How can I position it so that it pops up in the center like with the popup and overlap styles?

      M 1 Reply Last reply
      0
      • A acerunner316

        hwndSaveFocus = GetFocus(); that gives me the error: error C2440: '=' : cannot convert from 'class CWnd *' to 'struct HWND__ *

        S Offline
        S Offline
        Scott Holt
        wrote on last edited by
        #21

        OK, hang on, let me check the API documentaiton....be right back

        1 Reply Last reply
        0
        • A acerunner316

          hwndSaveFocus = GetFocus(); that gives me the error: error C2440: '=' : cannot convert from 'class CWnd *' to 'struct HWND__ *

          S Offline
          S Offline
          Scott Holt
          wrote on last edited by
          #22

          OK, my bad...you're evidently using MFC, which provides its own "flavor" of 'GetFocus()'. Try the following: CWnd* pwndSaveFocus = GetFocus() ; ... SetFocus(pwndSaveFocus) ; The difference is that 'GetFocus()' and 'SetFocus()' from the MFC classes operate on an instance of the 'CWnd' class. The code I originally gave you is bare-bones Windows API, and operates on window handles (HWND). The 'CWnd' class in MFC actually encapsulates HWNDs. Alternatively, you could force the use of the Windows API functions by using the scoping operator to go "outside" the MFC scope to the global scope, as follows: HWND hwndSaveFocus = ::GetFocus() ; ... ::SetFocus(hwndSaveFocus) ; The '::' at the beginning of each of the above statements forces the compiler to bypass the MFC functions and map directly to the Windows API. Hope this gets you a little closer. Scott

          A 2 Replies Last reply
          0
          • A acerunner316

            Yes i am creating, processing and destroying all in one function. But on different calls of the function. Therefore, the pointer to CLoading has to be static. I've tried your new node, it works! But the dialog box is created in the upper left corner of the main dialog box. How can I position it so that it pops up in the center like with the popup and overlap styles?

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

            acerunner316 wrote:

            How can I position it so that it pops up in the center like with the popup and overlap styles?

            Center of the main dialog? You could set the Center style to TRUE or move the dialog yourself:

            pLoadingDlg->Create(IDD_LOADING,this);
            CRect MainDialogRect, LoadDialogRect;
            GetClientRect(&MainDialogRect);
            pLoadingDlg->GetWindowRect(&LoadDialogRect);
            pLoadingDlg->MoveWindow((MainDialogRect.Width() - LoadDialogRect.Width()) / 2,
            (MainDialogRect.Height() - LoadDialogRect.Height()) / 2,
            LoadDialogRect.Width(), LoadDialogRect.Height());

            *EDIT* Fixed the MoveWindow call heh :laugh: -- modified at 21:55 Monday 27th November, 2006

            A 1 Reply Last reply
            0
            • S Scott Holt

              OK, my bad...you're evidently using MFC, which provides its own "flavor" of 'GetFocus()'. Try the following: CWnd* pwndSaveFocus = GetFocus() ; ... SetFocus(pwndSaveFocus) ; The difference is that 'GetFocus()' and 'SetFocus()' from the MFC classes operate on an instance of the 'CWnd' class. The code I originally gave you is bare-bones Windows API, and operates on window handles (HWND). The 'CWnd' class in MFC actually encapsulates HWNDs. Alternatively, you could force the use of the Windows API functions by using the scoping operator to go "outside" the MFC scope to the global scope, as follows: HWND hwndSaveFocus = ::GetFocus() ; ... ::SetFocus(hwndSaveFocus) ; The '::' at the beginning of each of the above statements forces the compiler to bypass the MFC functions and map directly to the Windows API. Hope this gets you a little closer. Scott

              A Offline
              A Offline
              acerunner316
              wrote on last edited by
              #24

              The MFC SetFocus apparently takes 0 parameters. Then I tried the global scope with the :: compiled, but still loses focus after destroying the "loading" dialog. Looks like Marks method is getting me closer. I just need to figure out how to center the child dialog. Thanks for your help.

              1 Reply Last reply
              0
              • M Mark Salsbery

                acerunner316 wrote:

                How can I position it so that it pops up in the center like with the popup and overlap styles?

                Center of the main dialog? You could set the Center style to TRUE or move the dialog yourself:

                pLoadingDlg->Create(IDD_LOADING,this);
                CRect MainDialogRect, LoadDialogRect;
                GetClientRect(&MainDialogRect);
                pLoadingDlg->GetWindowRect(&LoadDialogRect);
                pLoadingDlg->MoveWindow((MainDialogRect.Width() - LoadDialogRect.Width()) / 2,
                (MainDialogRect.Height() - LoadDialogRect.Height()) / 2,
                LoadDialogRect.Width(), LoadDialogRect.Height());

                *EDIT* Fixed the MoveWindow call heh :laugh: -- modified at 21:55 Monday 27th November, 2006

                A Offline
                A Offline
                acerunner316
                wrote on last edited by
                #25

                The center style seems to center the child dialog relative to the screen and not to the main window. The code you provided positioned the child dialog where I wanted, except for one problem. The controls in the main dialog appear to overlap the "loading" dialog. I know that controls are considered child windows as well. So how to I make the "loading" dialog on top of the other child dialogs?

                M 1 Reply Last reply
                0
                • A acerunner316

                  The center style seems to center the child dialog relative to the screen and not to the main window. The code you provided positioned the child dialog where I wanted, except for one problem. The controls in the main dialog appear to overlap the "loading" dialog. I know that controls are considered child windows as well. So how to I make the "loading" dialog on top of the other child dialogs?

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

                  Instead of MoveWindow... pLoadingDlg->SetWindowPos(wndTop, (MainDialogRect.Width() - LoadDialogRect.Width()) / 2, (MainDialogRect.Height() - LoadDialogRect.Height()) / 2, LoadDialogRect.Width(), LoadDialogRect.Height(), SWP_NOSIZE | SWP_SHOWWINDOW); Maybe? :)

                  1 Reply Last reply
                  0
                  • A acerunner316

                    Hi. I am trying to create a pop up loading message. Something like the MessageBox function would do, but no buttons will be visible or enabled until done loading. The app is dialog based. Loading/Done loading will be controled in the main window, and the pop up will be a modal simply to prevent any action from the user in the main window until done loading. Is this possible? Thanks in advance.

                    A Offline
                    A Offline
                    Aqueel
                    wrote on last edited by
                    #27

                    There is one more way to do it. Make a dialog box with desired message. Create a thread, call DoModal() in this thread to display that dialog box. When u need to kill dialog, kill the thread. How's that??

                    We Believe in Excellence www.aqueelmirza.cjb.net

                    1 Reply Last reply
                    0
                    • S Scott Holt

                      OK, my bad...you're evidently using MFC, which provides its own "flavor" of 'GetFocus()'. Try the following: CWnd* pwndSaveFocus = GetFocus() ; ... SetFocus(pwndSaveFocus) ; The difference is that 'GetFocus()' and 'SetFocus()' from the MFC classes operate on an instance of the 'CWnd' class. The code I originally gave you is bare-bones Windows API, and operates on window handles (HWND). The 'CWnd' class in MFC actually encapsulates HWNDs. Alternatively, you could force the use of the Windows API functions by using the scoping operator to go "outside" the MFC scope to the global scope, as follows: HWND hwndSaveFocus = ::GetFocus() ; ... ::SetFocus(hwndSaveFocus) ; The '::' at the beginning of each of the above statements forces the compiler to bypass the MFC functions and map directly to the Windows API. Hope this gets you a little closer. Scott

                      A Offline
                      A Offline
                      acerunner316
                      wrote on last edited by
                      #28

                      ok, i tried the MFC SetFocus() without any parameters. It works if it comes after destroying the child window. I was using it before destroying the child window before. Only thing is, the window loses focus for a split second after destroying the child window and then regains focus. So it sorta blinks. That's good enough for me right now. So I'll keep it.

                      S 1 Reply Last reply
                      0
                      • A acerunner316

                        ok, i tried the MFC SetFocus() without any parameters. It works if it comes after destroying the child window. I was using it before destroying the child window before. Only thing is, the window loses focus for a split second after destroying the child window and then regains focus. So it sorta blinks. That's good enough for me right now. So I'll keep it.

                        S Offline
                        S Offline
                        Scott Holt
                        wrote on last edited by
                        #29

                        Good! I'm sorry, I should have been more clear that I thought the LAST thing you would do is reset the focus, making sure it was done after the child window was destroyed. Windows will attempt to set the focus using its own internal (and often misundertood) logic when it shuts down a window. And, or course, God only knows what MFC is doing. Scott :)

                        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