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 


Edit box in listview with vertical scroll bar

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

Joined: 17 Jan 2018
Posts: 202

PostPosted: Mon Feb 26, 2024 10:43 am    Post subject: Edit box in listview with vertical scroll bar Reply with quote

I have a question about listview with vertical scroll bar. How to get row number by clicking on the listview SubItems, if listview.RowSelect = false?
How to place the Edit box in the right place in the listview, if listview has a vertical scroll bar? Because after we move the scrollbar, the location of the Edit box should change accordingly after we click on the listview again.

Example: listview with 60 rows and 16 columns. ListView displays 60*16=960 1-byte values. (CEListView1 ViewStyle = vsReport; CEEdit1 BorderStyle = bsNone)

This code works if listview.RowSelect = true :
Code:
UDF1_CEListView1.OnMouseDown = function(sender, button, x, y)
local i
  local xpos=0;
  local edit = UDF1_CEEdit1

  for i=0, sender.Columns.Count-1 do
    if sender.Columns[i].Visible then

      local start=xpos;
      local stop=xpos+sender.Columns[i].Width

      if (x>=start) and (x<stop) then
        --print("clicked on column "..i)
        local Ind=sender.ItemIndex
        edit.Visible = true
        if i == 0 then --if 1-st column clicked
        edit.Text = sender.Items[Ind].Caption
        else
        edit.Text = sender.Items[Ind].SubItems[i-1]
        end
        edit.Tag = Ind*0x10+i --0x10 = row
        break
      end

      xpos=stop
    end
  end

  if sender.ItemIndex ~= -1 then
  edit.Left = sender.Left+3+xpos
  edit.Top = sender.ItemIndex*14+sender.Top+22
  end
end

UDF1_CEButton1.OnClick = function(sender)

  local items = UDF1_CEListView1.Items

  for x = 0, 59 do
  local offset = 0x9CEF7C+x*0x10
  local item = items[x]
  item.Caption = readBytes(offset)
  for y = 0, 14 do
  local val = readBytes(offset+1+y)
  item.SubItems[y] = val
  end
  end
end
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25298
Location: The netherlands

PostPosted: Tue Feb 27, 2024 12:42 am    Post subject: Reply with quote

listview.TopItem is the item at top, use that to calculate the rest
_________________
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
View user's profile Send private message MSN Messenger
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Tue Feb 27, 2024 3:40 am    Post subject: Reply with quote

Dark Byte wrote:
listview.TopItem is the item at top, use that to calculate the rest

Thanks, it works. This calculation is used in the code:
Code:
edit.Top = (sender.ItemIndex-sender.TopItem.Index)*14+sender.Top+22
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