My FAQ,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > Visual C++ > WINDOWS窗口视图
Windows资源管理器Web视图界面
作者:未知 时间:2005-07-20 14:13 出处:VC知识库 责编:MyFAQ
              摘要:Windows资源管理器Web视图界面

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(cx>400)
    {
        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类,增加了几个有效函数。
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 myfaq.com.cn All rights reserved. www.myfaq.com.cn 版权所有