Jump to content

Cristian Peța

Members
  • Content Count

    330
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Cristian Peța


  1. Delphi 10.4.2

    I try to understand this exception. I occurs at the app start and this is the only message, then the app closes.

    It happens only on one machine and the same code but truncated by some IFDEFs (a reduced version of the main app) is working.

    I suppose that class destructor TDBNavigator.Destroy is called when class constructor TDBNavigator.Create is still looping with FButtonsImageCollection.Add()

    But what means this address 400000?

    exception class    : EAccessViolation
    exception message  : Access violation at address 76B6C9ED in module 'combase.dll'. Write of address 00400000.
    
    thread $4b7c:
    76b6c9ed +db combase.dll
    00e3c89a +22 WinArhi.exe  Vcl.ImageCollection   282  +2 TImageCollectionSourceItem.Create
    0054c757 +0b WinArhi.exe  System.Classes       6213  +1 TCollection.Add
    00e3c965 +05 WinArhi.exe  Vcl.ImageCollection   325  +1 TImageCollectionItemSources.Add
    00e3d48b +53 WinArhi.exe  Vcl.ImageCollection   651  +9 TImageCollection.CreateSourceItem
    00e3d576 +2a WinArhi.exe  Vcl.ImageCollection   670  +1 TImageCollection.Add
    00e3d65a +76 WinArhi.exe  Vcl.ImageCollection   683  +2 TImageCollection.Add
    00e4f11d +7d WinArhi.exe  Vcl.DBCtrls          4188  +3 InitButtonsImageCollection
    026cb28d +09 WinArhi.exe  Vcl.DBCtrls          4192  +1 TDBNavigator.Create@
    0040b186 +42 WinArhi.exe  System              23832 +21 InitUnits
    0040b1ef +3f WinArhi.exe  System              23907 +14 @StartExe
    004140fa +42 WinArhi.exe  SysInit              1535 +11 @InitExe
    026f025f +0b WinArhi.exe  WinArhi               277  +0 initialization
    75f7fa27 +17 KERNEL32.DLL                               BaseThreadInitThunk

     


  2. I prefer that changing the SQL to simply close the dataset. Then possibly I want to set some parameters. I will open it again when all is ready.

    But sincerely I always call Close before changing SQL.

    If this is a documented behavior then it's OK but otherwise this can change anytime.

     

    I voted for the last. It's closer to what I prefer.


  3. Set an event handler:

      if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(AppEventService)) then
        AppeventService.SetApplicationEventHandler(My_ApplicationEventHandler);

    And in that event you will receive the warning:

    function TFormMain.My_ApplicationEventHandler(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
    begin
      case AAppEvent of
        TApplicationEvent.LowMemory: ;
      end;
    end;

     

    • Like 2

  4. I start a new VM for every major app version and I want old versions to be stable. In this case I prefer to keep the sources in VMs.

    I don't write 3rd party components and I need only one Delphi version per my app version. It is easier so.

    When I start a new version I do a copy of the VM and all is there.


  5. This "image/text/plain" is strange for me.

    You can try this. This will enable share for image and text. If you need only text delete the "image/* "

    22 hours ago, Magno said:

    Intent.setType(StringToJString('image/* text/plain'));

    This setType() will filter the applications that supports that type.


  6. Then not the memory limit is the problem.

    I think I had something similar but long time ago I starter to avoid compile and use build almost every time. It is better to wait 10-15 seconds (in my case) than to fight with these issues.

     

    If I remember well this started for me about ten years ago when iOS was first introduced as a new platform.


  7. To send text you could use this function.

    If the previous change fixed the issue I suppose this will also fix it without to change anything else. You could also store binary data in AnsiString but I would not do this. It's better to use TBytes for this.

     

    procedure TThermalPrinter.SendString(AValue: AnsiString);
    var
      SND: TBytes;
    begin
      SetLength(SND, Length(AValue));
      CopyMemory(@SND[0], @AValue[1], Length(AValue));
      LSockect.SendData(SND); // send data to the printer
    end;

    And better this in TThermalPrinter.DoPrintBitmap()

      vTempStr : AnsiString;
    • Thanks 1

  8. If this was the fix then this was a lottery.

    I was thinking you need to get rid of that SendString() everywhere.

    At least when you send binary data. And Lo(ABitmap.Width) is binary data.

    If you want to send text and to be readable in source you can use AnsiString and convert to TBytes.

    Using String to store bytes is as @David Heffernan would say: perverse.


  9. 11 minutes ago, at3s said:

    Actually Delphi code above should do exactly what Nicholas Piasecki did in his article using C#.

    If you don't have the documentation then at least follow what that article says clearly: " This is because low-level programmers, such as those who designed the ESC/POS language, tend to blur the lines between data types: it’s all bytes at the end of the day."

    You need to write binary data. Simply don't put binary data in String and convert using TEncoding.ASCII.GetBytes().

     

    18 minutes ago, at3s said:

    Can you please send me in PM your procedure of saving TBitmap to PCX format?

    This won't help you. But if you want to know I used TBytes.


  10. 2 minutes ago, shineworld said:

    {$SetPEFlags $20}

    IMAGE_FILE_LARGE_ADDRESS_AWARE. I use this also but not enough in some cases. And 64 bit is not yet an option because I don't want both 32 and 64 and there are about 10% with 32bit OS in case of my users.

     

    3 minutes ago, shineworld said:

    I'm searching for a good native Delphi library to substitute MSXML and have all in Delphi project...

    https://github.com/neslib/Neslib.Xml

    • Like 1

  11. 14 hours ago, shineworld said:

    I'use MSXML for many years and works very fine and fast.

    Fine, if you are not on 32bit and memory is at limit when you save the XML. It will save nicely but truncated.

    Fast, if you don't have to many attributes in a node. If you have 100 attributes it's starting to slow down perceptible. I had a case with tens of thousands.

    These are corner cases but showstoppers for me.

     

    Better try Neslib.Xml.

    I have an implementation that is not faster than Neslib.Xml (slightly slower and more memory) but faster in my case if there are many attributes in a node because I use a dictionary for storing the attributes.


  12. On 2/24/2021 at 9:25 AM, at3s said:

    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.

    You are using examples from others that doesn't work or doesn't work in your case.

    Maybe it's time to read the documentation of that printer, understand it and do it right.

     

    From what I understood reading a little Nicholas Piasecki's article is that you need to send binary data. Not ASCII.

    And from your code it's clear that you need (like in Nicholas Piasecki's article) a monochrome, one bit per pixel image. In top-bottom and right-left order. This is binary data. A sort of simplified PCX graphic format (long time ago I wrote a little procedure to save TBitmap to PCX format).

     

    Your don't need SendString(AValue: String) function. Use directly LSockect.SendData() instead. And don't use String but TBytes like LSockect.SendData() is expecting.

     

×