| JDoggieIII (1) | |||||
|
Hi, 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.
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:
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. | |||||
|
Last edited on
|
|||||
| modoran (1101) | |
| Your CDraw2::drawMonitor method must be declared as static or use a normal function (not a member of a class). | |
|
|
|
| codewalker (159) | |||
_beginthread(drawMonitor, 0, (void*)12);is good except you need to pass instance/object of the class CDraw2 as argument (why is the "12" even passed? its not used anyway) like _beginthread(drawMonitor, 0, (void*)cdDrawObject);and in the function
To make it work like _beginthread(CDraw2::drawMonitor, 0, (void*)12);You need to make CDraw2::drawMonitor a static function Now this should make it work, but if you are using MFC anyway why don't you use CWinThread/AfxBeginThread instead of _beginthread? Why mix plain windows API and MFC? Also you need to look at synchronising threads, you are accessing global variables from the thread. Look at http://www.codeproject.com/Articles/3539/Threads-with-MFC and http://msdn.microsoft.com/en-us/library/975t8ks0(v=vs.71).aspx | |||
|
|
|||
| kbw (5375) | |
| You should try to do your GUI updates from the main thread. You're asking for trouble if you have multiple threads updating the screen. | |
|
|
|