2
votes

I have followed the sample supplied by EMB that can be found on

"C:\Users\Public\Documents\Embarcadero\Studio\14.0\Samples\Object Pascal\FireMonkey Desktop\CustomListBox"

this is how it looks like:

Firemonkey Custom List

This is the code that add the row to the listbox:

procedure TfrmCustomList.Button2Click(Sender: TObject);
var
  Item: TListBoxItem;
begin
  // create custom item
  Item := TListBoxItem.Create(nil);
  Item.Parent := ListBox1;
  Item.StyleLookup := 'CustomItem';
  Item.Text := 'item ' + IntToStr(Item.Index); // set filename
  if Odd(Item.Index) then
    Item.ItemData.Bitmap := Image1.Bitmap // set thumbnail
  else
    Item.ItemData.Bitmap := Image2.Bitmap; // set thumbnail
  Item.StylesData['resolution'] := '1024x768 px'; // set size
  Item.StylesData['depth'] := '32 bit';
  Item.StylesData['visible'] := true; // set Checkbox value
  Item.StylesData['visible.OnChange'] := TValue.From<TNotifyEvent>(DoVisibleChange); // set OnChange value
  Item.StylesData['info.OnClick'] := TValue.From<TNotifyEvent>(DoInfoClick); // set OnClick value
end;

As you can see there is this line where the custom style is applyed:

  Item.StyleLookup := 'CustomItem';

There is a StyleBook on the form, and the form is associated to it. The TListBox has not style applied.

However if you change this CustomItem Style, nothing happens. You can even change the names of the itens and nothing happens (not visual change at all) the layout keeps fixed as it is shown on the windows above.

I have added another TTlabel with its own name and tried to assign to it:

  Item.StylesData['ghost'] := 'scary thing';

It does not give any error, but no text is shown. The style keeps immutable.

If removed the Item.StyleLookup assignment when creating the item the only thing changed is that the name of the TLabel are lost and then there is no way to assign the value.

So, the style is defined, but I see somehow it seems to be fixed. Any layout change is not applied, somehow seems to only understand the style sub items name changing. That is not useful at all.

How can I truly modify this style? I want to put each of the 3 TLabels side by side in a horizontal layout.

1
what I can see is that Firemonkey is not prepared for business applications. On the 3rd version should be better. For 20 years I used VCL and since version 1 it is possible to create real apps easy. I understand that for multiplatform you can eventually need more complex stuff. But anything, like customizing a grid cell (Tstringgrid, TListview, etc) or just adjusting a background color is frustrating. Sorry to say that but I want to express that somehow.Eduardo Elias
Firemonkey is still rough around the edges, for example the Style designer is an absolute pain in the ass and hardly ever works as intended. However, I don't think it's in such a terrible state. Most often people will make mistakes because they are unfamiliar with the framework and then blame Firemonkey for it.Peter
@PeterV. yes, i know... I decided to go with Firemonkey, but there are some stuff that is amazingly simple and is so difficult, like a simple grid connected to its data and with currency format columns. The minimal for a business directed framework is to have currency mask or whatever! I mean, they should care more about this basic functionality, and let the more fancy stuff be difficult. My rant is because I am taking 2/3 of my project time just to figure out how to do basic things... so you imagine.Eduardo Elias
I've updated my answer, you can now download my ListBox example to compare and see where you made the mistakes, let me know what you find out.Peter
@PeterV. Hey thanks, I will take a look later and let you know, this is important for me. ThanksEduardo Elias

1 Answers

1
votes

While I understand and share your frustration this problem appears to be your own doing.

However if you change this CustomItem Style, nothing happens.

There are three reasons why this might happen:

  • You have multiple Stylebook components and you are not editing the active one.
  • StyleLookup doesn't match any style name in the StyleBook
  • You copied the example project to a new location and failed to realize that you are still modifying the original files.

I'm quite positive that it's the second reason.

If your Delphi IDE is set to Autosave Project desktop then a .dsk file is generated when you close your project.

When you reopen the project later, the .dsk file is read, and your desktop layout, your breakpoints, and your watches are all restored. Also, all files that were opened when the project was closed are opened again, regardless of whether they are used by the project.


Here is the example with labels in a horizontal layout:

enter image description here

You can download the example from dropbox and examine it to see where you went wrong.