CListCtrl improving
-
Hi. I've subclassed the CListCtrl. You can edit a subitem, and type some text into it. But if you resize the column (making it larger for example) then the editbox need to be redrawn to fill the whole (new) column space. Mine stays the same, how can i achieve this? Greetings Jens
-
Hi. I've subclassed the CListCtrl. You can edit a subitem, and type some text into it. But if you resize the column (making it larger for example) then the editbox need to be redrawn to fill the whole (new) column space. Mine stays the same, how can i achieve this? Greetings Jens
derive a Class from CEdit and overwite in ON_WM_WINDOWPOSCHANGING... add a Variable for the Size of the Subitem e.g RECT m_Position; In the Beginlabeledit-Handler of your ListCtrl SubClass the ListCtrl's EditCtrl with your derived class like this: OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult) { // Pseudo Code CREct Rect; GetSubItemRect(nItem, nSubItem, LVIR_LABEL, Rect); HWND hWnd=(HWND)SendMessage(LVM_GETEDITCONTROL); m_DerivedEdit.SubclassWindow(hWnd); m_DerivedEdit.SetPosition(Rect); } with SetPosition you should set the RECT m_Position of your derived Edit class... in the ON_WM_WINDOWPOSCHANGING - Handler you can adjust the Position of the ListCtrl's EditCtrl as follows: CDerivedEdit::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { lpwndpos->x = m_Position.left; lpwndpos->y = m_Position.top; lpwndpos->cx = m_Position.Width(); lpwndpos->cy = m_Position.Height(); } Hope this helps...
-
derive a Class from CEdit and overwite in ON_WM_WINDOWPOSCHANGING... add a Variable for the Size of the Subitem e.g RECT m_Position; In the Beginlabeledit-Handler of your ListCtrl SubClass the ListCtrl's EditCtrl with your derived class like this: OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult) { // Pseudo Code CREct Rect; GetSubItemRect(nItem, nSubItem, LVIR_LABEL, Rect); HWND hWnd=(HWND)SendMessage(LVM_GETEDITCONTROL); m_DerivedEdit.SubclassWindow(hWnd); m_DerivedEdit.SetPosition(Rect); } with SetPosition you should set the RECT m_Position of your derived Edit class... in the ON_WM_WINDOWPOSCHANGING - Handler you can adjust the Position of the ListCtrl's EditCtrl as follows: CDerivedEdit::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { lpwndpos->x = m_Position.left; lpwndpos->y = m_Position.top; lpwndpos->cx = m_Position.Width(); lpwndpos->cy = m_Position.Height(); } Hope this helps...
It should help but void CMyEdit::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { RECT temp= GetPosition(); lpwndpos->x = temp.left; lpwndpos->y = temp.top; lpwndpos->cx = temp.Width(); lpwndpos->cy = temp.Right(); SetPosition(temp); } m_position is private, that's why i need a temp one. I get an error on the temp.Width() and temp.Right(): error C2039: 'Width' : is not a member of 'tagRECT' error C2039: 'Right' : is not a member of 'tagRECT' which is kinda normal becz RECT is a structure, not a class. How can i fix it? (when to use RECT, and when to use CRect?)
-
It should help but void CMyEdit::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { RECT temp= GetPosition(); lpwndpos->x = temp.left; lpwndpos->y = temp.top; lpwndpos->cx = temp.Width(); lpwndpos->cy = temp.Right(); SetPosition(temp); } m_position is private, that's why i need a temp one. I get an error on the temp.Width() and temp.Right(): error C2039: 'Width' : is not a member of 'tagRECT' error C2039: 'Right' : is not a member of 'tagRECT' which is kinda normal becz RECT is a structure, not a class. How can i fix it? (when to use RECT, and when to use CRect?)
JensB wrote: void CMyEdit::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { CRect temp= GetPosition();// use CRect instead of RECT and it will work lpwndpos->x = temp.left; lpwndpos->y = temp.top; lpwndpos->cx = temp.Width(); lpwndpos->cy = temp.Right(); SetPosition(temp); }
-
Hi. I've subclassed the CListCtrl. You can edit a subitem, and type some text into it. But if you resize the column (making it larger for example) then the editbox need to be redrawn to fill the whole (new) column space. Mine stays the same, how can i achieve this? Greetings Jens
-
JensB wrote: void CMyEdit::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { CRect temp= GetPosition();// use CRect instead of RECT and it will work lpwndpos->x = temp.left; lpwndpos->y = temp.top; lpwndpos->cx = temp.Width(); lpwndpos->cy = temp.Right(); SetPosition(temp); }
ok, i've changed the data member to CRect instead of RECT structure but it still doesn't work. I'll paste what i have done: in the derived class of CListCtrl CEdit* CMyListCtrl::EditSubLabel( int nItem, int nCol ) { ... CRect rect; //set rect .. CEdit *pEdit = new CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol), GetColumnType(nCol), rect); pEdit->Create...... void CInPlaceEdit::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { //CEdit::OnWindowPosChanging(lpwndpos); //Positie veranderde! CRect temp; temp = GetPosition(); lpwndpos->x = temp.left; lpwndpos->y = temp.top; lpwndpos->cx = temp.Width(); lpwndpos->cy = temp.Height(); SetPosition(temp); //positie zetten //CEdit::OnWindowPosChanging(lpwndpos); } i don't see any difference, if i move the column more larger (editbox isn't made langer). what am i still doing wrong? :(
-
hello..... hey do u know how to disable the user control from resizing the columns of the list control...... plz reply if u have any idea abt it yaar thanks in advance Adi
yes, check: http://www.codeguru.com/listview/no\_col\_resize.shtml http://www.codeguru.com/listview/no\_col\_resize2.shtml here you go :)
-
ok, i've changed the data member to CRect instead of RECT structure but it still doesn't work. I'll paste what i have done: in the derived class of CListCtrl CEdit* CMyListCtrl::EditSubLabel( int nItem, int nCol ) { ... CRect rect; //set rect .. CEdit *pEdit = new CInPlaceEdit(nItem, nCol, GetItemText(nItem, nCol), GetColumnType(nCol), rect); pEdit->Create...... void CInPlaceEdit::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) { //CEdit::OnWindowPosChanging(lpwndpos); //Positie veranderde! CRect temp; temp = GetPosition(); lpwndpos->x = temp.left; lpwndpos->y = temp.top; lpwndpos->cx = temp.Width(); lpwndpos->cy = temp.Height(); SetPosition(temp); //positie zetten //CEdit::OnWindowPosChanging(lpwndpos); } i don't see any difference, if i move the column more larger (editbox isn't made langer). what am i still doing wrong? :(
-
yes, check: http://www.codeguru.com/listview/no\_col\_resize.shtml http://www.codeguru.com/listview/no\_col\_resize2.shtml here you go :)