Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Thread Problem, CreateThread

Status
Not open for further replies.

ackka

Programmer
Sep 25, 1999
269
0
0
US
Hi, I am writing an animation program for work using Visual C++, in a Windows based Environment. In order to get the animation to run smoothly I used 2 extra threads to control the refresh rate and creation of the animation objects (rectangles, circles etc..) To do this I use the Windows API function CreateThread(), this function needs a pointer to a function, where the thread will start. The pointer is of type (LPTHREAD_START_ROUTINE) and the function simply has to be a DWORD AnyFunc(LPVOID param). The thread start function in the test program is global, I was trying to get it to be a public function inside of a class.

The class name is SysAnimation

I created a pointer named

LPTHREAD_START_ROUTINE FuncPtr;

If I use FuncPtr inside of CreateThread() as the 3rd paramter, the program compiles fine.

The function I want to use as the thread start is defined as...

DWORD WINAPI SysAnimation::RefThread(LPVOID param)

I try to set the function pointer inside of the SysAnimation construtor

FuncPtr = RefThread;

When trying to do this conversion, It will not compile saying that it cannot convert
"unsigned long (__stdcall SysAnimation::*)(void *) to unsigned long(__stdcall *)(void *) "

Does anyone know a way to get this function pointer to copy?

////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////

I can get the program working using a global function that acts as the thread start. However I want to avoid having to use global functions. The only other thing I could think of was having a class, that when it is Instantiated becomes a thread. I know how to do this in java, but not in MS Visual C++

Thanks for any help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top