Click here to Skip to main content
14,741,926 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 6:34
MemberTom Wright27-Jan-05 6:34 
GeneralRe: Can someone explain this please Pin
Chris Losinger27-Jan-05 6:38
professionalChris Losinger27-Jan-05 6:38 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 6:44
MemberTom Wright27-Jan-05 6:44 
GeneralRe: Can someone explain this please Pin
Chris Losinger27-Jan-05 6:51
professionalChris Losinger27-Jan-05 6:51 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 11:48
MemberTom Wright27-Jan-05 11:48 
GeneralRe: Can someone explain this please Pin
Chris Losinger27-Jan-05 11:55
professionalChris Losinger27-Jan-05 11:55 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 12:09
MemberTom Wright27-Jan-05 12:09 
GeneralRe: Can someone explain this please Pin
Chris Losinger27-Jan-05 13:07
professionalChris Losinger27-Jan-05 13: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 6:42
MemberDavid Crow27-Jan-05 6:42 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 6:49
MemberTom Wright27-Jan-05 6:49 
GeneralRe: Can someone explain this please Pin
David Crow27-Jan-05 6:53
MemberDavid Crow27-Jan-05 6:53 
GeneralRe: Can someone explain this please Pin
Tom Wright27-Jan-05 11:26
MemberTom Wright27-Jan-05 11:26 
GeneralDocument order Pin
vineas27-Jan-05 5:33
Membervineas27-Jan-05 5:33 
GeneralRe: Document order Pin
Neville Franks27-Jan-05 6:57
MemberNeville Franks27-Jan-05 6:57 
GeneralRe: Document order Pin
vineas27-Jan-05 7:31
Membervineas27-Jan-05 7:31 
Generalmodulus error result Pin
mytz27-Jan-05 4:05
Membermytz27-Jan-05 4:05 
GeneralRe: modulus error result Pin
Chris Losinger27-Jan-05 4:16
professionalChris Losinger27-Jan-05 4:16 
GeneralRe: modulus error result Pin
Antony M Kancidrowski27-Jan-05 4:17
MemberAntony M Kancidrowski27-Jan-05 4:17 
GeneralRe: modulus error result Pin
Maximilien27-Jan-05 4:17
MemberMaximilien27-Jan-05 4:17 
Generalmodulus prob Pin
mytz27-Jan-05 4:00
Membermytz27-Jan-05 4:00 
GeneralRe: modulus prob Pin
Chris Losinger27-Jan-05 4:05
professionalChris Losinger27-Jan-05 4:05 
Generalcann't complie .c files in vc++ 6.0 Pin
vikram yadav27-Jan-05 3:38
Membervikram yadav27-Jan-05 3:38 
GeneralRe: cann't complie .c files in vc++ 6.0 Pin
David Crow27-Jan-05 3:46
MemberDavid Crow27-Jan-05 3:46 
GeneralRe: cann't complie .c files in vc++ 6.0 Pin
Bob Ciora27-Jan-05 7:10
MemberBob Ciora27-Jan-05 7:10 
Generalusing modulus... Pin
mytz27-Jan-05 3:35
Membermytz27-Jan-05 3: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.