Click here to Skip to main content
15,920,688 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Dynamic cast question Pin
Richard MacCutchan24-Jun-12 22:29
mveRichard MacCutchan24-Jun-12 22:29 
AnswerRe: Dynamic cast question Pin
fat_boy25-Jun-12 0:45
fat_boy25-Jun-12 0:45 
QuestionSetDIBits and GetDIBits (Aarot.zip) Pin
Rabindra Laheri24-Jun-12 18:33
Rabindra Laheri24-Jun-12 18:33 
AnswerRe: SetDIBits and GetDIBits (Aarot.zip) Pin
Richard Andrew x6424-Jun-12 18:49
professionalRichard Andrew x6424-Jun-12 18:49 
GeneralRe: SetDIBits and GetDIBits (Aarot.zip) Pin
Rabindra Laheri24-Jun-12 19:39
Rabindra Laheri24-Jun-12 19:39 
AnswerRe: SetDIBits and GetDIBits (Aarot.zip) Pin
Richard MacCutchan24-Jun-12 22:22
mveRichard MacCutchan24-Jun-12 22:22 
QuestionPrecompiled Headers Pin
ForNow24-Jun-12 11:36
ForNow24-Jun-12 11:36 
AnswerRe: Precompiled Headers Pin
Chris Losinger24-Jun-12 12:35
professionalChris Losinger24-Jun-12 12:35 
AnswerRe: Precompiled Headers Pin
jschell25-Jun-12 9:45
jschell25-Jun-12 9:45 
QuestionPut text data to position where cursor is blinking Pin
khanhnd14058224-Jun-12 4:34
khanhnd14058224-Jun-12 4:34 
QuestionWin32 local aplication using accessing mysql instaled in a site with easyphp ... Pin
SNArruda23-Jun-12 13:02
SNArruda23-Jun-12 13:02 
AnswerRe: Win32 local aplication using accessing mysql instaled in a site with easyphp ... Pin
markkuk23-Jun-12 23:43
markkuk23-Jun-12 23:43 
QuestionBinary value Division Pin
Syed umair shah23-Jun-12 0:48
Syed umair shah23-Jun-12 0:48 
AnswerRe: Binary value Division Pin
Richard MacCutchan23-Jun-12 2:14
mveRichard MacCutchan23-Jun-12 2:14 
AnswerRe: Binary value Division Pin
Software_Developer23-Jun-12 11:20
Software_Developer23-Jun-12 11:20 
Questionhow to do logic gates Pin
Syed umair shah23-Jun-12 0:47
Syed umair shah23-Jun-12 0:47 
AnswerRe: how to do logic gates Pin
Brandon-X1200023-Jun-12 13:11
Brandon-X1200023-Jun-12 13:11 
Questionhow to do logiz gates Pin
Syed umair shah23-Jun-12 0:45
Syed umair shah23-Jun-12 0:45 
AnswerRe: how to do logiz gates Pin
Software_Developer23-Jun-12 11:07
Software_Developer23-Jun-12 11:07 
QuestionWhat FTP pack can obtain the detail events? Pin
includeh1022-Jun-12 22:36
includeh1022-Jun-12 22:36 
AnswerRe: What FTP pack can obtain the detail events? Pin
Jochen Arndt22-Jun-12 23:03
professionalJochen Arndt22-Jun-12 23:03 
QuestionOnly unist.isu gets installed by visual C++ install shield Pin
adityarao3122-Jun-12 20:30
adityarao3122-Jun-12 20:30 
QuestionMFC UI Thread vs. Background Thread Pin
Richard Andrew x6422-Jun-12 10:19
professionalRichard Andrew x6422-Jun-12 10:19 
AnswerRe: MFC UI Thread vs. Background Thread Pin
«_Superman_»22-Jun-12 17:19
professional«_Superman_»22-Jun-12 17:19 
SuggestionRe: MFC UI Thread vs. Background Thread Pin
Roger Stoltz23-Jun-12 0:26
Roger Stoltz23-Jun-12 0:26 
«_Superman_» wrote:
In MFC, you should not directly access UI elements from background threads.


True.


«_Superman_» wrote:
Instead, you must send messages to the UI thread to get and set elements for the UI.

Use can use SendMessage or PostMessage.


Not entirely true.
The reason for not accessing UI elements from another thread than the main thread is that you can quite easily create a deadlock situation. MFC classes for UI elements uses ::SendMessage() which will block until the message has been handled. If the main thread is not processing messages, possibly waiting for the thread that manipulates the UI element, the application will deadlock.
This of course means that you cannot use ::SendMessage(), even if you call it directly, as it would create the same potential deadlock situation.

::PostMessage() must be used since it doesn't wait for the message to be handled. It is possible to use ::SendMessageTimeout() to avoid a deadlock situation, but if the call fails the receiving thread never gets the message.

"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


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.