Click here to Skip to main content
15,885,278 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Up-Down control Pin
David Crow25-Sep-09 9:08
David Crow25-Sep-09 9:08 
AnswerRe: Up-Down control Pin
dipuks25-Sep-09 9:25
dipuks25-Sep-09 9:25 
QuestionRe: Up-Down control Pin
David Crow25-Sep-09 9:28
David Crow25-Sep-09 9:28 
AnswerRe: Up-Down control Pin
dipuks25-Sep-09 9:37
dipuks25-Sep-09 9:37 
QuestionRe: Up-Down control Pin
David Crow25-Sep-09 9:41
David Crow25-Sep-09 9:41 
AnswerRe: Up-Down control Pin
dipuks25-Sep-09 9:48
dipuks25-Sep-09 9:48 
AnswerRe: Up-Down control Pin
Rolf Kristensen26-Sep-09 7:39
Rolf Kristensen26-Sep-09 7:39 
QuestionRules for what you can/can't do inside DOC class serialization(loading) routine Pin
al250025-Sep-09 6:27
al250025-Sep-09 6:27 
Hi all,

I have a MDI document which has to load an ascii file into a collection class on File-Open, preferably before serialization of the classes that I load using the standard CArchive serialization since those elements are dependent on the collection class. In other words my code looks like this -

void CMyDoc::Serialize(CArchive& ar)
{

if (ar.IsStoring())
	{.....

else {

CFile ChartFile;
  if (!ChartFile.Open(m_DataPathName, CFile::modeRead)){
	return FALSE;
   }

  CArchive archive(&ChartFile, CArchive::load);

  while (archive.ReadString(FileData) != NULL){

   //misc code to format ascii data

   m_MyCArray.Add();

 ar >> MyVar1
    >> MyVar2
    >> ....
}


It's all working now but the code to read the ascii file originally read some variables from the DOC class and also wrote some to the DOC class. Here is what happened before I removed that code -

1. I would get random exceptions on accesses to the variables in the doc class (sometimes they would happen, sometimes not) when exercising the File-Open menu.

2. Any Doc class variable that was set from inside this routine would be garbage after it completed.

The odd thing about this is that the container class m_MyCArray is valid after exiting this routine. Perhaps it's because m_MyCArray is instantiated (indirectly) in the Doc class while I accessed the other Doc variables with a pointer to the doc class (because the ascii file read routine is actually a seperate module instantiated in the doc class - to complex to show above).

I got this idea from an example in Jeff Prosise's book so presumably it's valid but I think there were some timing issues with my code. Perhaps the new doc class is still being initialized or is initialized after the completion of serialization. Mike Blaszczak's book has some info on how a new doc comes to life but he does not say anything about serialization in this regard.

As I said, after removing all pointer based accesses to the doc class everything seems to work fine but it would be nice to understand what state the doc class is in at the time of serialiazation or what happens afterward.

Thanks
AnswerRe: Rules for what you can/can't do inside DOC class serialization(loading) routine Pin
Iain Clarke, Warrior Programmer25-Sep-09 21:21
Iain Clarke, Warrior Programmer25-Sep-09 21:21 
QuestionFunction does not return String as wanted Pin
Tomicmanka25-Sep-09 6:26
Tomicmanka25-Sep-09 6:26 
AnswerRe: Function does not return String as wanted Pin
markkuk25-Sep-09 7:05
markkuk25-Sep-09 7:05 
QuestionRe: Function does not return String as wanted Pin
David Crow25-Sep-09 7:51
David Crow25-Sep-09 7:51 
AnswerRe: Function does not return String as wanted Pin
Tomicmanka25-Sep-09 8:47
Tomicmanka25-Sep-09 8:47 
GeneralRe: Function does not return String as wanted Pin
David Crow25-Sep-09 8:57
David Crow25-Sep-09 8:57 
AnswerRe: Function does not return String as wanted Pin
Tomicmanka25-Sep-09 9:28
Tomicmanka25-Sep-09 9:28 
GeneralRe: Function does not return String as wanted Pin
Stuart Dootson26-Sep-09 0:07
professionalStuart Dootson26-Sep-09 0:07 
GeneralRe: Function does not return String as wanted Pin
Tomicmanka26-Sep-09 0:55
Tomicmanka26-Sep-09 0:55 
QuestionHiding and showing CSplitterWnd panes "mistery" Pin
Vaclav_25-Sep-09 6:07
Vaclav_25-Sep-09 6:07 
QuestionConstant Expression Required Pin
nowrocktheworld25-Sep-09 4:49
nowrocktheworld25-Sep-09 4:49 
AnswerRe: Constant Expression Required Pin
Naveen25-Sep-09 4:59
Naveen25-Sep-09 4:59 
GeneralRe: Constant Expression Required Pin
nowrocktheworld25-Sep-09 6:18
nowrocktheworld25-Sep-09 6:18 
AnswerRe: Constant Expression Required Pin
David Crow25-Sep-09 5:40
David Crow25-Sep-09 5:40 
AnswerRe: Constant Expression Required Pin
CPallini25-Sep-09 9:51
mveCPallini25-Sep-09 9:51 
AnswerRe: Constant Expression Required Pin
Iain Clarke, Warrior Programmer25-Sep-09 21:26
Iain Clarke, Warrior Programmer25-Sep-09 21:26 
QuestionSet/get Controls of an Another dialog box [modified] Pin
hrishiS25-Sep-09 4:32
hrishiS25-Sep-09 4:32 

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.