How to make items in a FMX TListBox bold? - firemonkey

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.

Related

How do I change the visibility of multiple decorations in LabVIEW programatically?

I am trying to make a number of front panel decorations hidden in LabVIEW by the use of a boolean control. I have figured out how to do this with one object fine and have made it work with multiple items however it is not very elegant to say the least (see attached image). While in this case I only have 5 elements what if I had an elaborate front panel and had many more decorations I wanted to hide? There must be a better way to do this.
Thanks in advance.
Cheers
It works, just not very efficient....
As you might now you can use a for loop to iterate over array elements. What I would suggest is in the initialization code of your application put the controls of interest on to arrays, and when a user clicks a particular button iterate over those arrays to execute the visible non visible property node call on your decos and or controls of interest.

Is there a SetText message for the Win32 ListBox control?

This is easy in .NET (not my question) but I'm trying to figure out if it is possible to simply change the text of a string in a Win32 list box control given an index.
There is a GetText function that takes an item index but nothing to change the text of an existing item/string. My workaround will be to remove it and add it back in the box (which is also a weird prospect since there is no single command to add a string + item data -- these must be done carefully by inserting the string and then setting the item data on the index of the inserted string, which is tricky (not possible?) with sorting active).
Yes, the lack of a LB_SETITEMTEXT message is a bit weird.
You should put your Delete+Insert+SetData calls between calls to WM_SETREDRAW...
At the risk of being off topic...
I tend to use the ListView control all of the time. You'll want it in report view to mimic a listbox, and, as a plus, it supports multiple columns.
Oh.. and it has a LVM_SETITEM Message :)
http://msdn.microsoft.com/en-us/library/bb761186(v=VS.85).aspx
Although this question is old, but I think this documentation presented by Microsoft will be able to answer anyone questions based on this one.
So according to Microsoft documentation which you can find here
Changes the text of a list-view item or subitem. You can use this
macro or send the LVM_SETITEMTEXT message explicitly.
void ListView_SetItemText(
hwndLV,
i,
iSubItem_,
pszText_
);
And it also presents other macros for managing the list box. You can build a wrapper around this macros to simplify handling list view controls, etc.

Is there a way to nest an Excel spreadsheet within another Excel spreadsheet?

I am not entirely sure if this is the place to ask this, but this is the only think I could think of. I want to know if I could have a spreadsheet, say 10 cells wide. I would like the first 5 cells to be static, and the second 5 to be A/B based on, I guess a drop down? Not sure if this is possible, thanks for the input.
Both are possible.
In regards to the static question, you want to look at Excel's ability to Split the worksheet and then Freeze sections. With Excel 2007 you can find this within the View ribbon and Window group. (I am not sure of the exact menu terminology.)
For a cell to act as a Dropdown, you want to look at Data Validation. This option (with Excel 2007) is found under the Data ribbon within the Data Tools section. This allows you to set a given cell to dates, times, whole numbers, and lists. With the list you set the source to a range elsewhere in the workbook and the cell will render as a dropdown.
Hope this helps.

Outlook 2003 - Add an icon column to a View?

I want to add a custom column to the Inbox which is a Yes/No column. I want an icon to show in the Yes case. How can I do this?
Everything I've looked up is either about adding a column through the View.XML property, through UserProperties.Add with addToFolderFields = true, or through Field Chooser.
There are also a lot of forums where Dmitry from dimastr.com just tells people it's not possible to set an icon with no real explanation.
It's pretty frustrating - why would Outlook's UI support creating Icon fields if you can't set an icon for them?! Won't they just always be blank columns?!
Some alternative questions that would also help if they were answered:
What is the "bitmap" element in the View.XML of a <column>?
How can I set a userproperty as the value of a column using the "prop" element of a <column>?
Where can I find a description of the View.XML definition? Microsoft articles all have bad links.
Icons in the Header and icons in the column itself aren't possible without some kind of Windows API hacks on the column cells.
If someone has a good one, I'll mark it as an answer. Otherwise, I'll mark this ("Impossible") as the accepted answer.
EDIT: I looked with Spy++. Outlook's view is a "SUPERGRID" that is manually painted. You don't have access to individual cells. So that makes it a lot harder. A hack would have to like subclass the SUPERGRID and override some internal method or something. Then replace Outlook's SUPERGRID with the subclassed one. Or something equally terrible. I'm thinking impossible is the only real answer...
may you check that thread, therer might be an solution via form
http://www.outlookcode.com/threads.aspx?forumid=3&messageid=31897

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

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.

Resources