Click here to Skip to main content
15,896,557 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Reverse Triangle Star Pin
AREYASB20-Nov-11 21:48
AREYASB20-Nov-11 21:48 
QuestionRe: Reverse Triangle Star Pin
David Crow21-Nov-11 4:13
David Crow21-Nov-11 4:13 
QuestionStar Shear Pin
AREYASB18-Nov-11 15:58
AREYASB18-Nov-11 15:58 
QuestionRe: Star Shear Pin
David Crow1-Dec-11 7:43
David Crow1-Dec-11 7:43 
QuestionUnderstanding wndproc, callbacks and threads, win32 c++ Pin
jkirkerx18-Nov-11 6:47
professionaljkirkerx18-Nov-11 6:47 
AnswerRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
David Crow18-Nov-11 7:05
David Crow18-Nov-11 7:05 
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
jkirkerx18-Nov-11 7:47
professionaljkirkerx18-Nov-11 7:47 
AnswerRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
Chuck O'Toole18-Nov-11 7:46
Chuck O'Toole18-Nov-11 7:46 
Sticking just to threads:

Go to the basics, the Windows API first. The problem with classes is that they help you but you have to do it the way the class author wanted it done. That doesn't help you learn threads, only gives you some magic to make it work. Personally I hate magic and need to see behind the curtain.

All you need to start is one function,
C#
long thread_id;
HANDLE h = _beginthreadex(NULL, 0, ActuallyGetStats, NULL, 0, (unsigned *)&thread_id);

and some code with the proper calling conventions
C#
unsigned int __stdcall ActuallyGetStats(void *)
{
    // do stuff with my network connection until it's done, then return
    return ERROR_SUCCESS;
}

This will run as a separate thread. You can put some code in there to, let say, loop 10 times, sleeping for 10 seconds each time and printing / TRACE() a message saying "I'm alive". You can also set breakpoints in there.

Now you can do some tests on the returned HANDLE in the main code to see if it's done or you can do other things. In my case, that _beginthreadex() call is done when a button is pushed on the GUI, kind of like what you had in mind.

You can also pass parameters to the function that it can use to get pointers to objects that might tell it what to do. That would be in the 4th parameter, which I've set to NULL here because there are no arguments needed.

Anyway, this is the basic start of a thread. It might be easier to play with than figuring out somebody's conventions in a class.
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
jkirkerx18-Nov-11 8:04
professionaljkirkerx18-Nov-11 8:04 
AnswerRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
Chuck O'Toole18-Nov-11 10:01
Chuck O'Toole18-Nov-11 10:01 
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
enhzflep18-Nov-11 15:27
enhzflep18-Nov-11 15:27 
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
Richard MacCutchan18-Nov-11 21:57
mveRichard MacCutchan18-Nov-11 21:57 
AnswerRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
Erudite_Eric18-Nov-11 21:55
Erudite_Eric18-Nov-11 21:55 
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
jkirkerx19-Nov-11 7:27
professionaljkirkerx19-Nov-11 7:27 
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
Erudite_Eric20-Nov-11 2:10
Erudite_Eric20-Nov-11 2:10 
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
jkirkerx20-Nov-11 7:27
professionaljkirkerx20-Nov-11 7:27 
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
Erudite_Eric20-Nov-11 23:38
Erudite_Eric20-Nov-11 23:38 
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
jkirkerx21-Nov-11 7:18
professionaljkirkerx21-Nov-11 7:18 
GeneralRe: Understanding wndproc, callbacks and threads, win32 c++ Pin
Erudite_Eric21-Nov-11 21:01
Erudite_Eric21-Nov-11 21:01 
QuestionHow to disable context-menu web browser control Pin
belfd18-Nov-11 4:28
belfd18-Nov-11 4:28 
QuestionCapturing screen content behind an open window Pin
ryan218917-Nov-11 10:38
ryan218917-Nov-11 10:38 
AnswerRe: Capturing screen content behind an open window Pin
Richard MacCutchan17-Nov-11 11:12
mveRichard MacCutchan17-Nov-11 11:12 
AnswerRe: Capturing screen content behind an open window Pin
Bernhard Hiller18-Nov-11 1:31
Bernhard Hiller18-Nov-11 1:31 
AnswerRe: Capturing screen content behind an open window Pin
Software_Developer18-Nov-11 5:07
Software_Developer18-Nov-11 5:07 
GeneralRe: Capturing screen content behind an open window Pin
ryan218921-Nov-11 5:04
ryan218921-Nov-11 5:04 

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.