Click here to Skip to main content
16,005,149 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 5:34
Tom Wright27-Jan-05 5:34 
GeneralRe: Can someone explain this please Pin
Chris Losinger27-Jan-05 5:38
professionalChris Losinger27-Jan-05 5:38 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 5:44
Tom Wright27-Jan-05 5:44 
GeneralRe: Can someone explain this please Pin
Chris Losinger27-Jan-05 5:51
professionalChris Losinger27-Jan-05 5:51 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 10:48
Tom Wright27-Jan-05 10:48 
GeneralRe: Can someone explain this please Pin
Chris Losinger27-Jan-05 10:55
professionalChris Losinger27-Jan-05 10:55 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 11:09
Tom Wright27-Jan-05 11:09 
GeneralRe: Can someone explain this please Pin
Chris Losinger27-Jan-05 12:07
professionalChris Losinger27-Jan-05 12:07 
Tom Wright wrote:
I'm trying to setup a Timer in my UI thread. While doing this I found that the easiest way was to do the SetTimer with the forth parameter being the callback function.

if you're doing this in an MFC app, you can just use the OnTimer function to handle this: use the class wizard, if you're using VC6, or change the window/dialog/app properties in VC7, to add a handler for WM_TIMER. that way, the function will be a member of your CWnd and you can use any class functions you want.

the problem with the callback method, in my opinion, is that it doesn't give you a way to pass any custom info into the callback function. some callbacks give you a parameter that you can use for things like pointers. this one requires you to get all the data from global variables.

Tom Wright wrote:
So comming full circle I'm still trying to understand when one needs to cast a pointer and when one needs to pass a pointer.

you pass a pointer when you need a pointer to something.

you cast a pointer when the pointer doesn't point to what you need it to point to, but can safely interpreted as if it was pointing to what you need. for example, if you have a pointer to an object of type C, you can cast that pointer to anything that C is derived from; this lets you call functions from the base classes; ex. if class C is derived from class B, you can cast your C* pointer to B* and then call class B's functions. likewise, if you have a C* pointer (a pointer to an object of type C), and you've cast it to a base class of type "B" ( B* pB = (B*)pC; ), you can cast that back up to a "C". but, all this requires that you know what the pointer is really pointing to, and what the class heirarchy looks like.


Image Toolkits | Image Processing | Cleek

GeneralRe: Can someone explain this please Pin
David Crow27-Jan-05 5:42
David Crow27-Jan-05 5:42 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 5:49
Tom Wright27-Jan-05 5:49 
GeneralRe: Can someone explain this please Pin
David Crow27-Jan-05 5:53
David Crow27-Jan-05 5:53 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 10:26
Tom Wright27-Jan-05 10:26 
GeneralDocument order Pin
vineas27-Jan-05 4:33
vineas27-Jan-05 4:33 
GeneralRe: Document order Pin
Neville Franks27-Jan-05 5:57
Neville Franks27-Jan-05 5:57 
GeneralRe: Document order Pin
vineas27-Jan-05 6:31
vineas27-Jan-05 6:31 
Generalmodulus error result Pin
mytz27-Jan-05 3:05
mytz27-Jan-05 3:05 
GeneralRe: modulus error result Pin
Chris Losinger27-Jan-05 3:16
professionalChris Losinger27-Jan-05 3:16 
GeneralRe: modulus error result Pin
Antony M Kancidrowski27-Jan-05 3:17
Antony M Kancidrowski27-Jan-05 3:17 
GeneralRe: modulus error result Pin
Maximilien27-Jan-05 3:17
Maximilien27-Jan-05 3:17 
Generalmodulus prob Pin
mytz27-Jan-05 3:00
mytz27-Jan-05 3:00 
GeneralRe: modulus prob Pin
Chris Losinger27-Jan-05 3:05
professionalChris Losinger27-Jan-05 3:05 
Generalcann't complie .c files in vc++ 6.0 Pin
vikram yadav27-Jan-05 2:38
vikram yadav27-Jan-05 2:38 
GeneralRe: cann't complie .c files in vc++ 6.0 Pin
David Crow27-Jan-05 2:46
David Crow27-Jan-05 2:46 
GeneralRe: cann't complie .c files in vc++ 6.0 Pin
Bob Ciora27-Jan-05 6:10
Bob Ciora27-Jan-05 6:10 
Generalusing modulus... Pin
mytz27-Jan-05 2:35
mytz27-Jan-05 2:35 

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.