Click here to Skip to main content
15,911,896 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Check if a window is hidden by another window Pin
Richard Andrew x643-Jan-12 5:57
professionalRichard Andrew x643-Jan-12 5:57 
AnswerRe: Check if a window is hidden by another window Pin
Randor 3-Jan-12 6:42
professional Randor 3-Jan-12 6:42 
AnswerRe: Check if a window is hidden by another window Pin
Albert Holguin4-Jan-12 9:39
professionalAlbert Holguin4-Jan-12 9:39 
QuestionThread sync Pin
columbos149272-Jan-12 20:05
columbos149272-Jan-12 20:05 
GeneralRe: Thread sync Pin
Randor 2-Jan-12 20:20
professional Randor 2-Jan-12 20:20 
GeneralRe: Thread sync Pin
columbos149272-Jan-12 20:29
columbos149272-Jan-12 20:29 
GeneralRe: Thread sync Pin
Randor 2-Jan-12 21:01
professional Randor 2-Jan-12 21:01 
AnswerRe: Thread sync Pin
Bob Ciora4-Jan-12 1:06
Bob Ciora4-Jan-12 1:06 
Client area painting must occur in the main Windows thread. The problem is that the thread grabbing the frames is not the main Windows thread. So while it's drawing to the client area, any old windows message might come along and cause a crash as the two threads bump into each other. This is especially true when resizing - there are lots of "PAINT" messages hitting the dialog, and there's a good chance that PAINT handling is happening at the same time your other thread is drawing to the client area. Result is a crash.

The solution is to have the main windows thread do the drawing. So you'll need a way to move the frames from the grabber thread to the windows thread, and signal your dialog that it's time to draw a new frame.

You could try using a custom message, e.g. WM_USER+<n> ( see here: http://www.ucancode.net/Visual_C_MFC_Example/RegisterWindowMessage-WM_USER--VC-Example.htm[^] ). You can allocate a buffer to hold the frame and pass the pointer to that buffer as the LPARAM. The frame-grabber thread then just needs to PostMessage(...) to the Dialog.

On the Dialog side, add the handler for the WM_USER+<n> message to draw the image pointed to by LPARAM. Don't forget to deallocate that buffer when done!

This is just one example for moving information from some "outside" thread to the main windows thread. You can probably find many others.

- Bob
Bob Ciora

GeneralRe: Thread sync Pin
columbos149274-Jan-12 1:26
columbos149274-Jan-12 1:26 
AnswerRe: Thread sync Pin
JackDingler4-Jan-12 12:19
JackDingler4-Jan-12 12:19 
QuestionDLL Questions Pin
Richard Andrew x642-Jan-12 17:19
professionalRichard Andrew x642-Jan-12 17:19 
AnswerRe: DLL Questions Pin
Rajesh R Subramanian2-Jan-12 17:41
professionalRajesh R Subramanian2-Jan-12 17:41 
GeneralRe: DLL Questions Pin
Richard Andrew x642-Jan-12 17:45
professionalRichard Andrew x642-Jan-12 17:45 
AnswerRe: DLL Questions Pin
Randor 2-Jan-12 18:50
professional Randor 2-Jan-12 18:50 
GeneralRe: DLL Questions Pin
Richard Andrew x642-Jan-12 18:57
professionalRichard Andrew x642-Jan-12 18:57 
GeneralRe: DLL Questions Pin
Randor 2-Jan-12 19:13
professional Randor 2-Jan-12 19:13 
QuestionHow to modify hardware's property via win32 API Pin
freshtiny2-Jan-12 16:17
freshtiny2-Jan-12 16:17 
AnswerRe: How to modify hardware's property via win32 API Pin
Vaclav_2-Jan-12 17:04
Vaclav_2-Jan-12 17:04 
AnswerRe: How to modify hardware's property via win32 API Pin
freshtiny2-Jan-12 21:05
freshtiny2-Jan-12 21:05 
QuestionDynamic array of afx_msg functions - using CPtrArray ( MFC VC 6.0) Pin
Vaclav_2-Jan-12 15:56
Vaclav_2-Jan-12 15:56 
AnswerRe: Dynamic array of afx_msg functions - using CPtrArray ( MFC VC 6.0) Pin
Chuck O'Toole2-Jan-12 16:01
Chuck O'Toole2-Jan-12 16:01 
GeneralRe: Dynamic array of afx_msg functions - using CPtrArray ( MFC VC 6.0) Pin
Vaclav_2-Jan-12 16:39
Vaclav_2-Jan-12 16:39 
GeneralRe: Dynamic array of afx_msg functions - using CPtrArray ( MFC VC 6.0) Pin
ThatsAlok3-Jan-12 19:45
ThatsAlok3-Jan-12 19:45 
GeneralRe: Dynamic array of afx_msg functions - using CPtrArray ( MFC VC 6.0) Pin
Chuck O'Toole3-Jan-12 21:38
Chuck O'Toole3-Jan-12 21:38 
GeneralRe: Dynamic array of afx_msg functions - using CPtrArray ( MFC VC 6.0) Pin
ThatsAlok3-Jan-12 23:12
ThatsAlok3-Jan-12 23:12 

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.