Forum > LCL

Interesting discovery with TListView with OwnerData checked and Adding items.

(1/3) > >>

jamie:
 If you have OwnerData checked and then use the IDE to add items, upon completion of the editor, you get a nice Index of bounds with the trunk.
 
  Older IDE's, it puts the IDE into a loop and you need to hard exit.

dsiders:

--- Quote from: jamie on March 17, 2024, 10:56:36 pm --- If you have OwnerData checked and then use the IDE to add items, upon completion of the editor, you get a nice Index of bounds with the trunk.
 
  Older IDE's, it puts the IDE into a loop and you need to hard exit.

--- End quote ---

Interesting.

So, in essence, the property editor should not be displayed at all when OwnerData is enabled?

jamie:
I would say so.

Not just that, the items should be deleted if one checks the ownerdata too.

dsiders:

--- Quote from: jamie on March 17, 2024, 11:51:58 pm ---I would say so.

Not just that, the items should be deleted if one checks the ownerdata too.

--- End quote ---

SetOwnerData already does that. It frees the Items list are creates the TOwnerDataListItems container used instead.

I made a patch (for 3.99) to catch the circumstance you described, if you'd like to try it out...


--- Code: Diff  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---diff --git a/components/ideintf/listviewpropedit.pp b/components/ideintf/listviewpropedit.ppindex 0fc4ca719d..73ba02c024 100644--- a/components/ideintf/listviewpropedit.pp+++ b/components/ideintf/listviewpropedit.pp@@ -92,6 +92,13 @@ function EditListView(AListView: TListView): Boolean; var   ListViewEditorDlg: TListViewItemsEditorForm; begin+  if AListView.OwnerData then+  begin+    Beep;+    Application.MessageBox(PChar(sccsLvEdtMsgOwnerData), PChar(sccsLvEdt));+    Result := False;+    Exit;+  end;   ListViewEditorDlg := TListViewItemsEditorForm.Create(Application);   try     ListViewEditorDlg.LoadFromList(AListView);diff --git a/components/ideintf/objinspstrconsts.pas b/components/ideintf/objinspstrconsts.pasindex 27366703fb..17099884ca 100644--- a/components/ideintf/objinspstrconsts.pas+++ b/components/ideintf/objinspstrconsts.pas@@ -134,6 +134,7 @@ resourcestring   sccsLvEdtLabelImageIndex = 'Image Index:';   sccsLvEdtLabelStateIndex = 'State Index:';   sccsLvEdtItem            = 'Item';+  sccsLvEdtMsgOwnerData    = 'Cannot edit list items at design-time when OwnerData is enabled. Use Items.Count and OnData at run-time instead.';    // Image editor strings   oisImageListComponentEditor = 'I&mageList Editor ...';  
The Beep and Application.MessageBox calls are debatable, but they did not introduce any new dependencies in the unit.

wp:
I don't like the Beep. Is a Beep used within the IDE anywhere else? And I'd also replace the Application.MessageBox by MessageDlg even it if makes the unit depend on the Dialogs unit. But Dialogs is used already by PropEdits. So, this should not make a difference. Or am I missing something?

Navigation

[0] Message Index

[#] Next page

Go to full version