CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    How do I allow user access to a window while it is doing lengthy work?

    here's my situation...

    i have a popup dlg with a listbox. the list box has tons of items being added to it upon the creation of the popup dlg. it is very lengthy and all messages are halted until the listbox is fully updated.
    i like to give the user the ability to do stuff, like close the popup dlg if he/she so desires. here is my code...

    while (very_long_update)
    {
    if ((PeekMessage(&lpMsg, NULL, 0, 0, PM_REMOVE)) > 0)
    DispatchMessage(&lpMsg);

    //do something lengthy...
    }

    this seems to work for all messages except when the user closes the popup dlg. (ex. the user can move the dlg around, minimize it, etc. while the listbox is updating...) but when the user closes it (clicking on the X), the dlg dissapears but the thread is still running! i know this for a fact because the VC++ debugger's output doesn't say that the thread has exited with 0x2 code or something like that. In fact when i close the dlg that originally called the lengthy popup dlg (my main dlg), the debugger doesn't end until i have to force it to end by clicking the "Stop Debugging" button (Shift F5).
    is there more to processing a QUIT message than what i am doing? or is there another way to do what i want with out peeking into messages? i tried using threads, but it is very unstable since i have to update the popup dlg everytime an item gets inserted into the listbox.

    thanks in advance...



  2. #2
    Join Date
    Apr 1999
    Location
    Manchester, UK
    Posts
    56

    Re: How do I allow user access to a window while it is doing lengthy work?

    It would probably be better to fill your listbox using another thread, that way your dialog can process its messages without being obstructed.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured