Recent

Author Topic: Problem registering a new field type  (Read 596 times)

dpap

  • Jr. Member
  • **
  • Posts: 53
Problem registering a new field type
« on: March 04, 2025, 02:59:31 pm »
In Delphi I had a custom BLOB field that had compression capability, named TZipedBLOBfield. I can't recall where I had found it but it was very helpful. Now I'm trying to port in lazarus 3.6 but, although the installation succeeds when I try to use it (eg. change the class of an existing BLOB field), Lazarus deletes the field. When I create a new field I can't find the the TZipedBLOB type.
What am I doing wrong? Can you help me, please?

PS. I attached the unit

wp

  • Hero Member
  • *****
  • Posts: 12864
Re: Problem registering a new field type
« Reply #1 on: March 04, 2025, 07:12:12 pm »
Your code looks correct to me. But I think the problem is: How do you make sure that the dataset creates a TZippedBlobstream instead of a standard TBlobStream? There is a method TDataset.CreateBlobStream - but this is a virtual method (and no event) which you only can change by subclassing the dataset. I think Delphi has the same problem. How was it solved in your Delphi solution?

dpap

  • Jr. Member
  • **
  • Posts: 53
Re: Problem registering a new field type
« Reply #2 on: March 04, 2025, 08:09:20 pm »
I have use it many times in Delphi 2007 to Delphi 11.3 with success. It creates compressed BLOB that can be uncompessed/read from the field and can be individually decompressed with Zlibx routines.

korba812

  • Sr. Member
  • ****
  • Posts: 468
Re: Problem registering a new field type
« Reply #3 on: March 04, 2025, 08:49:47 pm »
It seems that you can use TZipedBLOBfield class if you create fields by code (see attached example). I know of no other way without subclassing TDataSet.

How do you use this class in Delphi?

edit

when I try to use it (eg. change the class of an existing BLOB field), Lazarus deletes the field. When I create a new field I can't find the the TZipedBLOB type.
I overlooked this. Do you have any package installed in Lazarus that contains this unit?
If so, try registering class using RegisterClass(es).
Code: Pascal  [Select][+][-]
  1. procedure Register;
  2. begin
  3.   RegisterClasses([TZipedBLOBfield]);
  4.   RegisterNoIcon([TZipedBLOBfield]);
  5. end;
  6.  
« Last Edit: March 05, 2025, 01:57:38 am by korba812 »

dpap

  • Jr. Member
  • **
  • Posts: 53
Re: Problem registering a new field type
« Reply #4 on: March 05, 2025, 08:01:40 am »
@korba812, thanks for your help.
Your approach is very-very interesting. So, if I can not install it as fieldType, as in Delphi, at least I can use it as typecast.
Unfortunately, your test application raises the error "list index (-1) out of bounds" in the statement outPut := DataSet.CreateBlobStream(Self, bmWrite) of the method TZipedBLOBfield.LoadFromStream, so I can't see its results.
Why happens it?
Meanwhile, I will try to register it as you show me.

EDIT:
I tried to register the fieldType but, although it installs without problem, it isn't actually registered.
« Last Edit: March 05, 2025, 08:41:26 am by dpap »

 

TinyPortal © 2005-2018