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

C / C++ / MFC

 
GeneralRe: Check box control Pin
Steve Obbayi24-Oct-03 3:22
professionalSteve Obbayi24-Oct-03 3:22 
GeneralRe: Check box control Pin
Anonymous24-Oct-03 5:51
Anonymous24-Oct-03 5:51 
GeneralAbout MAP Development in which i can display longitude and latitude information Pin
Member 99701023-Oct-03 20:24
Member 99701023-Oct-03 20:24 
GeneralRe: About MAP Development in which i can display longitude and latitude information Pin
Ted Ferenc23-Oct-03 21:40
Ted Ferenc23-Oct-03 21:40 
Questionusing typedef on class function pointer ? Pin
not_happy023-Oct-03 20:03
not_happy023-Oct-03 20:03 
AnswerRe: using typedef on class function pointer ? Pin
Michael Dunn23-Oct-03 20:18
sitebuilderMichael Dunn23-Oct-03 20:18 
GeneralRe: using typedef on class function pointer ? Pin
not_happy023-Oct-03 21:26
not_happy023-Oct-03 21:26 
AnswerRe: using typedef on class function pointer ? Pin
Iain Clarke, Warrior Programmer24-Oct-03 3:43
Iain Clarke, Warrior Programmer24-Oct-03 3:43 
You problem is that you are trying to store a pointer to a non-static function. You just can't.
There are ways around it though.

Imagine a class with a work thread function in it.

class CMyClass
{
    virtual	DWORD	DoScan ();
    static	DWORD WINAPI DoScanStatic (LPVOID lpParameter);
    ... etc.
};

main ()
{
    ...
    DWORD dwID;
    HANDLE hThread;
    hThread = ::CreateThread (NULL, 0, DoScan, this, CREATE_SUSPENDED, &dwID);   // This will error
    hThread = ::CreateThread (NULL, 0, DoScanStatic, this, CREATE_SUSPENDED, &dwID);   // This will work
    ...
}


You can make your life simpler by renaming DoScanStatic to DoScan and using overloading.
eg.
virtual DWORD   DoScan ();
static  DWORD WINAPI DoScan (LPVOID lpParameter)
{
    CMyClass *my = (CMyClass *) lpParameter;
    ASSERT(my);
    if (my == NULL)
        return 0;  // Or throw an exception, etc.
    return my->DoScan ();
}


This way you can use a static callback, and make in inheritable via indirection.
Did that help?

Iain.
GeneralRe: using typedef on class function pointer ? Pin
Michael Dunn24-Oct-03 12:33
sitebuilderMichael Dunn24-Oct-03 12:33 
GeneralRe: using typedef on class function pointer ? Pin
Iain Clarke, Warrior Programmer26-Oct-03 0:16
Iain Clarke, Warrior Programmer26-Oct-03 0:16 
GeneralRe: using typedef on class function pointer ? Pin
Iain Clarke, Warrior Programmer26-Oct-03 0:32
Iain Clarke, Warrior Programmer26-Oct-03 0:32 
GeneralRe: using typedef on class function pointer ? Pin
Mike O'Neill24-Oct-03 14:12
Mike O'Neill24-Oct-03 14:12 
GeneralRe: using typedef on class function pointer ? Pin
Iain Clarke, Warrior Programmer26-Oct-03 0:13
Iain Clarke, Warrior Programmer26-Oct-03 0:13 
GeneralRe: using typedef on class function pointer ? Pin
Mike O'Neill26-Oct-03 11:32
Mike O'Neill26-Oct-03 11:32 
GeneralRe: using typedef on class function pointer ? Pin
Iain Clarke, Warrior Programmer26-Oct-03 22:39
Iain Clarke, Warrior Programmer26-Oct-03 22:39 
AnswerRe: using typedef on class function pointer ? Pin
Michael Dunn24-Oct-03 12:35
sitebuilderMichael Dunn24-Oct-03 12:35 
GeneralRe: using typedef on class function pointer ? Pin
not_happy028-Oct-03 14:20
not_happy028-Oct-03 14:20 
Generalunocows.lib Pin
nikoladsp23-Oct-03 19:10
nikoladsp23-Oct-03 19:10 
GeneralRe: unocows.lib Pin
Shog923-Oct-03 19:51
sitebuilderShog923-Oct-03 19:51 
GeneralMSChart question Pin
nikoladsp23-Oct-03 19:07
nikoladsp23-Oct-03 19:07 
GeneralAnother registry question Pin
dafunkt23-Oct-03 18:42
dafunkt23-Oct-03 18:42 
GeneralRe: Another registry question Pin
Michael Dunn23-Oct-03 19:04
sitebuilderMichael Dunn23-Oct-03 19:04 
GeneralRe: Another registry question Pin
David Crow24-Oct-03 3:04
David Crow24-Oct-03 3:04 
GeneralRe: Another registry question Pin
Alexander M.,24-Oct-03 10:03
Alexander M.,24-Oct-03 10:03 
GeneralRe: Another registry question Pin
Atlantys24-Oct-03 11:10
Atlantys24-Oct-03 11:10 

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.