Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Creating a column with bitmaps on CListCtrl residing on a dialog Pin
JJeffrey18-May-09 23:21
JJeffrey18-May-09 23:21 
GeneralRe: Creating a column with bitmaps on CListCtrl residing on a dialog Pin
Stuart Dootson19-May-09 0:34
professionalStuart Dootson19-May-09 0:34 
GeneralRe: Creating a column with bitmaps on CListCtrl residing on a dialog Pin
JJeffrey19-May-09 23:26
JJeffrey19-May-09 23:26 
QuestionPure win32 cross-process child windows Pin
megaadam18-May-09 21:36
professionalmegaadam18-May-09 21:36 
Answer[Message Deleted] Pin
Perisic, Aleksandar18-May-09 23:59
Perisic, Aleksandar18-May-09 23:59 
General[Message Deleted] Pin
megaadam19-May-09 1:01
professionalmegaadam19-May-09 1:01 
General[Message Deleted] Pin
Perisic, Aleksandar19-May-09 1:42
Perisic, Aleksandar19-May-09 1:42 
QuestionClosing an MDI child window having a worker thread in execution Pin
CString(0xcccccccc)18-May-09 21:29
CString(0xcccccccc)18-May-09 21:29 
Currently I'm developping a MFC MDI application using document/view architecture.

I have a CWinThread running in a MDI child window. To stop it prematurely, I use two BOOL variables, bThreadMustStop to request the termination of the thread and another variable bThreadStopped to check if the thread is stopped.

My headaches start when the user closes the MDI child window while the thread is running.
I know several places from where I can control what's going on:
CWinApp::SaveAllModified
CDocument::SaveModified
CChildFrame::OnSysCommand
and several others.

Currently I'm using CChildFrame::OnSysCommand.

Normally I set the bThreadMustStop to TRUE, then enter a loop waiting for bThreadStopped to become TRUE. Just one problem, while the system is executing OnSysCommand, the thread is not running, I don't know why. Because the thread is not running, it cannot read the bThreadMustStop variable, cannot exit and set the bThreadStopped to TRUE so my waiting loop runs infinitely.

To detect if the thread or my waiting loop is running I used TRACE1 statements (with a counter variable). The thread never runs while the waiting loop is running from the inside of OnSysCommand.

Supposing Windows suspended my thread, I tried to call ResumeThread to force the thread to resume, but it returned 0 (thread not suspended).

If I don't wait for the thread termination or if I wait just a limited amount of time, after exiting OnSysCommand, the application will crash. That's because the thread will start running again and will try to acces the objects of a destroyed document.

My question is, what the hell is my thread doing during the execution of CChildFrame::OnSysCommand ? What's its state ? How can I restart it while I'm in OnSysCommand ? What other options do I have to stop the thread and destroy the window gracefully ?
AnswerRe: Closing an MDI child window having a worker thread in execution Pin
Stuart Dootson18-May-09 22:57
professionalStuart Dootson18-May-09 22:57 
QuestionCheck file is open or not Pin
Davitor18-May-09 20:50
Davitor18-May-09 20:50 
AnswerRe: Check file is open or not Pin
Naveen18-May-09 22:06
Naveen18-May-09 22:06 
AnswerRe: Check file is open or not Pin
Stuart Dootson18-May-09 22:44
professionalStuart Dootson18-May-09 22:44 
AnswerRe: Check file is open or not Pin
Divyang Mithaiwala19-May-09 1:00
Divyang Mithaiwala19-May-09 1:00 
GeneralRe: Check file is open or not Pin
_Flaviu4-Oct-11 23:39
_Flaviu4-Oct-11 23:39 
Questionusing container class for c++ class objects Pin
hawk23reddy18-May-09 20:27
hawk23reddy18-May-09 20:27 
AnswerRe: using container class for c++ class objects Pin
CPallini18-May-09 21:26
mveCPallini18-May-09 21:26 
GeneralRe: using container class for c++ class objects Pin
hawk23reddy18-May-09 23:14
hawk23reddy18-May-09 23:14 
GeneralRe: using container class for c++ class objects Pin
CPallini18-May-09 23:53
mveCPallini18-May-09 23:53 
GeneralRe: using container class for c++ class objects Pin
hawk23reddy19-May-09 0:57
hawk23reddy19-May-09 0:57 
GeneralRe: using container class for c++ class objects Pin
CPallini19-May-09 1:23
mveCPallini19-May-09 1:23 
AnswerRe: using container class for c++ class objects Pin
BadKarma18-May-09 22:19
BadKarma18-May-09 22:19 
AnswerRe: using container class for c++ class objects Pin
«_Superman_»18-May-09 23:42
professional«_Superman_»18-May-09 23:42 
Questionsegmentation fault issue in derived class assigment [modified] Pin
hawk23reddy18-May-09 19:35
hawk23reddy18-May-09 19:35 
AnswerRe: segmentation fault issue in derived class assigment Pin
Taran918-May-09 19:55
Taran918-May-09 19:55 
AnswerRe: segmentation fault issue in derived class assigment Pin
tolw18-May-09 19:59
tolw18-May-09 19:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.