Jump to content

Serge_G

Members
  • Content Count

    332
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Serge_G

  1. Serge_G

    Load image from splite blob field

    Hi, The simplest way (without checking errors) procedure loadbitmapfromblob(abitmap : TBitmap; aBlob : TField); var aStream : TMemoryStream; begin aStream:=TMemoryStream.Create; try TBlobField(aBlob).SaveToStream(aStream); // aStream.Position:=0; aBitmap.LoadFromStream(aStream); finally aStream.Free; end; end; usage loadbitmapfromblob(Image1.Bitmap,datamodule2.InsertImg.FieldByName('camarapic')); But can I suggest this ? (FMX program) or even using Livebindings for "no code" procedure loadImagefromblob(aImage: TImage; aBlob: TField); begin var aStream: TMemoryStream; begin if aBlob.IsNull then aImage.Visible := False else begin aStream := TMemoryStream.Create; try TBlobField(aBlob).SaveToStream(aStream); try aImage.Bitmap.LoadFromStream(aStream); aImage.Visible:=true; except aImage.Visible := False; end; finally aStream.Free; end; end; end; end; for VCL use this procedure, not forgetting to declare units Vcl.Imaging.jpeg and Vcl.Imaging.pngimage procedure TFormVCL.loadImage(aImage: Timage; aField: TField); var aStream : TmemoryStream; begin if aField.IsNull then aImage.Visible:=false else begin aStream:=TmemoryStream.Create; try TBlobField(aField).SaveToStream(aStream); aStream.Position:=0; AImage.Picture.LoadFromStream(aStream); aImage.Visible:=true; finally aStream.Free; end; end; end;
  2. Serge_G

    BindLinkFMXProject, where is the data?

    Sorry, I found file fishfacts.cds in <RadStudioDemos-Main> \Object Pascal\LiveBindings\common demo found here on GitHub
  3. Serge_G

    BindLinkFMXProject, where is the data?

    It's Livebindings. On your form you certainly have a TClientDataset (database name is now C:\Users\Public\Documents\Embarcadero\Studio\21.0\Samples\Data\biolife.cds) a TBindingList and a TBindSourceDB
  4. Serge_G

    search between two dates

    Il existe un très bon forum en français https://www.developpez.net/forums/f15/environnements-developpement/delphi/ (mon pseudo SergioMaster)
  5. Serge_G

    Good data grid for VCL and FMX

    Hi, perhaps TMSFNCGrid
  6. Serge_G

    search between two dates

    👍 programmerd2k response, and, with firedac, you can simplify his code to : procedure TForm1.Button1Click(Sender : TObject) begin Salestable.open('',[DateFrom.Date,Dateto.Date]); end;
  7. Serge_G

    FMX Default style in TStyleBook

    To respond to question point 8. There are one style for each platform because doing this you reduce size of the app. In your case, my usage is to create one data module per platform and using IFDEF$ clause on each data module a Stylebook corresponding to platform, all the Stylebook have UseStylemanager=true.
  8. Serge_G

    corrupt primary key?

    I was thinking this way, even if I don't know it could solve your problem
  9. Serge_G

    corrupt primary key?

    Using Charset NONE is a regrettable habit ! I still have some database with this default encoding and migration to best encoding is not so easy, no easy tool for this ! Try to use WIN1252 as fdconnexion charset
  10. Serge_G

    Mysql connection problem

    You need 32bit version for the IDE
  11. Il ne faut pas rêver, j'ai bien sûr conçu un logiciel de ce genre (magasin usine d'un fabricant de chaussures), mais, fournir les sources sans rémunération, comment je me paye la maintenance de Delphi ?
  12. Serge_G

    ExtendedMetadata and .AsInteger for small int column

    Since FB.3 boolean type exists https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref30/fblangref30-datatypes-booleantypes.html
  13. Serge_G

    Custom TListBoxItem Live Bindings Advice

    Ah, ok, in this case TListBox (or a <Vert,Horz>ScrollBox with Frames) is the need. When XE4, ListView and dynamic appearance does not exist, as neophyte to styles I wrote my experience in this paper. I think this chapter will cover your needs
  14. Serge_G

    Custom TListBoxItem Live Bindings Advice

    Don't you think you can use FMX.Tlistview (dynamic appearance) instead of FMX.Tlistbox ? I wrote many (french) notes here or tutorials (here) about
  15. Serge_G

    How do I handle the 'closed dataset' error ?

    Sure, you can't catch the error if the error is in the upper code ! I think you use a wrong way. As I understand you have a FDQuery so one way is to use edit/post/delete and so on is to link it to a FDUpdateSQL (fill clauses with expert or by hand) with this method, you can use a "classic" qry.Insert; // or qry.append qry.FieldByName('col1').asString:='some string'; qry.fieldbyname('col2').as ... qry.post In a livebinded grid nothing to code Some remarks : - when you open a query (or a table) the connection is connected automatically - use your commands SQL directly on the connection and parameters con.ExecSQL('insert into tblBarcodes values (:i, :p1,:p2,:p3,:p4)', [6,'120422','Q','abc1','2 120422 Q abc1 desc1']); - use the INSERT INTO TABLE (<list of column>) VALUES (<list of values>) to avoid auto increment columns - except if you want a "physical" ordered table don't worry about APPEND
  16. I don't think this is a good one solution. You say it's a FMX project and I assume : - you use livebindings - con is your fdconnection You can do your delete via the FDConnection like this procedure TForm1.btnDelLastRowClick(Sender: TObject); var lastrowid : integer; begin Query1.last; lastrowid:=Query1.Fieldbyname('IDNO').asInteger; if lastrowid.isnull then exit; // if table is empty con.ExecSQL('delete from tblBarcodes where IDNo=:s',[lastRowValue]); query1.Open(); // or Query1.open('Select * from tblbarcodes'); end; now this code should show some flickering and have disadvantage to unselect the current row selected 😞 because of Query1.open 1- flickering can be avoided by BeginUpdate .. EndUpdate block 2- there are many ways to memorize current position in the dataset - using key, memorize in another variable the current idno and using var currentid : integer :=Query1.FieldbyName('IDNO').asInteger; // code for deleting Query1.Open(); Query1.Locate('IDNO',currentid,[]); not recommended if not mono user app - using recordno - using FDQuery.GetBookmark and FDQuery.GotoBookmark
  17. Serge_G

    TRichEdit equivalent in FMX?

    Perhaps this one https://www.trichview.com/ showed in getIt ?
  18. Serge_G

    TTextAlign problems in TEdit in FMX

    Hi, You need to give the type of the enumeration, use Edit1->TextSettings->HorzAlign =TTextAlign.Leading Edit1.TextSettings.HorzAlign :=TTextAlign.Leading It's only some ways to change. I use Delphi from D3 version, my new applications are all FMX, it took me 1-2 years to take the plunge, but now I much prefer FMX
  19. Serge_G

    FastReport - Check printing

    Hi, use paragraphgap, linespacing, wordwarp and wordbreak properties (as I answered on french delphi forum ) Serge aka SergioMaster
  20. Serge_G

    SQL problem

    Depends of SGBD I think, but if not it's possible to, use Firedac macros 1- This zip contains a SQLite database not a MySQL one as indicated first ! 2- The database contains a really poor lines for testing ! And nothing to do with directories Suggestion for Button2.OnClick uses System.IoUtils; procedure TForm1.Button2Click(Sender: TObject); var FileListe : TArray<String>; i: integer; begin FileListe:=TDirectory.GetFiles(Edit1.Text); for var s: String in FileListe do i:=i+FDQuery1.ExecSQL('INSERT INTO Files(maindirectory) Values (:s)',[S]); Showmessage(i.ToString+' records added'); end; Suggestion for Query procedure TForm1.Button1Click(Sender: TObject); begin FDQuery1.Close; FDQuery1.SQL.Text:='SELECT Maindirectory from files WHERE Maindirectory LIKE &S'; FDQuery1.MacroByName('S').AsRaw:=Quotedstr(Edit1.Text+'%'); FDQuery1.Open; end; As you can see, this also include ability to use macro char % in the like clause value so for MySQL INSTR function, you can set Edit1.Text to '%AEnvoyer' TAKE CARE of SQL Injection with macro usage Ah, yes 👍 so Button2.Onclick can be wrote on different ways procedure TForm1.Button1Click(Sender: TObject); begin // FDQuery1.Close; // By Macro Need FDQuery1.Close and FDQuery1.Open // FDQuery1.SQL.Text:='SELECT Maindirectory from files WHERE Maindirectory LIKE &S'; // FDQuery1.MacroByName('S').AsRaw:=Quotedstr(Edit1.Text+'%'); // By Parameter Need FDQuery1.Close and FDQuery1.Open // FDQuery1.SQL.Text:='SELECT Maindirectory from files WHERE Maindirectory LIKE :p'; // FDQuery1.ParamByName('P').AsString:=Edit1.Text+'%'; // FDQuery1.Open; // By Parameter No Need of FDQuery1.Close and FDQuery1.Open, my preference FDQuery1.Open('SELECT Maindirectory from files WHERE Maindirectory LIKE :p', [Edit1.Text+'%']) ; end;
  21. Serge_G

    Listview Programming

    When I use ScrollBox and Frames, I never use anchors, preferring to calculate positions of each frame. Why ? I remember a video of a Brazilian guy demonstrating that this way was minus time-consuming
  22. Serge_G

    Listview Programming

    So I suggest you to use Frames and a ScrollBox (or VertScrollBox or HorzScrollBox) Here my "french" way to do it. But I remember also a some videos of CodeRage 2019 #13
  23. Serge_G

    Listview Programming

    Hi, 2 solutions. First one is to use a TListView and Dynamic appearance, like this (listview "livebinded" to fdmemtable) In this case, it could be easy to manage groups. pro : if data is in a Table, it's easy to fill with livebindings and easy to manage groups con : if you want different size (possible) you have to code Second one is to use a TScollbox and a TFrame (same design as Item). pro : It's easy to resize a TFrame. In this case, Headergroup should certainly be another frame. con : All is to code Depending of solution you choose, I will explain more if needed
  24. I don't think soundex to be a good algorithm, I certainly look for phonetic
  25. Hi, No, this new TSpinBox should use the same style. Except if you put this style in the default collection. As I remember when style is to be applied, "delphi" look for platform style and then default style if stylelookup is not found. Ah, this should be a possibility Another solution is to change the style of the component during runtime (I found this trick some month ago, but I don't remember where I save this one) [EDIT] Finally, found. If you read French it's in my blog I explain 2 methods, I think second one "modify the style directly" could apply. If you can screenshot what you expect I will take this like a challenge 😉
×