|
-
April 7th, 1999, 02:21 AM
#1
[RESOLVED] Accessing Main Dialog within a Thread
I have a Main Dialog with several data members.
The situation is that I have a popup progress dialog with a cancel button and a worker thread performing the conversion.
I need to get this worker thread to read some of the data members of the overall main dialog window.
What is the simplest way of doing this?
-
April 7th, 1999, 07:54 AM
#2
Re: Accessing Main Dialog within a Thread
You may share them with the structure used with the worker thread, and protect access with a mutex for example;
An other way may be to share only the handle of your main dialog, and use CWnd::FromHandle to get a pointer on it.
HTH.
K.
Ash to ash and clay to clay, if the enemy doesn't get you, your own folk may.
We're talking ****, 'cause life is a 'biz
You know it is
Everybody tryin' to get rich
God ****!
All I wanna do is live !
KoRn, Children of the Korn
-
April 8th, 1999, 01:56 AM
#3
Re: Accessing Main Dialog within a Thread
Hi Karl
I've ended up using 2 CEvents to check for start and stopping.
The function which calls AfxBeginThread also sets a global pointer:
m_MainWnd = (CDxfRenDlg *)AfxGenMainWnd();
m_MainWnd is declared at the top of the file as:
CDxfRenDlg *m_MainWnd;
I've tested it out and it all seems to work.
-
April 8th, 1999, 03:04 AM
#4
Re: Accessing Main Dialog within a Thread
Yes, I think you're right; I've seen this in the doc:
"CWinThread::m_pMainWnd (value returned by AfxGetMainWnd when the app is not an OLE server)
Remarks:
Use this data member to store a pointer to your thread's main window object. ...In a worker thread, the value of this data member is inherited from its parent thread.
Thanks for the precision.
K.
Ash to ash and clay to clay, if the enemy doesn't get you, your own folk may.
We're talking ****, 'cause life is a 'biz
You know it is
Everybody tryin' to get rich
God ****!
All I wanna do is live !
KoRn, Children of the Korn
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|