Click here to Skip to main content
16,008,299 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Warnings compiling STL Pin
Anders Molin31-Mar-01 6:59
professionalAnders Molin31-Mar-01 6:59 
Generalsending messages from a worker thread to cdocument Pin
derhackler29-Mar-01 23:17
derhackler29-Mar-01 23:17 
GeneralRe: sending messages from a worker thread to cdocument Pin
markkuk30-Mar-01 0:09
markkuk30-Mar-01 0:09 
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler30-Mar-01 0:54
derhackler30-Mar-01 0:54 
GeneralRe: sending messages from a worker thread to cdocument Pin
BenDev30-Mar-01 3:03
BenDev30-Mar-01 3:03 
GeneralRe: sending messages from a worker thread to cdocument Pin
Ajit Jadhav30-Mar-01 6:47
Ajit Jadhav30-Mar-01 6:47 
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler30-Mar-01 6:50
derhackler30-Mar-01 6:50 
GeneralRe: sending messages from a worker thread to cdocument Pin
Ajit Jadhav30-Mar-01 7:19
Ajit Jadhav30-Mar-01 7:19 
OK. Got the picture almost fully.

Just one more part. Guess you have to look at how the message map entries for the UWM_PROGRESSDELETE look like in the project (not just in the Doc).

Since CDocument is not a CWnd (and also not a CWinThread), MFC will NOT find a way to directly route UWM_PROGRESSDELETE to CUserManagerDoc.

Therefore, you might have to add ON_THREAD_MESSAGE entries in CMyView or CMyFrameWnd where MFC will route these messages. Then, you could arrange for MFC to forward those to CDocument....

I would probably go for a more lengthy but a very straightforward and clean solution as following.

Derive a CMyWorkerThread from CWinThread class, and add ON_THREAD_MESSAGE entries for PROGRESSDELETE in CMyWorkerThread class, *not* in the CUserManagerDoc class.

Have a CMyWorkerThread* as m_pThread in Doc. Instantiate CMyWorkerThread on the heap in a doc function, and then call m_pThread->Create() to get the worker thread going. You can also cache the doc ptr as a member variable into the CMyWorkerThread class. If so, ensure you say
m_pThread->m_pCreatingDoc = this; // this means doc

before calling m_pThread->Create().

To use: In CUserManagerDoc, call
m_pThread->PostThreadMessage( UWM_PROGRESSDELETE, 0, (LPARAM) pData );

To access Doc from CMyWorkerThread handler for ProgressDelete(), just use the cached ptr. (Some multi-threading synch object might be necessary to ensure m_pDoc in CMyWorkerThread is valid.)

This will always work. See if it is suitable for your needs.

-- Ajit


Your project today is your great-grandchildrens' "ancestor clock."
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler30-Mar-01 8:50
derhackler30-Mar-01 8:50 
GeneralRe: sending messages from a worker thread to cdocument Pin
Ajit Jadhav31-Mar-01 12:42
Ajit Jadhav31-Mar-01 12:42 
GeneralRe: sending messages from a worker thread to cdocument Pin
Ajit Jadhav31-Mar-01 15:45
Ajit Jadhav31-Mar-01 15:45 
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler2-Apr-01 4:08
derhackler2-Apr-01 4:08 
GeneralRe: sending messages from a worker thread to cdocument Pin
30-Mar-01 3:18
suss30-Mar-01 3:18 
GeneralRe: sending messages from a worker thread to cdocument Pin
derhackler30-Mar-01 6:53
derhackler30-Mar-01 6:53 
GeneralShortcuts on desktop and groups... Pin
29-Mar-01 22:07
suss29-Mar-01 22:07 
GeneralRe: Shortcuts on desktop and groups... Pin
Erik Thompson30-Mar-01 9:01
sitebuilderErik Thompson30-Mar-01 9:01 
GeneralGetting a handle to a resource Pin
Jared Allen29-Mar-01 20:12
Jared Allen29-Mar-01 20:12 
Generalowner-draw combo-box Pin
Bruno Vais29-Mar-01 11:17
Bruno Vais29-Mar-01 11:17 
Questionwhat are threads and processes Pin
29-Mar-01 8:40
suss29-Mar-01 8:40 
AnswerRe: what are threads and processes Pin
Wayne Fuller29-Mar-01 8:59
Wayne Fuller29-Mar-01 8:59 
GeneralRe: what are threads and processes Pin
29-Mar-01 9:24
suss29-Mar-01 9:24 
GeneralRe: what are threads and processes Pin
Scott!29-Mar-01 9:48
Scott!29-Mar-01 9:48 
GeneralRe: what are threads and processes Pin
Peter Sjöström29-Mar-01 21:00
Peter Sjöström29-Mar-01 21:00 
AnswerRe: what are threads and processes Pin
Erik Funkenbusch29-Mar-01 11:29
Erik Funkenbusch29-Mar-01 11:29 
GeneralRe: what are threads and processes Pin
30-Mar-01 8:18
suss30-Mar-01 8:18 

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.