Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Replace the old scrollbar mode in another way(imperfect)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Wed Sep 16, 2020 11:50 am    Post subject: Replace the old scrollbar mode in another way(imperfect) Reply with quote

How to accurately calculate the ratio between them: ListBox.TopIndex , Panel.Width , Panel.Left
Code:
function  setColor(control)
  if pb then pb.destroy() end
  pb=createPaintBox(control)
  pb.setSize(control.Width,control.Height)
  pb.OnPaint=function(s)
    s.canvas.Clear()
    s.Canvas.gradientFill(0,0,s.Width,s.Height,0xff00ff,0xffff00,1)
  end
end
function setMouseWheelDown(control,Panel)
  control.OnMouseWheelDown=function()
    if Panel.Width >=10 and Panel.Width <=280 then
      if control.TopIndex>0 then
        Panel.Width=Panel.Width - control.TopIndex//2
        Panel.Left=Panel.Left + control.TopIndex//4
      end
    else
      Panel.Left=20  Panel.Width=280
    end
    setColor(Panel)  f.Caption='W:'..Panel.Width..'   L:'..Panel.Left..'   Index:'..control.TopIndex
  end
end
function setMouseWheelUp(control,Panel)
  control.OnMouseWheelUp=function()
    if control.TopIndex==0 then  Panel.Left=20  Panel.Width=280  end
    if Panel.Left >=20 and Panel.Width <=280 then
        Panel.Width=Panel.Width + control.TopIndex//2
        Panel.Left=Panel.Left - control.TopIndex//4
    else
      Panel.Left=20   Panel.Width=280
    end
    setColor(Panel)  f.Caption='W:'..Panel.Width..'   L:'..Panel.Left..'   Index:'..control.TopIndex
  end
end
if f then f.destroy() end
f=createForm()
f.Position='poDesktopCenter'
Box1=createListBox(f)
Box1.setPosition(20,20)
Box1.setSize(100,150)
for i=1,50,2 do
  strings_add(Box1.Items, i)
end

Box2=createListBox(f)
Box2.setPosition(200,20)
Box2.setSize(100,150)
for i=0,100,2 do
  strings_add(Box2.Items, i)
end

P=createPanel(f)
P.setPosition(20,200)
P.setSize(280,5)
setColor(P)


setMouseWheelDown(Box1,P)
setMouseWheelUp(Box1,P)

setMouseWheelDown(Box2,P)
setMouseWheelUp(Box2,P)



A new attempt.gif
 Description:
 Filesize:  268.93 KB
 Viewed:  1366 Time(s)

A new attempt.gif


Back to top
View user's profile Send private message
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 203

PostPosted: Thu Sep 17, 2020 2:16 am    Post subject: Reply with quote

After research, we finally found the value of Max, so we can bind the width of the control
Code:
function  setColor(control)
  if pb then pb.destroy() end
  pb=createPaintBox(control)
  pb.setSize(control.Width,control.Height)
  pb.OnPaint=function(s)
    s.canvas.Clear()
    s.Canvas.gradientFill(0,0,s.Width,s.Height,0xff00ff,0xffff00,1)
  end
end
function setMouseWheelDown(control,Panel)
  control.OnMouseWheelDown=function()  local max=(control.Items.getCount()-1)-(control.Height//20)
    if control.TopIndex >=0 then
      Panel.Width=control.Height-max*2
    end
    if control.TopIndex <max-2 then
      Panel.Left=(control.TopIndex+3)*4
    else
      Panel.Left=Pa.width-Panel.Width-5
    end
    setColor(Panel)  f.Caption='W:'..Panel.Width..'   L:'..Panel.Left..'   Index:'..control.TopIndex
  end
end
function setMouseWheelUp(control,Panel)
  control.OnMouseWheelUp=function()  local max=(control.Items.getCount()-1)-(control.Height//20)
    if control.TopIndex<=3 then
      Panel.Left=0  Panel.Width=control.Height-max*2
    end
    if Panel.Left>=0 and Panel.Left<=Pa.Width-Panel.Width then
      if control.TopIndex>0 then
        Panel.Width=control.Height-max*2
      end
      if control.TopIndex<max then
        Panel.Left=(control.TopIndex+1)*4
      end
    end
    setColor(Panel)  f.Caption='W:'..Panel.Width..'   L:'..Panel.Left..'   Index:'..control.TopIndex
  end
end
if f then f.destroy() end
f=createForm()
f.Position='poDesktopCenter'
Box1=createListBox(f)
Box1.setPosition(20,20)
Box1.setSize(100,150)
for i=1,50,2 do
  strings_add(Box1.Items, i)
end

Box2=createListBox(f)
Box2.setPosition(200,20)
Box2.setSize(100,150)
for i=0,130,2 do
  strings_add(Box2.Items, i)
end

Pa=createPanel(f)
Pa.setPosition(20,200)
Pa.setSize(282,7)
Pa.BevelColor=0xb4b4b4

P=createPanel(Pa)
P.setPosition(1,1)
P.setSize(200,5)
setColor(P)


setMouseWheelDown(Box1,P)
setMouseWheelUp(Box1,P)

setMouseWheelDown(Box2,P)
setMouseWheelUp(Box2,P)



GIF.gif
 Description:
 Filesize:  102.33 KB
 Viewed:  1331 Time(s)

GIF.gif


Back to top
View user's profile Send private message
MMM-304
Expert Cheater
Reputation: 0

Joined: 17 Aug 2020
Posts: 170
Location: Milkey Way

PostPosted: Thu Sep 17, 2020 9:12 am    Post subject: Reply with quote

works only when mouse wheel is used to scroll otherwise doesnt work
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Thu Sep 17, 2020 7:09 pm    Post subject: Reply with quote

MMM-304 wrote:
works only when mouse wheel is used to scroll otherwise doesnt work


Of course, that is why it's call as 'Scroll Bar Indicator'

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites