Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Posts posted by PeterBelow

  1. 2 hours ago, Henry Olive said:

    Good Day,
    MyCode in Database = VARCHAR(20)


    MyCode could be 

    (120 or 250)  like 3 digit Integer,  or

    (200.001  or  600.010)  there is a dot between numbers,  or

    (500.005.0010 or 100.010.1500)   there are 2 dots between numbers


    I need to Increase MyCode by 1  that is

    if MyCode = 100 then requested result = 101

    if MyCode = 300.001 then requested result = 300.002

    if MyCode = 600.005.0010 then requested result = 600.005.0011


    How can i do that


    Do it on the string itself, like you learned addition in school. :classic_cool:

    function incrementID(const aID: string):string;
      ch: Char;
      N: Integer;
      Result := aID;
      N:= Length(Result);
      while N > 0 do begin
        ch := Result[N];
        case ch of
          '0'..'8': begin
                      Result[N] := Succ(ch);
          '9': begin
                 Result[N] := '0';
          '.': Dec(N);
          raise Exception.CreateFmt('Invalid character "%s" in ID "%s" at position %d.',
            [ch, aID, N]);
        end; {case ch}
      end;  {while}


    • Like 2

  2. 2 hours ago, Der schöne Günther said:

    That they cannot be passed as var or out was more a comparison to simple fields, I should have made that clearer. Meaning: If you don't need getter/setters, I fail to see why you would ever go with properties at all.

    You can change the visibility of properties inherited from an ancestor, you cannot do that with fields. The VCL itself makes heavy use of that.

  3. 3 hours ago, direktor05 said:

    Ah you used LockBox component... what a shame! Real professionals don't use other people's components they make their own. But it's OK, it works.

    Real professionals have to earn money with their works, they don't have the time to reinvent the wheel, debug and validate it. If you want to shoot yourself in the foot be my guest, but don't expect me to supply the bullets...

    • Haha 3

  4. On 6/17/2022 at 7:27 PM, direktor05 said:

    Ok thanks I think the problem with the above code is that it gives whole file buffer as input while only 16 B is acceptable. Thats why it takes first 16 B and the rest throws away. The right way should be ReadBlock 16 by 16 B until EOF and perform readblock 16B - encrypt 16B - write 16 B until EOF.

    Attached find a little example program that definitely works :classic_cool:.



  5. 3 hours ago, direktor05 said:

    Yes, but its component. Is there any standalone unit? Like this one: https://github.com/stijnsanders/tools - has standalone units in crypto folder, but unfortunately they do not produce accurate results: https://github.com/stijnsanders/tools/tree/master/crypto 

    https://github.com/stijnsanders/tools/blob/master/crypto/aes.pas - when encrypting binary file I get only 16 B file back. But no error when building/compiling.

    You don't need to install the component, it is just a convenience wrapper. I'll try to create a small demo over the weekend, no time at the moment.

  6. 7 hours ago, zsleo said:

    I am using Delphi 11.1 Enterprise.

    I have an app that is now very commonly deployed and accessed though Windows RD Web.

    Often one of my forms “disappears” behind another for and the use thinks my application has hung because they cannot take control of the form that is displayed uppermost.

    There is a feature used by Microsoft to display the apps and sometime forms for each session as shown in the red box in Picture_1.png.

    The form types in my app are both modal and non-modal.

    Make sure that all modal forms have PopupMode set to pmAuto and in the dpr file you have

    Application.MainformOnTaskbar := true;

    That avoids such isssues at least on classic Windows systems. I know nothing about Windows RD Web, though.

  7. 1 hour ago, direktor05 said:

    Hello, does anybody know of any good Delphi AES (or similar) unit to encrypt/decrypt binary files? I found plenty however none works well - there is loss of information or can only encrypt/decrypt strings. Must be able to encrypt/decrypt binary file without loss of information - after decrypting back to original the exe file must be exactly the same in size.


    Help is needed.

    I use Lockbox 3 for such purposes.

  8. 2 hours ago, Thomas Lassen said:

    I am in the process of updating from 10.3.2 to 11.1, I have run into a major problem that I have not been able to solve: Upon updating to the 11.1 my GUI is complete destroyed, fx font sizes and widths of all my labels have changed. The same problem applies to all the control on my main form. Other forms that are a part of the project seem to be unaffected.


    Has anyone experienced a similar problem?



    See Tools -> Options -> User interface -> Form designer -> High DPI, the designer itself is now DPI aware and you may have to change the default setting if you design on a high DPI monitor.

  9. 13 hours ago, patrik-xyndata said:

    Hello, I'm using Delphi on macOS with Parallels, with setup 500% scaling.


    Text Editor looks like it should, everything is fine.

    But in designer the components and everything is sooooo small, that I can't read it / see it.


    When the App is compiled, everything looks just fine....


    I do not know what to do 😞

    In Delphi 11 the designer itself can be configured to be DPI-aware. Which version are you using?

  10. 1 hour ago, PeterPanettone said:

    I suspect a bug in the IDE itself. So I am not sure whether madExcept could help here. If the IDE were open-source, it would be easy to catch the bug.

    Unlikely, it would be reported much more frequently in this case. I have never seen it, for example, but in my case the only 3rd party package used is MMX...

  11. 3 hours ago, Rollo62 said:

    Thanks, Peter.

    Thats what I assumed too, but is there any deeper explanation how overload resolution of Char and String really works, and how this could be solved ?

    Maybe even the general resolution between Char and String.


    I understand that a String can be made of one Char 'a', which may be resolved as Char or String, which leads to ambiguities.

    Is there any clever trick to make this type references clear, and maybe even workable in overloads ?

    - I can use casts ( but that won't work for overlaod either )

    - I could define and cast to my own types, like MyChar and MyString ( which is also not very elegant )

    - Maybe constants like #13, #10, #0 have more "char-type-ness" than their string '' conterparts, but in practice that doesn't help much.


    Pascal has had the reputation of being the most type-safe language for quite some time, but just that char/string ambiguity has always left a bad taste, at least for me.

    I always wondered if these types cannot be made more "type-safe" nicely somehow.




    I think the core of the problem is an ambiguity inherent in the original language syntax inherited from the days of Turbo Pascal and earlier. 'x' can be interpreted either as a character constant or a string constant, and the compiler decides which it should be dependent on the context. A char is also assignment compatible with a variable or parameter of type string (but not vice versa).

    I see no way to get around this, and changing these rules will never happen since they make sense and changing them would break heaps of older code.


    Of course the compiler could use more stringent rules for overload resolution, e.g. require type identity and not only assignment compatibility. That would solve the conflict in the case you noticed but would be quite bothersome in other situations, requiring more overloaded versions of a function to be implemented. Think about what a type identity requirement would mean for overloaded functions taking numeric types as parameter. Do you really want to declare versions for byte, smallint, integer,  word, cardinal etc. ?

    • Like 2

  12. 4 hours ago, Rollo62 said:

    Hi there,


    I'm looking for an IndexOfAny( array or string, ... ) function, and find that there is already one in the TStringHelper.

    Unfortunately this is declared as a private function.


      TStringHelper = record helper for string
        //<== NICE TO HAVE
        function IndexOfAny(const Values: array of string; var Index: Integer; StartIndex: Integer): Integer; overload;
        // Maybe these bites with above declaration, as Char may interpreted as string too ?
        function IndexOfAny(const AnyOf: array of Char): Integer; overload;
        function IndexOfAny(const AnyOf: array of Char; StartIndex: Integer): Integer; overload;
        function IndexOfAny(const AnyOf: array of Char; StartIndex: Integer; Count: Integer): Integer; overload;

    I'm not realy sure why this function is hidden.

    Maybe because Char and String might cause issues when mixing in a overload, I haven't checked what would happen when making this public too ?




    There would probably be a conflict in overload resolution.


    Anyway, System.StrUtils contains IndexStr and IndexText functions that would serve your need here.

  13. 42 minutes ago, stacker_liew said:

    Anyone experience this or not? I'm using Delphi 11.1, it stuck occassionaly while opening project.


    Btw, I'm using Windows 11.

    I have seen something like this occasionally (D 11.1 on Win10). Task Manager shows 100% use of one CPU core for the process. Sometimes it resolves itself after a few seconds but often the only option is to kill the process. On restarting the IDE it usually works normally. I have never been able to reproduce it at will.

    • Like 1

  14. The VCL is not thread-safe in itsself, creating top-level objects like forms, frames or datamodules accesses some global stuff in vcl.forms connected to reading components from the dfm file.


    Try to replace your datamodules with a class (not derived from TCustomForm) that creates and configures all components you now place at design-time in code. I dimly remember a tool that could create such code from a dfm file, never used it myself, though.


    Are all your threads created in the same host thread? If so that should actually mitigate the problem since the thread constructor runs in the host thread, so all datamodules would be created in the same thread. But that may cause another problem: database connections are usually bound to the thread that creates them. If the datamodule creation already creates the connection, which is then later used in the context of the thread that owns the datamodule that may cause problems since the db access library may try to solve the conflict by serializing all DB access in a separate thread.


    Multithreading using a database can be even trickier than multithreading itself...:classic_mellow:

    • Like 1

  15. 19 hours ago, David Heffernan said:

    I'm not happy.  Optional parens means that a symbol like MyFunc can mean either the procedure or the value returned by a call to the procedure.  And there are times when that ambiguity can't be resolved by the compiler.  Most commonly when MyFunc returns another procedural type.  So when you write SomeFunc := MyFunc are you assigning MyFunc or MyFunc() to SomeFunc?  It sucks that in Delphi there is this ambiguity.  The ambiguity would not exist if () were not optional.  Like they aren't in so many other better designed languages.

    As far as I remember this "feature" comes from the original Wirth Pascal in Delphi's anchestry. Dropping it now would break heaps of legacy code, so is very unlikely to happen.

  16. 3 hours ago, ChrisChuah said:


    Actually I want to use delphi to create a DLL with functions or procedures containing a callback.

    How can i create such functions in delphi so that the project can be compiled to a dll for C Sharp programmer to use

    Previously all DLL functions does not have function pointer or callback functions when i was using Delphi 6 era.

    Also my C sharp programmers said they cannot use COM because their program will be running in Docker for linux


    A COM dll usually uses interfaces as callbacks as well, not function pointers.


    I know nothing about Docker so cannot give you any advice on this topic. .NET has an interface to unmanaged code, which is used to interact with the OS API, though. Your dll would be unmanaged code, you just have to make sure you do not use any Delphi-specific types (especially compiler-managed ones, like String or dynamic arrays) in the functions the DLL exports.

  17. 2 hours ago, ChrisChuah said:


    I have an existing component that communicates with a server via TCP.

    However, this component can only be used in delphi.

    When i call a function in this component, it will send out a TCP message.

    After some time, it will return back data and it will trigger an event back in the component.

    So, anytime i want to use this component, i can drop the component into the form.

    I can double click on the event and write codes to handle the result from the event.


    Now, if i want to make this component into a DLL for C sharp programmer to use

    How can i create events into the dll for C Sharp programmer to use?


    Create a COM dll, Delphi has a wizard for that. Google for "C# com interop" to find examples for how to use such a thing from the .NET side.

    • Like 1

  18. 35 minutes ago, Diego Simonini said:

    Hi everyone, I'm guessing if exists a shortcut or a plugin to keep declaration of functions and procedures in sync with implementation.

    Something bidirectional, if positioned on declaration the shortcut should update implementation and viceversa.


    Thank you

    ModelMaker Code Explorer (MMX) can do this, as well as a lot of other things. Could not live without it...  See https://www.mmx-delphi.de/ It is free and maintained.

  19. 42 minutes ago, AndrewHoward said:

    RaizeComponentsVcl_Reg.pas(25) Fatal: E2213 Bad packaged unit format: C:\Program Files (x86)\Embarcadero\Studio\17.0\lib\win32\release\rtl.dcp.System

    The script is looking at the  wrong version of the rtl package. 17.0 is not 10.2 Tokyo, that would be 19.0. Check the pathes used in the script or the dproj files it refers to. 17.0 is 10.0 Seattle if memory serves.

  20. 13 hours ago, abdellahmehdi said:

    When recalling a shape from another project😩

    please what should i do🙏


    The error message looks like the designer tries to read values from a dfm file into a component that has not been created yet.


    Was this other project created with the same Delphi version? Does it open and compile in Delphi Alexandria?  Does the form you are trying to use in the new project use any self-written or 3rd-party components you are not yet using in forms of the new project?






    • Like 1

  21. 9 hours ago, Behdadsoft said:


    I added many images into Access Database as binary. Now I want to load them form database and put in TImage.

    I wrote code below but it doesn't work and give me an error (Attached). 

    I compound my code with this example: Streaming Bitmaps and other Binary Data to BLOB Fields



    The source of your problem is probably the line


    Should'nt that be