How to edit columns in-place with CListCtrl? - mfc

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 the cell.
The final step is to handle the focus and keyboard enter events for the CEdit so that the text details of the CEdit can be put back into the list view cell.
It does take a fair amount of coding but when done right it does work well as an alternative to a grid control.

Don't attempt with CListCtrl.
Use the MFC Grid Control. We deploy it in an off-the-shelf app with success. It offers in-place edit, checkbox, spin, etc for all cells, as well as column and row headers, auto-size, auto-expand, colors, drag-drop.

Related

Narrow the field Buttons Adding

I create a hierarchy matrix table but can't figure it out where "narrow the field" buttons are.
Recent view:
and how I'd like to see is like this:
How can i Turn on/off those buttons?
Thanks in advance
Solution to your first question is:-
To adjust the column width you can follow below steps:
Put your cursor on the line between both column
Press your mouse key and move width of column according to your requirement
Solution to your second question is:-
You can turn on/off +/- icons properties so those button will display if its on or will not display if it off

Roku-Create Selectable List

I am in the process of making a Roku channel. The idea is to have a full screen player going, if the user presses a particular button on remote, a small pop up menu will display in a corner of the screen with a list of available channels. I have all working with the following exception: I can't figure out how to populate the area where the menu displays. Currently I have a transparent roImageCanvas on layer 1, the menu box is drawn on layer 2. The problem is that roImageCanvas allows for a text element but only one Item. So if I have a list of 10 channels, I would have to create 10 items on the canvas. The roImageCanvas does not accept arrays. So there is no way to create the pop menu on the fly if the number of channels changes. The number of items on the canvas has to be hard coded as far as I can tell. Ideally the roListScreen is what I would like to pop up but from what I understand all screens are full screen all the time. Does anybody know of a way to populate the targetbox on the canvas or create a screen that is resizable? Thanks for any suggestions
A roImageCanvas layer is an array. There is no technical limitation to you adding >1 elements to a layer and so you can add as many separate text items as you want (not hard-coded!). It seems to me best to have 1 text element per 1 menu item, so you can use their bounding rectangles (or text color) to highlight the choice

How can I wrap the item text in treeview control in WTL

I am maintaining a ATL/WTL project in which it contains a tree view. The class used for the tree view is CTreeViewCtrl. Now the client has asked to wrap the tree item text when it goes out of view though we can re-size the pane or scroll left of right anytime to see the content. It also shows the full string, when hidden, as a tool tip when mouse pointer is hovered on a tree item.
Is there any way I can set in the tree item or the tree view to wrap the text content.
Thanks
There's a way: do custom drawing of treeview's items while processing NM_CUSTOMDRAW message from treeview control, specifically the CDDS_ITEMPOSTPAINT drawing stage.
On custom drawing you draw multi-line text using ::DrawText() with DT_WORDBREAK flag.
In order to have enough space available for text to fit in use TVITEMEX structure's iIntegral field. You'll have to specify number of lines for each node by sending TVM_SETITEM message to treeview window with pointer to TVITEMEX as LPARAM. You'll have to recalculate number of lines for each of tree's nodes every time treeview's width changes (WM_SIZE).

extjs grid ListFilter scroll handles (ListFilter overflow)

I have a grid with a ListFilter on one of the columns. The list of filter items is long enough that it overflows the height the pages. However I do not get scroll handles on the list like I do with the column menu.
To illustrate this:
Column menu comes standard with top and bottom scroll handles on overflow, top handle shown here:
The ListFilter menu has no scroll handle on overflow (though it will scroll with mouse wheel):
Initially, I thought this was happening because my ListFilter implementation was based off a remote data store rather than a fixed list of options (the data isn't loaded before the grid renders). I changed to a fixed list and I still dont have any handles. Has anyone implemented scroll handles on these filter lists?
Add this.self.xtype='menu'; to the constructor function inside ListMenu.js and it should work.

Get relative X/Y of a mouse-click on a MFC CListBox item

I have a CListBox with custom drawing being used, and need to detect mouse-clicks within each item to perform actions.
I can listen for mouse-clicks on the main control and mess about translating coords into the local space of the RECT for the item under the mouse. But is it possible to register message handlers for clicks on individual list items... are there messages for that?
You can use the LVM_HITTEST message to find out which item was clicked.
Well you could just listen for the LBN_SELCHANGE notification. This will fire every time the user clicks a new item. It won't activate if the already selected item is selected though. This may, or may not, be a problem.
Beyond that I'm pretty sure you'll need to intercept WM_LBUTTONUP messages and transform them to the list box's client space ...
OR You could just use a single columned CListCtrl (ListView) class with headers turned off (LVS_NOCOLUMNHEADER). You can then trap the NM_CLICK message. Personally, I massively prefer CListCtrl to CListBox. It IS a little more complex but way more powerful :)
Edit: Or you could try using http://msdn.microsoft.com/en-us/library/bb761323(VS.85).aspx
I'm not certain I understand why you need to have the XY coordinate inside each item of a Clistbox ?
anyway,
AFAIK, Individual items are not CWnd derived objects.
You could get the mouse position inside the control with OnLButtonDown (or up), it returns a CPoint.
After that, use CListBox::GetItemRect to get the rect of the currently selected item, do a bit of pixel computation and you should be able to get the XY inside the rect of the selected item.
Max.
Use the DPtoLP function to convert device coordinates into logical coordinates.
http://msdn.microsoft.com/en-us/library/dd162474(v=vs.85).aspx