Click here to Skip to main content
16,005,037 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ function pointers Pin
Peter Weyzen4-Nov-04 8:08
Peter Weyzen4-Nov-04 8:08 
GeneralRe: C++ function pointers Pin
Michael Dunn4-Nov-04 12:28
sitebuilderMichael Dunn4-Nov-04 12:28 
GeneralDisabling Scripts in IWebBrowser2 Pin
Member 14952024-Nov-04 7:52
Member 14952024-Nov-04 7:52 
QuestionNULL pContext on Dynamic Window Creation?? Pin
Ali Niaz4-Nov-04 6:57
Ali Niaz4-Nov-04 6:57 
QuestionWhat's wrong with this???? Pin
Tom Wright4-Nov-04 5:49
Tom Wright4-Nov-04 5:49 
AnswerRe: What's wrong with this???? Pin
David Crow4-Nov-04 7:41
David Crow4-Nov-04 7:41 
GeneralRe: What's wrong with this???? Pin
Tom Wright4-Nov-04 7:56
Tom Wright4-Nov-04 7:56 
GeneralRe: What's wrong with this???? Pin
Antony M Kancidrowski4-Nov-04 8:24
Antony M Kancidrowski4-Nov-04 8:24 
OK, this may help you out. Firtly make the myThreadFunc static as David says.

Then if you alter the parameter class/struct to hold a pointer to the CLAMsgSwDlg class you can call the non-static member function and therefore other member elements.

Add the following to the ThreadInfo class/struct
CLAMsgSwDlg* thdParent;

Make the alterations in bold
void CLAMsgSwDlg::StartAllThreads()
{
int nCount = m_lClientConn.GetItemCount();
<p></p>
ThreadInfo *mythreadinfo = new ThreadInfo[nCount];
for (int i = 0; i < nCount; i++)
{
mythreadinfo[i].thdIPaddress = m_lClientConn.GetItemText(i, 0);
mythreadinfo[i].thdPort = m_lClientConn.GetItemText(i, 1);
mythreadinfo[i].thdParent = this;
<p></p>
//Start all threads here.
CWinThread* pThread = new CWinThread[nCount];
pThread[i] = AfxBeginThread(myThreadFunc, &mythreadinfo[i]);
<p></p>
//Save the handle to the thread
HANDLE* hThread = new HANDLE[nCount];
hThread[i] = pThread->m_hThread;
}
}
<p></p>
UINT CLAMsgSwDlg::myThreadFunc(LPVOID pParam)
{
ThreadInfo *threadinfo = reinterpret_cast<ThreadInfo*>(pParam);
ASSERT(theadinfo != NULL);

threadinfo->thdParent->DoThreadStuff();
}
<p></p>
void CLAMsgSwDlg::DoThreadStuff()
{
m_sConnectSocket.SetParent(this);
//if (OnCreate)
//{

//}
}


Ant.

I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return!
- David Walliams (Little Britain)

AnswerRe: What's wrong with this???? Pin
Sujan Christo4-Nov-04 19:55
Sujan Christo4-Nov-04 19:55 
GeneralCurrent directory defining Pin
dudic4-Nov-04 5:27
dudic4-Nov-04 5:27 
GeneralRe: Current directory defining Pin
Tom Wright4-Nov-04 6:12
Tom Wright4-Nov-04 6:12 
GeneralThread question Pin
Tom Wright4-Nov-04 4:12
Tom Wright4-Nov-04 4:12 
GeneralRe: Thread question Pin
lesnikowski4-Nov-04 5:21
lesnikowski4-Nov-04 5:21 
QuestionAdd menu to CDialog? Pin
DanYELL4-Nov-04 4:00
DanYELL4-Nov-04 4:00 
AnswerRe: Add menu to CDialog? Pin
Tom Wright4-Nov-04 4:15
Tom Wright4-Nov-04 4:15 
GeneralScreenshot to .PNG Pin
peterchen4-Nov-04 3:50
peterchen4-Nov-04 3:50 
GeneralSkin on scrollbar of richedit control Pin
verma-rahul4-Nov-04 3:18
verma-rahul4-Nov-04 3:18 
GeneralPath to pdb file in binary Pin
kydfru4-Nov-04 2:51
kydfru4-Nov-04 2:51 
GeneralRe: Path to pdb file in binary Pin
Blake Miller4-Nov-04 6:13
Blake Miller4-Nov-04 6:13 
GeneralRe: Path to pdb file in binary Pin
kydfru4-Nov-04 6:22
kydfru4-Nov-04 6:22 
GeneralRe: Path to pdb file in binary Pin
Blake Miller4-Nov-04 6:32
Blake Miller4-Nov-04 6:32 
GeneralTnaks! Pin
kydfru4-Nov-04 6:53
kydfru4-Nov-04 6:53 
QuestionHow to get why LoadLibrary fails ? Pin
leandrobecker4-Nov-04 2:45
leandrobecker4-Nov-04 2:45 
AnswerRe: How to get why LoadLibrary fails ? Pin
Cedric Moonen4-Nov-04 2:51
Cedric Moonen4-Nov-04 2:51 
GeneralRe: How to get why LoadLibrary fails ? Pin
leandrobecker4-Nov-04 4:18
leandrobecker4-Nov-04 4:18 

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.