global carray
-
how can i make a carray global. i have tried adding it in a header but it does not like my definion. i have tried making it extern but it again does not like my definion. it works great within the dialog it is created in. i am using it to hold report data. thank you. this is how i have it created. ******************************************* in h file ******************************************* typedef struct{ CString a; CString b; CString c; } MYCARRAYSTRUCT; ******************************************** in cpp file ******************************************** *************created global for the cpp MYCARRAYSTRUCT mycarraystruct; CArray mycarray; *************my funtion do{ ........ mycarraystruct.a = m_pSet->firstfield; mycarraystruct.b = m_pSet->secondfield; ..................... m_pSet->MoveNext(); }while.............
-
how can i make a carray global. i have tried adding it in a header but it does not like my definion. i have tried making it extern but it again does not like my definion. it works great within the dialog it is created in. i am using it to hold report data. thank you. this is how i have it created. ******************************************* in h file ******************************************* typedef struct{ CString a; CString b; CString c; } MYCARRAYSTRUCT; ******************************************** in cpp file ******************************************** *************created global for the cpp MYCARRAYSTRUCT mycarraystruct; CArray mycarray; *************my funtion do{ ........ mycarraystruct.a = m_pSet->firstfield; mycarraystruct.b = m_pSet->secondfield; ..................... m_pSet->MoveNext(); }while.............
Put it as a public member variable of your application class. Martin
-
Put it as a public member variable of your application class. Martin
-
how can i make a carray global. i have tried adding it in a header but it does not like my definion. i have tried making it extern but it again does not like my definion. it works great within the dialog it is created in. i am using it to hold report data. thank you. this is how i have it created. ******************************************* in h file ******************************************* typedef struct{ CString a; CString b; CString c; } MYCARRAYSTRUCT; ******************************************** in cpp file ******************************************** *************created global for the cpp MYCARRAYSTRUCT mycarraystruct; CArray mycarray; *************my funtion do{ ........ mycarraystruct.a = m_pSet->firstfield; mycarraystruct.b = m_pSet->secondfield; ..................... m_pSet->MoveNext(); }while.............
You must define the extern declaration on the top of the .cpp file... otherwise your cpp doesnot know about the the structure you defined globally do it now..! Trace The Bugs...
-
how can i make a carray global. i have tried adding it in a header but it does not like my definion. i have tried making it extern but it again does not like my definion. it works great within the dialog it is created in. i am using it to hold report data. thank you. this is how i have it created. ******************************************* in h file ******************************************* typedef struct{ CString a; CString b; CString c; } MYCARRAYSTRUCT; ******************************************** in cpp file ******************************************** *************created global for the cpp MYCARRAYSTRUCT mycarraystruct; CArray mycarray; *************my funtion do{ ........ mycarraystruct.a = m_pSet->firstfield; mycarraystruct.b = m_pSet->secondfield; ..................... m_pSet->MoveNext(); }while.............
If your application is called MyDialog Add the following structure right after the line: #include "resource.h" in the file MyDialog.h (Not MyDialogDlg.h): /////////////////////////// typedef struct { CString a; CString b; CString c; } MYCARRAYSTRUCT; ////////////////////////// Right after the declaration of MyDialogApp() a little further down in the .h file, Add the line: /////////////////////////// MYCARRAYSTRUCT mm_Global; /////////////////////////// Now in your dialog's (it is now global). Add the following line into any subroutine /////////////////////////////////////////////////////////////////////////// MYCARRAYSTRUCT *m_GData = &( ( MyDialogApp * ) AfxGetApp() ) -> mm_Global; /////////////////////////////////////////////////////////////////////////// The above line sets up a pointer to the global mm_Global. Now you can refer to the variables as pointer extensions ('->'). Best of all, VS's autocompletion will give you a list of variables in the structure, and if you put a comment ('//') after each declaration, it will show them in the autocompletion as well. Be careful if you have a timer event, that you are not clobbering work. I've chased this problem from time to time. :laugh: Woo Hoo! That's it I hope this helps Doug Doug Joseph (Engineering Guy)
-
You must define the extern declaration on the top of the .cpp file... otherwise your cpp doesnot know about the the structure you defined globally do it now..! Trace The Bugs...
-
that is another part of my problem. the external function that i want to use it in is another class.
Declare your struct just before your application class. Declare your array as: public: CArray m_mycarray; in your appilication class. Write function like: CYourApp *GetApp() { return (CYourApp *)AfxGetApp(); } Declare your function (where you want use m_mycarray) as YourFunction(CArray & m_mycarray) And then you can use it as: YourFunction(GetApp()->m_mycarray); Is it possible? Martin