Click here to Skip to main content
15,913,709 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionplease see this code Pin
amitsax7611-Nov-05 2:16
amitsax7611-Nov-05 2:16 
QuestionFile name of file opened throught Open/Save as Dialog Pin
ragavan9-Nov-05 17:44
ragavan9-Nov-05 17:44 
AnswerRe: File name of file opened throught Open/Save as Dialog Pin
Siarhei Alikhver9-Nov-05 20:37
Siarhei Alikhver9-Nov-05 20:37 
GeneralRe: File name of file opened throught Open/Save as Dialog Pin
ragavan9-Nov-05 22:05
ragavan9-Nov-05 22:05 
GeneralRe: File name of file opened throught Open/Save as Dialog Pin
Siarhei Alikhver9-Nov-05 22:37
Siarhei Alikhver9-Nov-05 22:37 
QuestionVirtual list view and multiple selection problem Pin
Jan Itor9-Nov-05 17:08
Jan Itor9-Nov-05 17:08 
Questionhow is the code here can be used? Pin
ewighell9-Nov-05 16:50
ewighell9-Nov-05 16:50 
AnswerRe: how is the code here can be used? Pin
James R. Twine9-Nov-05 17:25
James R. Twine9-Nov-05 17:25 
   The cast (which might not really be required) works because the type fGetType is really specifying the signature of the function.  In this case, that signature is "function taking an int that returns an int".  It does not return pointer-to-int, it only looks that way at first glance because of the asterisk used in the typedef.

   The _List_Type function is already a function that takes an int that returns an int.

   Here is the trick: function names, when they are being used to call a function, are really pointers behind the scenes.  They point to the address of the start of the function.  When you apply the parens to it, the parens become the "function call operator", and cause a jump to the beginning of the address of the function (and it starts being executed).  Each function pointer has an implicit type, and that type is basically its signature (although things are a little bit different when dealing with C++ object members).

   Take the following examples:
typedef int (*PFSomeFuncType)(int);
 
int SomeFunc( int iValue )
{
    return( iValue + 42 );
}
double SomeOtherFunc( double iValue )
{
    return( iValue + 42 );
}
// 
// ...
//
int main( int iArgC, char *pArgVp[] )
{
    DWORD    dwFuncAddr = (DWORD)SomeFunc;
    int      iRet = 0;
 
    iRet = ((PFSomeFuncType)dwFuncAddr)( 42 );
 
    return( 0 );
}
   In the above example, the "type" of SomeFunc is int (__cdecl *)(int), and the "type" of SomeOtherFunc is double (__cdecl *)(double).  Note that this looks a bit like the typedef above...

   If you compile and execute the above code snippet, what do you think iRet will be equal to right before main(...) returns?

   Peace!

-=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites
(Please rate this post!)
GeneralRe: how is the code here can be used? Pin
ewighell9-Nov-05 17:45
ewighell9-Nov-05 17:45 
QuestionGUI Pin
BlitzPackage9-Nov-05 13:28
BlitzPackage9-Nov-05 13:28 
AnswerRe: GUI Pin
Christian Graus9-Nov-05 13:43
protectorChristian Graus9-Nov-05 13:43 
GeneralRe: GUI Pin
BlitzPackage9-Nov-05 14:38
BlitzPackage9-Nov-05 14:38 
GeneralRe: GUI Pin
Christian Graus9-Nov-05 14:51
protectorChristian Graus9-Nov-05 14:51 
GeneralRe: GUI Pin
BlitzPackage9-Nov-05 14:58
BlitzPackage9-Nov-05 14:58 
Questioninternet Get Filetime Or Filesize. Pin
oversight_19749-Nov-05 13:21
oversight_19749-Nov-05 13:21 
QuestionCDC memory leak Pin
_Tom_9-Nov-05 11:49
_Tom_9-Nov-05 11:49 
AnswerRe: CDC memory leak Pin
Christian Graus9-Nov-05 13:45
protectorChristian Graus9-Nov-05 13:45 
QuestionExtract MS Word Menu Bar layout Pin
Ishan Banerjee9-Nov-05 11:25
Ishan Banerjee9-Nov-05 11:25 
Questionopengl drawtext Pin
lrola9-Nov-05 9:12
lrola9-Nov-05 9:12 
AnswerRe: opengl drawtext Pin
Mathieu Dijkstra9-Nov-05 9:53
Mathieu Dijkstra9-Nov-05 9:53 
QuestionSaving exceptions Pin
Federico Milano9-Nov-05 9:07
Federico Milano9-Nov-05 9:07 
Questionproblem with variable in 2 diferent dialog boxes Pin
Mathieu Dijkstra9-Nov-05 8:59
Mathieu Dijkstra9-Nov-05 8:59 
QuestionRe: problem with variable in 2 diferent dialog boxes Pin
David Crow9-Nov-05 10:11
David Crow9-Nov-05 10:11 
AnswerRe: problem with variable in 2 diferent dialog boxes Pin
Mathieu Dijkstra9-Nov-05 10:24
Mathieu Dijkstra9-Nov-05 10:24 
GeneralRe: problem with variable in 2 diferent dialog boxes Pin
David Crow9-Nov-05 10:34
David Crow9-Nov-05 10: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.