Home | Products | Download | Purchase | Support 


   

DynamicLink Sample

 

The DynamicLink sample demonstrates how to build an dynamic link line, it likes water flowing, as below.

Steps:

1. Design any symbols with ShapeDesigner.

2. Create diagram with DiagramEditor and save it to a xdg file.

3. Load Xdg file to the canvas by call:

#define ID_TIMER_ID 1123

void CDynamicLinkView::OnInitialUpdate()
{
	SetCurrentModel(GetDocument()->m_pDataModel);
	CFODrawView::OnInitialUpdate();
	LoadXdgFromResource(IDR_MAIN, _T("XdgRes"), FALSE);
	GetCurrentModel()->SetDesignMode(FALSE);
//	this->ZoomToFitPageWidth();
	SetTimer(ID_TIMER_ID, 50, NULL);

	for(int x = 0; x < GetCurrentModel()->GetShapes()->Count(); x++)
	{
		CFODrawShape *pShape = (CFODrawShape *)GetCurrentModel()->GetShapes()->GetObject(x);
		if(pShape->IsKindOf(RUNTIME_CLASS(CFOLinkShape)))
		{
			m_Links.AddTail(pShape);
		}
	}
}

4.  Do animate with timer:


void CDynamicLinkView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	
	if(nIDEvent == ID_TIMER_ID)
	{
		if(m_Links.GetCount() > 0)
		{
			POSITION pos = m_Links.GetHeadPosition();
			while(pos != NULL)
			{
				CFOLinkShape *pLink = (CFOLinkShape *)m_Links.GetNext(pos);
				pLink->DoAnimate();
			}
	
			UpdateShapes(&m_Links);
		}
	}
	else
	{
		CFODrawView::OnTimer(nIDEvent);
	}
}

[ Home | Products | Download Area | Purchase | SupportContact us ]


Copyright ?1998-2007 UCanCode.Net Software, all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.com