Jump to content

Change Color TUniProgressBar runtime


tarcisionmjr

Recommended Posts

Just now, Sherzod said:

Hello,

This post may help you:

 

unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, uniGUITypes, uniGUIAbstractClasses,
  uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniTrackBar, uniProgressBar,
  uniGUIBaseClasses, uniButton, uniEdit, uniBitBtn;

type
  TMainForm = class(TUniForm)
    UniButton1: TUniButton;
    UniProgressBar1: TUniProgressBar;
    UniTrackBar1: TUniTrackBar;
    UniEdit1: TUniEdit;
    UniBitBtn1: TUniBitBtn;
    procedure UniTrackBar1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function MainForm: TMainForm;

implementation

{$R *.dfm}

uses
  uniGUIVars, MainModule, uniGUIApplication;

function MainForm: TMainForm;
begin
  Result := TMainForm(UniMainModule.GetFormInstance(TMainForm));
end;

procedure TMainForm.UniTrackBar1Change(Sender: TObject);
var
  cor: string;
begin
  UniProgressBar1.Position := UniTrackBar1.Position;
  if UniTrackBar1.Position < 50 then
  begin
    cor := 'white, green';
  end
  else if UniTrackBar1.Position < 75 then
  begin
    cor := 'white, yellow';
  end
  else
  begin
    cor := 'white, red';
  end;
  with UniBitBtn1.JSInterface do
  begin
    JSCall('btnWrap.setStyle', ['background-image', 'linear-gradient(to right, ' +
      cor + ')']);
    JSCall('btnWrap.setStyle', ['background-size',
      UniTrackBar1.Position.toString + '% 100%']);
    JSCall('btnWrap.setStyle', ['background-repeat', 'no-repeat']);
  end;
end;

initialization

RegisterAppFormClass(TMainForm);

end.

I found this code here and it is working well, but in this case the progress bar is being made and a TUniBitBtn component I want to do in the same code style but in a TUniProgressBar what would be the change I need to make in JSCALL for it to work. ...

Link to comment
Share on other sites

17 minutes ago, tarcisionmjr said:

I want to do in the same code style but in a TUniProgressBar...

Something like this:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  with UniProgressBar1 do
  begin
    JSInterface.JSCall('bar.setStyle', ['background-image', 'linear-gradient(to right, green, lime)']);
    ...
  end;
end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...