Black line appears when updating a ListView with selected items - winapi

I have a list view that draws an additional black line when items in the list are modified and there are selected items in the list.
The code iterates over the list and updates the cells using the line of code below:
ListView_SetItem(m_hListCtrl, &lvItem);
Additional rows are added using the ListView_InsertItem macro.
If a row is added and there are other rows selected, the following happens:
The line disappears if the user selects a different row. How can this black line be prevented/removed?

The LVS_EX_GRIDLINES style has a number of bugs associated with it that Microsoft have never bothered to fix, and this is one of them. The workaround is to forcibly redraw the list items when you make the particular changes that trigger the problem. You can redraw a range of list items using the LVM_REDRAWITEMS message, or even simpler just repaint the whole control with InvalidateRect().

Related

How to control which GTK widgets visible in an expanded row of a tree?

I'm building a tree store with GTK3 in C in which there are primary rows that are always displayed, and by clicking on the little triangle icon to the left of a primary row, additional secondary (child) rows expand below the primary. As an example, consider that the primary rows could be directories, and when they're expanded, rows below that show the files in those directories. I'm doing this to allow a user to select primary items to be deleted, while the secondary rows are just informational, telling, for example, what files are in the directory, so they'll know if they really want to delete the whole thing.
To enable selection for deletion, the first column contains a GTK_CELL_RENDERER_TOGGLE, and I have a callback associated with the checkbox toggle. Everything works nicely except for one thing. When the user clicks the little triangle item to expand a row, most of the content of the primary row does not appear in the secondary rows (this is expected and desired), but... the checkbox toggle does appear in the first column. Although in a directories/files example that might be meaningful, in my case it makes no sense to think of deleting the content of the secondary rows.
When building the secondary rows, I've tried things like just:
gtk_tree_store_set(TS,&J,2,"filename",-1);
or
gtk_tree_store_set(TS,&J,0,NULL,2,"filename",-1);
hoping that NULL would cause the toggle to be suppressed, but to no avail. GTK still displays a checkbox, probably just interpreting the NULL as a zero.
Is there a way to control (and in my case, suppress) display of the toggle? Or more generally, is there a clean way to control which columns are displayed in child rows? It seems to work with TEXT, but just not with TOGGLE.
A little later: There is a potentially useful function called gtk_cell_renderer_set_visible(), but it requires a reference to the cell renderer. How to acquire that on a per-row or per-cell basis when all I have during construction is the GtkTreeStore and a GtkTreeIter?
There are (at least) 2 solutions:
Base class GtkCellRenderer has visible property. You can add extra field to your model which indicates, whether Toggle should be visible for this row.
If there are other fields in you model which indicate whether it's a primary or secondary row but not directly you can use gtk_tree_view_column_set_cell_data_func to set a function to be called before rendering. There you can call gtk_cell_renderer_set_visible or any other function to set renderer's properties manually.

JavaFX - After changing Label Text, Animation resets

I have a dynamically filled GridPane, where I'm animating the first row and column, so if there is a lot of information, the user doesn't get lost, because the row and column jumps to the selected area.
(Animating: I created two GridPanes, one for the first row and the second one for the first column, then I move the labels into the new GridPanes and finally starts the animation.)
It looks like this:
The user can also select some cells and change the content (using KeyEvents).
But there is a problem, when I change the text of a label, the animated row and column jumps back to their first position, but I don't understand why. It happens only, when I change the text, the CSS style for example is not causing the issue.

Does anyone know why an object would miss a property?

We have a script that export our Indesign documents to HTML and one of the routine is to export tables. In this script we go throught each Tables->Rows->Cells and evaluate some of the properties (i.e. bottomEdgeStrokeType, topEdgeStrokeType, etc...) and transport them to HTML.
Now yesterday we had problem converting one particular document because some cells were missing the "bottomEdgeStrokeType" property entirely. I've discovered this by outputting the properties of each cells and compare the faulty ones with the others.
This line bellow was trowing the error: "Invalid object for this request.".
var cellType = cell["bottomEdgeStrokeType"];
Now, to fix this I've wrapped this around a try catch block to handle the case when it's not there, but now what is puzzling me is how on earth can Extendscript instantiate an object with missing properties?
Indesign version: CS5.5
A property is not only 'undefined' if it cannot exist at all (such as asking for the parent text frame for a character in overset text), but InDesign's Javascript engine also fails to return a reasonably accurate result for multiple values.
If you ask for "the" point size of a paragraph, where this paragraph contains multiple sizes, poor ID does not consider to return something like CONSTANT.Mixed, or the first value only, or (what I might have preferred) an array of the values; it returns undefined instead.
So how can a single table cell have multiple bottom strokes? If the cell underneath it is split into multiple cells, and one has a "top" stroke but the other has not.
It's difficult to recommend an adequate solution. You could first test if the current cell is "merged" (as far as InDesign's internal table model is concerned) with columnSpan; and if so, iterate over the number of columns spanned and test the next row's cells for their top stroke, which in theory should match the bottom stroke of the cell above. (I find myself wondering if this is always true. ID's table model is ... weird. It's not entirely like a HTML table, despite the functional overlaps.)
If columnSpan is greater than 1 and equal to the number of cells immediately below the current one, you could test if all of their "top" values are the same and if so use that value. (I never tested this so ID's table model may simply fail because a cell is merged, regardless of same-values or not.)
One could attempt to flag this cell's next row to output "top" strokes as well -- but alternating top and bottom strokes may not align nicely in CSS, side to side. Perhaps it's best to translate only the first top stroke value to "the" bottom stroke property for your current cell, and fix up manually where needed (how?) or, a reasonable action, hope that no-one will ever notice it.

Persistent selections in SlickGrid

In Example 9, if you execute
grid.setSelectedRows([0, 1]);
the first two rows are effectively selected. But said selection disappears when clicking a row or traversing them with the arrow keys.
Note that active (related to the clicks/keydowns) and selected (related to the selection model) are two different CSS classes.
How to prevent the mouse and keyboard actions from interacting with the selection model?
If you don't want the active cell tracking affecting the selection, you can set the "selectActiveRow" option in the RowSelectionModel to false.

List Control Adds a Space for an Image to Column 0 When Subsequent Columns Have Images

I’ve come across a problem with Windows list controls (I am specifically using MFC, but it looks like it applies to all list controls in the Windows common controls library).
In my specific case, I want to create a list control that has two or more columns. The first column (0) is text-only and is used to allow the user to jump to entries by typing the text in that row. Column two (or three, or four, or whatever) has an image (or an image and text; either way).
This much is all well and good and can be done easily without problem, however the final list control then ends up having a space to the left of the text in column 0 (it may be on the right on an RTL system). This spacer appears to be reserved for an image and I cannot figure out a way to prevent it. (Arranging the specific order of the columns did not change anything.)
Looking around, I found some other people complaining of the same thing, specifically this thread which leads to this thread. The proposed solution does not work because as was stated, simply shrinking the width of column zero merely cuts off the text rather than the image spacer (plus, you then have to prevent and/or process any changes to column widths that the user tries to make).
Does anyone have any ideas of how to fix this bug short of writing a list control from scratch or using one of the too-fancy grid controls on CodeProject/CodeGuru/etc.?
Thanks a lot.
Did you try to change the iIndent member of the LVITEM struct? MSDN says this:
iIndent Version 4.70. Number of image widths to indent the item. A
single indentation equals the width of
an item image. Therefore, the value 1
indents the item by the width of one
image, the value 2 indents by two
images, and so on. Note that this
field is supported only for items.
Attempting to set subitem indentation
will cause the calling function to
fail.
Column 0 is special in a ListView. As soon as you assign a small image list to the ListView, the control expects you to show an image in column 0, so it leaves space for it.
Solutions:
make column 0 zero-width, give it the value you want the user to be able to type. Column 1 becomes your "first" text column. Columns 2+ are for your images. You need full row select style for this to work. Yes, you have to prevent the user from resizing column 0. Yes, that is a pain.
make a column that does have an image to be column 0 and use LVM_SETCOLUMNORDERARRAY to rearrange the display order
owner draw the items.
give column 0 an icon (just to cover all bases)

Resources