Click here to Skip to main content
15,923,087 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralConvert CString to CTime / COleDateTime Pin
P-Rex14-Jun-05 4:39
P-Rex14-Jun-05 4:39 
GeneralRe: Convert CString to CTime / COleDateTime Pin
David Crow14-Jun-05 2:07
David Crow14-Jun-05 2:07 
GeneralRe: Convert CString to CTime / COleDateTime Pin
P-Rex14-Jun-05 5:17
P-Rex14-Jun-05 5:17 
GeneralRe: Convert CString to CTime / COleDateTime Pin
David Crow14-Jun-05 2:22
David Crow14-Jun-05 2:22 
GeneralRe: Convert CString to CTime / COleDateTime Pin
DavidR_r14-Jun-05 8:00
DavidR_r14-Jun-05 8:00 
GeneralRe: Convert CString to CTime / COleDateTime Pin
David Crow14-Jun-05 8:04
David Crow14-Jun-05 8:04 
GeneralRe: Convert CString to CTime / COleDateTime Pin
JWood14-Jun-05 6:03
JWood14-Jun-05 6:03 
GeneralRe: Convert CString to CTime / COleDateTime Pin
P-Rex14-Jun-05 20:22
P-Rex14-Jun-05 20:22 
Questionmake stacktrace or what calls DllCanUnloadNow? Pin
ThinkingPrometheus14-Jun-05 4:21
ThinkingPrometheus14-Jun-05 4:21 
GeneralLooking for Dialog Manager component for VC++ 7. Pin
mlatimer14-Jun-05 4:00
mlatimer14-Jun-05 4:00 
QuestionHow to run a thread as a member function of a class? Pin
Eytukan14-Jun-05 3:45
Eytukan14-Jun-05 3:45 
AnswerRe: How to run a thread as a member function of a class? Pin
Bob Stanneveld14-Jun-05 4:08
Bob Stanneveld14-Jun-05 4:08 
GeneralRe: How to run a thread as a member function of a class? Pin
Eytukan14-Jun-05 1:43
Eytukan14-Jun-05 1:43 
GeneralRe: How to run a thread as a member function of a class? Pin
Bob Stanneveld14-Jun-05 1:49
Bob Stanneveld14-Jun-05 1:49 
GeneralRe: How to run a thread as a member function of a class? Pin
Eytukan14-Jun-05 1:55
Eytukan14-Jun-05 1:55 
GeneralRe: How to run a thread as a member function of a class? Pin
Eytukan14-Jun-05 2:06
Eytukan14-Jun-05 2:06 
GeneralRe: How to run a thread as a member function of a class? Pin
David Crow14-Jun-05 2:20
David Crow14-Jun-05 2:20 
GeneralRe: How to run a thread as a member function of a class? Pin
Bob Stanneveld14-Jun-05 21:17
Bob Stanneveld14-Jun-05 21:17 
AnswerRe: How to run a thread as a member function of a class? Pin
Cedric Moonen14-Jun-05 1:57
Cedric Moonen14-Jun-05 1:57 
AnswerRe: How to run a thread as a member function of a class? Pin
Michael Dunn14-Jun-05 4:21
sitebuilderMichael Dunn14-Jun-05 4:21 
GeneralRe: How to run a thread as a member function of a class? Pin
Eytukan14-Jun-05 2:14
Eytukan14-Jun-05 2:14 
Generali'm Noosed down by the THREADS!! Pin
Eytukan14-Jun-05 2:25
Eytukan14-Jun-05 2:25 
GeneralSolution for the thread Pin
Eytukan15-Jun-05 6:11
Eytukan15-Jun-05 6:11 
bob,david,cedric,michael, and paul........
paul the link u gave is ultimate.. thank u so much. really resourceful.i think i wont be disturbing u guys again.. everything's there Smile | :)

The Thread Solution

It is almost always the case that you can use threads to do the job more easily. This is not without certain costs and hazards, but it ultimately is the better method.

Here's a solution to handling the invert-everything. Note that we have to move from the pure-C domain (which we interface to via a static method) to the MFC domain.

To the class (in this example, a CView-derived class), add the following declarations:

static UINT run(LPVOID p);
void run();
volatile BOOL running;
To start a thread, your handler does

void CMyView::doInvert()
{
running = TRUE;
AfxBeginThread(run, this);
}

UINT CMyView::run(LPVOID p)
{
CMyView * me = (CMyView *)p;
me->run();
return 0;
}

void CMyView::run()
{
for(int x=y = 0; running && y < image.height; y++)
for(int x = 0; running && x < image.width; x++)
changePixel(x, y);
running = FALSE;
}
The command to stop the thread is very simple:

void CMyView::OnStop()
{
running = FALSE;
}
That's all there is to it!
Laugh | :laugh:


vivek
AnswerRe: How to run a thread as a member function of a class? Pin
Paul Steane14-Jun-05 19:28
Paul Steane14-Jun-05 19:28 
Generalplease check out this link Pin
Eytukan15-Jun-05 6:20
Eytukan15-Jun-05 6:20 

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.