Click here to Skip to main content
15,890,043 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CDC MoveTo(int,int) Pin
Hamid_RT11-Jun-08 2:04
Hamid_RT11-Jun-08 2:04 
AnswerRe: CDC MoveTo(int,int) Pin
achainard11-Jun-08 2:09
achainard11-Jun-08 2:09 
Questionthreadcreation Pin
Mohanraj D11-Jun-08 1:32
Mohanraj D11-Jun-08 1:32 
AnswerRe: threadcreation Pin
Jijo.Raj11-Jun-08 1:39
Jijo.Raj11-Jun-08 1:39 
GeneralRe: threadcreation Pin
Mohanraj D11-Jun-08 2:22
Mohanraj D11-Jun-08 2:22 
GeneralRe: threadcreation Pin
Jijo.Raj11-Jun-08 2:56
Jijo.Raj11-Jun-08 2:56 
AnswerRe: threadcreation Pin
CPallini11-Jun-08 1:39
mveCPallini11-Jun-08 1:39 
AnswerRe: threadcreation Pin
achainard11-Jun-08 2:02
achainard11-Jun-08 2:02 
Hi,

There's a class call CWinThread (for more information look on msdn).
-> MFC is a good lib only for Graphic User Interface, for the rest to not use it...

Perso i prefere use the win32 version :

// H.
HANDLE m_hThread;
DWORD m_dwThreadId;
static DWORD WINAPI ThreadProc( LPVOID pParam );
inline bool ThreadFuntion ();

// CPP.

xxxxxxx:xxxxxxxx () :
hThread ( NULL )
, m_dwThreadId ( 0 )
{
}

xxxxxx::OnClick ()
{
hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadProc, // thread function
this, // argument to thread function
0, // use default creation flags
&dwThreadId ); // returns the thread identifier

....
}

bool xxxxxx::ThreadFuntion ()
{

}

// Static function.
DWORD xxxxxx::ThreadProc ( LPVOID pParam )
{
xxxxxx * pThis = reinterpret_cast<xxxxxx *="">( pParam );

if ( !pThis )
{
return -1;
}

// Call non static function.
if ( !pThis -> ThreadFuntion ())
{
return -1;
}

return 0;
}

Use CriticalSection (InitializeCriticalSection)to secure data Access.
Use Event (CreateEvent) with WaitForMultipleObjects or WaitForSingleObject for synchonysation.
Thinks to release handle ( THread, critical section, event...) when your finised.
Take care to thread and application ending condition.
Do not call GUI object (button, list, edit...) from the thread.

Bye...

...

GeneralRe: threadcreation Pin
Mohanraj D11-Jun-08 2:30
Mohanraj D11-Jun-08 2:30 
GeneralRe: threadcreation Pin
achainard11-Jun-08 3:58
achainard11-Jun-08 3:58 
GeneralRe: threadcreation Pin
Mohanraj D11-Jun-08 20:36
Mohanraj D11-Jun-08 20:36 
GeneralRe: threadcreation Pin
achainard12-Jun-08 3:52
achainard12-Jun-08 3:52 
QuestionOnTImer in CListCtrl [modified] Pin
Anu_Bala11-Jun-08 1:02
Anu_Bala11-Jun-08 1:02 
AnswerRe: OnTImer in CListCtrl Pin
Jijo.Raj11-Jun-08 1:22
Jijo.Raj11-Jun-08 1:22 
GeneralRe: OnTImer in CListCtrl Pin
Anu_Bala11-Jun-08 1:48
Anu_Bala11-Jun-08 1:48 
GeneralRe: OnTImer in CListCtrl Pin
Jijo.Raj11-Jun-08 2:04
Jijo.Raj11-Jun-08 2:04 
Questionsnapshot code Pin
projectip11-Jun-08 0:08
projectip11-Jun-08 0:08 
AnswerRe: snapshot code Pin
Hamid_RT11-Jun-08 1:16
Hamid_RT11-Jun-08 1:16 
QuestionCapture control Pin
capint11-Jun-08 0:05
capint11-Jun-08 0:05 
AnswerRe: Capture control Pin
achainard11-Jun-08 2:12
achainard11-Jun-08 2:12 
AnswerRe: Capture control Pin
Nibu babu thomas11-Jun-08 2:14
Nibu babu thomas11-Jun-08 2:14 
GeneralRe: Capture control Pin
capint11-Jun-08 3:02
capint11-Jun-08 3:02 
GeneralRe: Capture control Pin
Nibu babu thomas11-Jun-08 3:05
Nibu babu thomas11-Jun-08 3:05 
QuestionHow to use "IOlkAccount" and other outklook related interfaces through VC++ Pin
Vikash Singh10-Jun-08 23:09
Vikash Singh10-Jun-08 23:09 
QuestionConvert int to wstring Pin
CodingLover10-Jun-08 22:34
CodingLover10-Jun-08 22:34 

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.