显示股票视图的全局函数

BOOL AfxShowStockRealTime( int nStockIndex, BOOL bFromSList );

BOOL AfxShowStockRealTime( const char * szCode );

BOOL AfxShowStockGraph( int nStockIndex, BOOL bFromSList );

BOOL AfxShowStockGraph( const char * szCode );

BOOL AfxShowStockBase( int nStockIndex, BOOL bFromSList );

BOOL AfxShowStockInfo( int nStockIndex, BOOL bFromSList );

BOOL AfxShowStockTech( UINT nTech );

BOOL AfxShowStockRealTime( const char * szCode )

{

     //得到CRealTimeView 的对象

     CRealTimeView * pView = AfxGetRealTimeView();

     if( pView )

     {

         改变画图模式 分时价格线

         pView->ChangeDrawMode( CRealTime::modePriceLine );

         画线

         pView->ShowMultiStock( 1 );

         文档更新所有视图

         AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_REALTIMEVIEW, NULL );

         切换并显示视图

         AfxSwitchToStaticView( RUNTIME_CLASS(CRealTimeView) );

     }

     else

     {

         切换并显示视图

         AfxSwitchToStaticView( RUNTIME_CLASS(CRealTimeView) );

         pView = AfxGetRealTimeView();

         if( pView )

         {

              pView->ChangeDrawMode( CRealTime::modePriceLine );

              pView->ShowMultiStock( 1 );

         }

     }

     return TRUE;

}

CRealTimeView * AfxGetRealTimeView( )

{

     得到文档类对象,返回CRealTimeView 类对象。

     CNineDoc * pNineDoc = AfxGetStaticDoc();

     return (CRealTimeView *)( pNineDoc->GetViewIfExist(RUNTIME_CLASS(CRealTimeView)) );

}

BOOL AfxShowStockGraph( const char * szCode )

{

     文档更新所有视图

     AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_GRAPHVIEW, NULL );

     AfxSwitchToStaticView( RUNTIME_CLASS(CGraphView) );

     return TRUE;

}

判断视图是否存在,并返回视图。

CView * CNineDoc::GetViewIfExist( CRuntimeClass *pViewClass )

{

     POSITION pos = GetFirstViewPosition( );

     CView * pView = NULL;

     while( pView = GetNextView(pos) )

     {

         if( pView && pView->IsKindOf( pViewClass ) )

         {

              return pView;

         }

     }

     return NULL;

}

文档更新所有视图核心代码

void CDocument::UpdateAllViews(CView* pSender, LPARAM lHint, CObject* pHint)

{

     POSITION pos = GetFirstViewPosition();

     while (pos != NULL)

     {

         CView* pView = GetNextView(pos);

         pView->OnUpdate(pSender, lHint, pHint);

     }

}

posted @ 2013-01-17 16:36  中国男孩  阅读(297)  评论(0编辑  收藏  举报