Cannot store TBookmark in ListItem.Data anymore lazarus / 16-Databases ---------------------------------------------------------------------- slai · 2016-03-08 10:38 Hy together Today i've installed Lazarus 1.6. Since then i have the issue that i e.g. this code line Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i aitem.Item[zaehler2].Data := tempquery.GetBookmark;tempquery is an ZeosQuery (TZQuery) aitem is TListItems. is not compiling anymore with the error: Error: Incompatible type for arg no. 1: Got "TBytes", expected "Pointer" This was working with Lazarus 1.4.4, i think it could be because of fpc version change? Does anyone of you have the same issues? Was there a change of .data property of a ListItem to Pointer? Thx for any help! ---------------------------------------------------------------------- marcov · 2016-03-08 15:12 TBookmark changed. The same change happened in Delphi. ---------------------------------------------------------------------- balazsszekely · 2016-03-08 16:34 @slai You can do something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TData = class(TObject)    FBookMark: TBookMark;    //add other stuff here if necessary  end;... //assign bookmark to TListItemprocedure TForm1.Button1Click(Sender: TObject);var  Data: TData;begin  Data := TData.Create;  Data.FBookMark := ZQuery1.Bookmark;  //...other data  ListView1.Items.Item[X].Data := Data; //replace Xend; //get bookmark from TListItemprocedure TForm2.Button1Click(Sender: TObject);var  Data: TData;begin  Data := TData(ListView1.Items.Item[X]) //replace X  ZQuery1.BookMark := Data.FBookMark;  //...other dataend; Don't forget to free Data when you delete a TListItem! ---------------------------------------------------------------------- slai · 2016-03-08 18:33 Hy GetMem Thx a lot, didn't thought about a wrapper class  I now created a class that takes a bookmark in the constructor so i directly can create the object itself then. class: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit bookmarkHelper; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, db; type   TData = class(TObject)    FBookMark: TBookMark;    Constructor Init(bMark : TBookMark);  end; implementation Constructor TData.Init(bMark : TBookMark);begin     FBookMark := bMark;end; end. Usage: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i aitem.Item[aitem.Count-1].Data := TData.Init(ZTable.GetBookmark); Thinking now of a destructor and to handle freeing memory automatically when the object isn't used anymore. But anyway, thx a lot! ---------------------------------------------------------------------- mangakissa · 2016-03-09 08:18 It's a good point of view. But why not save the primary key in property data with pointer(id) and use it in a locate. Bookmarks are not working anymore if data is changed in the dataset.