Jump to content

RaelB

Members
  • Content Count

    79
  • Joined

  • Last visited

Posts posted by RaelB


  1. I create a number of Frames and store them in a Frame Object List (declared as FFrames: TObjectList<TMyFrame>)

    The frames are also added to the VCL form.

     

    I try to replace a Frame with below code, but it results in an "Invalid Pointer Operation": (I'm replacing the last Frame in the list with a new one)

     

    procedure TForm1.btnReplaceClick(Sender: TObject);
    var
      NewFrame: TMyFrame;
      OldFrame: TMyFrame;
    begin
      if FFrames.Count = 0 then exit;
    
      NewFrame := GetNewFrame;
      OldFrame := FFrames[FFrames.Count - 1];
      FFrames[FFrames.Count - 1] := NewFrame;
      OldFrame.Free;
    end;

    What's wrong with the code?

     

    Full code follows:

     

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
      System.Generics.Collections, MyFrameU;
    
    type
      TForm1 = class(TForm)
        ScrollBox1: TScrollBox;
        btnAdd: TButton;
        btnReplace: TButton;
        procedure btnAddClick(Sender: TObject);
        procedure btnReplaceClick(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
        FFrames: TObjectList<TMyFrame>;
        function GetNewFrame: TMyFrame;
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
      Counter: Integer;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      FFrames := TObjectList<TMyFrame>.Create;
    end;
    
    procedure TForm1.FormDestroy(Sender: TObject);
    begin
      FFrames.Free;
    end;
    
    function TForm1.GetNewFrame: TMyFrame;
    begin
      Result := TMyFrame.Create(Self);
      Result.Name := 'MyFrame' + Counter.ToString;
      Result.Parent := ScrollBox1;
      Result.Align  := alLeft;
      Result.SetName(Result.Name);
      Inc(Counter);
    end;
    
    procedure TForm1.btnAddClick(Sender: TObject);
    var
      Frame: TMyFrame;
    begin
      Frame := GetNewFrame;
      FFrames.Add(Frame);
    end;
    
    procedure TForm1.btnReplaceClick(Sender: TObject);
    var
      NewFrame: TMyFrame;
      OldFrame: TMyFrame;
    begin
      if FFrames.Count = 0 then exit;
    
      NewFrame := GetNewFrame;
      OldFrame := FFrames[FFrames.Count - 1];
      FFrames[FFrames.Count - 1] := NewFrame;
      OldFrame.Free;
    end;
    
    end.

     


  2. The GUI examples work fine for demonstration purposes, but how do I use the components to execute python code and get a result within my own code, i.e synchronous execution, or be notified when execution is done?

    e.g:

    S := PythonExec(input_script)

     

    Then I can use S in next line of code, or in an event that notifies script is done.

    Thanks


  3. Hi,

     

    I create object list collections as below:

     

      TNotes = class(TObjectList<TNote>)
      public
        ...
      end;
      
      TBooks = class(TObjectList<TBook>)
      public
        ...
      end; 
      
      etc..

    Is there a way I can write some generic code that will be able to take in TNotes or TBooks instances, for e.g.:

    function ListToJSONString(List: TObjectList<T>): string;
    begin
    ...
    end;

    I want to call as:

      s := ListToJSONString(FNotes) or

      s := ListToJSONString(FBooks)

     

    But the function does not compile...

     

    Can such a function be declared, or do I need to change my definition of TNotes and TBooks?

     

    (I don't like using TObjectList<TNote> or TObjectList<TBook> in my code, since I want to create local (i.e. public) methods for each list type, and it is also simpler writing TNotes instead of TObjectList<TNote> each time)

     

    Thanks


  4. Is using "TJSON.ObjectToJsonObject" to convert an object into a TJSONValue (and ultimately into a string).

    Is it possible for this conversion to leave out a specific field/fields, for e.g. using some type of attribute?

     

    For example:

      TPersistItem = class(TPersistent)
      private
        FChangeStatus: TChangeStatus;
        FId: Variant;
        FLoading: Boolean;
        procedure SetId(const Value: Variant);
      protected
    ...
        procedure SetChangeStatus(const Value: TChangeStatus);
      public
    ...
      published
        property ChangeStatus: TChangeStatus read FChangeStatus write SetChangeStatus;
        property Id: Variant read FId write SetId;
      end;

    I don't want fields "ChangeStatus" and "Loading" to be included in the result.

     

    Thanks


  5. Hi,

    I ask this question because I don't have 2 monitors so I can't test this for myself.

    Is moving from Per Monitor V1 to Per Monitor V2 "only good and no bad", or does one need to take care of certain things when making the move?

    By "only good and no bad", I mean there will be advantages, however, if certain V2 related events are not handled, the behaviour will default to V1 behaviour..

    Thanks

    Rael


  6. On 9/17/2021 at 3:45 PM, dummzeuch said:

    ...  And not just for 10 projects but for about 50 (not all of these active at the same time, of course). That's nothing I need to imagine, that's my actual working environment.

    So how do you manage working in an IDE with all those different lib versions?

     

    - Do you use specific IDE's for specific projects?

    - Are you using any tools to help you with that?..

     

    Peter Below, once told me this:

    Quote

    It is possible to create project-specific IDE configurations if you really run into performance problems and the project in question really needs only a subset of your complete component set. You can disable specific design-time packages on a per-project basis, for instance. That does not solve the long search path (and browsing path, more relevant for code insight etc.) issue, though. But you can create a copy of the IDE's registry key tree (the one under HKEY_CURRENT_USER/Software) under a new key name, modify that to only get the packages needed for the project mentioned on the IDE pathes, and start the IDE with the -r command line parameter to make it use this key instead of the default. This requires a bit of fiddling with regedit, but can pay off if you have to maintain several big projects in parallel. You would have then one shortcut to the IDE for each of the projects and use the appropriate one to load a project with the associated component set.

    Perhaps you are using this idea..


  7. Hello,

     

    I have opened an old open source project in the IDE (10.3), and breakpoints seem to have been disabled for this project.

     

    image.thumb.png.553ff3cd220f0ea1b70e1d6bfc74f564.png

     

    Q1. How can I re-enable breakpoints?

    In "Linking" I have set "Debug Information" = True, and "Map file" = Detailed. What other setting is relevant here?

     

    Q2. Another thing is that whenever an error occurs, the IDE goes straight to CPU view. How do I revert to the usual behaviour of going to the line of code where the error occurred?

     

    Thanks

    Rael

     


  8. Hi,

    I'm using 15.0.33. If I change to Dark Theme, and then back to Light theme, the members area remains dark:

    image.thumb.png.e72dda1d3f4fb1d3cc98004acb821b02.png

     

    If there are members, they will fill up the box with the correct theme, but there is still an area left in dark theme:

     

    image.png.6ee70a4d7fed241dc52f108f24e38839.png

     

    I'm using Delphi 10.3.2

    Thanks

     

     

×