How to access function in different classes
-
Hello all I am developing dialog based application. I have written a function in main dialog class and I want to access that in other classes. How to access this function in difffernt dialogs "onInitDialog()" function regards, Aj
Hey....Simply create an object to that main dialog and call the function. If you want to call the function of main dialog from its child dialog then the child oen have a member m_pParentWnd to the MainDialog Then simply call
m_pParentWnd->GetFunction();
:)Dream bigger... Do bigger...Expect smaller aji
-
Hey....Simply create an object to that main dialog and call the function. If you want to call the function of main dialog from its child dialog then the child oen have a member m_pParentWnd to the MainDialog Then simply call
m_pParentWnd->GetFunction();
:)Dream bigger... Do bigger...Expect smaller aji
Thanks for reply. can you please explain in detail that will help me. I am developing dialog based application. I have written a function in main dialog class(TestDlg.cpp) on button click i am opening new dialog (Say child.cpp ) I want to access the fuction from main dialog (TestDlg.cpp) from child.cpp. How to access the function from
-
Hello all I am developing dialog based application. I have written a function in main dialog class and I want to access that in other classes. How to access this function in difffernt dialogs "onInitDialog()" function regards, Aj
if main dialog is CMain and other class is CLocal you can use in local class CMain* m_Main=(CMain*)GetParent(); m_Main->your_variable or your_function(and also include "Main.h" in other classess)
_**
**_
WhiteSky
-
if main dialog is CMain and other class is CLocal you can use in local class CMain* m_Main=(CMain*)GetParent(); m_Main->your_variable or your_function(and also include "Main.h" in other classess)
_**
**_
WhiteSky
I tried this CMain* m_Main=(CMain*)GetParent(); m_Main->Test(1); Test is function decleareed in CMainDlg; also CMainDlg.h included in child dialog class. it gives following errors; 'm_Main': identifier not found, even with argument-dependent lookup 'CMainDlg' : undeclared identifier 'm_Main' : undeclared identifier left of '->Test' must point to class/struct/union ‘CMainDlg’: identifier not found, even with argument-dependent lookup
-
I tried this CMain* m_Main=(CMain*)GetParent(); m_Main->Test(1); Test is function decleareed in CMainDlg; also CMainDlg.h included in child dialog class. it gives following errors; 'm_Main': identifier not found, even with argument-dependent lookup 'CMainDlg' : undeclared identifier 'm_Main' : undeclared identifier left of '->Test' must point to class/struct/union ‘CMainDlg’: identifier not found, even with argument-dependent lookup
You shall use
CMainDlg
insteadCMain
and where you declare CMainDlg_**
**_
WhiteSky