Click here to Skip to main content
16,011,988 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Ruler Control Pin
26-Feb-01 22:56
suss26-Feb-01 22:56 
GeneralRe: Ruler Control Pin
Erik Funkenbusch26-Feb-01 12:43
Erik Funkenbusch26-Feb-01 12:43 
GeneralRe: Ruler Control Pin
26-Feb-01 23:26
suss26-Feb-01 23:26 
GeneralCasting thread functions Pin
Joe Moldovan23-Feb-01 23:53
Joe Moldovan23-Feb-01 23:53 
GeneralRe: Casting thread functions Pin
Tim Deveaux24-Feb-01 3:57
Tim Deveaux24-Feb-01 3:57 
GeneralRe: Casting thread functions Pin
Joe Moldovan24-Feb-01 9:32
Joe Moldovan24-Feb-01 9:32 
GeneralRe: Casting thread functions Pin
aes24-Feb-01 10:49
aes24-Feb-01 10:49 
GeneralRe: Casting thread functions Pin
Joe Moldovan24-Feb-01 14:34
Joe Moldovan24-Feb-01 14:34 
You are 100% correct. I have traced this through and I now understand what is happening. THIS METHOD IS EVIL. DO NOT USE! It works by accident. My "smartass" technique is just that - smartass.

When a method with a single parameter like my thread function is called in C++, the parameter is pushed onto the stack and then the address of the instance object is pushed. This is the hidden "this" parameter. My member thread function understands these two stack entries as "this" and lpParameter.

The CreateThread only pushes ONE parameter when it calls the thread function. This is meant to be lpParameter but my function mistakes it to be "this". The second stack entry is rubbish but my function takes it to be lpParameter. So if I call CreateThread from a member function and pass "this" as the lpParameter it all seems to work as long as I don't try to use lpParameter. But in fact my stack is already corrupt. Because the thread has its own stack and when it returns this is destroyed, I don't actually blow anything up. But would you bungee jump 300 metres on a 10 kilo fishing line? Back to the drawing board.

GeneralRe: Casting thread functions Pin
Tim Deveaux24-Feb-01 15:07
Tim Deveaux24-Feb-01 15:07 
GeneralRe: Casting thread functions Pin
Joe Moldovan24-Feb-01 18:21
Joe Moldovan24-Feb-01 18:21 
GeneralRe: Casting thread functions Pin
NormDroid25-Feb-01 5:41
professionalNormDroid25-Feb-01 5:41 
GeneralRe: Casting thread functions Pin
Tim Deveaux24-Feb-01 14:58
Tim Deveaux24-Feb-01 14:58 
GeneralRe: Casting thread functions Pin
Todd Wilson24-Feb-01 15:20
Todd Wilson24-Feb-01 15:20 
GeneralRe: Casting thread functions Pin
Tim Deveaux24-Feb-01 15:32
Tim Deveaux24-Feb-01 15:32 
GeneralRe: Casting thread functions Pin
Erik Funkenbusch26-Feb-01 12:55
Erik Funkenbusch26-Feb-01 12:55 
GeneralRe: Casting thread functions Pin
Todd Wilson26-Feb-01 13:13
Todd Wilson26-Feb-01 13:13 
GeneralRe: Casting thread functions Pin
Erik Funkenbusch26-Feb-01 13:32
Erik Funkenbusch26-Feb-01 13:32 
GeneralRe: Casting thread functions Pin
Joe Moldovan24-Feb-01 17:44
Joe Moldovan24-Feb-01 17:44 
GeneralRe: Casting thread functions Pin
Tim Deveaux25-Feb-01 5:13
Tim Deveaux25-Feb-01 5:13 
GeneralRe: Casting thread functions Pin
Erik Funkenbusch26-Feb-01 13:11
Erik Funkenbusch26-Feb-01 13:11 
GeneralRe: Casting thread functions Pin
Joe Moldovan26-Feb-01 19:45
Joe Moldovan26-Feb-01 19:45 
QuestionHow to use handle_wm_notify macro which comes with win32? Pin
Sachin23-Feb-01 23:04
Sachin23-Feb-01 23:04 
AnswerRe: How to use handle_wm_notify macro which comes with win32? Pin
Sardaukar24-Feb-01 1:23
Sardaukar24-Feb-01 1:23 
GeneralOnSize Pin
Starodubtsev Sergey23-Feb-01 22:53
Starodubtsev Sergey23-Feb-01 22:53 
GeneralRe: OnSize Pin
Erik Funkenbusch26-Feb-01 13:17
Erik Funkenbusch26-Feb-01 13:17 

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.