clistctrl

How to change color of CListCtrl column

我的梦境 提交于 2019-12-02 11:47:56
问题 I want to change the background color of a specific column to a color of the dialog (grey). How can I achive it? void CUcsOpTerminalDlg::OnCustomdrawFeatureList(NMHDR *pNMHDR, LRESULT *pResult) { LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR); // TODO: change color *pResult = 0; } Thanks 回答1: If you are using the "new" MFC Feature Pack classes (VS 2008 SP1 and up), you can use CMFCListCtrl instead of CListCtrl and use CMFCListCtrl::OnGetCellBkColor. You would have to derive

Vertical Scrollbar in CListCtrl

拈花ヽ惹草 提交于 2019-12-02 10:08:02
问题 I'm using a CListCtrl in Icon view, but it scrolls horizontally: 1 3 5 7 --> 2 4 6 8 --> I'd rather it scroll horizontally: 1 2 3 4 5 6 | | V V Is there a way to do this? 回答1: Change the Alignment style in designer from Left to Top. 回答2: I seem to have resolved the issue by using a 'Report' view. Through the VS Designer this means changing the 'View' style to Report, resulting the control given the LVS_REPORT attribute in the .RC file. Note that this is equivalent to calling CListCtrl:

Vertical Scrollbar in CListCtrl

拜拜、爱过 提交于 2019-12-02 06:28:46
I'm using a CListCtrl in Icon view, but it scrolls horizontally: 1 3 5 7 --> 2 4 6 8 --> I'd rather it scroll horizontally: 1 2 3 4 5 6 | | V V Is there a way to do this? Change the Alignment style in designer from Left to Top. I seem to have resolved the issue by using a 'Report' view. Through the VS Designer this means changing the 'View' style to Report, resulting the control given the LVS_REPORT attribute in the .RC file. Note that this is equivalent to calling CListCtrl::SetView(LV_VIEW_DETAILS) in code. This isn't sufficient however. It is also necessary to create a column if you don't

CListCtrl: How to maintain scroll position?

点点圈 提交于 2019-12-01 03:17:42
I have a CListCtrl (report style) where I clear the list and repopulate it at certain times. I'd like to maintain the vertical scroll position when doing this. I see there are a couple methods that look promising: EnsureVisible() GetScrollPos() SetScrollPos() GetScrollInfo() GetTopIndex() Scroll() I'm trying GetScrollPos() and then SetScrollPos() but it doesn't appear to be working. What is the simple correct way to save a scroll position and then later restore it? UPDATE Actually it seems I can get to save the scroll position GetScrollPos() and then SetScrollPos() to restore it, however it

How to edit columns in-place with CListCtrl?

旧巷老猫 提交于 2019-11-29 15:17:56
I want to have CListCtrl.EditLabel() for any column of the list. How can I implement such a feature? This is doable but it does require a fair bit of stuffing around with mouse clicks and focus events. In a nutshell you trap the left mouse button down message and convert it into a cell hit details (i.e a row and column index). With these cell details you can not determine the size and location of the list view cell and also the text value that it contains. Now create a CEdit control directly over this cell by using size and location details from the previous step and give it the text value of

How to disable the CListCtrl select option

杀马特。学长 韩版系。学妹 提交于 2019-11-29 11:32:27
I don't know how to disable the CListCtrl select option. I want to override the CListCtrl class method or handle any window command ? Thanks. If you want to stop the user selecting an item in a CListCtrl , you need to derive your own class from CListCtrl and add a message handler for the LVN_ITEMCHANGING notification. So, an example class CMyListCtrl would have a header file: MyListCtrl.h #pragma once class CMyListCtrl : public CListCtrl { DECLARE_DYNAMIC(CMyListCtrl) protected: DECLARE_MESSAGE_MAP() public: // LVN_ITEMCHANGING notification handler afx_msg void OnLvnItemchanging(NMHDR *pNMHDR,

How to detect a CListCtrl selection change?

血红的双手。 提交于 2019-11-28 10:41:51
I want to execute some code when the user selects a row in a CListCtrl (report view, I don't care about the other viewing modes). How do I catch this event? is there some message I can map or a method like "OnSelectionChanged" or something like that? djeidot Also try: BEGIN_MESSAGE_MAP(cDlgRun, CDialog) ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2) END_MESSAGE_MAP() /* ... */ void cDlgRun::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; if ((pNMListView->uChanged & LVIF_STATE) && (pNMListView->uNewState & LVIS_SELECTED)) { //

How to edit columns in-place with CListCtrl?

こ雲淡風輕ζ 提交于 2019-11-28 09:25:11
问题 I want to have CListCtrl.EditLabel() for any column of the list. How can I implement such a feature? 回答1: This is doable but it does require a fair bit of stuffing around with mouse clicks and focus events. In a nutshell you trap the left mouse button down message and convert it into a cell hit details (i.e a row and column index). With these cell details you can not determine the size and location of the list view cell and also the text value that it contains. Now create a CEdit control

How to disable the CListCtrl select option

雨燕双飞 提交于 2019-11-28 05:32:31
问题 I don't know how to disable the CListCtrl select option. I want to override the CListCtrl class method or handle any window command ? Thanks. 回答1: If you want to stop the user selecting an item in a CListCtrl , you need to derive your own class from CListCtrl and add a message handler for the LVN_ITEMCHANGING notification. So, an example class CMyListCtrl would have a header file: MyListCtrl.h #pragma once class CMyListCtrl : public CListCtrl { DECLARE_DYNAMIC(CMyListCtrl) protected: DECLARE

CListCtrl 使用技巧

淺唱寂寞╮ 提交于 2019-11-28 03:09:14
以下未经说明,listctrl默认view 风格为report 相关类及处理函数 MFC:CListCtrl类 SDK:以 “ListView_”开头的一些宏。如 ListView_InsertColumn 1. CListCtrl 风格 LVS_ICON: 为每个item显示大图标 LVS_SMALLICON: 为每个item显示小图标 LVS_LIST: 显示一列带有小图标的item LVS_REPORT: 显示item详细资料 直观的理解:windows资源管理器,“查看”标签下的“大图标,小图标,列表,详细资料” 2. 设置listctrl 风格及扩展风格 LONG lStyle; lStyle = GetWindowLong(m_list.m_hWnd, GWL_STYLE);//获取当前窗口style lStyle &= ~LVS_TYPEMASK; //清除显示方式位 lStyle |= LVS_REPORT; //设置style SetWindowLong(m_list.m_hWnd, GWL_STYLE, lStyle);//设置style DWORD dwStyle = m_list.GetExtendedStyle(); dwStyle |= LVS_EX_FULLROWSELECT;//选中某行使整行高亮(只适用与report风格的listctrl)