Click here to Skip to main content
15,919,245 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Correct Way to Terminate a Named Pipe Server Pin
Mark Salsbery1-Nov-07 11:47
Mark Salsbery1-Nov-07 11:47 
AnswerRe: Correct Way to Terminate a Named Pipe Server Pin
Llasus1-Nov-07 13:57
Llasus1-Nov-07 13:57 
QuestionPassing pointers to function into another function Pin
acerunner3161-Nov-07 10:04
acerunner3161-Nov-07 10:04 
AnswerRe: Passing pointers to function into another function Pin
Nemanja Trifunovic1-Nov-07 10:07
Nemanja Trifunovic1-Nov-07 10:07 
GeneralRe: Passing pointers to function into another function Pin
acerunner3161-Nov-07 10:13
acerunner3161-Nov-07 10:13 
AnswerRe: Passing pointers to function into another function Pin
David Crow1-Nov-07 10:44
David Crow1-Nov-07 10:44 
GeneralRe: Passing pointers to function into another function Pin
acerunner3161-Nov-07 11:43
acerunner3161-Nov-07 11:43 
GeneralRe: Passing pointers to function into another function Pin
David Crow1-Nov-07 12:13
David Crow1-Nov-07 12:13 
acerunner316 wrote:
I need FunctTask1,2,&3 to be able to access other member variables and functions that aren't static, so making it static wont work.


You're not out of luck just yet. Two plausible solutions still exist. One is to change the third parameter of ManageTasks() to include CModule. I don't have the syntax readily available, but it's not uncommon and can easily be searched.

The other would be to create two versions of FunctTask1(), FunctTask2(), and FunctTask3(). One would be static and the other would not. That would look something like:

BYTE CModule::FunctTask1(BYTE Param1, BYTE Param2)
{
    // access CModule variables and functions
}
 
static BYTE CModule::FunctTask1(BYTE Param1, BYTE Param2, CModule *pThis )
{
    // call the non-static version
    return pThis->FunctTask1(Param1, Param2);
}
 
void CModule::ManageTasks(BYTE Param1, BYTE Param2, BYTE (*ptrFunct)(BYTE, BYTE), CModule *pThis )
{   
    ... //unrelated code removed   
    switch (ptrFunction(1, 1, pThis))   
    {   
        case 0: // handle results   
        case 1: // handle results   
    }   
 
    ... //unrelated code removed
}
 
void CModule::OnSelchangeCombobox()
{   
    switch(m_Combobox->GetCurSel())   
    {   
        case 0: ManageTask(1, 1, FunctTask1, this); break;   
        case 1: ManageTask(1, 1, FunctTask2, this); break;   
        case 2: ManageTask(1, 1, FunctTask3, this); break;   
    }
}



"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne


GeneralRe: Passing pointers to function into another function Pin
acerunner3161-Nov-07 12:22
acerunner3161-Nov-07 12:22 
GeneralRe: Passing pointers to function into another function Pin
David Crow2-Nov-07 2:43
David Crow2-Nov-07 2:43 
AnswerRe: Passing pointers to function into another function Pin
Mark Salsbery1-Nov-07 11:04
Mark Salsbery1-Nov-07 11:04 
AnswerRe: Passing pointers to function into another function Pin
Randor 1-Nov-07 11:44
professional Randor 1-Nov-07 11:44 
GeneralRe: Passing pointers to function into another function [modified] Pin
acerunner3161-Nov-07 12:06
acerunner3161-Nov-07 12:06 
AnswerRe: Passing pointers to function into another function [modified] Pin
Stephen Hewitt1-Nov-07 14:35
Stephen Hewitt1-Nov-07 14:35 
QuestionSimple FTP Client Pin
dellthinker1-Nov-07 9:26
dellthinker1-Nov-07 9:26 
AnswerRe: Simple FTP Client Pin
JudyL_MD1-Nov-07 10:20
JudyL_MD1-Nov-07 10:20 
AnswerRe: Simple FTP Client Pin
Peter Weyzen1-Nov-07 16:24
Peter Weyzen1-Nov-07 16:24 
GeneralRe: Simple FTP Client Pin
dellthinker1-Nov-07 17:07
dellthinker1-Nov-07 17:07 
GeneralRe: Simple FTP Client Pin
Peter Weyzen1-Nov-07 20:30
Peter Weyzen1-Nov-07 20:30 
GeneralRe: Simple FTP Client Pin
dellthinker2-Nov-07 6:53
dellthinker2-Nov-07 6:53 
GeneralRe: Simple FTP Client Pin
Peter Weyzen2-Nov-07 7:32
Peter Weyzen2-Nov-07 7:32 
GeneralRe: Simple FTP Client Pin
Bram van Kampen2-Nov-07 3:22
Bram van Kampen2-Nov-07 3:22 
QuestionWizard 2000 Style Wizard Pin
Larry Mills Sr1-Nov-07 7:14
Larry Mills Sr1-Nov-07 7:14 
QuestionCan I pass through a variable number of arguments to another function? Pin
jp-mocs1-Nov-07 6:25
jp-mocs1-Nov-07 6:25 
AnswerRe: Can I pass through a variable number of arguments to another function? Pin
Luc Pattyn1-Nov-07 7:12
sitebuilderLuc Pattyn1-Nov-07 7:12 

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.