首页 > 其他分享 >对话框变化大小后。CBCGPListCtrl、CListCtrl重新显示行数列数m_list_.Arrange(LVA_ALIGNTOP);

对话框变化大小后。CBCGPListCtrl、CListCtrl重新显示行数列数m_list_.Arrange(LVA_ALIGNTOP);

时间:2023-06-03 13:33:14浏览次数:34  
标签:CListCtrl 对话框 pWnd list saveRect _. rect saveChild vec

h文件中

afx_msg void OnSize(UINT nType, int cx, int cy);

void ResizeUI();

vector<CRect> m_vec_rect_;

 

BEGIN_MESSAGE_MAP(CDlgXXX, CBCGPDialog)
	ON_WM_SIZE()
	
END_MESSAGE_MAP()

BOOL CDlgXXX::OnInitDialog()
{
	CBCGPDialog::OnInitDialog();
	EnableVisualManagerStyle(TRUE,TRUE);

******

	//获取区域
	CRect rect;
	GetWindowRect(&rect);
	m_vec_rect_.push_back(rect);
	CWnd* pWnd = GetWindow(GW_CHILD);//获取子窗体  
	while (pWnd)
	{
		pWnd->GetWindowRect(rect);
		m_vec_rect_.push_back(rect);
		pWnd = pWnd->GetNextWindow();
	}
	
	return TRUE;
}


void CDlgXXX::OnSize(UINT nType, int cx, int cy)
{
	CBCGPDialog::OnSize(nType, cx, cy);
	if (nType != SIZE_MINIMIZED)
	{
		ResizeUI();
	}
}

void CDlgXXX::ResizeUI()
{
	if (m_vec_rect_.size() > 0)
	{
		CRect rect;
		GetWindowRect(&rect);
		ScreenToClient(rect);

		//第一个保存的是对话框的Rect  
		CRect saveRect = m_vec_rect_[0];
		//根据当前和之前保存的对话框的宽高求比例  
		float x = rect.Width() * 1.0f / saveRect.Width();
		float y = rect.Height() * 1.0f / saveRect.Height();

		int iSize = m_vec_rect_.size();
		int idx = 1;
		ClientToScreen(rect);
		CRect saveChild;
		CWnd* pWnd = GetWindow(GW_CHILD);
		while (pWnd && idx < iSize)
		{
			saveChild = m_vec_rect_[idx];
			//根据比例调整控件上下左右距离对话框的距离  
			saveChild.left = rect.left + (saveChild.left - saveRect.left) * x;
			saveChild.right = rect.right + (saveChild.right - saveRect.right) * x;
			saveChild.top = rect.top + (saveChild.top - saveRect.top) * y;
			saveChild.bottom = rect.bottom + (saveChild.bottom - saveRect.bottom) * y;
			ScreenToClient(saveChild);
			pWnd->MoveWindow(saveChild);

			pWnd = pWnd->GetNextWindow();
			++idx;
		}

		if (m_list_.m_hWnd)
		{
			m_list_.Arrange(LVA_ALIGNTOP);
		}
	}
}

  

if (m_list_.m_hWnd)
{
m_list_.Arrange(LVA_ALIGNTOP);
}

标签:CListCtrl,对话框,pWnd,list,saveRect,_.,rect,saveChild,vec
From: https://www.cnblogs.com/XiHua/p/17453861.html

相关文章

  • 2023年6月2日,ArrayList
    1.ArrayListpackagecom.wz.arraylist_class;importjava.util.*;publicclasstest02{/***知识点:集合中可以存储不同类型的元素*泛型*@paramargs**/publicstaticvoidmain(String[]args){ArrayList<String>list......
  • [Debug] Debug and inspect event listeners with Devtools
    Youcanuse getEventListeners(button)directlyinsidechromedevtool,butnotinsideapplicationcode. Youcanuse monitorEvents(button,'keydown'),noweverytimeskeydownhappens,eventwillbeloggedintotheconsole.Use unmonitorEvents(but......
  • Java8新特性-关于List的操作
    1Java获取List对象的某属性组成新的ListList<String>list=signPicsDtoEntityList.stream().map(e->e.getType()).collect(Collectors.toList());2Java批量修改List里面某个属性的方法方法一:通过流的方式List<DishFlavor>flavors=dishDto.getFlavors();flavors=f......
  • 武汉星起航:亚马逊新手卖家上架新品如何成功推广Listing
    随着电商的蓬勃发展,亚马逊成为了许多卖家选择的首选平台。对于新手卖家来说,成功上架新品并有效推广Listing是关键的一步。今天,武汉星起航将为读者朋友介绍一些关键步骤,帮助您在亚马逊上取得销售的突破。1.研究市场与竞争对手:在上架新品之前,仔细研究市场需求和竞争对手的表现非常重......
  • List系列集合:LinkedList集合的应用场景:做队列、栈
                ......
  • List系列集合:LinkedList集合的底层原理
          ......
  • 十一、python列表list
    十一、python列表list列表是一种基本的序列数据结构(字符串和元组也属于序列)列表是一种可变值的数据类型(再次强调数字,字符串,元组是不可变类型)1.列表的创建使用中括号括起来,里面的数据称为元素。可以放同类型数据,也可以放不同类型数据,但通常是同类型。os=["rhel","centos","......
  • List系列集合:ArrayList集合的底层原理
        ......
  • 武汉星起航:亚马逊新品上架,新手卖家如何优化Listing?
    随着亚马逊成为全球最大的电商平台之一,越来越多的新手卖家希望在这个巨大的市场上获得成功。然而,对于新品上架后的推广,许多卖家都面临着困惑。今天,武汉星起航将专为新手卖家分享几个巧妙的推广技巧,助您打造热卖Listing!在亚马逊上,与众多竞争对手相比,独特的产品定位可以帮助您吸引更......
  • util:list map set
     packagecn.zno.testutil;importjava.util.List;importjava.util.Map;importjava.util.Set;importorg.springframework.stereotype.Component;publicclassFoo{privateList<String>list;privateMap<String,String>map;priva......