Odd CEdit
-
Hello, guys. Check this out:
void CCtrlsDlg::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult) { LPNMITEMACTIVATE pIA = (LPNMITEMACTIVATE)pNMHDR; *pResult = 0; if((-1 == (m_nItem = pIA->iItem)) || (0 == (m_nSubitem = pIA->iSubItem))) return; CRect rc; m_ctrlList.GetSubItemRect(pIA->iItem, pIA->iSubItem, LVIR_BOUNDS, rc); if(!m_pEdit) m_pEdit = new CEdit; CString strText = m_ctrlList.GetItemText(m_nItem, m_nSubitem); m_pEdit->Create(WS_CHILD | WS_VISIBLE | WS_BORDER, rc, &m_ctrlList, 12); m_pEdit->ModifyStyleEx(0, WS_EX_CLIENTEDGE, 0); m_pEdit->SetWindowText(strText); m_pEdit->SetSel(0, -1); m_pEdit->SetFocus(); }
This whole thing displays an edit box for CListCtrl's subitems, but as CEdit control is created it has some odd look - it looks like edit control from Windows 3.1 rather anything else. Where's the problem? -
Hello, guys. Check this out:
void CCtrlsDlg::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult) { LPNMITEMACTIVATE pIA = (LPNMITEMACTIVATE)pNMHDR; *pResult = 0; if((-1 == (m_nItem = pIA->iItem)) || (0 == (m_nSubitem = pIA->iSubItem))) return; CRect rc; m_ctrlList.GetSubItemRect(pIA->iItem, pIA->iSubItem, LVIR_BOUNDS, rc); if(!m_pEdit) m_pEdit = new CEdit; CString strText = m_ctrlList.GetItemText(m_nItem, m_nSubitem); m_pEdit->Create(WS_CHILD | WS_VISIBLE | WS_BORDER, rc, &m_ctrlList, 12); m_pEdit->ModifyStyleEx(0, WS_EX_CLIENTEDGE, 0); m_pEdit->SetWindowText(strText); m_pEdit->SetSel(0, -1); m_pEdit->SetFocus(); }
This whole thing displays an edit box for CListCtrl's subitems, but as CEdit control is created it has some odd look - it looks like edit control from Windows 3.1 rather anything else. Where's the problem?I'm guessing that you are seeing the System font which looks very old. Try
m_pEdit->ModifyStyleEx(0, WS_EX_CLIENTEDGE, 0); m_pEdit->SetFont(&newfont); m_pEdit->SetWindowText(strText);
where newfont is a CFont that you find acceptable. Paul Hooper If you spend your whole life looking over your shoulder, they will get you from the front instead.