ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Add text or color to thumbs using TIEDBMultiBitmap and value from the database
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jalbrecht

20 Posts

Posted - Feb 14 2023 :  13:30:23  Show Profile  Reply
Hello,

I have a TImageEnmView Attached to a dataset.

I would like to show some differences on thumbs from values contained into the same dataset.

The dataset shows many pages gathered for different documents, and I would like to show where certain words contained into a text blob field are found attached to the image of the page.

Like
Onimageload do
If Pos(Searchtext , blobtextfield) > 0 then
Imagetoptexte := 'Found'

My problem is that the TImageEnmView on load event does not appear to synchronise with TIEDBMultiBitmap and it's dataset.


Best regards.

xequte

38319 Posts

Posted - Feb 14 2023 :  20:11:45  Show Profile  Reply
Hi

You can't set the thumb text values for content read from a database because it is dynamically filled.

You would be better to use one of the events that is called when each thumbnail is shown, for example:

http://www.imageen.com/help/TImageEnMView.OnGetText.html
http://www.imageen.com/help/TImageEnMView.OnImageDraw2.html


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jalbrecht

20 Posts

Posted - Feb 22 2023 :  04:59:33  Show Profile  Reply
Hi Ngel,

I have tested you proposed solution.
I can't have access to the current data behind the loaded thumb.
It is always on the first record that is providing links to the displayed images.

The cursor only move when I click on a thumb.

// In the form show.
ImageEnView1.SetModernStyling;
fDBMBitmap := TIEDBMultiBitmap.create( udm1.DS_fi_Img , '', 'CHEMIN_CPL', dmAllRecords ); //The file name is complete in field CHEMIN_CPL

fDBMBitmap.ImagePath := '';
fDBMBitmap.FollowDBCursor := True;
fDBMBitmap.AutoLoad := true;
fDBMBitmap.FilenameFieldIsUnique := True;
fDBMBitmap.mode := dmAllRecords ;
fDBMBitmap.FollowDBCursor := true;

ImageEnView1.SetExternalMBitmap( fDBMBitmap );
imageEnView1.DefaultTopText := iedtCustom;
...

procedure Tmain1.ImageEnView1GetText(Sender: TObject; Index: Integer;Position: TIEMTextPos; var Text: WideString);
begin
if Discreminant then // test if the searched text is in the record.
begin
if Position = iemtpTop then
Text := inttostr(Index) + ' [*]';
end
else
if Position = iemtpTop then
Text := inttostr(Index);
end;



Best regards.
Go to Top of Page

xequte

38319 Posts

Posted - Feb 22 2023 :  21:30:45  Show Profile  Reply
Hi

You should be able to use the Index parameter of the OnGetText event to look up the database values.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jalbrecht

20 Posts

Posted - Feb 23 2023 :  02:28:39  Show Profile  Reply
Hi Nigel,

the IDX only changes value on click on the thumbs.
It does not change when loading all the thumbs from a dataset.

Best regards.
Go to Top of Page

xequte

38319 Posts

Posted - Feb 23 2023 :  20:50:00  Show Profile  Reply
Hi

Yes, OnGetText will be called any time the text field needs to be filled:

e.g.

procedure TMainForm.ImageEnMView1GetText(Sender: TObject; Index: Integer;
    Position: TIEMTextPos; var Text: WideString);
begin
  if Position = iemtpBottom then
    Text := Index.ToString;
end;





You can use the Index, to get the Database ID:

https://www.imageen.com/help/TImageEnMView.ImageID.html

Use the ID to perform a look up on the database record and then fill the text string.


procedure TMainForm.ImageEnMView1GetText(Sender: TObject; Index: Integer;
    Position: TIEMTextPos; var Text: WideString);
var
  id: Integer;
  blobText: string;
begin
  if Position <> iemtpTop then
    exit;

  id := ImageEnMView1.ImageID[Index];
  blobText := LookUpRecordText( id );
  If Pos( Searchtext, blobText ) > 0 then
    Text := 'Found';
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jalbrecht

20 Posts

Posted - Feb 24 2023 :  02:26:07  Show Profile  Reply
Hi,

I tried this:
id := ImageEnView1.ImageID[Index];
if Position = iemtpBottom then
Text := inttostr(id);

And the text is always -1






Go to Top of Page

xequte

38319 Posts

Posted - Feb 24 2023 :  19:23:28  Show Profile  Reply
Hmm, what sort of database is this? Are you able to send me a small demo that shows the issue without me needing to install any dependent libraries?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jalbrecht

20 Posts

Posted - Feb 28 2023 :  08:23:59  Show Profile  Reply
Hi Nigel,

It is a Firebird database.
Please find attached the XLS result of the loaded dataset that gives me the links to the loaded images and records.
My idea in the given case, is to show a mark on every images that has the word "PALE" in the given indexes to the images.
i.e. in the other columns of the dataset.

This means for the lines 5,8,13,25,28,29,33,50 and 59.

Best regards

attach/jalbrecht/202322882446_data example.zip
26.2 KB
Go to Top of Page

xequte

38319 Posts

Posted - Feb 28 2023 :  19:39:26  Show Profile  Reply
Hi

Here is an example using the filename field to look up a database record:

procedure TMainForm.ImageEnMView1GetText(Sender: TObject; Index: Integer;
    Position: TIEMTextPos; var Text: WideString);
const
  Seek_Field = 'Description';
var
  fn, s: string;
  v: variant;
begin
  if chkCustomText.Checked and ( Position = iemtpBottom ) then
  begin
    // Get filename so we can locate record
    fn := ImageEnMView1.ImageFilename[Index];
    v := qryImages.Lookup( 'Filename', fn, Seek_Field );

    // Get field value (may be NULL for memo types if field not filled)
    s := '';
    if not VarIsNull( v ) then
      s := v;

    if Pos( 'SUN', Uppercase( s )) > 0 then
      Text := 'SUNNY Picture'
    else
      Text := 'No sun :-('
  end;
end;


attach/xequte/2023228193914_IEDemoDB_Lookup.zip
640.98 KB

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jalbrecht

20 Posts

Posted - Mar 01 2023 :  04:04:39  Show Profile  Reply
Thank you Nigel but...

I did this :

procedure Tmain1.ImageEnView1GetText(Sender: TObject; Index: Integer;Position: TIEMTextPos; var Text: WideString);
var
  fn, s: string;
  v: variant;
begin
  if (JvXPCheckbox1.checked) and (JvEdit4.Text <> '' ) and ( Position = iemtpBottom ) then
  begin
     fn := ImageEnView1.ImageFilename[Index];
     v:=udm1.fi_Img.Lookup('CHEMIN_IMG' , fn , 'CHEMIN_IMG;TEXT;TITRE;TITRE2;AD;WORK_ORDER;TASK_REF;SB');
     s := '';
     if not VarIsNull( v ) then
        s := v;
     if Pos( Uppercase(JvEdit4.Text) , Uppercase( s )) > 0 then
       Text := 'Found';

  end;
end;

And my window is now endlessly blinking ...

Best regards.
Go to Top of Page

xequte

38319 Posts

Posted - Mar 02 2023 :  13:52:13  Show Profile  Reply
Hmm. Maybe accessing the table is triggering a change event??

Try performing the lookup in a second instance of the dataset (fi_Img)


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

jalbrecht

20 Posts

Posted - Mar 04 2023 :  12:20:10  Show Profile  Reply
Nigel,

You're the man !! it worked perfectly ...
As long as I lookup in the correct field .......

Thanks you very much.
Go to Top of Page

xequte

38319 Posts

Posted - Mar 06 2023 :  15:46:58  Show Profile  Reply
Good to hear you got it working

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: