|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Flux. Advanced Cheater Reputation: 0
Joined: 10 Nov 2016 Posts: 84 Location: Another World - N5X2 106311411+2123518
|
Posted: Sat Feb 04, 2023 4:22 pm Post subject: Progress bar help. |
|
|
Hello,
looking for a bit of help with a progress bar.
These 2 directions don't seem to work for me -
orientation 'pbTopDown' & 'pbRightToLeft'
Does anyone know a solution ?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Sun Feb 05, 2023 3:28 am Post subject: |
|
|
not sure if you wanted this in lua or general programming.
This is a lazarus issue. Likely windows has no support for topdown or righttoleft
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Flux. Advanced Cheater Reputation: 0
Joined: 10 Nov 2016 Posts: 84 Location: Another World - N5X2 106311411+2123518
|
Posted: Sun Feb 05, 2023 3:48 am Post subject: |
|
|
Just found this on the Lazarus forums.
https://forum.lazarus.freepascal.org/index.php?topic=31663.0[url]
Is it possible someone could adapt this code to work in cheat engine ?
Windows progress bar supports right to left if WS_EX_LAYOUTRTL flag is added to its ExStyle:
Code: | uses
..., ComCtrls, LCLType;
type
TR2LProgressBar = class(TCustomProgressBar)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;
...
procedure TR2LProgressBar.CreateParams(var Params: TCreateParams);
const
WS_EX_LAYOUTRTL = $00400000; { Should be added to LCLType? }
begin
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_LAYOUTRTL;
end; |
Test it with something like:
Code: | procedure TForm1.Button1Click(Sender: TObject);
var
pb: TCustomProgressBar;
begin
pb := TR2LProgressBar.Create(Self);
with pb do
begin
Parent := self;
Left := 10;
Top := 10;
Width := 100;
Position := 15;
end;
end; |
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Feb 05, 2023 5:54 am Post subject: |
|
|
WS_EX_LAYOUTRTL is use for 'mirroring (component iin CE) or '(controls in VB or other programming language). Usually use by apps in Arabic.
In case progressbar from Right to Left, here is an example:
Code: | if frm then frm.destroy() end
frm = createForm()
frm.Position = poScreenCenter
frm.Caption = 'Test PB'
lb = createLabel(frm)
lb.Left = 10
lb.Top = 30
lb.Caption = 'Waiting...'
lb.Font.Size = 20
pb = createProgressBar(frm)
pb.Left = 10
pb.Top = 80
pb.Width = frm.Width - 20
pb.Height = 30
pb.Min = 0
pb.Max = 100
pb.Position = 0
bt1 = createButton(frm)
bt1.Left = 50
bt1.Top = 140
bt1.Width = 100
bt1.Caption = 'Start'
bt2 = createButton(frm)
bt2.Left = 170
bt2.Top = 140
bt2.Width = 100
bt2.Caption = 'Reset'
WS_EX_LAYOUTRTL = 4194304
GWL_EXSTYLE = -20
function SetWindowLong(hWnd, nIndex, dwNewLong)
return executeCodeLocalEx("user32.SetWindowLongPtrA", hWnd, nIndex, dwNewLong)
end
function ctlRightToLeft(ctl)
SetWindowLong(ctl.handle, GWL_EXSTYLE, WS_EX_LAYOUTRTL)
end
function start()
ctlRightToLeft(pb)
t.enabled = true
end
function reset()
pb.Position = 0
lb.Caption = 'Waiting...'
end
function pbProgress()
pb.Position = pb.Position + 2
lb.Caption = 'On going...'
if pb.Position == pb.Max then
t.enabled = false
lb.Caption = 'Complete..'
end
end
t = createTimer()
t.enabled = false
t.Interval = 200
t.OnTimer = pbProgress
frm.Show()
bt1.OnClick = start
bt2.OnClick = reset |
In case you want the ptogessbar from Top to Down, just change the pb orientation to 'pbVertical' and use same code as example above.
write down, WS_EX_LAYOUTRTL not only use for pb. Other components like tree view, list box, etc should work to mirroring. Try yourself.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Flux. Advanced Cheater Reputation: 0
Joined: 10 Nov 2016 Posts: 84 Location: Another World - N5X2 106311411+2123518
|
Posted: Sun Feb 05, 2023 7:33 am Post subject: |
|
|
@Corroder
Thanks for the info, much appreciated.
The code works great for right to left, but top down doesn't seem to work even after setting the orientation to 'pbVertical'.
any thoughts ?
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Feb 05, 2023 10:28 pm Post subject: |
|
|
IDK, if the pb orientasion pbVertical with WS_EX_LAYOUTRTL doesn't work,
Anyhow, I am usually make my custom pb by using panel, shape, frame, etc.
Below is an example, top bottom progress bar using custom shape. You are free to change TShape with panel or another component.
Code: | if frm then frm.destroy() end
frm = createForm()
frm.Position = poScreenCenter
frm.Caption = 'Test PB'
lb = createLabel(frm)
lb.Left = 10
lb.Top = 20
lb.Caption = 'Waiting...'
lb.Font.Size = 20
bt1 = createButton(frm)
bt1.Left = 10
bt1.Top = 80
bt1.Width = 100
bt1.Caption = 'Start'
bt2 = createButton(frm)
bt2.Left = 10
bt2.Top = 110
bt2.Width = 100
bt2.Caption = 'Reset'
pnl = createPanel(frm)
pnl.Top = 10
pnl.Left = 200
pnl.Width = 25
pnl.Height = 220
pnl.BevelOuter = 'bvLowered'
pnl.Color = 14737632
--------------------------------------------------------------------------------
function createShape(Parent)
local sh = createComponentClass('TShape', Parent)
sh.Parent = Parent
return sh
end
function clamp(number) return number end
function lerp(a,b,t) return math.floor(a+(b-a)*t) end
function lerpRGB(r,g,b,r2,g2,b2, t) return lerp(r,r2,t), lerp(g,g2,t), lerp(b,b2,t) end
function makeColor(r,g,b) return r | (g<<8) | (b<<16) end
local ColorHigh = 0x0000FF
local ColorLow = 0x00FF00
local factor
local InitialSize = pnl.Height
function start()
if sh1 then sh1.destroy() end
sh1 = createShape(pnl)
sh1.Top = 0
sh1.Height = 0
sh1.Width = pnl.Width
sh1.brush.Color = clBlue
t.enabled = true
end
function reset()
t.enabled = false
if sh1 then sh1.destroy() end
lb.Caption = 'Waiting...'
end
function pbProgress()
lb.Caption = 'On going...'
sh1.Height = sh1.Height + 2
if sh1.Height == pnl.Height then
t.enabled = false
lb.Caption = 'Complete..'
end
factor = sh1.Height / pnl.Height
-- sh1.Brush.Color = makeColor(lerpRGB(ColorLow,0,0, ColorHigh,0,0, factor))
-- sh1.Height = math.floor(InitialSize * factor)
end
t = createTimer()
t.enabled = false
t.Interval = 100
t.OnTimer = pbProgress
frm.Show()
bt1.OnClick = start
bt2.OnClick = reset |
Note, on the example above, I am use a single color for progress bar foreground color (TShape). So, some functions on the example use for if we want to change the TShape color, in this case form Green to Red.
EDIT :
Anyway, if you really must use 'real progress bar component', then the example below, set to 'manipulating progress bar color and viewer'.
Try yourself and feel free to make progress bar color improvisation.
Code: | function ProgressBarColor(ProgressBarName, BarColor, BGColor)
executeCodeLocalEx("uxtheme.SetWindowTheme", ProgressBarName.handle, "", "")
SendMessage(ProgressBarName.handle, 1024 + 9, 0, BarColor)
SendMessage(ProgressBarName.handle, 1024 + 7169, 0, BGColor)
end
if f then f.destroy() end
f = createForm()
f.Position = poScreenCenter
f.Caption = 'Vertical PB Top2Bottom'
bt1 = createButton(f)
bt1.Left = 10
bt1.Top = 10
bt1.Caption = 'Start'
bt2 = createButton(f)
bt2.Left = 10
bt2.Top = 40
bt2.Caption = 'Reset'
pb = createProgressBar(f)
pb.Left = 150
pb.Top = 10
pb.Width = 25
pb.Height = f.Height - 20
pb.Orientation = 'pbVertical'
pb.Min = 0
pb.Max = 100
ProgressBarColor(pb, 13619151, 52480)
pb.Position = 100
pb2 = createProgressBar(f)
pb2.Left = 180
pb2.Top = 10
pb2.Width = 25
pb2.Height = f.Height - 20
pb2.Orientation = 'pbVertical'
pb2.Min = 0
pb2.Max = 100
ProgressBarColor(pb2, 13850042, 13619151)
pb2.Position = 0
function start()
t.enabled = true
end
function reset()
t.enabled = false
pb.Position = 100
pb2.Position = 0
end
function progress()
pb.Position = pb.Position - 1
pb2.Position = pb2.Position + 1
if pb.Position == 0 and pb2.Position == 100 then
t.enabled = false
showMessage('Complete..')
end
end
t = createTimer()
t.Interval = 100
t.enabled = false
t.OnTimer = progress
f.Show()
bt1.OnClick = start
bt2.OnClick = reset
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Flux. Advanced Cheater Reputation: 0
Joined: 10 Nov 2016 Posts: 84 Location: Another World - N5X2 106311411+2123518
|
Posted: Mon Feb 06, 2023 8:27 am Post subject: |
|
|
@Corroder
Thanks for those examples, much appreciated, +rep.
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|