Click here to Skip to main content
15,900,378 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMulti-threaded graphics in MFC Pin
Iceman16-Apr-03 5:26
Iceman16-Apr-03 5:26 
GeneralRe: Multi-threaded graphics in MFC Pin
Chris Losinger16-Apr-03 5:47
professionalChris Losinger16-Apr-03 5:47 
GeneralRe: Multi-threaded graphics in MFC Pin
Iceman16-Apr-03 6:07
Iceman16-Apr-03 6:07 
GeneralUse of class function in thread Pin
Tomaz Rotovnik16-Apr-03 5:02
Tomaz Rotovnik16-Apr-03 5:02 
GeneralRe: Use of class function in thread Pin
valikac16-Apr-03 5:35
valikac16-Apr-03 5:35 
GeneralRe: Use of class function in thread Pin
Tomaz Rotovnik16-Apr-03 5:55
Tomaz Rotovnik16-Apr-03 5:55 
GeneralRe: Use of class function in thread Pin
Joaquín M López Muñoz16-Apr-03 8:35
Joaquín M López Muñoz16-Apr-03 8:35 
GeneralRe: Use of class function in thread Pin
jason9916-Apr-03 12:53
jason9916-Apr-03 12:53 
Hi Tomaz,

the problem is that CreateThread() is a c function...and c doesn't know anything about classes or virtual tables...

try this:

//---------------------------------------------------

void YourClass::AnyFunction()
{
// declarations
DWORD dwId;

// create the thread
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartAddress,(LPVOID)this,0,&dwId);
}

DWORD YourClass::StartAddress(LPVOID lpParam)
{
// call the thread function
((YourClass*)lpParam)->ThreadFunction();
}

void YourClass::ThreadFunction()
{
...
}

//---------------------------------------------------

in the header you should declare the thread start procedure as follows:

static DWORD StartAddress(LPVOID lpParam);

..this should do it

GeneralRe: Use of class function in thread Pin
Tomaz Rotovnik16-Apr-03 23:24
Tomaz Rotovnik16-Apr-03 23:24 
GeneralCRichEditView drag and drop.. Pin
RobJones16-Apr-03 4:34
RobJones16-Apr-03 4:34 
GeneralRe: CRichEditView drag and drop.. Pin
G. Steudtel17-Apr-03 4:23
G. Steudtel17-Apr-03 4:23 
GeneralCD-ROM Status Pin
pmask16-Apr-03 3:41
pmask16-Apr-03 3:41 
GeneralRe: CD-ROM Status Pin
David Crow16-Apr-03 4:11
David Crow16-Apr-03 4:11 
GeneralRe: CD-ROM Status Pin
Joaquín M López Muñoz16-Apr-03 4:20
Joaquín M López Muñoz16-Apr-03 4:20 
QuestionHow to make an installer package Pin
gumber16-Apr-03 2:35
gumber16-Apr-03 2:35 
AnswerRe: How to make an installer package Pin
Jim Crafton16-Apr-03 3:15
Jim Crafton16-Apr-03 3:15 
AnswerRe: How to make an installer package Pin
Chris Richardson16-Apr-03 6:34
Chris Richardson16-Apr-03 6:34 
AnswerRe: How to make an installer package Pin
Ravi Bhavnani16-Apr-03 6:36
professionalRavi Bhavnani16-Apr-03 6:36 
GeneralRe: How to make an installer package Pin
Martin_Viet16-Apr-03 8:26
Martin_Viet16-Apr-03 8:26 
GeneralTermination of a thread Pin
Vassili16-Apr-03 2:11
Vassili16-Apr-03 2:11 
GeneralRe: Termination of a thread Pin
David Crow16-Apr-03 2:16
David Crow16-Apr-03 2:16 
GeneralRe: Termination of a thread Pin
Vassili16-Apr-03 3:27
Vassili16-Apr-03 3:27 
GeneralRe: Termination of a thread Pin
David Crow16-Apr-03 3:33
David Crow16-Apr-03 3:33 
GeneralRe: Termination of a thread Pin
Vassili16-Apr-03 4:24
Vassili16-Apr-03 4:24 
GeneralRe: Termination of a thread Pin
David Crow16-Apr-03 4:31
David Crow16-Apr-03 4:31 

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.