Click here to Skip to main content
15,916,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: using sscanf in a loop Pin
Chris Losinger13-Apr-10 5:56
professionalChris Losinger13-Apr-10 5:56 
AnswerRe: using sscanf in a loop Pin
David Crow13-Apr-10 5:52
David Crow13-Apr-10 5:52 
GeneralRe: using sscanf in a loop Pin
b-rad31113-Apr-10 5:53
b-rad31113-Apr-10 5:53 
GeneralRe: using sscanf in a loop Pin
David Crow13-Apr-10 5:58
David Crow13-Apr-10 5:58 
Questionstatic text color and backgroung color Pin
D.Manivelan13-Apr-10 4:14
D.Manivelan13-Apr-10 4:14 
QuestionRe: static text color and backgroung color Pin
David Crow13-Apr-10 4:52
David Crow13-Apr-10 4:52 
QuestionGeting the calling modules names Pin
Mugiwara13-Apr-10 3:39
Mugiwara13-Apr-10 3:39 
AnswerRe: Geting the calling modules names Pin
Eugen Podsypalnikov13-Apr-10 4:40
Eugen Podsypalnikov13-Apr-10 4:40 
GeneralRe: Geting the calling modules names Pin
Mugiwara13-Apr-10 9:15
Mugiwara13-Apr-10 9:15 
GeneralRe: Geting the calling modules names Pin
David Crow13-Apr-10 9:50
David Crow13-Apr-10 9:50 
QuestionIf the data is static, how can you access that data in another file ? Pin
krish_kumar13-Apr-10 2:54
krish_kumar13-Apr-10 2:54 
AnswerRe: If the data is static, how can you access that data in another file ? Pin
Chris Losinger13-Apr-10 3:11
professionalChris Losinger13-Apr-10 3:11 
GeneralRe: If the data is static, how can you access that data in another file ? Pin
krish_kumar13-Apr-10 3:46
krish_kumar13-Apr-10 3:46 
GeneralRe: If the data is static, how can you access that data in another file ? Pin
Chris Losinger13-Apr-10 3:47
professionalChris Losinger13-Apr-10 3:47 
QuestionCRectTracker Pin
shiv@nand13-Apr-10 1:55
shiv@nand13-Apr-10 1:55 
AnswerRe: CRectTracker Pin
Eugen Podsypalnikov13-Apr-10 3:00
Eugen Podsypalnikov13-Apr-10 3:00 
QuestionMFC Thread queue size Pin
ajmalsiddiqi12-Apr-10 23:42
ajmalsiddiqi12-Apr-10 23:42 
QuestionRe: MFC Thread queue size Pin
David Crow13-Apr-10 2:52
David Crow13-Apr-10 2:52 
AnswerRe: MFC Thread queue size Pin
ajmalsiddiqi13-Apr-10 7:14
ajmalsiddiqi13-Apr-10 7:14 
GeneralRe: MFC Thread queue size Pin
David Crow13-Apr-10 7:32
David Crow13-Apr-10 7:32 
AnswerRe: MFC Thread queue size Pin
Stephen Hewitt13-Apr-10 13:57
Stephen Hewitt13-Apr-10 13:57 
GeneralRe: MFC Thread queue size Pin
ajmalsiddiqi13-Apr-10 21:30
ajmalsiddiqi13-Apr-10 21:30 
GeneralRe: MFC Thread queue size Pin
Stephen Hewitt14-Apr-10 1:18
Stephen Hewitt14-Apr-10 1:18 
There are a number of issues here.
 
The first problem you may encounter is related to the posting of thread messages. Does the main thread have any UI? Messages boxes, dialogs, anything like that? If so you may encounter the problem described here[^]. The solution (posting the messages to a hidden window instead) is also described.
 
The next problem is that the main thread will sometimes throw away messages:
// code snap shot
Controller::Run()
{
	While(1)
	{
		while(PeekMessage(pmsg, NULL, 0, 0, PM_NOREMOVE)) // -(1)
		{
			switch(pmsg ->message)
			{
			case MSG_RE_START:
			// log here pending messages in queue
			//do some functionality
			case MSG_RE_StOP:
			// log here pending messages in queue
			//do some functionality
			}
		}

		PeekMessage(pmsg, NULL, 0, 0, PM_REMOVE); // -(2)
	}
}

If there are no messages in the queue at point (1) but there is at point (2) the message is simply discarded.

Another issue is that the main thread is constantly spinning in a busy loop doing nothing, degrading system performance.

Also you simply discard all messages, even ones that don't belong to you. You should dispatch them.

Also, even if your code was even close to working (which it's not) how do you know all the messages in the queue are yours?
Steve

GeneralRe: MFC Thread queue size Pin
ajmalsiddiqi14-Apr-10 2:10
ajmalsiddiqi14-Apr-10 2:10 
GeneralRe: MFC Thread queue size Pin
Stephen Hewitt14-Apr-10 2:48
Stephen Hewitt14-Apr-10 2:48 

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.