Click here to Skip to main content
15,896,413 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: drawline for VC++ Pin
CPallini14-Dec-07 3:32
mveCPallini14-Dec-07 3:32 
GeneralOffline [modified] Pin
Nelek16-Dec-07 21:45
protectorNelek16-Dec-07 21:45 
QuestionRe: drawline for VC++ Pin
David Crow14-Dec-07 3:23
David Crow14-Dec-07 3:23 
GeneralRe: drawline for VC++ Pin
Mark Salsbery14-Dec-07 5:23
Mark Salsbery14-Dec-07 5:23 
GeneralRe: drawline for VC++ Pin
mercenary0114-Dec-07 15:59
mercenary0114-Dec-07 15:59 
GeneralDirectShow MPEG Encoder Filter & Encoder API in VC++ Pin
Andy Rama13-Dec-07 23:10
Andy Rama13-Dec-07 23:10 
QuestionFile Dialogs Pin
Derick Magagula13-Dec-07 23:10
Derick Magagula13-Dec-07 23:10 
GeneralRe: File Dialogs Pin
CPallini13-Dec-07 23:38
mveCPallini13-Dec-07 23:38 
GeneralRe: File Dialogs Pin
santhoshv8414-Dec-07 17:41
santhoshv8414-Dec-07 17:41 
QuestionRe: File Dialogs Pin
Hamid_RT14-Dec-07 18:40
Hamid_RT14-Dec-07 18:40 
QuestionWhat is the Disadvantage of Multiple Inheritance Pin
santhoshv8413-Dec-07 22:34
santhoshv8413-Dec-07 22:34 
AnswerRe: What is the Disadvantage of Multiple Inheritance Pin
CPallini13-Dec-07 23:05
mveCPallini13-Dec-07 23:05 
AnswerRe: What is the Disadvantage of Multiple Inheritance Pin
David Crow14-Dec-07 3:31
David Crow14-Dec-07 3:31 
QuestionAbout Thread argument Pin
manish.patel13-Dec-07 22:23
manish.patel13-Dec-07 22:23 
GeneralRe: About Thread argument Pin
Cedric Moonen13-Dec-07 22:30
Cedric Moonen13-Dec-07 22:30 
GeneralRe: About Thread argument Pin
manish.patel13-Dec-07 22:46
manish.patel13-Dec-07 22:46 
GeneralRe: About Thread argument Pin
CPallini13-Dec-07 23:32
mveCPallini13-Dec-07 23:32 
GeneralRe: About Thread argument Pin
manish.patel13-Dec-07 23:53
manish.patel13-Dec-07 23:53 
GeneralRe: About Thread argument [modified] Pin
CPallini14-Dec-07 0:12
mveCPallini14-Dec-07 0:12 
Well, as it stands you cannot.

But what about changing a bit you design?

I mean do you really need x as local variable? Cannot it be a class one?.
Or, from an opposite point of view, do you really need to access the entire class? If you need to access a subset of class data, plus some local vars, then you may package that all inside a struct and pass the struct pointer to the thread function.

BTW In fact there is a direct solution of your problem, and it is so ugly that I cannot resist the temptation to post it Blush | :O :
[modified afterwards Cedric Moonen reply  :-O ].
//-> HERE STARTS BAD CODE
class className;
struct MyUglyThreadArg
{
 className * pClass;
 int * px;
};
class className
{

  ...
  MyUglyThreadArg muta;
  void methodName()
  {
    static int x = 100;
    muta.pClass = this;
    muta.px = &x;
    _beginthread(&threadFunction, 0, &muta);
  }
...
}; 

void threadFunction( void *p )
{
  if ( ! p ) return;
  MyUglyThreadArg *pMuta = (MyUglyThreadArg *) p;
  className * pClass = (className *) p->pClass; 
  pClass->m_count++; // where count is class public int data
  *(pMuta->px) = 200; 
...
}
//<- HERE ENDS BAD CODE



Please, please, don't do that! Unsure | :~

Smile | :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.


modified on Friday, December 14, 2007 6:59:21 AM

GeneralRe: About Thread argument Pin
Cedric Moonen14-Dec-07 0:53
Cedric Moonen14-Dec-07 0:53 
GeneralRe: About Thread argument Pin
CPallini14-Dec-07 1:09
mveCPallini14-Dec-07 1:09 
GeneralRe: About Thread argument Pin
Cedric Moonen14-Dec-07 1:15
Cedric Moonen14-Dec-07 1:15 
GeneralRe: About Thread argument Pin
CPallini14-Dec-07 2:43
mveCPallini14-Dec-07 2:43 
GeneralRe: About Thread argument Pin
Cedric Moonen14-Dec-07 1:12
Cedric Moonen14-Dec-07 1:12 
GeneralRe: About Thread argument Pin
CPallini14-Dec-07 2:50
mveCPallini14-Dec-07 2: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.