Cita:
Empezado por Casimiro Notevi
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
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;
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...