Jump to content

PeterBelow

Members
  • Content Count

    468
  • Joined

  • Last visited

  • Days Won

    13

Posts posted by PeterBelow


  1. 18 hours ago, CoMPi74 said:

    Hi there,


    I am looking for the IDE's (or a third party add-on's) option which auto sets the editor in a readonly mode when opening a file from search path. I remember that years ago I was using such an option but now I can not find it again. Any ideas?

     

    Piotr

    In my opinion source files you want to protect from modification should be located in a folder tree the user you are working with does not have write access to. Don't use an admin account to work in the IDE!


  2. 15 hours ago, Stano said:

    Cannot load package 'JasotComponents.'  It contains unit 'DAScript', which is also contained in package 'dac280'

    I don't understand this message.

    It means that the JasotComponents package has DAScript listed in its "contains" clause while also listing dac280 in the "requires" clause. You have to remove the unit from the "contains" clause. In a package collection (packages that depend on others in the collection) each unit can only be contained in one single package. Complex package collections can drive you berserk if you have to build them manually, without a manufacturer-supplied build script. :classic_cool:


  3. 5 hours ago, Stano said:

    Well thank you. I haven't made a runtime package yet. I'll look into it. Won't it yell at me that it already has it in the search path?
    It doesn't make sense to me: he linked the files and the compilation fails. I don't have any (other) mistakes there.

    If the dcp file for the package is there and in the search path you just have to add that package to the requires clause of the design-time package, that should eliminate all these warnings.


  4. 18 hours ago, Stano said:

    Hi,
    It's a DB navigator and I want to deploy IBDAC there instead of FireDAC. I have about 30 similar lines. 

    [dcc32 Warning] JasotComponents.dpk(73): W1033 Unit 'IBCProps' implicitly imported into package 'JasotComponents' 

    Compilation will fail.
    Tried to add some *.dcp file. I got a notification that it is already in the search path.
    I do not know what to do.

    Well, the warning means that the unit in question was not found in any of the packages named in the "requires" clause and, since it was not in the "contains" clause of the package, had to be added to build the package.  This is not in itself an error and will not cause the build to fail, but it is an indication that there should be a run-time package available which contains the unit and should be added to the design-time packages "requires" clause.  You may have to build that run-time package first, though.

     

     


  5. 2 hours ago, karl Jonson said:

    Hi,
    Does anyone have a working logic for Tlistview with checkboxes where a user can multi select options similar to these:
    None
    Not Known
    OptionOne
    OptionTwo

     

    Thanks

     

     

    unit TestbedU1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Classes,
      Vcl.ComCtrls;
    
    type
      TForm1 = class(TForm)
        ViewButton: TButton;
        Edit1: TEdit;
        ListView1: TListView;
        Memo1: TMemo;
        CheckButton: TButton;
        UncheckButton: TButton;
        procedure CheckButtonClick(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure UncheckButtonClick(Sender: TObject);
        procedure ViewButtonClick(Sender: TObject);
      strict private
        procedure SetCheckstate(aListview: TListView; Value: Boolean);
      private
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    {$R *.dfm}
    procedure TForm1.CheckButtonClick(Sender: TObject);
    begin
      SetCheckstate(listview1, true);
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    const
      ColCaptions: array [0..3] of string = (
        'Zero','One','Two','Three');
    var
      I: Integer;
      LCol: TListColumn;
      LItem: TListItem;
      N: Integer;
    begin
      memo1.Clear;
      listview1.ViewStyle := vsReport;
      listview1.Checkboxes := true;
      listview1.MultiSelect := true;
      for I := 0 to 3 do begin
        LCol:= listview1.Columns.Add;
        LCol.Caption := ColCaptions[I];
        LCol.AutoSize := true;
      end;
      for I := 1 to 5 do begin
        LItem:= listview1.Items.Add;
        LItem.Caption := Format('Item %d',[I]);
        for N := 1 to 3 do
          LItem.SubItems.Add(Format('Item %d%d',[I, N]));
      end;
    end;
    
    procedure TForm1.ViewButtonClick(Sender: TObject);
    const
      State: array [boolean] of string = ('not','');
    var
      I: Integer;
      LItem: TListItem;
    begin
      for I := 0 to listview1.items.count-1 do begin
        LItem:= ListView1.Items[I];
        memo1.Lines.Add(
          Format( 'Item %d is %s checked.', [Succ(I), State[LItem.Checked]])
          );
      end;
    end;
    
    procedure TForm1.SetCheckstate(aListview: TListView; Value: Boolean);
    var
      I: Integer;
      LItem: TListItem;
    begin
      for I := 0 to listview1.items.count-1 do begin
        LItem:= ListView1.Items[I];
        if LItem.Selected then
           LItem.Checked := Value;
      end;
    end;
    
    procedure TForm1.UncheckButtonClick(Sender: TObject);
    begin
      SetCheckstate(listview1, false);
    end;
    
    end.

     

    TestbedU1.dfm

    TestbedU1.pas


  6. When you deverlop a custom component it is a good idea to use a test project first in which you create an instance of the component in code. This allows you to debug the run-time behaviour of the component without endangering the IDE itself. Only when everything works as it should do you add it to a design-time package and install it, to validate the design-time behaviour. If you need to add a custom property or class editor these can also be developed and tested in the test project, by just doing what the IDE designer does for invoking them. I don't remember the details since it has been literally decades since I last needed to do this, but it can be done.

    • Like 1

  7. 12 hours ago, abdellahmehdi said:

    When I open a project, this problem appears.

     

     

    The  error message suggests that a component on one of the autocreated forms has not been created yet when some other component tries to refer to it when the IDE designer loads the form. This may be a sequence problem. Try to change the autocreation sequence to create the datamodule before the forms.

    • Thanks 1

  8. 48 minutes ago, neumimnemecky said:
    
    This is my new project, where I try to open bmp file and save it as jpg with NativeJPG by Simdesign.  https://sourceforge.net/projects/ahk...t.zip/download

    I did not uploaded images. Folder img should be created and in it bmp.jpg . Why nothing is created?

    
    procedure TForm1.LoadJpegFile(const AFileName: string);
    var bmp_filename, JpgFileName, dest_path: String; 
    begin BMP_filename := 'F:\bmp.bmp';
      JpgFileName := '.\img\bmp.jpg';
      dest_path := ExtractFilePath(JpgFileName);
      if not DirectoryExists(dest_path) then CreateDir(dest_path); 
      if not fileexists(bmp_filename) then 
        begin
        showmessage('File not found: '+bmp_filename);
        exit;
      end;
    try
      Bmp.LoadFromFile(bmp_filename); 
      Jpg.CompressionQuality := 100;
      Jpg.Assign(Bmp); 
      Jpg.SaveToFile(JpgFileName); // nothing happens?
    finally 
    end;
    end;

     

    Never rely on relative path names! They depend on whatever the application thinks the "current directory" is, and that is frequently not what you think it should be. Have you checked what destPath contains after your assignment?

    • Like 1

  9. 13 hours ago, ginnix said:

    AssignFile(F, 'c:\tmp\test.txt');
      Rewrite(F);
      for i := Low(CompanyDataBase) to High(CompanyDataBase) do
       Write(F, CompanyDataBase);
       CloseFile(F);

    Have you tried the obvious:

    AssignFile(F, 'c:\tmp\test.txt');
    Reset(F);
    for i := Low(CompanyDataBase) to High(CompanyDataBase) do
       Read(F, CompanyDataBase[I]);
    CloseFile(F); 

     


  10. 4 hours ago, neumimnemecky said:

    On D7 I try to install the package from here:

    https://github.com/acbarbosa1964/simdesign/tree/master/simlib/nativejpg

    There are some dependencies on simdesign-master\simlib\general

    so I have tried to create my own package with general and compile/build it. Also the

    simdesign-master\simlib\nativejpg\packages\NativeJpgD7.dpk I have tried with the same error.

    in general/sdStringtable.pas on line 75 there is this component needed:

      TsdStringTable = class(TsdDebugComponent)

    which is contained in simdesign-master\simlib\debug\sdDebug.pas

    But still the error is like it is not declared. Any advices how to compile this for Delphi 7?

    Have you added simdesign-master\simlib\debug to the project search path?


  11. 7 hours ago, AlanScottAgain said:

    Hi

    I have an object that holds a TObjectList.

     

    I have a helper class that builds The objects that go into the TObjectList.

    Currently I just Assign the helper ObjectList to the RootObjectList.

     

     RootObject.ObjectsList := Helper.DrawingObjectsList;

     

    I was wondering if I should Free the RootObjectList - if it has objects - before I assign the new list?

     

    Otherwise what happens to the old possibly orphaned list? Does the compilers take care of it?
    I have OwnsObjects set to True.

     

    Thanks

    Alan

    Object references are not automatically managed by the compiler-generated code, unlike interface references. So your code has a couple of possible problems re lifetime control:

    • If the assignment just replaces the RootObject.Objectlist (the internal reference held by RootObject) you leak the old object list's memory, as well as the objects held by the old list. After the assignment you now have two object list references referring to the same objectlist instance, one in RootObject.Objectlist, the other in Helper.DrawingObjectlist. If you free one the other becomes invalid and will cause an AV when next accessed.
    • If the assignment resolves to a call to a setter method (i.e. RootObject.Objectlist is a property with a setter method) and the setter frees the old reference before storing the one passed in you do not leak memory for the old list, but you still have two references to the same object list, with the problems mentioned above.
    • If the assignment resolves (via setter method) to clearing the content of the internal list first (assuming OwnsObject = true, so the contained objects are freed) and then storing the content of the passed list into the internal list you don't have the two problems mentioned in the first bullet point, but you have another: you now have two lists holding references to the same objects. Free an object in one list and the reference in the other becomes invalid. Especially fun if both lists have OwnsObjects set to true.
    • If the assignment resolves (via setter method) to clearing the content of the internal list first (assuming OwnsObject = true, so the contained objects are freed) and then moving the content of the passed-in list to the internal one you don't have a memory management problem, but the source list is now empty after the assignment. That may not be acceptible, depending on your requirements.

    There are two ways out of this mess:

    1. Change the design from using object references to using interface references. This gives you automatic lifetime control of the objects behind the interfaces via reference counting.
    2. Implement a deep copy mechanism for the objects held in the lists. The assignment would then clear the old content of the list and then store copies (clones) of the objects in the source list into the internal list. This way the two lists are completely independent of each other, changing objects in one has no effect on the objects in the other. Both lists can have OwnsObject = true and there will be no memory leaks.

     


  12. 6 hours ago, Fuandi said:

    Hi, I need to do base64 decoding then decrypt the result with aes256

     

    I managed to do it in linux, this is the command

    printf "<encrypted string>" | base64 -d | gpg --no-options --batch --cipher-algo AES256 --passphrase "<client secret>" --decrypt

     

    How to do this with delphi ? Anyone can help me ?

    Well, Delphi has the System.NetEncoding.TBase64Encoding class you can use for the first step to convert the string to an array of bytes (TBytes) or put it into a stream directly, e.g. a TMemorystream. The decryption is a different matter, though.  There was a recent thread on using the free Lockbox 3 library for this purpose on these groups. See here...


  13. 4 hours ago, gioma said:

    in the original project use of graphic components.
    In that case I have problems with the visualization of these components (buttons, labels, etc.) ..
    All this always if the form has the visible = false property.
    It is probably a component problem, but the fact that with standard components I get such an error makes me think there is so much more.

    Just to explain your problem: the VCL creates window handles on an as needed basis, which may delay this action until the window is shown and needs to be drawn.  In your example (without Synchronize) this causes the window handle to be created in the background thread, not the main thread, and that thread has no message loop...


  14. 38 minutes ago, A.M. Hoornweg said:

    Hello all,

     

    I have the impression that Delphi's SHL operator only handles 32 bits even when compiling for 64-bit.   

     

    Does anybody have an alternative routine that handles 64 bits?

     

    
    function bit(idx,value: uint64): Boolean;
    begin
      Result := ((1 shl idx) and value) <> 0;
    end;
    
    procedure test;
    var i:uint64;    b:boolean;
    begin
        i:=$ffffffff00000000;
        b:=bit(33,i);  // Should return TRUE but returns FALSE
    end;

     

    Your test case is in error, your value i has all top 32 bits set to zero.

  15. panel


    3 hours ago, abdellahmehdi said:

    How to make semi-transparent panel in Delphi VCL

    Set the ParentBackground property of the panel to true.

    • Thanks 1

  16. After opening the project go to the Project Manager pane; it's docked to the right of the editor by default. Under the project node you should have a noded named "Target platforms". Right-click on it to get a menu with an "Add platform" caption. Click that to get a list of available platforms, select "Windows 64 bit" from that. You should now have two subnodes under "Target platforms", double-click on the one you want to build to activate it.


  17. 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;
    var
      ch: Char;
      N: Integer;
    begin
      Result := aID;
      N:= Length(Result);
      while N > 0 do begin
        ch := Result[N];
        case ch of
          '0'..'8': begin
                      Result[N] := Succ(ch);
                      Break;
                    end;
          '9': begin
                 Result[N] := '0';
                 Dec(N);
               end;
          '.': Dec(N);
        else
          raise Exception.CreateFmt('Invalid character "%s" in ID "%s" at position %d.',
            [ch, aID, N]);
        end; {case ch}
      end;  {while}
    end;

     

    • Like 2

  18. 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.


  19. 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...

    • Thanks 1
    • Haha 3

  20. 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:.

     

    FileEncryption.zip


  21. 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.


  22. 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.


  23. 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.

×