|
@@ -146,6 +146,7 @@ void CTestWizardToolDlg::DoDataExchange(CDataExchange* pDX)
|
|
|
DDX_Control(pDX, COMBO_SINGALS, m_cbSignals);
|
|
|
DDX_Control(pDX, BTN_OPEN_COM, m_btnOpen);
|
|
|
DDX_Control(pDX, BTN_RELOAD_SIGNAL, m_btnReload);
|
|
|
+ DDX_Control(pDX, IDC_STATIC_GROUP, m_stGroup);
|
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CTestWizardToolDlg, CDialog)
|
|
@@ -199,6 +200,8 @@ BOOL CTestWizardToolDlg::OnInitDialog()
|
|
|
|
|
|
// TODO: 在此添加额外的初始化代码
|
|
|
InitBtnStyle();
|
|
|
+ m_stGroup.GetWindowRect(m_rcGroup);
|
|
|
+ ScreenToClient(m_rcGroup);
|
|
|
|
|
|
GetSysSerialPort(m_vtPorts);
|
|
|
InitSerialCombobox();
|
|
@@ -296,14 +299,11 @@ void CTestWizardToolDlg::AdjustLayout()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- CRect rcCtrl;
|
|
|
CRect rectClient;
|
|
|
GetClientRect(rectClient);
|
|
|
TRACE2(_T("更新后的大小:%d,%d\n"), rectClient.Width(), rectClient.Height());
|
|
|
- m_cbCOM.GetWindowRect(rcCtrl);
|
|
|
- ScreenToClient(rcCtrl);
|
|
|
|
|
|
- int sx = 0, sy = rcCtrl.bottom + m_nTopMargin;
|
|
|
+ int sx = 0, sy = m_rcGroup.bottom + m_nTopMargin;
|
|
|
int i = 0, id = 10000;
|
|
|
int nWidth = (rectClient.Width() - 25) / m_nCols;
|
|
|
DWORD dwStyle = WS_CHILD | WS_VISIBLE;
|
|
@@ -333,6 +333,8 @@ void CTestWizardToolDlg::LoadSignals()
|
|
|
{
|
|
|
m_cbSignals.AddString(fh.getfilename(it->c_str()).c_str());
|
|
|
}
|
|
|
+
|
|
|
+ AutoSetDroppedWidth(&m_cbSignals);
|
|
|
}
|
|
|
|
|
|
void CTestWizardToolDlg::LoadKeyInfo(std::vector<KeyInfo> &vtKeyInfo, std::string path)
|
|
@@ -420,7 +422,7 @@ void CTestWizardToolDlg::LoadKeyInfo(std::vector<KeyInfo> &vtKeyInfo, std::strin
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- int sx = 0, sy = m_nComboHeight * 2 + 15;
|
|
|
+ int sx = 0, sy = m_rcGroup.bottom + m_nTopMargin;
|
|
|
int i = 0, id = 10000;
|
|
|
DWORD dwStyle = WS_CHILD | WS_VISIBLE;
|
|
|
int maxX = 0, maxY = 0;
|
|
@@ -463,12 +465,13 @@ void CTestWizardToolDlg::LoadKeyInfo(std::vector<KeyInfo> &vtKeyInfo, std::strin
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
- m_nDefaultHeight = sy + m_nTopMargin;
|
|
|
+ std::vector<KeyInfo>::iterator it = vtKeyInfo.begin();
|
|
|
+ m_nDefaultHeight = m_rcGroup.bottom + 15 + (vtKeyInfo.size()/m_nCols + (vtKeyInfo.size()%m_nCols > 0 ? 1 : 0)) * (it->height + m_nRowSpacing);
|
|
|
m_nDefaultHeight = m_nDefaultHeight < MINIMUM_WINDOWS_Y ? MINIMUM_WINDOWS_Y : m_nDefaultHeight;
|
|
|
m_nDefaultWidth = m_nDefaultWidth < MINIMUM_WINDOWS_X ? MINIMUM_WINDOWS_X : m_nDefaultWidth+30;
|
|
|
|
|
|
// 设置窗口大小;
|
|
|
- SetWindowPos(NULL,0,0, m_nDefaultWidth, m_nDefaultHeight, SWP_NOMOVE);
|
|
|
+ SetWindowPos(NULL, 0, 0, m_nDefaultWidth, m_nDefaultHeight + 23/*标题栏高度*/, SWP_NOMOVE);
|
|
|
|
|
|
AdjustLayout();
|
|
|
}
|
|
@@ -866,3 +869,43 @@ BOOL CTestWizardToolDlg::PreTranslateMessage(MSG* pMsg)
|
|
|
}
|
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
|
}
|
|
|
+
|
|
|
+void CTestWizardToolDlg::AutoSetDroppedWidth(CComboBox* pCombobox)
|
|
|
+{
|
|
|
+ if (!pCombobox)
|
|
|
+ return;
|
|
|
+ // Find the longest string in the combo box.
|
|
|
+ CString str;
|
|
|
+ CSize sz;
|
|
|
+ int dx = 0;
|
|
|
+
|
|
|
+ TEXTMETRIC tm = { 0 };
|
|
|
+ CDC* pDC = pCombobox->GetDC();
|
|
|
+ CFont* pFont = pCombobox->GetFont();
|
|
|
+
|
|
|
+ // Select the listbox font, save the old font
|
|
|
+ CFont* pOldFont = pDC->SelectObject(pFont);
|
|
|
+
|
|
|
+ // Get the text metrics for avg char width
|
|
|
+ pDC->GetTextMetrics(&tm);
|
|
|
+
|
|
|
+ for (int i = 0; i < pCombobox->GetCount(); i++)
|
|
|
+ {
|
|
|
+ pCombobox->GetLBText(i, str);
|
|
|
+ sz = pDC->GetTextExtent(str);
|
|
|
+
|
|
|
+ // Add the avg width to prevent clipping
|
|
|
+ sz.cx += tm.tmAveCharWidth;
|
|
|
+
|
|
|
+ if (sz.cx > dx)
|
|
|
+ dx = sz.cx;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Select the old font back into the DC
|
|
|
+ pDC->SelectObject(pOldFont);
|
|
|
+ pCombobox->ReleaseDC(pDC);
|
|
|
+
|
|
|
+ // Set the horizontal extent so every character of all strings can
|
|
|
+ // be scrolled to.
|
|
|
+ pCombobox->SetHorizontalExtent(dx);
|
|
|
+}
|