Click here to Skip to main content
15,893,564 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralFile searching Pin
Shah Shehpori27-May-03 21:21
sussShah Shehpori27-May-03 21:21 
GeneralRe: File searching Pin
David Crow28-May-03 3:11
David Crow28-May-03 3:11 
GeneralRe: File searching Pin
Dudi Avramov28-May-03 3:13
Dudi Avramov28-May-03 3:13 
QuestionHow to 'talk' to an OPC server Pin
Vassili27-May-03 21:03
Vassili27-May-03 21:03 
Generaldisable/enable network adapter card on NT4 Pin
Member 36342727-May-03 20:34
Member 36342727-May-03 20:34 
GeneralRe: disable/enable network adapter card on NT4 Pin
David Crow28-May-03 4:30
David Crow28-May-03 4:30 
Generalstatic function access member variable and member function Pin
yccheok27-May-03 20:09
yccheok27-May-03 20:09 
GeneralRe: static function access member variable and member function Pin
Daniel Strigl27-May-03 20:25
Daniel Strigl27-May-03 20:25 
You need the this pointer in your static callback function!

Just take a look at Why can't I use a member function as a callback? at The Code Project Visual C++ Forum FAQ.

One way is to save the this pointer in a static member variable, like this:
class CXFaceRecognitionDlg : public CDialog
{
// Construction
public:
CXFaceRecognitionDlg(CWnd* pParent = NULL); // standard constructor
static void callback(IplImage* image);
static CXFaceRecognitionDlg* m_pThis; 
};

static CXFaceRecognitionDlg::m_pThis = NULL;

// Somewhere in one of your member function
{
    ...
    m_pThis = this;
    ...
    // call the function that need the callback function
    FunctionThatNeedCallback(callback);
    ...
}

void CXFaceRecognitionDlg::callback(IplImage* image)
{
DetectAndDrawFaces( image ); // c function lib

// Here you can use the static pointer to this

this->DoSomeMemberFunction(...); // must be public

}

Daniel Wink | ;)
---------------------------
Never change a running system!
GeneralRe: static function access member variable and member function Pin
John R. Shaw27-May-03 20:59
John R. Shaw27-May-03 20:59 
GeneralRe: static function access member variable and member function Pin
John R. Shaw27-May-03 20:47
John R. Shaw27-May-03 20:47 
GeneralQuestion for the strong Pin
aguest27-May-03 19:17
aguest27-May-03 19:17 
GeneralRe: Question for the strong Pin
John R. Shaw27-May-03 19:53
John R. Shaw27-May-03 19:53 
GeneralRe: Question for the strong Pin
qweas27-May-03 19:56
qweas27-May-03 19:56 
GeneralRe: Question for the strong Pin
aguest27-May-03 22:30
aguest27-May-03 22:30 
GeneralRe: Question for the strong Pin
Rage28-May-03 1:21
professionalRage28-May-03 1:21 
GeneralRe: Question for the strong Pin
MemLeak28-May-03 2:58
MemLeak28-May-03 2:58 
GeneralRe: Question for the strong Pin
aguest28-May-03 6:20
aguest28-May-03 6:20 
GeneralRe: Question for the strong Pin
aguest28-May-03 6:29
aguest28-May-03 6:29 
GeneralRe: Question for the strong Pin
MemLeak29-May-03 5:24
MemLeak29-May-03 5:24 
GeneralCaputuring all keystrokes Pin
SAK27-May-03 18:42
SAK27-May-03 18:42 
GeneralRe: Caputuring all keystrokes Pin
J. Dunlap27-May-03 19:35
J. Dunlap27-May-03 19:35 
GeneralRe: Caputuring all keystrokes Pin
SAK28-May-03 6:01
SAK28-May-03 6:01 
Questionhow can I close a windows process from a windows sevice Pin
fftongzhi27-May-03 17:50
fftongzhi27-May-03 17:50 
AnswerRe: how can I close a windows process from a windows sevice Pin
billdwilson328-May-03 10:27
billdwilson328-May-03 10:27 
GeneralRe: how can I close a windows process from a windows sevice Pin
fftongzhi28-May-03 15:08
fftongzhi28-May-03 15:08 

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.