Click here to Skip to main content
15,909,747 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralUser Interface Pin
Mark Salsbery9-Nov-07 12:09
Mark Salsbery9-Nov-07 12:09 
GeneralRe: User Interface Pin
Bram van Kampen10-Nov-07 14:13
Bram van Kampen10-Nov-07 14:13 
NewsRe: User Interface Pin
Mark Salsbery11-Nov-07 6:12
Mark Salsbery11-Nov-07 6:12 
GeneralRe: User Interface Pin
DevMentor.org10-Nov-07 15:17
DevMentor.org10-Nov-07 15:17 
Question_beginthread, can we create a thread in a class? [modified] Pin
Gofur Halmurat9-Nov-07 11:53
Gofur Halmurat9-Nov-07 11:53 
AnswerRe: _beginthread, can we create a thread in a class? Pin
Mark Salsbery9-Nov-07 12:32
Mark Salsbery9-Nov-07 12:32 
GeneralRe: _beginthread, can we create a thread in a class? Pin
Gofur Halmurat9-Nov-07 12:39
Gofur Halmurat9-Nov-07 12:39 
GeneralRe: _beginthread, can we create a thread in a class? Pin
Mark Salsbery9-Nov-07 12:49
Mark Salsbery9-Nov-07 12:49 
A static method can only access static class members.

To get around this, typically a pointer to an object of the class is passed
to the thread proc.  Then the thread proc can use that pointer to access
non static members of the class.

Here's an example (my changes are in red)...
class CMaClasse
{
   <font color="Red">void *pThreadArgs;</font>
public:
   void FoncAppnt(void* args);
   static void FoncApp(void* arg);
};

void CMaClasse::FoncAppnt(void* args)
{
   <font color="Red">pThreadArgs = args;</font>

   _beginthread(&CMaClasse::FoncApp,0,<font color="Red">this</font>);
}


void CMaClasse::FoncApp(void* arg)
{
<font color="Red">   // The passed param is a CMacClasse pointer
   CMaClasse *pThis = (CMaClasse *)arg;

   // example of accessing a class member
   pThis->pThreadArgs->...</font>

   //...
}



Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: _beginthread, can we create a thread in a class? Pin
Gofur Halmurat9-Nov-07 13:15
Gofur Halmurat9-Nov-07 13:15 
AnswerRe: _beginthread, can we create a thread in a class? Pin
George L. Jackson9-Nov-07 13:25
George L. Jackson9-Nov-07 13:25 
AnswerRe: _beginthread, can we create a thread in a class? Pin
dtr19-Nov-07 20:37
dtr19-Nov-07 20:37 
QuestionRe: _beginthread, can we create a thread in a class? Pin
George L. Jackson10-Nov-07 0:05
George L. Jackson10-Nov-07 0:05 
AnswerRe: _beginthread, can we create a thread in a class? Pin
dtr110-Nov-07 0:17
dtr110-Nov-07 0:17 
QuestionRC2135 Pin
Dr. Emmett Brown9-Nov-07 11:51
Dr. Emmett Brown9-Nov-07 11:51 
Questioncheck for decimal in numerical string Pin
kani989-Nov-07 11:40
kani989-Nov-07 11:40 
AnswerRe: check for decimal in numerical string Pin
chandu0049-Nov-07 20:44
chandu0049-Nov-07 20:44 
AnswerRe: check for decimal in numerical string [modified] Pin
dtr19-Nov-07 21:13
dtr19-Nov-07 21:13 
GeneralRe: check for decimal in numerical string Pin
Mark Salsbery10-Nov-07 6:01
Mark Salsbery10-Nov-07 6:01 
AnswerRe: check for decimal in numerical string Pin
David Crow10-Nov-07 15:47
David Crow10-Nov-07 15:47 
GeneralRe: check for decimal in numerical string Pin
kani9813-Nov-07 6:29
kani9813-Nov-07 6:29 
QuestionCTreeCtrl not showing tree Pin
act_x9-Nov-07 10:20
act_x9-Nov-07 10:20 
AnswerRe: CTreeCtrl not showing tree Pin
Mark Salsbery9-Nov-07 10:30
Mark Salsbery9-Nov-07 10:30 
GeneralRe: CTreeCtrl not showing tree Pin
act_x9-Nov-07 10:37
act_x9-Nov-07 10:37 
GeneralRe: CTreeCtrl not showing tree Pin
Mark Salsbery9-Nov-07 10:41
Mark Salsbery9-Nov-07 10:41 
GeneralRe: CTreeCtrl not showing tree Pin
act_x9-Nov-07 10:44
act_x9-Nov-07 10:44 

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.