Click here to Skip to main content
15,923,273 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Display 2 D plot Pin
Cedric Moonen14-May-07 7:37
Cedric Moonen14-May-07 7:37 
GeneralRe: Display 2 D plot Pin
gauravsaxena_1914-May-07 8:53
gauravsaxena_1914-May-07 8:53 
QuestionMouseover Pin
prathuraj11-May-07 6:35
prathuraj11-May-07 6:35 
AnswerRe: Mouseover Pin
Mark Salsbery11-May-07 7:04
Mark Salsbery11-May-07 7:04 
AnswerRe: Mouseover Pin
Nelek13-May-07 20:27
protectorNelek13-May-07 20:27 
QuestionStrange message during serialization. please help! Pin
Arris7411-May-07 6:17
Arris7411-May-07 6:17 
QuestionRe: Strange message during serialization. please help! Pin
Mark Salsbery11-May-07 6:28
Mark Salsbery11-May-07 6:28 
AnswerRe: Strange message during serialization. please help! Pin
Arris7411-May-07 8:56
Arris7411-May-07 8:56 
Yes I use CObject Serialization. About data storing and loading I indent the storing and I use "\r\n" to skip to the next line.

I have attached the code for your review.

void BnBSymbolTreeCtrl::Serialize(CArchive& ar)
{
	
	BnBSymbolInfos* pInfo = NULL;
	TVITEM tvi = {0};
	UINT state = NULL; ;
	LPARAM param = NULL ;
	UINT mask = TVIF_HANDLE |TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_STATE|TVIF_TEXT;
	int nImage = NULL;
	int nSelectedImage = NULL; 
	
	
	if (ar.IsStoring())
	{
		// storing code
		HTREEITEM hti = GetRootItem();		
		while( hti )
		{
			//Get node data from TVITEM to define which images are attached to the item
			tvi.mask = TVIF_HANDLE |TVIF_PARAM;
			tvi.hItem =hti ;
			GetItem(&tvi);
			LPARAM param = tvi.lParam;
			int nImage;
			int nSelectedImage;
			GetItemImage(hti, nImage, nSelectedImage);
			UINT state = GetItemState(hti,TVIS_BOLD);
			UINT ste = tvi.state;
			CString str = GetItemText( hti );
			int indent = GetIndentLevel( hti );
			while( indent -- )
				ar.WriteString( "\t" );//serialize the indent level
			ar.WriteString( GetItemText( hti ) + "\r\n");//Serialize node name 
			ar << state << param << nImage << nSelectedImage;//Serialize the node properties
			ar.WriteString("\r\n" );//go to the next line
			
			pInfo = m_SymbolInfo.GetSymbolInfoObject(hti);
			if(pInfo)
				ar << pInfo->lparam;//seriliaze the symbolinfo related to the node
			ar.WriteString("\r\n" );//go to the next line
			
			hti = GetNextNearItem( hti );	
		}

	}
//Loading from Archive section	
	else
	{
		
		CString sLine;
		
		if(!ar.ReadString( sLine ) )
			return;

		//be sure the tree is cleaned before loading
		DeleteAllItems( );
		HTREEITEM hti = NULL;
		int indent, baseindent = 0;
		CString strReturn = "\r\n";
		while( sLine[baseindent] == '\t' )
			baseindent++;
		do
		{
			if( sLine.GetLength() == 0 )
				continue;
			for( indent = 0; sLine[indent] == '\t'; indent++ )
				;		// We don't need a body
			sLine = sLine.Right( sLine.GetLength() - indent );
			indent -= baseindent;

			HTREEITEM parent;
			int previndent = GetIndentLevel( hti );
			if( indent ==  previndent)
				parent = GetParentItem( hti );
			else if( indent > previndent )
				parent = hti;
			else
			{
				int nLevelsUp = previndent - indent;
				parent = GetParentItem( hti );
				while( nLevelsUp-- )
					parent = GetParentItem( parent );
			}
			

			ar >> state >> param >> nImage >> nSelectedImage;//upload the node properties
			ar.ReadString(strReturn);//go to the next line
			hti = InsertItem( mask, sLine,nImage, nSelectedImage,state,\
				state ,param, parent ? parent : TVI_ROOT, TVI_LAST );//insert the node in the view
			//Deserialize the symbolInfo related to the node
			//tvi.mask = TVIF_HANDLE |TVIF_PARAM;
			tvi.hItem = hti;
			GetItem(&tvi);
			pInfo = new BnBSymbolInfos();
			ar >> pInfo->lparam;
			if(pInfo)//link the symbolinfo to its related node
			{
				if(pInfo->lparam == tvi.lParam)
				{
					tvi.lParam = reinterpret_cast<LPARAM> (pInfo);
					SetItem(&tvi);
				}	

			}
			
			ar.ReadString(strReturn);//Go to the next line

		}while(	ar.ReadString( sLine ));

	}

}

GeneralRe: Strange message during serialization. please help! Pin
Mark Salsbery11-May-07 9:55
Mark Salsbery11-May-07 9:55 
GeneralRe: Strange message during serialization. please help! Pin
Arris7411-May-07 10:59
Arris7411-May-07 10:59 
QuestionRe: Strange message during serialization. please help! Pin
Mark Salsbery11-May-07 11:14
Mark Salsbery11-May-07 11:14 
AnswerRe: Strange message during serialization. please help! Pin
Arris7411-May-07 11:54
Arris7411-May-07 11:54 
GeneralRe: Strange message during serialization. please help! Pin
Mark Salsbery11-May-07 12:19
Mark Salsbery11-May-07 12:19 
QuestionNo Windows xp visual styles in VC++ 2003 Pin
johnny__XP11-May-07 6:06
johnny__XP11-May-07 6:06 
AnswerRe: No Windows xp visual styles in VC++ 2003 Pin
Mark Salsbery11-May-07 6:22
Mark Salsbery11-May-07 6:22 
QuestionBreaking out of a blocking function...[Threads] Pin
Eytukan11-May-07 5:23
Eytukan11-May-07 5:23 
AnswerRe: Breaking out of a blocking function...[Threads] Pin
CPallini11-May-07 5:34
mveCPallini11-May-07 5:34 
GeneralRe: Breaking out of a blocking function...[Threads] Pin
Eytukan11-May-07 5:39
Eytukan11-May-07 5:39 
GeneralRe: Breaking out of a blocking function...[Threads] Pin
CPallini11-May-07 9:28
mveCPallini11-May-07 9:28 
GeneralRe: Breaking out of a blocking function...[Threads] Pin
Roger Stoltz11-May-07 9:43
Roger Stoltz11-May-07 9:43 
GeneralRe: Breaking out of a blocking function...[Threads] Pin
Eytukan11-May-07 23:14
Eytukan11-May-07 23:14 
GeneralRe: Breaking out of a blocking function...[Threads] Pin
Stephen Hewitt11-May-07 21:29
Stephen Hewitt11-May-07 21:29 
GeneralRe: Breaking out of a blocking function...[Threads] Pin
CPallini12-May-07 1:08
mveCPallini12-May-07 1:08 
GeneralRe: Breaking out of a blocking function...[Threads] Pin
Daniel Grunwald13-May-07 2:59
Daniel Grunwald13-May-07 2:59 
GeneralRe: Breaking out of a blocking function...[Threads] Pin
CPallini13-May-07 10:38
mveCPallini13-May-07 10:38 

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.