소스 검색

遥控器面板自适应宽度;

scbc.sat2 5 년 전
부모
커밋
21edf0719c
2개의 변경된 파일98개의 추가작업 그리고 18개의 파일을 삭제
  1. 90 17
      SATHelper/SATHelper/IRControlWnd.cpp
  2. 8 1
      SATHelper/SATHelper/IRControlWnd.h

+ 90 - 17
SATHelper/SATHelper/IRControlWnd.cpp

@@ -116,21 +116,72 @@ END_MESSAGE_MAP()
 
 void CIRControlWnd::AdjustLayout()
 {
-	if (GetSafeHwnd() == nullptr || (AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic()))
+	if (GetSafeHwnd() == nullptr ||
+		(AfxGetMainWnd() != nullptr && AfxGetMainWnd()->IsIconic()))
 	{
 		return;
 	}
 
+	int dr = 3;	// 行间距
+	int dc = 5; // 列间距;
+	CRect rcCtrl;
 	CRect rectClient;
 	GetClientRect(rectClient);
+	TRACE2(_T("更新后的大小:%d,%d"), rectClient.Width(), rectClient.Height());
+	m_btnRestart.SetWindowPos(nullptr, rectClient.left + dr, rectClient.top + dr, (rectClient.Width() - dr * 3) / 2, m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER);
+
+	m_btnRestart.GetWindowRect(rcCtrl);
+	ScreenToClient(rcCtrl);
+	m_wndSignalCheck.SetWindowPos(nullptr, rcCtrl.right + dr, rectClient.top + dr, rcCtrl.Width(), m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER);
+
+	m_wndSignalCheck.GetWindowRect(rcCtrl);
+	ScreenToClient(rcCtrl);
+	// 注意:此combobox高度并是包含了下拉项的高度;
+	m_wndSignalCombo.SetWindowPos(nullptr, rectClient.left + dr, rcCtrl.bottom + dr, rectClient.Width() - dc * 2, m_nComboHeight + 233, SWP_NOACTIVATE | SWP_NOZORDER);
+	//::MoveWindow(m_wndSignalCombo.m_hWnd, rectClient.left + 5, rcCtrl.bottom + 5, rectClient.Width() - 10, m_nComboHeight + 233, TRUE);
+	//m_wndSignalCombo.SendMessage(CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)19);   //改变控件本身的高度
+
+	m_wndSignalCombo.GetWindowRect(rcCtrl);
+	ScreenToClient(rcCtrl);
+	// 注意:此combobox高度并是包含了下拉项的高度;
+	m_cbTree1.SetWindowPos(nullptr, rectClient.left + dr, rcCtrl.bottom + dr, (rectClient.Width() - dr*4) / 3, m_nComboHeight + 233, SWP_NOACTIVATE | SWP_NOZORDER);
+
+	m_cbTree1.GetWindowRect(rcCtrl);
+	ScreenToClient(rcCtrl);
+	// 注意:此combobox高度并是包含了下拉项的高度;
+	m_cbTree2.SetWindowPos(nullptr, rcCtrl.right + 2, rcCtrl.top, rcCtrl.Width(), m_nComboHeight + 233, SWP_NOACTIVATE | SWP_NOZORDER);
+
+
+	m_cbTree2.GetWindowRect(rcCtrl);
+	ScreenToClient(rcCtrl);
+	// 注意:此combobox高度并是包含了下拉项的高度;
+	m_cbTree3.SetWindowPos(nullptr, rcCtrl.right + 2, rcCtrl.top, rcCtrl.Width(), m_nComboHeight + 233, SWP_NOACTIVATE | SWP_NOZORDER);
 
-	m_btnRestart.SetWindowPos(nullptr, rectClient.left + 5, rectClient.top + 5, 120, m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER);
-	m_wndSignalCheck.SetWindowPos(nullptr, rectClient.left + 130, rectClient.top + 5, 120, m_nComboHeight, SWP_NOACTIVATE | SWP_NOZORDER);
 
-	m_wndSignalCombo.SetWindowPos(nullptr, rectClient.left + 5, rectClient.top + m_nComboHeight + 10, 245, m_nComboHeight + 210, SWP_NOACTIVATE | SWP_NOZORDER);
 #if __PANE_DLG__
 	m_dlgIRControl.SetWindowPos(nullptr, rectClient.left, rectClient.top + m_nComboHeight + 50, rectClient.Width(), rectClient.Height(), SWP_NOACTIVATE);
 #endif
+
+	m_cbTree3.GetWindowRect(rcCtrl);
+	ScreenToClient(rcCtrl);
+
+	int sx = 0, sy = rcCtrl.bottom + dr;
+	int i = 0, id = 10000;
+	int nWidth = (rectClient.Width() - 25) / 4;
+	DWORD dwStyle = WS_CHILD | WS_VISIBLE;
+	for (std::vector<BtnInfo>::iterator it = m_vtBtnInfo.begin(); it != m_vtBtnInfo.end(); it++)
+	{
+		if (it->pBTN == nullptr)
+			continue;
+		if (i != 0 && i % 4 == 0)
+		{//换行;
+			sy += it->height + 5;
+		}
+
+		sx = (i % 4) * nWidth + (i % 4 + 1) * 5;
+		it->pBTN->SetWindowPos(nullptr, sx, sy, nWidth, it->height, SWP_NOACTIVATE | SWP_NOZORDER);
+		i++;
+	}
 }
 
 int CIRControlWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
@@ -165,13 +216,32 @@ int CIRControlWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
 	m_wndSignalCheck.m_nFlatStyle = CMFCButton::BUTTONSTYLE_FLAT;
 	m_wndSignalCheck.SizeToContent();
 
-	if (!m_wndSignalCombo.Create(dwViewStyle| WS_VSCROLL| WS_HSCROLL, rectDummy, this, ID_COMBOBOX_SIGNAL_FILE))
+	if (!m_wndSignalCombo.Create(dwViewStyle | WS_VSCROLL | WS_HSCROLL, CRect(0, 0, 100, 20), this, ID_COMBOBOX_SIGNAL_FILE))
+	{
+		TRACE0("未能创建信号集下拉框 \n");
+		return -1;      // 未能创建
+	}
+
+	if (!m_cbTree1.Create(dwViewStyle | WS_VSCROLL | WS_HSCROLL, rectDummy, this, ID_COMBOBOX_SIGNAL_FILE + 1))
+	{
+		TRACE0("未能创建信号集下拉框 \n");
+		return -1;      // 未能创建
+	}
+
+	if (!m_cbTree2.Create(dwViewStyle | WS_VSCROLL | WS_HSCROLL, rectDummy, this, ID_COMBOBOX_SIGNAL_FILE + 2))
+	{
+		TRACE0("未能创建信号集下拉框 \n");
+		return -1;      // 未能创建
+	}
+
+	if (!m_cbTree3.Create(dwViewStyle | WS_VSCROLL | WS_HSCROLL, rectDummy, this, ID_COMBOBOX_SIGNAL_FILE + 3))
 	{
 		TRACE0("未能创建信号集下拉框 \n");
 		return -1;      // 未能创建
 	}
 
 	LoadSignals();
+	SetPropListFont();
 
 	CRect rectCombo;
 	m_wndSignalCombo.GetClientRect(&rectCombo);
@@ -211,9 +281,9 @@ int CIRControlWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
 		TW::LoadXml(signalpath.c_str());
 	}
 
-	std::thread t([](CIRControlWnd *pWnd) {
+	std::thread t([](CIRControlWnd* pWnd) {
 		//while (true)
-		while( IsWindow(pWnd->m_hWnd) )
+		while (IsWindow(pWnd->m_hWnd))
 		{
 			if (g_pMainFrame->m_bShotIR && pWnd->m_bSendKey)
 			{
@@ -227,7 +297,7 @@ int CIRControlWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
 			}
 			Sleep(20);
 		}
-	},this);
+		}, this);
 	t.detach();
 
 	return 0;
@@ -289,7 +359,7 @@ void CIRControlWnd::OnSetFocus(CWnd* pOldWnd)
 void CIRControlWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
 {
 	CDockablePane::OnSettingChange(uFlags, lpszSection);
-	//SetPropListFont();
+	SetPropListFont();
 }
 
 void CIRControlWnd::OnCbnSelchangeSignal()
@@ -335,7 +405,10 @@ void CIRControlWnd::SetPropListFont()
 
 	m_fntPropList.CreateFontIndirect(&lf);
 
-	//m_wndObjectCombo.SetFont(&m_fntPropList);
+	m_wndSignalCombo.SetFont(&m_fntPropList);
+	m_cbTree1.SetFont(&m_fntPropList);
+	m_cbTree2.SetFont(&m_fntPropList);
+	m_cbTree3.SetFont(&m_fntPropList);
 }
 
 void CIRControlWnd::StartIRDevice(BOOL bReStart)
@@ -358,7 +431,7 @@ void CIRControlWnd::StartIRDevice(BOOL bReStart)
 			m_wndSignalCombo.SelectString(0, Global::g_Config.use_signal.c_str());
 		}
 
-		if ( !RedRat::g_IsAppRunning(Global::g_Config.redratpath.c_str()) )
+		if (!RedRat::g_IsAppRunning(Global::g_Config.redratpath.c_str()))
 		{
 			if (RedRat::g_StartIRApp(Global::g_Config.redratpath.c_str(), signale.c_str(), 40000))
 			{
@@ -394,7 +467,7 @@ void CIRControlWnd::StartIRDevice(BOOL bReStart)
 		}
 
 		return 1;
-	}, bReStart);
+		}, bReStart);
 	t.detach();
 }
 
@@ -586,7 +659,7 @@ void CIRControlWnd::Loadlayout(std::vector<BtnInfo>& vt)
 		}
 	}
 
-	int sx = 0, sy = m_nComboHeight*2+15;
+	int sx = 0, sy = m_nComboHeight * 2 + 15;
 	int i = 0, id = 10000;
 	DWORD dwStyle = WS_CHILD | WS_VISIBLE;
 	for (std::vector<BtnInfo>::iterator it = vt.begin(); it != vt.end(); it++)
@@ -612,7 +685,7 @@ void CIRControlWnd::Loadlayout(std::vector<BtnInfo>& vt)
 		it->pBTN->SetMouseCursorHand();
 
 		// 存入map中;
-		m_map_btn.insert(std::pair<UINT, BtnInfo&>(BTNID+i, *it));
+		m_map_btn.insert(std::pair<UINT, BtnInfo&>(BTNID + i, *it));
 
 		i++;
 	}
@@ -725,9 +798,9 @@ void CIRControlWnd::UpdateSignalBtnStatus()
 		if (TW::GetSignalsName)
 			data = TW::GetSignalsName();
 	}
-	else{
+	else {
 		// 获取信号集;
-		if (RedRat::g_getSignalsName){
+		if (RedRat::g_getSignalsName) {
 			// 获取信号数据集,以\n分隔;
 			data = RedRat::g_getSignalsName();
 		}
@@ -817,7 +890,7 @@ void CIRControlWnd::AddHScroll()
 
 LRESULT CIRControlWnd::OnIRShotImg(WPARAM wparam, LPARAM lparam)
 {
-	
+
 	return LRESULT();
 }
 

+ 8 - 1
SATHelper/SATHelper/IRControlWnd.h

@@ -24,7 +24,7 @@ typedef struct __BTN_INFO__
 	int width;
 	int height;
 	DWORD color;
-	CMFCButton *pBTN;
+	CMFCButton *pBTN = nullptr;
 	bool bEnable = false;
 }BtnInfo, *pBtnInfo;
 
@@ -61,6 +61,13 @@ protected:
 #if __PANE_DLG__
 	CDlgIRControl m_dlgIRControl;
 #endif
+
+	// TREE一级选项;
+	CComboBox m_cbTree1;
+	// TREE二级选项;
+	CComboBox m_cbTree2;
+	// TREE三级;
+	CComboBox m_cbTree3;
 	
 // 实现
 public: