Click here to Skip to main content
15,890,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Substring for char Pin
Green Fuze23-Aug-08 20:07
Green Fuze23-Aug-08 20:07 
AnswerRe: Substring for char Pin
Jijo.Raj23-Aug-08 23:26
Jijo.Raj23-Aug-08 23:26 
Questiona weird problem with global hooking of messages. Pin
Green Fuze23-Aug-08 3:07
Green Fuze23-Aug-08 3:07 
AnswerRe: a weird problem with global hooking of messages. Pin
Naveen23-Aug-08 21:32
Naveen23-Aug-08 21:32 
GeneralRe: a weird problem with global hooking of messages. Pin
Green Fuze23-Aug-08 21:47
Green Fuze23-Aug-08 21:47 
GeneralRe: a weird problem with global hooking of messages. Pin
Naveen23-Aug-08 22:20
Naveen23-Aug-08 22:20 
GeneralRe: a weird problem with global hooking of messages. Pin
Green Fuze24-Aug-08 0:35
Green Fuze24-Aug-08 0:35 
AnswerPassing the member function pointer to the AfxBeginThread and its problems. Pin
WindowsPistha23-Aug-08 3:01
WindowsPistha23-Aug-08 3:01 
Hi
I am writing this to help others who will also have the same problem

Creating worker thread :

CWinThread *pThread = AfxBeginThread(&MyThread,(LPVOID*)ptrParam);

MyThread is the member function of CWorker class,

and its prototype is UINT MyThread( LPVOID pParam ) ;

Now while compiling I am getting this error

Error 4 error C2665: ‘AfxBeginThread’ : none of the 2 overloads could convert all the argument types

We know the function prototype is correct.

MSDN ref :

UINT __cdecl MyControllingFunction( LPVOID pParam ); should be the function prototype.

We are also having the Exact prototype , so what could be the problem.

Solution :

All the Class member function will have one hidden parameter ( ie ) this pointer.

So Actucal function prototype of MyThread is UINT MyThread(CWorker pthis , LPVOID pParam ) ;

becoz of this, compiler gives this error.

To Solve the problem

1) Creating one global wrapper funciton around MyThread()

UINT wrapper(LPVOID pParam)
{

CWorker *p = new(std::nothrow) CWorker ;

if(!p)
return ;

p->MyThread(pParam);

return 0;
}

CWinThread *pThread = AfxBeginThread(&wrapper,(LPVOID*)ptrParam); wil work perfectly.


2) Declaring the member function as static

static UINT MyThread( LPVOID pParam ) ;

Note: static member funciton cant access non static member function and non static data member.



Regards,
WindowsPistha
GeneralRe: Passing the member function pointer to the AfxBeginThread and its problems. Pin
David Crow23-Aug-08 4:18
David Crow23-Aug-08 4:18 
GeneralRe: Passing the member function pointer to the AfxBeginThread and its problems. Pin
WindowsPistha24-Aug-08 19:11
WindowsPistha24-Aug-08 19:11 
GeneralRe: Passing the member function pointer to the AfxBeginThread and its problems. Pin
David Crow25-Aug-08 4:14
David Crow25-Aug-08 4:14 
GeneralRe: Passing the member function pointer to the AfxBeginThread and its problems. Pin
WindowsPistha26-Aug-08 4:22
WindowsPistha26-Aug-08 4:22 
QuestionDifference between 2 threads & 64 threads in VC++ Pin
lakshmiyv1723-Aug-08 2:14
lakshmiyv1723-Aug-08 2:14 
AnswerRe: Difference between 2 threads & 64 threads in VC++ [modified] Pin
SandipG 23-Aug-08 4:55
SandipG 23-Aug-08 4:55 
AnswerRe: Difference between 2 threads & 64 threads in VC++ Pin
bob1697223-Aug-08 8:22
bob1697223-Aug-08 8:22 
QuestionDebugging a Win32 dll loaded by LoadLibrary Pin
Klempie23-Aug-08 1:35
Klempie23-Aug-08 1:35 
AnswerRe: Debugging a Win32 dll loaded by LoadLibrary [modified] Pin
SandipG 23-Aug-08 4:52
SandipG 23-Aug-08 4:52 
GeneralRe: Debugging a Win32 dll loaded by LoadLibrary Pin
Klempie24-Aug-08 6:07
Klempie24-Aug-08 6:07 
AnswerRe: Debugging a Win32 dll loaded by LoadLibrary Pin
Hamid_RT23-Aug-08 6:50
Hamid_RT23-Aug-08 6:50 
QuestionHow to get a url if IP address is known Pin
Dhiraj kumar Saini23-Aug-08 1:04
Dhiraj kumar Saini23-Aug-08 1:04 
AnswerRe: How to get a url if IP address is known Pin
Perspx23-Aug-08 1:31
Perspx23-Aug-08 1:31 
AnswerRe: How to get a url if IP address is known Pin
enhzflep23-Aug-08 1:33
enhzflep23-Aug-08 1:33 
Question[Message Deleted] Pin
Dhiraj kumar Saini23-Aug-08 0:01
Dhiraj kumar Saini23-Aug-08 0:01 
QuestionRe: dictionary problem Pin
enhzflep23-Aug-08 1:36
enhzflep23-Aug-08 1:36 
QuestionRemove unexpexted out put Pin
vcprog22-Aug-08 23:58
vcprog22-Aug-08 23:58 

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.