clistctrl

How to set an item in CListCtrl as selected?

ClistCtrl is set to single selection & single column in report view with no header. I have tried SetItemState(0,LVIS_SELECTED,LVIF_STATE) and SetSelectionMark(int index) but these don't work. ...

Finding file size windows MFC application

Hey guys, I Am working on windows MFC application C...I am preparing a report list in my design using CListCtrl were i can list the name,size,type and modified date of the file..I dont know how to display the size of a file..do any one know how to do that..it will be helpful for me thanks in advance.. ...

Vertical Scrollbar in CListCtrl

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? ...

Displaying the size of a file in CListCtrl

I am working in Windows MFC application..In my design am displaying the file details (type,name,size) in a CListCtrl control. I found those file details using FileStatus but when I try to display, I am not able to display the file size since its an integer. I tried CListCtrl::SetItemText and I also tried to type cast but its not working....

CListCtrl: how to get column width when use different fonts on same column?

I derived a class from CListCtrl called CListCtrlCustomDraw, and use NM_CUSTOMDRAW handler to draw the list. The problem is I have different fonts for selected item and unselected item, they are member variables of the list control, but when I use m_list.SetColumnWidth(iCol, LVSCW_AUTOSIZE); int nTextWidth = m_list.GetColumnWidth(iCo...

HitTest not working as expected

I am wanting to display a context menu when a user right-clicks on an item within a CListCtrl. My code is as follows: void DatastoreDialog::OnContextMenu(CWnd *pWnd, CPoint pos) { // Find the rectangle around the list control CRect rectMainArea; m_itemList.GetWindowRect(&rectMainArea); // Find out if the user right-click...

Can't get OnContextMenu to work for custom CListCtl class.

I am trying to get a context menu to work for a CListCtrl derived class. I just created a method OnContextMenu, but it isn't being called. What am I missing? I am using Visual Studio 2008, to create a CDialog based MFC application. customlist.h class tcCustomListCtl : public CListCtl { DECLARE_DYNAMIC(tcCustomListCtl) public:...

Using a CListCtrl, how can I make selection color entire row?

I currently have NM_CUSTOMDRAW message calling a function to color the rows of a listctrl in report mode. I can detect when a row is selected and color it myself, but this method doesn't get called for the cell that is selected, so I can't color that cell. So my question is 1) is there a way to have windows call my custom draw method f...

Persist highlight in CListCtrl after double click

Figured it out. LVIF_STATE should have been LVIF_IMAGE. See, I knew it was elementary... I have a CListView derived class with an OnDoubleClick() handler in a VC++6.0 project. I need to persist the highlighting of the selected item after the OnDoubleClick() handler has done its thing. I had thought that GetListCtrl().SetItemState(m...

Is it possible to edit data in place using CListCtrl - if not, can anyone suggest an alternative control in MFC?

I'm designing a MFC app in which I'd like to have a grid with 2 coloumns : both editable in which the user will input data and the app will get notified about it. The number of rows can be increased/decreased by the user as he wants - What would be the ideal MFC control to use for this kind of requirement ? This is my first time designi...

How do I prevent flickering on CListCtrl?

I'm using a CListCtrl/CListView report view (LVS_REPORT) in virtual mode (LVS_OWNERDATA) with LVS_EX_DOUBLEBUFFER enabled and I encounter ugly flickering. Double buffer have a real effect but it doesn't stop all flickering (without it very slow). I'm not looking for switching to other controls that would require a high amount of rework ...

C++/MFC: Handling multiple CListCtrl's headers HDN_ITEMCLICK events

I'm coding an MFC application in which i have a dialog box with multiple CListCtrls in report view. I want one of them to be sortable. So i handled the HDM_ITEMCLICK event, and everything works just fine .. Except that if i click on the headers of another CListCtrl, it does sort the OTHER CListCtrl, which does look kind of dumb. This i...

Problem with OnMeasureItem()

Hi, I used OnMeasureItem() in my MFC ListControl to increase the height of the rows, and added WM_ON_MEASUREITEM() message in the Map. THe code I used is as follows: void CListCtrlTestDlg::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) { if( nIDCtl == IDC_LIST1 )//IDC_LIST1 is my ListControl ID { lpMeasu...

Auto Resizing in a ClistCtrl

Hi, Is there a way to resize the listcontrol automatically? Usually when the item gets too long the back end disappears from view and the user manually has to resize the width of the column. Is there anyway to do this by the code? Thank You!! ...

Limiting the number of entries in a list control MFC

Hi, I need to limit the entries that appear in my list control since two much entries make my MFC program slow. Is there a way to show only the last few entries (say for an example the most recent 100 entries) in a list control??? Thank You!!! ...

Coupling an MFC CListCtrl and CTreeCtrl to get a view of the whole tree, not just one node at a time

Consider Windows Explorer (or regedit or similar). To the left side, there is a tree view, and to the right, a list view. In all cases I know of, the contents of the right view reflect the attributes of the selected node from the left pane. This is all well and good... but just not what I want. The nodes of the tree I want to display ha...

Correct way to replace CHeaderCtrl with custom version in a CListCtrl

CListCtrl has a CHeaderCtrl 'built-in' and we want to override it with something customized, i.e a class which derives from CHeaderCtrl. What's the best/correct way to do this, assuming we have a dialog CMyDlg which contains a CListCtrl m_List, and a custom header CCustomHeader. ...

Up and Down icons in CListCtrl

I have a CListCtrl with multiple columns, all of which are able to be sorted by. I would like to add up and down icons so that it is clear which column is currently sorted upon, and in which direction; much like Windows Explorer. My thought was to add a solid up/down arrow to the column name. I tried using the extended ASCII chars 30/31;...

Virtual List Control Problem

Hi, I'm using a virtual lit control and I get the data from a map. My problem is when I run the code, it displays the list ok, but when the mouse cursor moves on to the list control or when I try to scroll down, it gives a Debug Assertion failure saying map/set iterator is not dereferencable. My GetDispInfo() method is as follows: voi...

how can i cancel editing in CListCtrl by hitting the "cancel" key?

I'm editing an item in CListCtrl control. an edit box appears where I can enter text. The event of entering the text will, however, not be catched by the LVN_KEYDOWN handler. how do I catch it otherwise? any samples? Thank you ...