zoukankan      html  css  js  c++  java
  • OnInitialUpdate函数

    virtual void OnInitialUpdate( );

    视图窗口完成建立后第一个被框架调用的函数,框架在第一次调用OnDraw前会调用OnInitialUpdate,因此OnInitialUpdate是设置滚动视图的逻辑尺寸和映射模式的最适合的地方。
          
    时间上,两者先后顺序不同,构造函数生成本类的对象,但没有创建窗口,OnCreate后窗口产生,然后才是视图的OnInitialUpDate,一般在这里对视图的显示做初始化。简单点,就是OnCreate只是产生View的基本结构和变量而在OnInitialUpDate()中,主要初始化视图中控件等,对各个变量进行初始化操作。

     

    视图被附加到文档时,框架中调用。OnInitialUpdate( )

    Called by the framework after the view is first attached to the document, but before the view is initially displayed. The default implementation of this function calls the OnUpdate member function with no hint information (that is, using the default values of 0 for the lHint parameter and NULL for the pHint parameter).

    virtual void OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint );

    当试图中的文档被修改后,框架中调用。OnUpdate

    Called by the framework after the view’s document has been modified;

    void UpdateAllViews( CView* pSender, LPARAM lHint = 0L, CObject* pHint = NULL );

    当文档被修改时调用UpdateAllViews,当你调用SetModifiedFlag函数时,UpdateAllViews被调用。

    Call this function after the document has been modified. You should call this function after you call the SetModifiedFlag member function.

                  // if no active child frame, maximize this frame

                  CMainFrame * pMainFrame = AfxGetMainFrame();

                  if( pMainFrame )

                  {

                       CFrameWnd * pActiveFrame = AfxGetMainFrame()->GetActiveFrame();

                       if( !pActiveFrame || !pActiveFrame->IsKindOf(RUNTIME_CLASS(CChildFrame)) )

                           pChildFrame->MDIMaximize();

                  }

             }

         }

        

         if( pChildFrame )

         {

             // activate it

             pChildFrame->MDIActivate();

             if( bMaximized )

                  pChildFrame->MDIMaximize();

             else

                  pChildFrame->ShowWindow( SW_SHOW );

         }

     

         return TRUE;

    }

    问题二、

    CView* CNineDoc::GetActiveView( )

    {

         CMainFrame * pMainFrame = AfxGetMainFrame();

         if( pMainFrame )

         {

             //这句代码的含义是什么  ?

             CChildFrame * pChildFrame = DYNAMIC_DOWNCAST( CChildFrame, pMainFrame->MDIGetActive() );

             if( pChildFrame )

             {

                  CView * pView = pChildFrame->GetActiveView();

                  if( pView && this == pView->GetDocument() )

                       return pView;

             }

         }

         return NULL;

    }

     

    BOOL AfxShowStockGraph( int nStockIndex, BOOL bFromSList )

    {

         文档更新所有视图  

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

         使用全局函数来切换CGraphView视图

         AfxSwitchToStaticView( RUNTIME_CLASS(CGraphView) );

         return TRUE;

    }

    BOOL AfxShowStockInfo( int nStockIndex, BOOL bFromSList )

    {

    文档更新所有视图  

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

         使用全局函数来切换CInfoView视图

         AfxSwitchToStaticView( RUNTIME_CLASS(CInfoView) );

         return TRUE;

    }

    AFXCORE_INLINE     BOOL AfxShowStockTech( UINT nTech )

    {

         判断技术指标是否在 1 和 7 之间

         if( nTech >= STT_KLINE_MIN && nTech <= STT_KLINE_MAX )

         {

             CSPDWordArray &    anKLine  =    AfxGetProfile().GetGraphTechsKLine();

             删除Arrary 数组所有的。

             anKLine.RemoveAll();

             添加一个整数类型

             anKLine.Add( nTech );

         }

         else

         {

             CSPDWordArray &    anTech   =    AfxGetProfile().GetGraphTechsShow();

             for( int k=anTech.GetSize()-1; k>=0; k-- )

             {

                  找到技术指标为 nTech 的删除掉它。

                  if( nTech == anTech[k] )

                       anTech.RemoveAt(k);

             }

             如果技术指标等于 0 ,则添加它。

             if( anTech.GetSize() == 0 )

                  anTech.Add( nTech );

             else

             修改容器中总最后一个,设置为 nTech。

                  anTech.SetAt( anTech.GetSize()-1, nTech );

         }

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

         AfxSwitchToStaticView( RUNTIME_CLASS(CGraphView) );

         return TRUE;

    }

     

    文档更新所有视图  

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

    使用全局函数来切换CGraphView视图

         AfxSwitchToStaticView( RUNTIME_CLASS(CGraphView) );

         return TRUE;

    }

  • 相关阅读:
    [NOIP模拟赛][贪心]奶牛晒衣服.
    BZOJ3750: [POI2015]Piecz
    BZOJ2348 [Baltic 2011]Plagiarism
    高精度乘法【高乘高
    codevs 1215 迷宫
    变量交换
    a+b问题与圆柱体表面积的计算
    算数表达式的练习
    [bzoj1070][SCOI2007]修车[ 网络流]
    [bzoj2502]清理雪道[上下界网络流]
  • 原文地址:https://www.cnblogs.com/boobuy/p/2864786.html
Copyright © 2011-2022 走看看