zoukankan      html  css  js  c++  java
  • OnInitialUpdate()

    [MSDN]

    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). Override this function to perform any one-time initialization that requires information about the document. For example, if your application has fixed-sized documents, you can use this function to initialize a view's scrolling limits based on the document size. If your application supports variable-sized documents, use OnUpdate to update the scrolling limits every time the document changes.

    [其他]

    视图窗口完全建立后第一个被框架调用的函数就是OnInitialUpdate。框架在第一次调用OnDraw前会调用OnInitialUpdate,因此OnInitialUpdate是设置滚动视图的逻辑尺寸和映射模式的最合适的地方。

      时间上,两者先后顺序不同,构造函数生成本类的对象,但没有产生窗口,OnCreate后窗口产生,然后才是视图的OnInitialUpDate,一般在这里对视图的显示做初始化。简单点,就是ONCREATE只是产生VIEW的基本结构和变量而在OnInitialUpDate()中,主要初始化视图中控件等,如对各个变量进行初始化操作。

      例子。我们要在视图中添加一个button和combobox控件则

      OnCreate函数中写法如下:

      int CFormView::OnCreate(LPCREATESTRUCT lpCreateStruct)

      {

      if (CView::OnCreate(lpCreateStruct) == -1)

      return -1;

      // TODO: Add your specialized creation code here

      CRect rect(20,20,100,50);

      m_ctrlButton.Create("Button1",WS_CHILD|WS_VISIBLE,rect,this,NULL);

      //创建按扭控件

      CFont *pFont=CFont::FromHandle((HFONT)::GetStockObject(ANSI_VAR_FONT));

      CRect rect1(150,20,350,100);

      m_combobox.Create(WS_CHILD|WS_VISIBLE|CBS_SIMPLE|CBS_NOINTEGRALHEIGHT|WS_VSCROLL,rect1,this,NULL);

      return 0;

      }

      OnInitialUpDate中写法

      void CFormView::OnInitialUpdate()

      {

      CView::OnInitialUpdate();

      // TODO: Add your specialized code here and/or call the base class

      //初始化组合框控件

      m_combobox.AddString("Mondy");

      m_combobox.AddString("Tuesday");

      m_combobox.AddString("Wednesday");

      m_combobox.AddString("Thursday");

      m_combobox.AddString("Saturday");

      m_combobox.AddString("Sunday");

      }

  • 相关阅读:
    [读书笔记]捉虫日记
    花生壳建站全过程
    (step4.3.9)hdu 1584(蜘蛛牌——DFS)
    鼠标移到导航上面 当前的LI变色 处于当前的位置
    JavaScript学习笔记
    由Maximum Gap,对话桶排序,基数排序和统计排序
    安德鲁斯Launcher得到的装在手机的应用程序列表
    broadAnywhere:Broadcast组件权限绕过漏洞(Bug: 17356824)
    Ubuntu logomaker sh: 1: pngtopnm: not found 解决方案
    HDU 1598 find the most comfortable road (罗列+Kruskal) 并检查集合
  • 原文地址:https://www.cnblogs.com/johnpher/p/2570693.html
Copyright © 2011-2022 走看看