Click here to Skip to main content
15,894,405 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Menu Bar Pin
xxhimanshu6-Jan-03 17:54
xxhimanshu6-Jan-03 17:54 
GeneralFrom CWnd to CFrameWnd: menu items appear disabled! Pin
Mr.Freeze6-Jan-03 13:43
Mr.Freeze6-Jan-03 13:43 
GeneralWorking now, but don't know why! Pin
Mr.Freeze6-Jan-03 17:44
Mr.Freeze6-Jan-03 17:44 
GeneralRe: From CWnd to CFrameWnd: menu items appear disabled! Pin
Michael Dunn6-Jan-03 21:24
sitebuilderMichael Dunn6-Jan-03 21:24 
QuestionFunction Pointer? Pin
Aidman6-Jan-03 11:16
Aidman6-Jan-03 11:16 
AnswerRe: Function Pointer? Pin
Stefan Pedersen6-Jan-03 11:35
Stefan Pedersen6-Jan-03 11:35 
AnswerRe: Function Pointer? Pin
Chris Richardson6-Jan-03 11:38
Chris Richardson6-Jan-03 11:38 
GeneralAdvanced Function Pointer? Pin
Aidman6-Jan-03 13:02
Aidman6-Jan-03 13:02 
Great Thanks Chris Richardson! Smile | :)
I am sorry, I feel a little dumb not realizing that C++ must hade such a method.

But here’s another “function pointer” related question, which may be more advanced if that’s ok? Let’s say you have a function (in your own application) whose arguments are stored customable in variable arrays and the function name you don’t know. The only thing you have as a pointer of the function is a simple memory pointer/adress (no real function pointer) that points to a memory location where the function is stored during run-time. The following code example would demonstrate what I am trying to say.

<br />
// MEMPTR is a variable type pointing to a location in memory<br />
<br />
struct FUNCSTRUCT { // Function calling structure<br />
      MEMPTR *FunctPtr; // Function pointer<br />
      int VarCount; // Number of Variables<br />
      MEMPTR *VarPtr[255]; // Varaible pointers<br />
      int VarSize[255]; // Varaible byte sizes<br />
}<br />
<br />
MEMPTR CallFunc(FUNCSTRUCT *FunctData); // The powerful function that does the call<br />
<br />
int TheRealFunc(int Argument){ // Declare normal function<br />
      return Argument;<br />
}<br />
<br />
int main(){<br />
      FUNCSTRUCT FuncData; // Declare function type<br />
      int Value = 1; // Give a value to send as argument<br />
<br />
      FuncData.FunctPtr = TheRealFunc; // Point to normal function<br />
      FuncData.VarCount = 1; // Number of values to send as arguments<br />
      FuncData.VarPtr[0] = Value; // Point to the value<br />
      FuncData.VarSize[0] = 2; // Byte size of an integer value<br />
<br />
      return CallFunc(&FuncData); // Call the function<br />
}<br />


Is it possible to create such a function as “CallFunc” that could call a function, only knowing the custom arguments and a memory pointer/address? If so then how and how would the “MEMPTR” variable type look like? I presume that this question is a lot harder and I guess it includes some low-level knowledge. But is this possible and if it is then please explain how and demonstrate it in code please or could you point me to a tutorial on this. Confused | :confused:
GeneralRe: Advanced Function Pointer? Pin
valikac6-Jan-03 14:13
valikac6-Jan-03 14:13 
GeneralRe: Advanced Function Pointer? Pin
Aidman6-Jan-03 21:37
Aidman6-Jan-03 21:37 
GeneralRe: Advanced Function Pointer? Pin
Stefan Pedersen7-Jan-03 1:55
Stefan Pedersen7-Jan-03 1:55 
GeneralRe: Advanced Function Pointer? Pin
Aidman7-Jan-03 3:28
Aidman7-Jan-03 3:28 
GeneralRe: Advanced Function Pointer? Pin
Stefan Pedersen7-Jan-03 3:34
Stefan Pedersen7-Jan-03 3:34 
GeneralRe: Advanced Function Pointer? Pin
Todd Smith7-Jan-03 5:46
Todd Smith7-Jan-03 5:46 
GeneralRe: Advanced Function Pointer? Pin
Aidman7-Jan-03 6:37
Aidman7-Jan-03 6:37 
GeneralRe: Advanced Function Pointer? Pin
Chris Richardson7-Jan-03 7:38
Chris Richardson7-Jan-03 7:38 
GeneralRe: Advanced Function Pointer? Pin
Aidman7-Jan-03 10:50
Aidman7-Jan-03 10:50 
GeneralFunction Pointers in OOP Pin
tilli again6-Jan-03 11:11
susstilli again6-Jan-03 11:11 
GeneralRe: Function Pointers in OOP Pin
Alvaro Mendez6-Jan-03 11:38
Alvaro Mendez6-Jan-03 11:38 
GeneralRe: Function Pointers in OOP Pin
William E. Kempf6-Jan-03 12:03
William E. Kempf6-Jan-03 12:03 
GeneralRe: Function Pointers in OOP Pin
valikac6-Jan-03 16:07
valikac6-Jan-03 16:07 
GeneralRe: Function Pointers in OOP Pin
tilli again7-Jan-03 8:43
susstilli again7-Jan-03 8:43 
GeneralRe: Function Pointers in OOP Pin
tilli again8-Jan-03 8:18
susstilli again8-Jan-03 8:18 
QuestionTree Control Check Boxes... ??? Pin
work_to_live6-Jan-03 9:31
work_to_live6-Jan-03 9:31 
AnswerRe: Tree Control Check Boxes... ??? Pin
work_to_live6-Jan-03 9:51
work_to_live6-Jan-03 9:51 

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.