Jump to content

at3s

Members
  • Content Count

    66
  • Joined

  • Last visited

Posts posted by at3s


  1. What is a way in Delphi FMX application to apply changes in SQLite database.

    F.e., there is an application v 1.0 in PlayMarked with the SQLite database v 0.1.

    New version 1.1 of an application comes with the database v 0.2 where was added new table, removed one field etc.

    How Delphi do (or not do and you did it instead) those migration work?

    When I was developing an application in Xamarin, there was a tool and it generated a "migration" script based on changes in DB classes, then Entity framework did all hard work.


  2. 14 hours ago, Remy Lebeau said:

    It really depends on the format that the ESC/POS is expecting.  It might be as simply as using TBitmap.SaveToStream() to save to a TBytesStream, and then using the stream's Bytes and Size properties.  Or it may be more complex, like having to extract the individual pixels, like that other code is doing.  You are going to have to provide more details about your particular situation.

    Here is my code. It's mostly the same as is in the sources here or here.

    And I'm getting the same result with the horizontal blank lines as here.

     

    uses
      System
      , System.SysUtils
      , System.UITypes
      , FMX.Graphics
      ;
    
    type
      TRgbTriple = packed record
        // do not change the order of the fields, do not add any fields
        Blue: Byte;
        Green: Byte;
        Red: Byte;
      end;
    
    // ---------------------------
    
    procedure TThermalPrinter.SendString(AValue: String);
    var
      SND: TBytes;
    begin
      SND := TEncoding.ASCII.GetBytes(AValue);
      LSockect.SendData(SND); // send data to the printer
    end;
    
    procedure TThermalPrinter.DoSetLineSpacing(AValue : integer);
    begin
     if (AValue = 0) then begin
       SendString(#$1B#$32{, false});  //Resetset to default
     end else begin
       SendString(#$1B#$33 + AnsiChar(AValue){, false});
     end;
    end;
    
    procedure TThermalPrinter.DoPrintBitmap(const ABitmap : TBitmap; const  BitsPerSlice : Byte);
    const
     Threshhold = 127;
    type
     TBitArray = array of boolean;
     TRGBTripleArray = ARRAY[Word] of TRGBTriple;
     pRGBTripleArray = ^TRGBTripleArray; // Use a PByteArray for pf8bit color.
    var
     BMPData: TBitmapData;
     vCol : integer;
     vRow : integer;
     vIndex : integer;
     vSliceIndex : integer;
     vBytePos : integer;
     vBitPos : integer;
     vOffset : integer;
     vLuminance : integer;
     vLine: pRGBTripleArray;
      vPixel: TAlphaColor;
     vDots: TBitArray;
     vSlice : Byte;
     vBit : Byte;
     vTmpBit: Byte;
     vVal: boolean;
     vTempStr : string;
    begin
     if not Assigned(ABitmap) then exit;
    
     ABitmap.Map(TMapAccess.Read, BMPData);
     try
        SetLength(vDots, (ABitmap.Height * ABitmap.Width));
        vIndex := 0;
    
        for vRow := 0 to ABitmap.Height-1 do
        begin
          for vCol := 0 to ABitmap.Width-1 do
          begin
            vPixel := BMPData.GetPixel(vCol, vRow);
            vLuminance := Trunc((TAlphaColorRec(vPixel).R * 0.3)  + (TAlphaColorRec(vPixel).G * 0.59) + (TAlphaColorRec(vPixel).B * 0.11));
            vDots[vIndex] := (vLuminance < 127);
            Inc(vIndex);
          end;
        end;
    
       DoSetLineSpacing(24);
       SendString(' ');
    
       vOffset := 0;
       while (vOffset < ABitmap.Height) do
       begin
        SendString(#$1B'*'#33 + AnsiChar(Lo(ABitmap.Width)) + AnsiChar(Hi(ABitmap.Width)){, false});
    
         vTempStr := '';
         for vCol := 0 to ABitmap.Width-1 do begin
           for vSliceIndex := 0 to 2 do begin // Remember, 24 dots = 24 bits = 3 bytes.
             vSlice := 0;
             for vBit := 0 to 7 do begin
               vBytePos := (((vOffset div 8) + vSliceIndex) * 8) + vBit;
               vBitPos := (vBytePos * ABitmap.Width) + vCol;
    
               vVal := false;
               if (vBitPos < Length(vDots)) then begin
                 vVal := vDots[vBitPos];
               end;
    
               if vVal then
                 vTmpBit := 1
               else
                 vTmpBit := 0;
               vSlice := vSlice or (vTmpBit shl (7 - vBit));
             end;
    
             vTempStr := vTempStr + AnsiChar(vSlice);
           end;
         end;
    
         Inc(vOffset, 24);
         SendString(vTempStr + #13#10);
       end;
    
       DoSetLineSpacing(0);
       SendString(' ');
     finally
        vDots := nil;
        ABitmap.Unmap(BMPData);
     end;
    end;

     


  3. 1 hour ago, weabow said:

    I use for Windows, Mac, IOs, Android and Linux TMS FNC UIpack, which contains FNC Core, which contains a pdf lib. Do NOT take FMX UI Pack if interested, as recommanded.

     

    I runs fine, very fast (2 seconds for 58 pages on Windows). You can draw, print texts and pictures, embed fonts.

     

    Very great tool.

     

    It's here...

     

    In attachment, an example with pictures in png, drawings (the targets), and texts.

    tms-fnc-pdf-lib.pdf

    Thanks. It sounds interesting.

     

    It seems I did not describe my topic clear.

    I'm interesting rather in a way how to send a PDF file from Android\iOS device to the printer connected to this device.


  4. 10 minutes ago, emailx45 said:

    please follow the links above.

    search in my profile my post about use of PERMISSIONS on Android. with sources tested.

     

    hug

    Based on topic "Runtime permissions in Android (new in Delphi 10.3)", do you think I have to grant ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions as well?

    Otherwise I do not see any differnces I already define in an application.


  5. Actually problem becomes in Android 10, in Android 6 I have so fine.

    I just have developed a form which shows folders and files in

    TPath.GetSharedPicturesPath

    directory.

    I have ask to grant READ_EXTERNAL_STORAGE permission for application, it is properly granted, checked in system.

    But 

    TDirectory.GetDirectories(TPath.GetSharedPicturesPath, '*')

    returns an empty list of folders as well as 

    TDirectory.GetFiles(TPath.GetSharedPicturesPath)

    returns an empty list of files in Android 10.

    Even I get a level up folder.

    Any idea?


  6. 9 minutes ago, Anders Melander said:

    No, not using a standard TPopupMenu. The menu loop is being handled by Windows (via the TrackPopupMenu API function) and you do not have any control of how it behaves - and that's how it should be; Altering the behavior of something like a menu just leads to poor usability. The fact that you've had to resort to keyboard & mouse hooks should be a hint that they don't want you messing with it.

     

    I suggest you display a non-modal form instead. You can easily make that behave like a popup menu, with your custom behavior, without raping the system.

    Thank you, it sounds reasonable.


  7. I'd like to realize a multiselection in Popup Ctrl+<Mouse click>.

    I've owerwrite a TPopupList.WndProc in recreated PopupList object and defined mouse and keyboard hooks on popup.

    So I able to mark an item as selected (checked) in popup by pressing space button, but I'm not able to make it working with the Ctrl+<Mouse click> - popup always closes.

     

    Keyboard hook:

    function PopupMenuKeyboardHookProc(Code: Integer; wParam : WPARAM; lParam : LPARAM): Longint; stdcall;
    begin
      try
        if (Code = HC_ACTION) and (wParam = WM_KEYUP) then
        begin
          if PKBDLLHOOKSTRUCT(lParam)^.vkCode = VK_SPACE then
          begin
            if Assigned(PopupList) then
            begin
              PostMessage(PopupList.Window, WM_POPUP_SPACE_KEY_MINE, wParam, lParam);
              wParam := WM_NULL;
              lParam := 0;
            end;
          end;
        end;
      finally
        Result := 0; 
      end;
    end;

    I tries to process WM_LBUTTONDOWN and WM_LBUTTONUP messages, but without success, popup anyway receives WM_MENUSELECT message with the (Msg.MenuFlag = $FFFF)and(Msg.Menu = 0)), so it closes.
    end;

    How to catch it?


  8. 6 minutes ago, Dave Nottage said:

    Yes - are you perhaps using an older version of the Grijjy Error Reporting code? The error in question was happening before they updated this unit:

     

    https://github.com/grijjy/JustAddCode/blob/master/ErrorReporting/Grijjy.ErrorReporting.pas

     

    Otherwise, you'd need to detail exactly what you're compiling and perhaps include a reproducible example.

     

     

    Exactly! I'm using this unit. But I do not see any newer versions of this unit on github.


  9. 23 minutes ago, emailx45 said:

    my tip:

    • my tip main: DONT INSTALL THE SOFTWARES IN FOLDERS WITH LONG-NAME
      • reason: PATH variable on system operating!
      • mainly software like SDK/NDK that use many "tree-nodes" in your default "installation"
    • Android SDK/NDK is not "installed" in your system... just unziped and copyed to your disk!
      • then, you can copy it from any other pc with same versions and updates (if necessary) using SDKManager.exe in SDK Windows folder
    • As "IT" is not installed, just copyed, then, you can have it in any disk or folder
      • try copy to another place with shor-name, like:  C:\SDKs\.... or D:\SDKs\...
      • if you want try, you can just delete this whole directory (..\\AndroidNDK-21-21.0.37889.9797\) or copy to another place with shor-name, like:  C:\SDKs\.... or D:\SDKs\...
      • try dont use this "horrible-root-name" AndroidNDK-21-21.0.37889.9797 -- change it for: NDK21  (NDK is Android, 21 is Sydney)
        • same for SDK for MSWindows used by Android!
    • for last, use your IDE (menu SDK Manager) to re-config your paths for Android setup.

    Last note: RAD 10.4 Sydney is a traged! if possible stay on RAD 10.3.3 Rio

    Thanks, but your propositions did not help: I've created a hard link D:\SDKs\SDK-25 and D:\NDKs\NDK-21, but I still get the same error.
     

    Quote


    [DCC Error] E2597 D:\NDKs\NDK-21\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: error: cannot find -lgnustl_static

     

     

    Any idea?


  10. An Android application compiles fine in Delphi 10.3.3 Rio, but after I've migrated to Delphi 10.4 Sydney I started to get an error:

     

    Quote

    [DCC Error] E2597 C:\Users\Public\Documents\Embarcadero\Studio\21.0\CatalogRepository\AndroidNDK-21-21.0.37889.9797\android-ndk-r21\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: error: cannot find -lgnustl_static

     

    Has anyone something similar?


  11. 20 hours ago, Kryvich said:

    Yes, I see the same. It's strange, because when I generate tom_TLB.pas, even in Windows XP there is Spacing property in ITextFont interface. After doc.Selection.Font.Spacing := ASpaces, the Spacing property is actually returns the new value, but the edit control is not displaying as expected.

    Exactly. I even tried to copy and load different MsftEdit.dll versions in Windows 7, but without success.


  12. 6 minutes ago, FPiette said:

    Maybe a new Win8 or Win10 feature not supported by Win7.

     

    It seems so.

     

    On 10/18/2020 at 7:32 PM, Kryvich said:

    You need RichEdit50W, but TRichEdit utilize Riched32.dll / Riched20.dll, not MsftEdit.dll.

     

    In my program I used JvRichEdit from JVCL library, modified to utilize MsftEdit.dll instead of Riched32.dll. Updating the component version also significantly speeds up a loading of large RTF files.

    Does JvRichEdit's Spacing work fine in all Windows versions (Win7 x32, Win XP f.e.)?


  13. 58 minutes ago, Kryvich said:

    You need RichEdit50W, but TRichEdit utilize Riched32.dll, not MsftEdit.dll.

     

    In my program I used JvRichEdit from JVCL library, modified to utilize MsftEdit.dll instead of Riched32.dll. Updating the component version also significantly speeds up a loading of large RTF files.

    It works in Delphi, thanks a lot. 


  14. 43 minutes ago, FPiette said:

    Would be nice if you publish the code you have already tried so that we can review it and even try to make it work without having to invent a full test program.

    Sure. Here is a unit:

    unit uRichEdit;
    
    interface
    
    uses
      System.SysUtils
      , Winapi.Windows
      , Vcl.ComCtrls
      , Winapi.RichEdit
      , tom_TLB
      ;
    
    type
      TRichEditHelper = class helper for TRichEdit
      private
        class function reGetTextDocument(RichEdit: TRichEdit): ITextDocument;
      public
        class function reSpacing(ARichEdit: TRichEdit; ASpaces: Integer): Boolean;
      end;
    
    implementation
    
    { TRichEditHelper }
    
    class function TRichEditHelper.reGetTextDocument(
      RichEdit: TRichEdit): ITextDocument;
    var
      re: IUnknown;
    begin
      if RichEdit.Perform(EM_GETOLEINTERFACE, 0, LParam(@re)) = 0 then
      begin
        Result := nil;
        Exit;
      end;
    
      re._AddRef;
    
      if not Supports(re, ITextDocument, Result) then
        Result := nil;
    end;
    
    class function TRichEditHelper.reSpacing(ARichEdit: TRichEdit;
      ASpaces: Integer): Boolean;
    var
      doc: ITextDocument;
      spacing: Single;
    begin
      doc := reGetTextDocument(ARichEdit);
    
      doc.Selection.Start := 0;
      doc.Selection.End_ := Length(doc.Selection.Text);
      doc.Selection.Font.Spacing := ASpaces;
    end;
    
    end.

    and its using:

    TRichEdit.RichEditSpacing(reSample, 10);

    You have to import 'tom' type library.

×