Click here to Skip to main content
14,973,498 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Error Message - How do i find missing library? Pin
Purple Monk15-Aug-06 4:24
MemberPurple Monk15-Aug-06 4:24 
GeneralRe: Error Message - How do i find missing library? Pin
Hamid_RT15-Aug-06 7:58
MemberHamid_RT15-Aug-06 7:58 
QuestionHow to declare WindowProc function in class Pin
mmhu10-Aug-06 3:15
Membermmhu10-Aug-06 3:15 
AnswerRe: How to declare WindowProc function in class Pin
Steve S10-Aug-06 3:59
MemberSteve S10-Aug-06 3:59 
GeneralRe: How to declare WindowProc function in class Pin
mmhu10-Aug-06 4:29
Membermmhu10-Aug-06 4:29 
GeneralRe: How to declare WindowProc function in class Pin
mmhu10-Aug-06 4:39
Membermmhu10-Aug-06 4:39 
GeneralRe: How to declare WindowProc function in class Pin
Steen Krogsgaard10-Aug-06 23:49
MemberSteen Krogsgaard10-Aug-06 23:49 
QuestionGetting 2 exceptions in a thread message pump Pin
TClarke10-Aug-06 3:10
MemberTClarke10-Aug-06 3:10 
Hi I've got a pretty curious situation occuring in a thread message pump i've written.
The program I've written basically involves a DDE Server passing on messages it receives to a seperate thread using PostThreadMessage with a registered windows message. Two strange things occur: Firstly, whenever a message is sent, two extra messages passing through the pump cause an exception. The messages causing the problem have a decimal value of 1000 (not a message I'm familiar with). Secondly, only ever other message gets through (though this is probably caused by the exceptions).

It's worth noting that this code resides within an ActiveX control, written with VS2003.

<br />
//A message to send, message comes out as 49732<br />
const UINT TM_ON_DDE_MESSAGE	= ::RegisterWindowMessage( _T("TM_ON_DDE_MESSAGE"));<br />
<br />
------------------------------------------<br />
//The message sending line from the DDE Server<br />
::PostThreadMessage(gdwThreadId, TM_ON_DDE_MESSAGE, (WPARAM) pInToWindow, 0);	<br />
<br />
------------------------------------------<br />
<br />
//The code used to start the thread<br />
//Start a thread to receive the messages from the DDE Server.<br />
		gdwThreadId = 0;<br />
		ghThread = ::CreateThread( <br />
			NULL,                        // default security attributes <br />
			0,                           // use default stack size  <br />
			DDEServerThreadFunc,         // thread function <br />
			this,						 // argument to thread function <br />
			0,                           // use default creation flags <br />
			&gdwThreadId);                // returns the thread identifier <br />
<br />
		// Check the return value for success.<br />
		char szMsg[50];<br />
		if (ghThread == NULL) <br />
		{<br />
			wsprintf( szMsg, "CreateThread failed. Unable to receive DDE messages from the Acrobat search plugin" ); <br />
			AfxMessageBox( szMsg, MB_OK );<br />
		}<br />
<br />
------------------------------------------<br />
<br />
//The thread message pump.<br />
WORD CDDEServer::OnWndThread()<br />
{<br />
	MSG msg;<br />
	m_keepThreadLoopGoing = TRUE;<br />
	// Wait here for messages or WM_QUIT to exit or for m_keepThreadLoopGoing to become false.<br />
	while ( ::GetMessage( &msg, NULL, 0, 0 ) != 0 && m_keepThreadLoopGoing) {<br />
		if ( !OnThreadProcess( msg.message, msg.wParam, msg.lParam ) ) {<br />
			// trace out messages for detailed debug purposes.<br />
			::DispatchMessage( &msg );<br />
		}<br />
	}<br />
	return static_cast<DWORD>( msg.wParam );	// thread exiting...<br />
}<br />
<br />
//Process thread messages, i.e in this case watch for the close thread message<br />
BOOL CDDEServer::OnThreadProcess( UINT uMsg, WPARAM wParam, LPARAM /*lParam*/ )<br />
{<br />
	bool bProcessed = true;<br />
	// require a critical section to wrap these APIs<br />
	// to avoid method re-entrant problems later.<br />
	if (uMsg == TM_ON_DDE_MESSAGE)<br />
	{//Received a DDE message.<br />
		if (wParam) {<br />
			CCriticalSection threadsafe;<br />
			threadsafe.Lock();<br />
			OnRunDDECommand( (WINDOW_LUGGAGE*) wParam);<br />
			threadsafe.Unlock();<br />
		}<br />
		bProcessed = true;<br />
	} else {<br />
		bProcessed = false;<br />
	}	<br />
	return bProcessed;<br />
}


Any ideas or insights would be very welcome.

Thanks in advance

Tom
AnswerRe: Getting 2 exceptions in a thread message pump Pin
Viorel.10-Aug-06 3:28
MemberViorel.10-Aug-06 3:28 
GeneralRe: Getting 2 exceptions in a thread message pump Pin
TClarke10-Aug-06 4:21
MemberTClarke10-Aug-06 4:21 
GeneralRe: Getting 2 exceptions in a thread message pump Pin
TClarke10-Aug-06 4:24
MemberTClarke10-Aug-06 4:24 
GeneralRe: Getting 2 exceptions in a thread message pump Pin
Viorel.10-Aug-06 5:26
MemberViorel.10-Aug-06 5:26 
GeneralRe: Getting 2 exceptions in a thread message pump Pin
TClarke10-Aug-06 22:10
MemberTClarke10-Aug-06 22:10 
GeneralRe: Getting 2 exceptions in a thread message pump Pin
TClarke10-Aug-06 22:19
MemberTClarke10-Aug-06 22:19 
Questiongetting font metrics Pin
Kiran Pinjala10-Aug-06 2:01
MemberKiran Pinjala10-Aug-06 2:01 
AnswerRe: getting font metrics Pin
sujtha10-Aug-06 2:10
Membersujtha10-Aug-06 2:10 
AnswerRe: getting font metrics Pin
Hamid_RT11-Aug-06 7:50
MemberHamid_RT11-Aug-06 7:50 
QuestionTAPI Problem ???????? Pin
Rocky Marrone10-Aug-06 1:36
MemberRocky Marrone10-Aug-06 1:36 
Question2 question regarding directories Pin
YaronNir10-Aug-06 0:58
MemberYaronNir10-Aug-06 0:58 
AnswerRe: 2 question regarding directories Pin
Parthi_Appu10-Aug-06 1:06
MemberParthi_Appu10-Aug-06 1:06 
AnswerRe: 2 question regarding directories [modified] Pin
kakan10-Aug-06 1:08
professionalkakan10-Aug-06 1:08 
GeneralRe: 2 question regarding directories Pin
Parthi_Appu10-Aug-06 1:25
MemberParthi_Appu10-Aug-06 1:25 
GeneralRe: 2 question regarding directories Pin
kakan10-Aug-06 1:59
professionalkakan10-Aug-06 1:59 
AnswerRe: 2 question regarding directories [modified] Pin
James R. Twine10-Aug-06 1:22
MemberJames R. Twine10-Aug-06 1:22 
GeneralRe: 2 question regarding directories Pin
Hamid_RT10-Aug-06 1:41
MemberHamid_RT10-Aug-06 1:41 

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.