Windows资源管理器Web视图界面,Windows资源管理器Web视图界面
【 tulaoshi.com - C语言心得技巧 】
Windows资源管理器Web视图界面
      
      
      作者/祝晓斌
      下载源代码      
      
          
      当我们使用Windows资源管理器(Exporlor)时,看到左边的视图能够显示所选目标的相关信息,比较好用。
      本例是一个简单的Web视图界面示例,不过左边不是一个Web视图,而是一个FormView。界面如下图所示:
      
      
      图一 程序运行画面
      
      本例是最简单的SDI工程,在View中创建了两个View:      
int CXindowView::OnCreate(LPCREATESTRUCT lpCreateStruct) {    if (CView::OnCreate(lpCreateStruct) == -1)        return -1;    /* 创建左右两个视图 */    m_pForm = (CXindowForm *) okCreateView(RUNTIME_CLASS(CXindowForm), 1001);    m_pList = (CXindowList *) okCreateView(RUNTIME_CLASS(CXindowList), 1002);     m_pForm-m_pParent = this;    return 0;}           当窗口宽度<400时,会隐藏左边的CXindowForm视图:    void CXindowView::OnSize(UINT nType, int cx, int cy) {    CView::OnSize(nType, cx, cy);    int nFormWidth = 200;    /* 如果窗口宽度<400, 就隐藏左视图 */    if(cx400)    {        if(m_pForm-GetSafeHwnd())  m_pForm-ShowWindow(SW_SHOW);        if(m_pForm-GetSafeHwnd())  m_pForm-MoveWindow(0,0,nFormWidth,cy);        if(m_pList-GetSafeHwnd())  m_pList-ShowWindow(SW_SHOW);        if(m_pList-GetSafeHwnd())  m_pList-MoveWindow(nFormWidth,0,cx-nFormWidth,cy);    }    else    {        if(m_pForm-GetSafeHwnd())  m_pForm-ShowWindow(SW_HIDE);        if(m_pList-GetSafeHwnd())  m_pList-ShowWindow(SW_SHOW);        if(m_pList-GetSafeHwnd())  m_pList-MoveWindow(0,0,cx,cy);    }}    其中左边的的CXindowForm视图中有个CXLabel控件“增加”,点击会产生WM_NOFITY消息,这样就能够响应了。    void CXindowForm::OnInitialUpdate() {    CFormView::OnInitialUpdate();        /* 相当于CListCtrl::SetItemData(), 用于区别是哪个CXLabel */    m_add.SetCommand(1);}BOOL CXindowForm::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) {    LPNMHDR pnmh = (LPNMHDR) lParam;        if(pnmh-code==NM_LINKCLICK)    {        CXLabel* pLabel = (CXLabel *)GetDlgItem(pnmh-idFrom);        CString str;        /* GetCommand() */        str.Format("d",pLabel-GetCommand());        AfxMessageBox(str);         if(m_pParent-GetSafeHwnd())         {             CListCtrl& listCtrl = ((CXindowView*)m_pParent)-m_pList-GetListCtrl();             int nCount = listCtrl.GetItemCount();              int nItem = listCtrl.InsertItem(nCount, "2003-8-15");             listCtrl.SetItemText(nItem, 1, "192.168.3.1");             listCtrl.SetItemText(nItem, 2, "www.vckbase.com");             listCtrl.SetItemText(nItem, 3, "编程");         }    }    return CFormView::OnNotify(wParam, lParam, pResult);}       注:CXLabel控件来自CLabel类,增加了几个有效函数。
                        来源:http://www.tulaoshi.com/n/20160129/1483834.html
看过《Windows资源管理器Web视图界面》的人还看了以下文章 更多>>