I am using C++ MFC and I wouldn't exactly call myself an expert :-). What I have is a thread drawMonitor which monitors when to draw and I would like it to call DrawLines() (which is a member function in the class) to do the drawing.

void drawMonitor(void *); //this is in the code file
void drawMonitor(void *arg)
    TCHAR buf[128];
    _stprintf(buf, _T("Draw Monitor started\n"));

    while (true)
        if (g_VangleReady)
            g_VangleReady = false;

    _stprintf(buf, _T("Draw Monitor stopped\n"));
void CDraw2::DrawLines() 
    //Code here

I am starting my thread using

_beginthread(drawMonitor, 0, (void*)12);

This builds and executes ok, but the DrawLines is commented out. When I remove the comments I get the error message: C3861: 'DrawLines': identifier not found. When I attempt to add drawMonitor to the class:

void CDraw2::drawMonitor(void *); //this is in the header file, all else is in the code file
void CDraw2::drawMonitor(void *arg) { /* same code as above but DrawLines is not commented out */ } //in code file

I am now starting my thread using

_beginthread(CDraw2::drawMonitor, 0, (void*)12);

I now get an error message C3867: 'CDraw2::drawMonitor': function call missing argument list; use '&CDraw2::drawMonitor' to create a pointer to member

I am not much a C++ progreammer, but we are trying to throw a demonstrator together which requires the use of C++ MFC. Any help with what I am doing wrong would be much appreciated as I've spent many hours trying to puzzle through this.

Thanks in advance.

The function passed to _beginthread() must be either a C/C++ standard global function or a static method of a class. You can't pass non-static class members because they do not exist at compile time. Make DrawLines() a static method of the class and it should compile. This is not peculiar to MFC but a requirement of all c++ programs.

This article has been dead for over six months. Start a new discussion instead.