zoukankan      html  css  js  c++  java
  • 对话框子窗口的滚动

    父类
    void CDlgXXXX::InitUIRes(CString strCatCode)
    {
    	if (NULL == m_pDlgSub_)
    	{
    		m_pDlgSub_ = new CDlgFilterSub(this);
    		m_pDlgSub_->Create(CDlgFilterSub::IDD, this);
    	}
    	
    	m_pDlgSub_->InitUI(strCatCode);
    
    	CRect rtClient;
    	GetWindowRect(&rtClient);
    
    	CRect rtDlg;
    	m_pDlgSub_->GetClientRect(&rtDlg);
    	rtDlg.MoveToY(40);
    	rtDlg.left = 0;
    	rtDlg.right = rtClient.Width();
    	m_pDlgSub_->MoveWindow(rtDlg);
    
    	m_pDlgSub_->GetWindowRect(&rtDlg);
    	rtClient.bottom = rtDlg.bottom + 10;
    	MoveWindow(rtClient);
    
    	if (!m_pDlgSub_->IsWindowVisible())
    	{
    		m_pDlgSub_->ShowWindow(SW_SHOW);
    	}
    }
    

      子窗口

    void CDlgFilterSub::InitUI(CString strCatCode)
    {
    	。。。。动态添加按钮

    CRect rtClient;
    GetClientRect(rtClient);

    rtCtrl最后一排控件的位置

    SCROLLINFO si;
    si.cbSize = sizeof(si);
    GetScrollInfo(SB_VERT, &si);
    si.nMax = max(rtCtrl.bottom + SPACE, rtClient.bottom);
    si.nPos = 0;
    SetScrollInfo(SB_VERT, &si);

    static int iHeight = rtClient.bottom;
    if (rtClient.bottom < rtCtrl.bottom + SPACE)
    {
    rtClient.bottom = iHeight;
    }
    else
    {
    rtClient.bottom = rtCtrl.bottom + SPACE;
    }
    MoveWindow(rtClient);

    }
    

      子窗口的初始化

    BOOL CDlgFilterSub::OnInitDialog()
    {
    	CBCGPDialog::OnInitDialog();
    	COLORREF bgColor = RGB(248, 248, 248);
    	SetBackgroundColor(bgColor);
    
    	CRect rtClient;
    	GetClientRect(rtClient);
    	SCROLLINFO si;
    	si.cbSize = sizeof(SCROLLINFO);
    	si.fMask = SIF_ALL;
    	si.nPos = 0;
    	si.nMin = 0;
    	si.nMax = rtClient.bottom;
    	SetScrollInfo(SB_VERT, &si);
    
    	return TRUE;
    }
    

      

    void CDlgFilterSub::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
    {
    	SCROLLINFO si;
    	si.cbSize = sizeof(si);
    	si.fMask = SIF_ALL;
    	GetScrollInfo(SB_VERT, &si);
    	INT nVscroll = si.nPos;
    	switch(nSBCode)
    	{  
    	case SB_LINEDOWN:
    		{
    			nVscroll += 20;
    			if (nVscroll > (si.nMax - si.nMin - si.nPage ))
    			{
    				nVscroll = si.nMax - si.nMin - si.nPage;
    			}
    		}
    		break;
    	case SB_LINEUP:
    		{
    			nVscroll -= 20;
    			if (nVscroll < si.nMin)
    			{
    				nVscroll = 0;
    			}
    		}
    		break;
    	case SB_PAGEDOWN:
    		{
    			nVscroll += si.nPage;
    			if (nVscroll > (si.nMax - si.nMin - si.nPage))
    			{
    				nVscroll = si.nMax - si.nMin - si.nPage;
    			}
    		}
    		break;
    	case SB_PAGEUP:
    		{
    			nVscroll -= si.nPage;
    			if (nVscroll < si.nMin)
    			{
    				nVscroll = 0;  
    			}
    		}
    		break;
    	case SB_THUMBTRACK:
    		{
    			nVscroll = nPos;
    		}
    		break;
    	}
    
    	if (si.nPos != nVscroll)
    	{
    		int yAmount = -(nVscroll - si.nPos);
    		ScrollWindow(0, yAmount, NULL,NULL);
    	}
    
    	si.nPos = nVscroll;
    	SetScrollInfo(SB_VERT, &si);
    
    	CBCGPDialog::OnVScroll(nSBCode, nPos, pScrollBar);
    }
    

      

    ON_WM_VSCROLL()
    

      

    afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
    

      

  • 相关阅读:
    在IIS上搭建WebSocket服务器(三)
    在IIS上搭建WebSocket服务器(二)
    在IIS上搭建WebSocket服务器(一)
    RDIFramework.NET ━ .NET快速信息化系统开发框架 V3.2->Web版本模块管理界面新增模块排序功能
    C#在WinForm中使用WebKit传递js对象实现与网页交互的方法
    c#用webkit内核支持html5
    .NET下WebBrowser的一个BUG以及其替代品——geckofx
    HTML5浏览器嵌入窗口程序解决方案
    saprk里面的action
    解释为什么word2vec也被称作deep learning
  • 原文地址:https://www.cnblogs.com/XiHua/p/13914988.html
Copyright © 2011-2022 走看看