Ver Mensaje Individual
  #4  
Antiguo 03-02-2025
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is online now
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.437
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Cita:
Empezado por Casimiro Notevi Ver Mensaje
Puedes hacer el ejercicio preguntando al chatgpt

Incluso, he visto que si le das este código del ejemplo que hay aquí:
https://neftali.clubdelphi.com/ejemp...-sin-utilidad/



Código Delphi [-]
type

  //: Clase para definir un Thread con prograssBar
  TProgressBarThread = class(TThread)
  private
    pb: TProgressBar;
    FStep: Integer;
  protected
    procedure Execute; override;
    procedure MoveTh;
  public
    property Step:Integer read FStep write FStep;
    constructor Create(Box: TProgressBar; AStep:Integer; ThreadPriority: TThreadPriority);
  end;
...


implementation

uses
  graphics;

{ TProgressBarThread }
constructor TProgressBarThread.Create(Box: TProgressBar; AStep:Integer;
                                      ThreadPriority: TThreadPriority);
begin
  inherited Create(False);
  Self.FStep := AStep;
  pb := Box;
end;

procedure TProgressBarThread.Execute;
begin

    while true do begin
      Synchronize(MoveTh);
      Sleep(50);
    end;

end;

procedure TProgressBarThread.MoveTh();
begin
  pb.Position := (pb.Position + FStep) MOD 100;
end;

Y le dices que te lo traduzca a C++Builder, saca algo que al menos está en C++

Código:
#include <vcl.h>
#pragma hdrstop
#include <tchar.h>
#include <Classes.hpp>
#include <ComCtrls.hpp>

class TProgressBarThread : public TThread
{
private:
    TProgressBar *pb;
    int FStep;
protected:
    void __fastcall Execute();
    void __fastcall MoveTh();
public:
    __fastcall TProgressBarThread(TProgressBar *Box, int AStep, TThreadPriority ThreadPriority);
    __property int Step = {read=FStep, write=FStep};
};

__fastcall TProgressBarThread::TProgressBarThread(TProgressBar *Box, int AStep, TThreadPriority ThreadPriority)
    : TThread(false)
{
    FStep = AStep;
    pb = Box;
    Priority = ThreadPriority;
}

void __fastcall TProgressBarThread::Execute()
{
    while (true)
    {
        Synchronize(&MoveTh);
        Sleep(50);
    }
}

void __fastcall TProgressBarThread::MoveTh()
{
    pb->Position = (pb->Position + FStep) % 100;
}
Habrá que ver sio lo que sale finalmente tiene sentido...
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita