Jump to content

stacker_liew

Members
  • Content Count

    106
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by stacker_liew


  1. I have used 64bit of OpenJDK 17.0.28 in Delphi 11.1, it can compile 64bit apk and aab without any problem, but when I tried with Delphi 10.3.3 and Delphi 10.4.2, it ends up with "could not create the Java Virtual Machine".

     

    I wonder whether is the version of jdk doesn't supported these two version of IDE? And what version of OpenJDK does these two IDE supported?

     

    I'm using Windows 11


  2. 45 minutes ago, Remy Lebeau said:

    That is because the TProgressBarInStatusBar.CreateIn() code provided earlier is not taking the Left position of the specified TStatusPanel into account, only its Width and Height.  So it is positioning the TProgressBar in the wrong place for any TStatusPanel other than the 1st one.

     

    Unfortunately, neither TStatusBar nor TStatusPanel provide a property or method to get the Left position of a TStatusPanel, so you will have to retrieve it manually, either by:

     

    - looping through the TStatusBar.Panels collection:

    
    function GetLeftOfStatusPanel(APanel: TStatusPanel); Integer;
    var
      I: Integer;
      Coll: TStatusPanels;
    begin
      Result := 0;
      Coll := APanel.Collection as TStatusPanels;
      for I := 0 to APanel.Index-1 do
        Inc(Result, Coll[I].Width);
    end;

    - or by asking the OS directly:

    
    uses
      ..., Winapi.CommCtrl;
    
    function GetLeftOfStatusPanel(APanel: TStatusPanel); Integer;
    var
      R: TRect;
    begin
      SendMessage((APanel.Collection.Owner as TStatusBar).Handle, SB_GETRECT, APanel.Index, LPARAM(@R));
      Result := R.Left;
    end;

    In which case, since CreateIn() wants the TProgressBar to fill the full rectangle of the TStatusPanel anyway, I would just ask the OS for the rectangle and use it as-is, eg:

    
    uses
      ..., Winapi.CommCtrl;
    
    class procedure TProgressBarInStatusBar.CreateIn(const inStatusBarPanel: TStatusPanel;
      var outProgressBar: TProgressBar; var outLabel: TLabel);
    var
      statusbar: TStatusBar;
      R: TRect;
    Begin
      statusbar := inStatusBarPanel.Collection.Owner As TStatusBar;
    
      SendMessage(statusbar.Handle, SB_GETRECT, inStatusBarPanel.Index, LPARAM(@R));
    
      outProgressBar := TProgressBar.Create(statusbar);
      outProgressBar.Parent := statusbar;
      outProgressBar.Top := R.top;
      outProgressBar.Left := R.left;
      outProgressBar.Width := R.Width;
      outProgressBar.Height := R.Height;
    
      outLabel := TLabel.Create(outProgressBar);
      outLabel.Parent := outProgressBar;
      outLabel.Align := alClient;
      outLabel.AutoSize := False;
      outLabel.Alignment := taCenter;
    end;

     

    Thanks, it works now.


  3. On 5/13/2022 at 4:04 PM, aehimself said:

    Something like this:

    
    Var
      pbar: TProgressBar;
      lbl: TLabel;
      a: Integer;
    Begin
      TProgressBarInStatusBar.CreateIn(StatusBar1, pbar, lbl);
      
      For a := 0 To 1000 Do
      Begin
        pbar.Position := a Div 10;
        lbl.Caption := 'Working ' + a.ToString + '...';
        Application.ProcessMessages; // Don't do this. It's just pseudocode.
        Sleep(500);
      End;
    End;

     

    Does this method support multiple TStatusPanel? I tried with a TStatusPanel in Panel[1], but the ProgressBar, still appear in Panel[0].


  4. 8 hours ago, aehimself said:

    Something like this:

    
    Var
      pbar: TProgressBar;
      lbl: TLabel;
      a: Integer;
    Begin
      TProgressBarInStatusBar.CreateIn(StatusBar1, pbar, lbl);
      
      For a := 0 To 1000 Do
      Begin
        pbar.Position := a Div 10;
        lbl.Caption := 'Working ' + a.ToString + '...';
        Application.ProcessMessages; // Don't do this. It's just pseudocode.
        Sleep(500);
      End;
    End;

     

    Thanks


  5. 3 hours ago, aehimself said:

    I create my progress bars in the first panel of the status bar, with a label on it to show some meaningful information on the progress... like "30 of 999 items processed". Yes, it won't work if you resize the panel, needs some adjustments if you want to create it in the 3rd, but this is the code I use:

    
    Unit uProgressBarInStatusBar;
    
    Interface
    
    Uses Vcl.ComCtrls, Vcl.StdCtrls;
    
    Type
     TProgressBarInStatusBar = Class
     public
      Class Procedure CreateIn(Const inStatusBarPanel: TStatusPanel; Var outProgressBar: TProgressBar; Var outLabel: TLabel);
     End;
    
    Implementation
    
    Uses Vcl.Controls, System.Classes;
    
    Class Procedure TProgressBarInStatusBar.CreateIn(Const inStatusBarPanel: TStatusPanel; Var outProgressBar: TProgressBar; Var outLabel: TLabel);
    Var
     statusbar: TStatusBar;
    Begin
     statusbar := inStatusBarPanel.Collection.Owner As TStatusBar;
    
     outProgressBar := TProgressBar.Create(statusbar);
     outProgressBar.Parent := statusbar;
     outProgressBar.Top := 2;
     outProgressBar.Left := 1;
     outProgressBar.Width := inStatusBarPanel.Width - 3;
     outProgressBar.Height := statusbar.ClientHeight - 3;
    
     outLabel := TLabel.Create(outProgressBar);
     outLabel.Parent := outProgressBar;
     outLabel.Align := alClient;
     outLabel.AutoSize := False;
     outLabel.Alignment := taCenter;
    End;
    
    End.

    The small sacrifice of having it in the first panel makes up to it with no custom drawings / hacks needed at all. And it looks good enough:

     

    image.png.a052b18560be4c685eedc70179a3f2ae.png

    Thanks, how to use it?


  6. 1 hour ago, Remy Lebeau said:

    Or, at the very least, calling Update() on the TProgressBar or TForm.  Or, the example shown, by simply using a timer or thread instead of a blocking loop, let the main message queue run unblocked and handle UI updates normally.

     

    That being said, TStatusBar is not really intended to host child controls.  And using a *drawing* event to update UI layout is a big no-no in general.

     

    Any time I've ever needed to show a progress bar inside of a status bar (or, any other non-container parent, such as TListView or TTreeView, etc), I always prefer to owner-draw the parent and actually draw a progress bar myself.  I never try to hack in a TProgressBar as a child control.  Especially in a parent that can be resized/scrolled at runtime.  Keeping a TProgressBar positioned correctly at all times can get ugly quick.

    Any example of these?


  7. On 4/28/2019 at 11:31 AM, Dave Nottage said:

    Make a copy of (bds)\source\fmx\FMX.Media.Android.pas, and put it in your project folder. Modify this routine:

    
      function CreateJBitmapFromYuvBuffer: JBitmap;
      var
        Image: JYuvImage;
        Rect: JRect;
        Stream: JByteArrayOutputStream;
        LoadOptions: JBitmapFactory_Options;
      begin
        SurfaceSection.Acquire;
        try
          Image := TJYuvImage.JavaClass.init(SharedBuffer, SharedBufferFormat, PreviewBufferSize.X, PreviewBufferSize.Y,
            nil);
        finally
          SurfaceSection.Release;
        end;

    Replacing the SurfaceSection references with QueueSection

    Thanks.

×