Solved

Problem with threads

Posted on 1998-04-23
4
171 Views
Last Modified: 2010-04-10
I have created a ui thread class in an application and would like it to do
some work while returning control back to the main application.

problem is, when the thread starts running, (it starts a modeless dialog) it
effectively becomes modal, stop any user interaction with the main
application (please see the result.zip file for example).

I am sure I am not doing this properly!  How should it be done??

Also, I notice that when downloading has finished, if the dialog is not
destroyed, it sits in front of the main application window; can the dialog
be made to go behind, even if the main application window is the parent???

All answers to this perplexing problem would be very gratefully received.


Oscar


Check example url:

http://homepages.enterprise.net/impala/doc/Result.zip







0
Comment
Question by:ossentoo
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
faster earned 100 total points
ID: 1163480
You need modaless dialog.  I mean the UI thread shall first create the dialog, then go to the message loop.  Another thread do the background processing, such as download file, when it completes, send message to the dialog to kill it.  If the user select cancel in the UI thread, then it can terminate the working thread.
0
 

Author Comment

by:ossentoo
ID: 1163481
I'm sure it is a modeless dialog.  See code below:

      m_pDlg=new CDownDlg;
      //pDlg=(CDownDlg*)m_pDlgArr.ElementAt(m_pDlgArr.GetSize());
      BOOL bReturn=m_pDlg->Create(IDD_DOWNLOAD);
      m_pDlg->ShowWindow(SW_SHOWNORMAL);

      ASSERT(m_pDlg);


This code should create a modeless dialog.  I have used the create() method, not DoModal(), unless I am doing something else wrong!!
0
 
LVL 7

Expert Comment

by:faster
ID: 1163482
can you show me the other part of your code?
0
 

Author Comment

by:ossentoo
ID: 1163483
send me an e-mail to impala@enterprise.net  I will then send you the code.

Thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question