Click here to Skip to main content
15,905,782 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: static control issue :-( Pin
Tomasz Sowinski4-Sep-02 23:13
Tomasz Sowinski4-Sep-02 23:13 
GeneralRe: static control issue :-( Pin
Nish Nishant5-Sep-02 0:44
sitebuilderNish Nishant5-Sep-02 0:44 
GeneralRe: static control issue :-( Pin
Tomasz Sowinski5-Sep-02 0:55
Tomasz Sowinski5-Sep-02 0:55 
GeneralRe: static control issue :-( Pin
Nish Nishant5-Sep-02 1:12
sitebuilderNish Nishant5-Sep-02 1:12 
GeneralPrint Unicode on Win98 Pin
Eugene Pustovoyt4-Sep-02 22:03
Eugene Pustovoyt4-Sep-02 22:03 
GeneralRe: Print Unicode on Win98 Pin
Tomasz Sowinski4-Sep-02 23:26
Tomasz Sowinski4-Sep-02 23:26 
GeneralRe: Print Unicode on Win98 Pin
Eugene Pustovoyt5-Sep-02 18:38
Eugene Pustovoyt5-Sep-02 18:38 
GeneralPassing a pointer to a thread Pin
Floppe4-Sep-02 21:08
Floppe4-Sep-02 21:08 
Hello!

How can I pass a pointer for a class correctly to a CWinThread derived class?

I've got the pointer global decleared as
CMyThread* pThread;
CComPort* pGSM = new CComPort();

and when I start the workerthread I pass along the pointer like this

<br />
void CMyView::OnStartThread()<br />
{<br />
	extern CMyThread* pThread;<br />
	extern CComPort* pGSM;<br />
<br />
	if (NULL != (pThread = new CMyThread()))<br />
	{<br />
		ASSERT_VALID(pThread);<br />
		pThread->m_pThreadParams = NULL;<br />
		pThread->m_pMainWnd = AfxGetMainWnd();<br />
		pThread->m_hWnd = this->GetSafeHwnd();<br />
		pThread->pGSM = pGSM;<br />
		pThread->m_hMutex = CreateMutex( NULL, FALSE, NULL );<br />
		if (!pThread->CreateThread(CREATE_SUSPENDED))<br />
		{<br />
			delete pThread;<br />
			return;<br />
		}<br />
		VERIFY(pThread->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL));<br />
		// Now the thread can run wild<br />
		pThread->ResumeThread();<br />
	}<br />
<br />
	return;<br />
}<br />


The application works on some computers, but on others it can halt or even show diffrent status on a bool returned from pGSM.

Thanks,

Floppe
GeneralRe: Passing a pointer to a thread [corrected] Pin
Joaquín M López Muñoz4-Sep-02 21:16
Joaquín M López Muñoz4-Sep-02 21:16 
GeneralRe: Passing a pointer to a thread [corrected] Pin
Floppe4-Sep-02 21:37
Floppe4-Sep-02 21:37 
GeneralRe: Passing a pointer to a thread [corrected] Pin
Jon Hulatt4-Sep-02 21:49
Jon Hulatt4-Sep-02 21:49 
GeneralRe: Passing a pointer to a thread Pin
Gary R. Wheeler5-Sep-02 2:59
Gary R. Wheeler5-Sep-02 2:59 
QuestionHow do I toggle the "password" style for an edit box? Pin
fferland4-Sep-02 14:12
fferland4-Sep-02 14:12 
AnswerRe: How do I toggle the "password" style for an edit box? Pin
Sprudling4-Sep-02 14:42
Sprudling4-Sep-02 14:42 
QuestionCan I monitor removable device with ReadDirectoryChangesW? Pin
Hiusing4-Sep-02 13:30
Hiusing4-Sep-02 13:30 
Generalfound source of error" invalid handle" need help debugging it Pin
ns4-Sep-02 11:46
ns4-Sep-02 11:46 
GeneralRe: found source of error" invalid handle" need help debugging it Pin
Chris Losinger4-Sep-02 11:48
professionalChris Losinger4-Sep-02 11:48 
GeneralRe: found source of error" invalid handle" need help debugging it Pin
Pavel Klocek4-Sep-02 11:59
Pavel Klocek4-Sep-02 11:59 
GeneralRe: found source of error" invalid handle" need help debugging it Pin
Michael Dunn4-Sep-02 16:41
sitebuilderMichael Dunn4-Sep-02 16:41 
GeneralCOM Containment Pin
Tim Wallace4-Sep-02 11:02
Tim Wallace4-Sep-02 11:02 
GeneralRe: COM Containment Pin
Bill Wilson4-Sep-02 11:11
Bill Wilson4-Sep-02 11:11 
GeneralOOPS correction Pin
Bill Wilson5-Sep-02 7:45
Bill Wilson5-Sep-02 7:45 
GeneralInsantiating COM Objects Pin
AJ1234-Sep-02 10:49
AJ1234-Sep-02 10:49 
Generalbuilding a string from hexadecimal values Pin
Kuniva4-Sep-02 10:11
Kuniva4-Sep-02 10:11 
GeneralRe: building a string from hexadecimal values Pin
Andrew Peace4-Sep-02 10:50
Andrew Peace4-Sep-02 10:50 

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.