Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCListCtrl: Automatic Scroll- Down Pin
romuzu13-Jan-06 0:27
romuzu13-Jan-06 0:27 
AnswerRe: CListCtrl: Automatic Scroll- Down Pin
Rajesh R Subramanian13-Jan-06 0:37
professionalRajesh R Subramanian13-Jan-06 0:37 
AnswerRe: CListCtrl: Automatic Scroll- Down Pin
khan++13-Jan-06 1:35
khan++13-Jan-06 1:35 
GeneralRe: CListCtrl: Automatic Scroll- Down Pin
Rajesh R Subramanian13-Jan-06 1:48
professionalRajesh R Subramanian13-Jan-06 1:48 
QuestionCan i pass MFC Objects in between thread ? Pin
vikas amin12-Jan-06 23:20
vikas amin12-Jan-06 23:20 
AnswerRe: Can i pass MFC Objects in between thread ? Pin
Owner drawn12-Jan-06 23:31
Owner drawn12-Jan-06 23:31 
AnswerRe: Can i pass MFC Objects in between thread ? Pin
Stephen Hewitt12-Jan-06 23:41
Stephen Hewitt12-Jan-06 23:41 
AnswerRe: Can i pass MFC Objects in between thread ? Pin
Roger Stoltz12-Jan-06 23:45
Roger Stoltz12-Jan-06 23:45 
It depends on what you mean by "pass" MFC objects and what kind of MFC objects you are "passing".

For instance you should never access any GUI objects from a worker thread to prevent a deadlock situation. Read this[^] if you want to know more. This article is also great to know about thread handling.
In the article forum that belongs to the article there is also a discussion regarding your original question.

I know that CAsyncSocket has some issues when being accessed from different threads, but I can't remember them at the top of my head.

Creating MFC objects, such as CString objects, on the heap and "pass" them to another thread using ::PostMessage is always save provided that you forget about the object in the thread that created the object setting the pointer to NULL and you only have one receiving thread.

You could also use some container class, such as std::queue, to "pass" objects from one thread to another. But then you have to provide synchronization with mutual exclusions such as CRITICAL_SECTION to prevent two threads accessing the same object simultaniously. You simply "lock" the container when accessing objects in the container and "unlock" the container when you're done.

Hope this helps
--
Roger


It's supposed to be hard, otherwise anybody could do it!

-- modified at 6:11 Friday 13th January, 2006 Added hint about article forum discussion.
AnswerRe: Can i pass MFC Objects in between thread ? Pin
Prakash Nadar12-Jan-06 23:45
Prakash Nadar12-Jan-06 23:45 
AnswerRe: Can i pass MFC Objects in between thread ? Pin
ThatsAlok15-Jan-06 18:19
ThatsAlok15-Jan-06 18:19 
AnswerThank you everyone Pin
vikas amin16-Jan-06 1:10
vikas amin16-Jan-06 1:10 
Questionwprintf() could not display unicode chars which is > 255 to console? Pin
wangdave12-Jan-06 23:11
wangdave12-Jan-06 23:11 
QuestionHow to block a window ? Pin
leenmie12-Jan-06 22:50
leenmie12-Jan-06 22:50 
AnswerRe: How to block a window ? Pin
Stephen Hewitt12-Jan-06 23:49
Stephen Hewitt12-Jan-06 23:49 
AnswerRe: How to block a window ? Pin
Roger Stoltz13-Jan-06 0:00
Roger Stoltz13-Jan-06 0:00 
GeneralRe: How to block a window ? Pin
Stephen Hewitt13-Jan-06 0:14
Stephen Hewitt13-Jan-06 0:14 
GeneralRe: How to block a window ? Pin
leenmie13-Jan-06 0:44
leenmie13-Jan-06 0:44 
GeneralRe: How to block a window ? Pin
Stephen Hewitt13-Jan-06 1:06
Stephen Hewitt13-Jan-06 1:06 
AnswerRe: How to block a window ? Pin
Koushik Biswas13-Jan-06 13:51
Koushik Biswas13-Jan-06 13:51 
AnswerRe: How to block a window ? Pin
toxcct13-Jan-06 0:53
toxcct13-Jan-06 0:53 
GeneralRe: How to block a window ? Pin
leenmie13-Jan-06 2:15
leenmie13-Jan-06 2:15 
AnswerRe: How to block a window ? Pin
FarPointer13-Jan-06 3:47
FarPointer13-Jan-06 3:47 
AnswerRe: How to block a window ? Pin
Koushik Biswas13-Jan-06 13:55
Koushik Biswas13-Jan-06 13:55 
GeneralRe: How to block a window ? Pin
leenmie13-Jan-06 15:47
leenmie13-Jan-06 15:47 
QuestionCapture all keyboard input inside a dialog Pin
kevincwong12-Jan-06 22:38
kevincwong12-Jan-06 22:38 

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.