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. How to know when a Dialog/Frame finish loading

How to know when a Dialog/Frame finish loading

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
6 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.
  • G Offline
    G Offline
    GameProfessor
    wrote on last edited by
    #1

    The task sounds simple: I have to load a long list of files into a list control box in a dialog. I do it by calling my function FeedFileToListControl() in the OnInitDialog(). The problem is that my function takes a long time to run and the dialog just doesn't show up before the OnInitDialog() returns. I want to have the dialog shows up first, then the Items are added into the list control in the dialog. So, where should I put my FeedFileToListControl() function ?

    C C T 3 Replies Last reply
    0
    • G GameProfessor

      The task sounds simple: I have to load a long list of files into a list control box in a dialog. I do it by calling my function FeedFileToListControl() in the OnInitDialog(). The problem is that my function takes a long time to run and the dialog just doesn't show up before the OnInitDialog() returns. I want to have the dialog shows up first, then the Items are added into the list control in the dialog. So, where should I put my FeedFileToListControl() function ?

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

      In a separate thread. If you don't do that, either your dialog won't be displayed (if you do that in OnInitDialog for example) or it will freeze during the loading (if you manage to call your function after everything has been initialized. Once everything has been loaded, you can send a message to your dialog so that it can fill the list. Don't work with the GUI directly in the separate thread.


      Cédric Moonen Software developer
      Charting control [v1.2 - Updated]

      1 Reply Last reply
      0
      • G GameProfessor

        The task sounds simple: I have to load a long list of files into a list control box in a dialog. I do it by calling my function FeedFileToListControl() in the OnInitDialog(). The problem is that my function takes a long time to run and the dialog just doesn't show up before the OnInitDialog() returns. I want to have the dialog shows up first, then the Items are added into the list control in the dialog. So, where should I put my FeedFileToListControl() function ?

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        There are several ways: (1) A separate thread. (2) A one-shot timer: set a timer in the InitDialog then fill the listbox the first time the WM_TIMER message occurs. (3) Make a PostMessage of a custom message for the application itself and then perform listbox initialization in the message handler. ... :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        G 1 Reply Last reply
        0
        • C CPallini

          There are several ways: (1) A separate thread. (2) A one-shot timer: set a timer in the InitDialog then fill the listbox the first time the WM_TIMER message occurs. (3) Make a PostMessage of a custom message for the application itself and then perform listbox initialization in the message handler. ... :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

          G Offline
          G Offline
          GameProfessor
          wrote on last edited by
          #4

          It seems that to avoid freezing the dialog, I should use a seperate thread to insert item into the list. This thread should be created and starts after the dialog has showed up. But exactly when to do it ??? I haven't got where should I put my AfxBeginThread(). (I don't want to use a timer here)

          C 1 Reply Last reply
          0
          • G GameProfessor

            It seems that to avoid freezing the dialog, I should use a seperate thread to insert item into the list. This thread should be created and starts after the dialog has showed up. But exactly when to do it ??? I haven't got where should I put my AfxBeginThread(). (I don't want to use a timer here)

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #5

            If you put the initialization code in a separate thread, you can also start it in InitDialog method, since it will not freeze the application. However, IMHO you can keep the whole matter simpler using a one-shoot timer or a PostMessage making apparent to the user that you're performing initialization (an hourglass cursor, for instance). :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

            1 Reply Last reply
            0
            • G GameProfessor

              The task sounds simple: I have to load a long list of files into a list control box in a dialog. I do it by calling my function FeedFileToListControl() in the OnInitDialog(). The problem is that my function takes a long time to run and the dialog just doesn't show up before the OnInitDialog() returns. I want to have the dialog shows up first, then the Items are added into the list control in the dialog. So, where should I put my FeedFileToListControl() function ?

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

              GameProfessor wrote:

              I want to have the dialog shows up first, then the Items are added into the list control in the dialog. So, where should I put my FeedFileToListControl() function ?

              thread is only solution, but beware calling UI function from Worker thread bring some drastic result !

              "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
              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