|
@@ -161,7 +161,7 @@ int CIRControlWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
|
m_wndSignalCheck.m_nFlatStyle = CMFCButton::BUTTONSTYLE_FLAT;
|
|
|
m_wndSignalCheck.SizeToContent();
|
|
|
|
|
|
- if (!m_wndSignalCombo.Create(dwViewStyle| WS_VSCROLL, rectDummy, this, ID_COMBOBOX_SIGNAL_FILE))
|
|
|
+ if (!m_wndSignalCombo.Create(dwViewStyle| WS_VSCROLL| WS_HSCROLL, rectDummy, this, ID_COMBOBOX_SIGNAL_FILE))
|
|
|
{
|
|
|
TRACE0("未能创建信号集下拉框 \n");
|
|
|
return -1; // 未能创建
|
|
@@ -632,6 +632,7 @@ void CIRControlWnd::UpdateSignalBtnStatus()
|
|
|
|
|
|
void CIRControlWnd::AutoSetDroppedWidth()
|
|
|
{
|
|
|
+ return AddHScroll();
|
|
|
// Set the height of every item so the item
|
|
|
// is completely visible.
|
|
|
CString str;
|
|
@@ -657,3 +658,41 @@ void CIRControlWnd::AutoSetDroppedWidth()
|
|
|
}
|
|
|
m_wndSignalCombo.ReleaseDC(pDC);
|
|
|
}
|
|
|
+
|
|
|
+void CIRControlWnd::AddHScroll()
|
|
|
+{
|
|
|
+ // Find the longest string in the combo box.
|
|
|
+ CString str;
|
|
|
+ CSize sz;
|
|
|
+ int dx = 0;
|
|
|
+
|
|
|
+ TEXTMETRIC tm = { 0 };
|
|
|
+ CDC* pDC = m_wndSignalCombo.GetDC();
|
|
|
+ CFont* pFont = m_wndSignalCombo.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 < m_wndSignalCombo.GetCount(); i++)
|
|
|
+ {
|
|
|
+ m_wndSignalCombo.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);
|
|
|
+ m_wndSignalCombo.ReleaseDC(pDC);
|
|
|
+
|
|
|
+ // Set the horizontal extent so every character of all strings can
|
|
|
+ // be scrolled to.
|
|
|
+ m_wndSignalCombo.SetHorizontalExtent(dx);
|
|
|
+}
|