Forgot your password?
Sign in with
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Python questions
View PHP questions
All Message Boards...
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Design and Architecture
Internet of Things
C / C++ / MFC
ATL / WTL / STL
Objective-C and Swift
Hardware & Devices
Hosting and Servers
.NET (Core and Framework)
Site Bugs / Suggestions
Spam and Abuse Watch
The Insider Newsletter
The Daily Build Newsletter
Most Valuable Professionals
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
What is 'CodeProject'?
Ask a Question
Bugs and Suggestions
Article Help Forum
Comments by 2buck56 (Top 9 by date)
Richard, I thought I had tried *ar << but I must not have because that does work. This was just a learning experience as I don't think there is any real advantage to using *ar versus using ar and br for store and load operations. But it does give me knowledge for future use. Thanks for all your help.
Hmmm..... This code:
CArchive* ar = new CArchive(&f, CArchive::store);
for(x=0; x<7; x++)
numarray[x] = m_ListCtrl.GetItemText(x,0);
ar << numarray[x];
numarray[x] = m_ListCtrl.GetItemText(x,1);
ar << numarray[x];
The compiler gives this error:
error C2678: binary '<<' : no operator found which takes a left-hand operand of type 'CArchive *' (or there is no acceptable conversion)
Richard, thanks for the suggestion. However, I've tried using CArchive* ar with new and delete. Even after you delete the ar pointer, you cannot re-use it. The compiler complains with the same error message. If I am going to have to create 2 objects anyway, I might as well use ar for writing and br for reading.
_Superman, thanks for all your help. That works perfectly now. The class constructor and private member variable in CEditData did the job. For calling from the CSmartBlockDlg class into the CEditData class I stayed with creating another instance of CEditData.
The next time I need to do this I will have this project for a reference. The Dialog based class created problems for me.
Can you show me a couple of code snippets on how to get the addresss of the Dialog box and pass it to the other function? I did this: CWnd *pWnd = GetDlgItem(IDD_SMARTBLOCK_DIALOG); and passed pWnd to the other function.
I changed the other function to this: void CEditData::CheckData(int DataType, CWnd *myData) but in the CheckData function when i use myData-> the CAddList is not available.
When I call the CEditData function from the CDialog class I will create another object for that. Since I will only be doing some math over there it doesn't matter if it is done with the original class or another instance.
I'm starting to get to the point I'm seriously considering forgetting about the other class and just have my original Dialog class do everything. I was trying to avoid 1500 lines of code in one class but there may not be a way to do that.
I'm not sure I understand. I don't want a new object of the class. I just want to call a function in the original class (CSmartBlockDlg) and have it populate the original ListCtrl. However, I changed the code in the CEditData class to this:
That works and the compiler warning goes away. I wind up in the CListAdd function because my MessageBox pops up and tells me I am there. However, the ListCtrl does not populate with the data that is in the CListAdd function. If I call the CListAdd function from within another function of CSmartBlockDlg, the ListCtrl does populate with the data.
From within the CDialog button function I call the other function this way:
pInfo = NULL;
pInfo->CheckData(0); // call function in EditData.cpp
Then from within the EditData::CheckData function I call the CDialog function this way:
pList = NULL;
pList->CListAdd(0); // call ListAdd in Smart BlockDlg.cpp
I found that if I comment out the pInfo = NULL and the pList = NULL, it works. But I get compiler warnings:
uninitialized local variable 'pList' used and uninitialized local variable 'pInfo' used
And I don't think warnings should be ignored.
I couldn't get the reference method to work. I'm not sure exactly how that would be coded. I did this:
It compiles but when I run it I get a "Debug Assertion Failed" error.
I created a function in CSmartBlockDlg named CListAdd(char Data). When I run test.CListAdd(char) to call the function and pass it a char it runs with no problem and passes the char. So I guess I will create a CListDel and CListGet function and do it that way since it appears impossible to directly access the original m_ListCtrl variable.
I'm sorry but I don't understand what you mean. Where did you get m_CDialog from?
My actual dialog class is named CSmartBlockDlg. And m_ListCtrl is the identifier within that class.
I could add something like CSmartBlockDlg.AddListItem. But I will also be removing items. When that happens I will need to re-read the entire list back into the class I am in so I can use the results to repopulate an array that is being sent to a piece of hardware through the USB port. So I really need full access to the List Control from within my other class.
Last Updated 1 Jan 1900
All Rights Reserved.