🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages Started by Christophe MINETTI Wed, 09 Jan 2008 08:58
CreateThread problem
#773
Author: Christophe MINETTI
Date: Wed, 09 Jan 2008 08:58
26 lines
1549 bytes
Hi all,

I have few problems with the CreateThread function. I am using a frame
grabber; to acquire an image I have to create a thread with the function
CreateThread. Here is my code :

threads_hdls[0] = CreateThread(NULL,0,GrabWithoutCallback,
&user_card[0], 0,NULL) ;

with the function :

DWORD WINAPI TFrameGrabber::GrabWithoutCallback(LPVOID _param)

When compiling, I have the following error messages :

Cannot convert unsigned long(stdcall*(_closure)(void*))(void *) to
unsigned long (__stdcall*)(void*)
Type mismatch in lpStartAdress in call to __stdcall
CreateThread(_Security_Attributes....)

I don't see where is the problem as the function GrabWithoutCallBack is
defined as requested by CreateThread ....

Many thanks in advance.

Christophe
Re: CreateThread problem
#774
Author: AlexB
Date: Wed, 09 Jan 2008 09:29
20 lines
1226 bytes
Christophe MINETTI wrote:

> I have few problems with the CreateThread function.
...
> threads_hdls[0] = CreateThread(NULL,0,GrabWithoutCallback,
> &user_card[0], 0,NULL) ;
... 
> DWORD WINAPI TFrameGrabber::GrabWithoutCallback(LPVOID _param)

Declare this metod as static:

class TFrameGrabber
{
 ...
 static DWORD WINAPI GrabWithoutCallback(LPVOID _param);
 ...
}

-- 
Alex
Re: CreateThread problem
#776
Author: AlexB
Date: Wed, 09 Jan 2008 12:03
12 lines
1181 bytes
Christophe MINETTI wrote:

> It works fine !

But don't forget that static methods don't receive hidden 'this'
parameter. It means that inside method you can't use fields of class
directly (i.e. this->SomeField doesn't work); if you need pointer on
class instance you should pass it manually (for example via global
variable or as part of parameters ("LPVOID _param")).

--
Alex
Re: CreateThread problem
#775
Author: Christophe MINETTI
Date: Wed, 09 Jan 2008 12:44
28 lines
1467 bytes
Thanks Alex,

It works fine !

Christophe

AlexB wrote:

> Christophe MINETTI wrote:
>
> > I have few problems with the CreateThread function.
> ...
> > threads_hdls[0] = CreateThread(NULL,0,GrabWithoutCallback,
> > &user_card[0], 0,NULL) ;
> ...
> > DWORD WINAPI TFrameGrabber::GrabWithoutCallback(LPVOID _param)
>
> Declare this metod as static:
>
> class TFrameGrabber
> {
>  ...
>  static DWORD WINAPI GrabWithoutCallback(LPVOID _param);
>  ...
> }
>
> --
> Alex
Re: CreateThread problem
#777
Author: Christophe MINETTI
Date: Wed, 09 Jan 2008 13:09
20 lines
1395 bytes
I had noticed it.

Many thanks.

Christophe

AlexB wrote:

> Christophe MINETTI wrote:
>
> > It works fine !
>
> But don't forget that static methods don't receive hidden 'this'
> parameter. It means that inside method you can't use fields of class
> directly (i.e. this->SomeField doesn't work); if you need pointer on
> class instance you should pass it manually (for example via global
> variable or as part of parameters ("LPVOID _param")).
>
> --
> Alex
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads