Win32 List-View Control SubItem padding for custom-drawn SubItems? - winapi

When using custom-draw (NM_CUSTOMDRAW) to draw the entire contents of a ListView SubItem (in Report/Details view), it would be nice to be able to apply the same left and right
padding in my custom paint method that is applied by the control itself for non-custom-drawn items.
Is there a way to programmatically retrieve this padding value? Is it
related to the width of a particular character (" " or "w" or something?) or
is it a fixed value (6px on left and 3px on right or something) or...?
EDIT: To clarify, I want to add the same padding to my NM_CUSTOMDRAWn SubItems that the control adds to items that it draws, and the metric that I'm looking for, for example, is the white space between the beginning of the 2nd column and the word "Siamese" in the following screenshot (Note: screenshot from MSDN added to help explain my question):
(source: microsoft.com)
Note that the word "Siamese" is aligned with the header item ("Breed"). I would like to be able to guarantee the same alignment for custom-drawn items.

use ListView Header message HDM_GETBITMAPMARGIN
see link text

ListView_GetSubItemRect (LVM_GETSUBITEMTECT)
http://msdn.microsoft.com/en-us/library/ms930172.aspx
Despite what the documentation says I suspect LVIR_LABEL returns just the returns the bounding rectangle of the item text, as per ListView_GetItemRect.
(This just kept niggling me as I though I had actually seen an answer somewhere when playing with NM_CUSTOMDRAW).
Edit After Comment 2:
I imagine you have seen NMLVCUSTOMDRAW which if you are willing to use Version 6.0. has rcText. I wouldn't since I use Win2K.
Given what you have found I would go back to the suggestion of using
ListView_GetItemRect to get LVIR_LABEL and compare that with LVIR_BOUNDS and use the difference.

the way for doing this is retrieving the format of the corresponding column with
ListView_GetColumn()
then check the retrieved myLVCOLUMN.mask
LVCOLUMN myLVCOLUMN;
myLVCOLUMN.mask=LVCF_FMT;
ListView_GetColumn(hwnd,nCol,&myLVCOLUMN);
then when we draw the corresponding label belonging to that column
if(myLVCOLUMN.fmt & LVCFMT_CENTER)
DrawText(x,x,x,x, DT_CENTER | DT_WORD_ELLIPSIS );
else if (myLVCOLUMN.fmt & LVCFMT_RIGHT)
DrawText(x,x,x,x, DT_RIGHT | DT_WORD_ELLIPSIS );
else
DrawText(x,x,x,x, DT_LEFT | DT_WORD_ELLIPSIS );

I would assume that GetSystemMetrics() is that you need to look at. I think that SM_CXEDGE and SM_CYEDGE are probably the values you want, but don't quote me on that. ;-)

Can only guess without seeing your output.
A few suggestions: If you are using the DrawTextEx function, have you have experimented with DT_INTERNAL et al?
Are you accidentally putting in a blank image/icon.
Does it look ok in classic screen mode? If so I would look at XP Theme functions to see if some thing is going on.
Late edit after first comment:
I wonder if the size of rectangle matches the space required for the LVN_ENDLABELEDIT edit box around the text so the text doesn't move (or for a focus rectangle)?
I guess you could compare the result of LVM_GETITEMRECT with LVIR_LABEL on the first column and use the difference as your left border.

Related

How to make items in a FMX TListBox bold?

How can I make the items in my FMX TListBox bold? I can't find anything by myself, either in the documentation or the Internet.
You need to set two properties for the tListItem in question. The first line of code below lets you set the font properties for that ListItem rather than having the style dictate the font properties (if you miss this step, the next step will have no affect). The second line sets that ListItem to bold (where, of course, x is the index within the list that should be made bold)
ListBox1.ListItems[x].StyledSettings:=[];
ListBox1.ListItems[x].Font.Style:=[TFontStyle.fsBold];
Thanks to Gregg who gave a working answer for delphi, i'll put a C++Builder version here.
I made a loop over my ListBox with the item count, and it does not affect the loading speed of the ListBox (around 4000 items in my case) so it's a good solution at least for me.
ListBox->ListItems[x]->StyledSettings = ListBox->ListItems[x]->StyledSettings >> TStyledSetting::Style;
ListBox->ListItems[x]->Font->Style = ListBox->ListItems[x]->Font->Style << fsBold;
You can use custom theme for TListBoxItems. Create one by right mouse on ListBox.

JavaFX: Cross-Platform Button Resizing Issue [duplicate]

If I make button relatively small, it's caption turns to ellipsis.
How to turn off this feature?
Don't let the button go below it's preferred size, then it will never need to elide the text of the button label:
button.setMinSize(Button.USE_PREF_SIZE, Button.USE_PREF_SIZE);
I want to make very small button
You can use any of the below either separately or in combination:
Apply CSS to use a very small font in the button.
Make the label text for the button very short.
Use brian's answer which proposes explicitly setting the ellipse string to empty.
Use a small graphic icon instead of text.
You can use setMinSize as documented above in all cases (if you wish the button not to go below a preferred size truncating or eliding content).
In all cases, if you wish, you can also apply CSS to minimize the padding between the label and button the border.
From your previous comment (I want to use simple captions like "<" and ">"), I think option 2 (Make the label text for the button very short) is what you want.
You may also be interested in Joel's Designing for People Who Have Better Things To Do With Their Lives which would indicate, usability-wise that very small buttons are usually a pretty bad idea.
in your label/button you can use the textOverrun property to turn off ellipsis.
textOverrun.set(OverrunStyle.CLIP);
this is probably a bit late for you, so i am putting it here for lone wanderers digging up this question.
It puts ... because there's no room for the text. You can use bigger buttons or a smaller font but if you really want the dots gone use button.setEllipsisString(""); , but then you just get truncated text.

How can I programmatically detect if some text is visible or has overflowed in an InDesign document using ExtendScript?

I am building an InDesign panel with ExtendScript which finds text and shows it to the user. To do this, I use the showText() method of the Character object. The problem is that sometimes the text I'm looking for doesn't appear because, even though the method does show the right page at the right place, the text has overflown and is not visible.
Is there a way to check if the text is visible or not? Ideally, I would like to be able to fall back on the story editor if the text cannot be seen as-is...
To check the situation for an individual character, see the parentTextFrames property, it returns an array with 0 or 1 frames. In rare cases of insertion points whose left side is in one frame while the right side is in the following, you get two frames.
app.selection[0].characters.item(0).parentTextFrames.length
You can also compare the index of your character against the last index in the last text container of the story, e.g.
app.selection[0].parentStory.textContainers.pop().characters.lastItem().index
Of course you should first see whether there is overflow at all ...
app.selection[0].parentStory.overflows
You may call the baseline property for the text in a try/catch statement. If text is visible, baseline will return a value, otherwise it will raise an error.
Loic

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)

Dynamics AX 2009 Report: LabelPosition above does not work?

I'm just in the process of changing the SalesInvoice Report. One thing I'm trying to do is show the label of some items not left of the item value but above it instead.
Seems easy enough: just change the LabelPosition (for example from CustInvoiceJour_InvoiceId) setting from "left" to "above" and voila: the label has vanished. It is just shown nowhere at all.
Strange. I would have expected the label to show up, well, above the content. Not to vanish.
Am I missing something (there is no label height to set), or is this functionality broken?
I'm not sure if this functionality is broken. But in generated design, these elements will not show the label if it's set to above:
Prolog
PageHeader
Header
Footer
Epilog
ProgrammableSection
If the item you're trying to change is in one of those, then the label position above will, from my experience, not work.
My tip is to create a new control of the text type and then use the same label that the extended data type for the field uses under the "text" property and then adjust the position so it is positioned above the field you're trying to set a label on.
From what I have noticed for a ProgrammableSection the column name labels are not shown only on the first page of the report. The labels are shown on the next pages.

Resources