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. Displaying Message Box while program(code) continues [modified]

Displaying Message Box while program(code) continues [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
question
17 Posts 7 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.
  • K Offline
    K Offline
    KongHL
    wrote on last edited by
    #1

    Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it. The message box will have to be closed after the function finishes. If yes, how can I go abt doing it? Another question is how can I display a dialog box ( using doModal() ) and perform a function immediately without User Interaction? Thanks!! -- modified at 3:33 Wednesday 31st May, 2006

    stefanmihaimogaS C S T 5 Replies Last reply
    0
    • K KongHL

      Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it. The message box will have to be closed after the function finishes. If yes, how can I go abt doing it? Another question is how can I display a dialog box ( using doModal() ) and perform a function immediately without User Interaction? Thanks!! -- modified at 3:33 Wednesday 31st May, 2006

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      KongHL wrote:

      Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it.

      You'll have to use modeless dialogs for that. Take a look at this article[^].

      KongHL wrote:

      Another question is how can I display a dialog box ( using doModal() ) and perform a function immediately without User Interaction?

      Override OnInitDialog and call the function there.


      Cédric Moonen Software developer
      Charting control

      K 1 Reply Last reply
      0
      • K KongHL

        Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it. The message box will have to be closed after the function finishes. If yes, how can I go abt doing it? Another question is how can I display a dialog box ( using doModal() ) and perform a function immediately without User Interaction? Thanks!! -- modified at 3:33 Wednesday 31st May, 2006

        stefanmihaimogaS Offline
        stefanmihaimogaS Offline
        stefanmihaimoga
        wrote on last edited by
        #3

        This might help you: Delay MessageBox with auto-close option[^] Good luck and keep the good coding!

        K 1 Reply Last reply
        0
        • stefanmihaimogaS stefanmihaimoga

          This might help you: Delay MessageBox with auto-close option[^] Good luck and keep the good coding!

          K Offline
          K Offline
          KongHL
          wrote on last edited by
          #4

          Delay MessageBox delays a short period of time before going to the next step of code.. But I would like to display the messagebox and continue the nxt step of code as per normal.. Am I correct to say that?

          T 1 Reply Last reply
          0
          • C Cedric Moonen

            KongHL wrote:

            Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it.

            You'll have to use modeless dialogs for that. Take a look at this article[^].

            KongHL wrote:

            Another question is how can I display a dialog box ( using doModal() ) and perform a function immediately without User Interaction?

            Override OnInitDialog and call the function there.


            Cédric Moonen Software developer
            Charting control

            K Offline
            K Offline
            KongHL
            wrote on last edited by
            #5

            Hmm I mean doModal(), then call a function of that dialog class immediately after the dialog is being displayed. Is it possible?

            _ 1 Reply Last reply
            0
            • K KongHL

              Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it. The message box will have to be closed after the function finishes. If yes, how can I go abt doing it? Another question is how can I display a dialog box ( using doModal() ) and perform a function immediately without User Interaction? Thanks!! -- modified at 3:33 Wednesday 31st May, 2006

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              KongHL wrote:

              Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it.

              This goes against the concept of a message box. One way you could get this effect is to display the message box in another thread. It might be simpler to make your own modeless dialog however. Steve

              1 Reply Last reply
              0
              • K KongHL

                Hmm I mean doModal(), then call a function of that dialog class immediately after the dialog is being displayed. Is it possible?

                _ Offline
                _ Offline
                _anil_
                wrote on last edited by
                #7

                you can write your funtion in OnShowWindow ; But still it won't fulfill your purpose as you want to call the funtion after the dialog is displayed. In that case I have two options. First in the OnInitDialog function you call SetTimer to set time say 1 sec. Then call your funtion in OnTimer and kill the timer in OnTimer function. Second method is that you create a thread to call your funtion. and start the thread in OnShowWindow. Regards Anil

                T 1 Reply Last reply
                0
                • K KongHL

                  Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it. The message box will have to be closed after the function finishes. If yes, how can I go abt doing it? Another question is how can I display a dialog box ( using doModal() ) and perform a function immediately without User Interaction? Thanks!! -- modified at 3:33 Wednesday 31st May, 2006

                  stefanmihaimogaS Offline
                  stefanmihaimogaS Offline
                  stefanmihaimoga
                  wrote on last edited by
                  #8

                  KongHL wrote:

                  Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it.

                  Please have a look on Mauro Leggieri's Background Task Dialog[^] Good luck and keep the good coding!

                  1 Reply Last reply
                  0
                  • K KongHL

                    Delay MessageBox delays a short period of time before going to the next step of code.. But I would like to display the messagebox and continue the nxt step of code as per normal.. Am I correct to say that?

                    T Offline
                    T Offline
                    ThatsAlok
                    wrote on last edited by
                    #9

                    KongHL wrote:

                    Delay MessageBox delays a short period of time before going to the next step of code.. But I would like to display the messagebox and continue the nxt step of code as per normal..

                    Create the ModelLess Dialog box!

                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                    cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                    1 Reply Last reply
                    0
                    • K KongHL

                      Is it possible for me to display the message box and let the nxt function to process while the message box remains displayed and the user cannot close it. The message box will have to be closed after the function finishes. If yes, how can I go abt doing it? Another question is how can I display a dialog box ( using doModal() ) and perform a function immediately without User Interaction? Thanks!! -- modified at 3:33 Wednesday 31st May, 2006

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

                      you could also call it from another thread...


                      TOXCCT >>> GEII power

                      [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                      T 1 Reply Last reply
                      0
                      • T toxcct

                        you could also call it from another thread...


                        TOXCCT >>> GEII power

                        [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                        T Offline
                        T Offline
                        ThatsAlok
                        wrote on last edited by
                        #11

                        toxcct wrote:

                        you could also call it from another thread...

                        UI Thread or worker Thread:)

                        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                        cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                        T 1 Reply Last reply
                        0
                        • T ThatsAlok

                          toxcct wrote:

                          you could also call it from another thread...

                          UI Thread or worker Thread:)

                          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                          cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

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

                          i'm not good at using thread (i nenver used them yet), so i cannot say exactly where is the difference b/w them.


                          TOXCCT >>> GEII power

                          [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                          T 1 Reply Last reply
                          0
                          • T toxcct

                            i'm not good at using thread (i nenver used them yet), so i cannot say exactly where is the difference b/w them.


                            TOXCCT >>> GEII power

                            [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                            T Offline
                            T Offline
                            ThatsAlok
                            wrote on last edited by
                            #13

                            toxcct wrote:

                            i'm not good at using thread (i nenver used them yet), so i cannot say exactly where is the difference b/w them.

                            Kiddin, it work well from both Option!

                            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                            T 1 Reply Last reply
                            0
                            • T ThatsAlok

                              toxcct wrote:

                              i'm not good at using thread (i nenver used them yet), so i cannot say exactly where is the difference b/w them.

                              Kiddin, it work well from both Option!

                              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                              cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

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

                              any hint btw about the diff between ui thread and worker thread ?


                              TOXCCT >>> GEII power

                              [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                              T 1 Reply Last reply
                              0
                              • T toxcct

                                any hint btw about the diff between ui thread and worker thread ?


                                TOXCCT >>> GEII power

                                [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                                T Offline
                                T Offline
                                ThatsAlok
                                wrote on last edited by
                                #15

                                toxcct wrote:

                                any hint btw about the diff between ui thread and worker thread ?

                                http://www.flounder.com/mvp_tips.htm#Using%20User-Interface%20Threads[^] http://www.flounder.com/mvp_tips.htm#Using%20Worker%20Threads[^]

                                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                                1 Reply Last reply
                                0
                                • _ _anil_

                                  you can write your funtion in OnShowWindow ; But still it won't fulfill your purpose as you want to call the funtion after the dialog is displayed. In that case I have two options. First in the OnInitDialog function you call SetTimer to set time say 1 sec. Then call your funtion in OnTimer and kill the timer in OnTimer function. Second method is that you create a thread to call your funtion. and start the thread in OnShowWindow. Regards Anil

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

                                  _anil_ wrote:

                                  First in the OnInitDialog function you call SetTimer to set time say 1 sec.

                                  very bad idea...!! consider the case where you init your dialog with a database which it connection is long to establish (at least more that 1 sec)... the program will behave badly.


                                  TOXCCT >>> GEII power

                                  [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                                  _ 1 Reply Last reply
                                  0
                                  • T toxcct

                                    _anil_ wrote:

                                    First in the OnInitDialog function you call SetTimer to set time say 1 sec.

                                    very bad idea...!! consider the case where you init your dialog with a database which it connection is long to establish (at least more that 1 sec)... the program will behave badly.


                                    TOXCCT >>> GEII power

                                    [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                                    _ Offline
                                    _ Offline
                                    _anil_
                                    wrote on last edited by
                                    #17

                                    Yes you are right:-), Its a bad idea, depending on the situation. But the programmer know what he wants, and aware of the conditions. if the condition is according to you then we can use thread instead. But I think still I can make it to work.

                                    void OnShowWindow(){
                                      // here I set timer
                                      SetTimer(....);
                                    
                                     // Then the database connection
                                     // Its long enough 1 sec 
                                     // problem .....
                                    
                                      return;
                                    }
                                    

                                    second case

                                    void OnShowWindow(){
                                      // Then the database connection
                                     // Its long enough 1 sec 
                                    
                                    
                                      // here I set timer
                                      SetTimer(....);  // less chance of problem
                                      return;
                                    }
                                    

                                    It depends on when you set the timer. But I still agree with you that its a bad idea. But is one of the solution depending on the situation. Regards Anil -- modified at 5:25 Friday 2nd June, 2006

                                    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