 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
cancandodo Advanced Cheater
Reputation: 0
Joined: 09 Mar 2012 Posts: 70
|
Posted: Wed Jan 22, 2020 7:58 pm Post subject: how to set listbox's items color? |
|
|
for ex
if adderess1 's value ==1
set lisebox1's No.5 item;s color to green
if adderess1 's value ==0
set lisebox1's No.5 item;s color to black
UDF1.CEListBox1.Font.Color=0x00ff00
can set all items's color to green
but i just want to set item[5] to green or red
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Thu Jan 23, 2020 8:49 pm Post subject: |
|
|
It is easier using listview instead.
| Code: | lv.ViewStyle='vsReport'
lv.RowSelect=true
lv.HideSelection=false
lv.Align = 'alClient'
-- Add coloumns
c1=lv.Columns.add()
c1.Caption='First Name'
c1.AutoSize = true
c2=lv.Columns.add()
c2.Caption='Last Name'
c3=lv.Columns.add()
c3.Caption='Gen'
-- Add items and sub-items
l=lv.Items.add()
l.Caption='Stevie'
l.SubItems.add('Wonder')
l.SubItems.add('50')
l=lv.Items.add()
l.Caption='Cancandodo'
l.SubItems.add('Dodo')
l.SubItems.add('20')
l=lv.Items.add()
l.Caption='Ali'
l.SubItems.add('Baba')
l.SubItems.add('500')
lv.Index = 1
lv.OnCustomDrawItem =function(sender, ListItem, state, DefaultDraw)
if ListItem.Index == 1 then
sender.canvas.font.color = 0x00ff
end
return true
end
|
So. that use 'OnCustomDrawItem' command. For CEListbox, there is some implementation for a custom draw but I don't know how to use it on CE Lua script.
Anyhow, this is from free pascal code.
| Code: | procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
ListBox: TListBox;
Canvas: TCanvas;
S: string;
begin
ListBox := Control as TListBox;
Canvas := ListBox.Canvas;
Canvas.Font.Assign(ListBox.Font);
if odSelected in State then
begin
Canvas.Brush.Color := clHighlight;
Canvas.Font.Color := clHighlightText;
end
else
begin
Canvas.Brush.Color := clWindow;
Canvas.Font.Color := clWindowText;
end;
if ListBox.Items.Objects[Index] = TObject(1) then
begin
Canvas.Font.Color := clRed;
Canvas.Font.Style := [fsBold, fsStrikeOut]
end;
Canvas.FillRect(Rect);
S := ListBox.Items[Index];
Canvas.TextRect(Rect, S, [tfSingleLine, tfVerticalCenter]);
end; |
Try in CE Lua script, but not work. Maybe someone able to fix it. Just for illustration.
| Code: | f = createForm()
lb = createListBox(f)
lb.setSize(300,200)
lb.Style = 'lbOwnerDrawVariable'
--lb.Style = 'lbStandard'
lb.Font.Color = 31542 -- green
lb.Font.Name = 'Arial'
lb.Font.Pitch = 'fpVariable'
lb.Font.Quality = 'fqDraft'
lb.Options = 'lboDrawFocusRect'
lb.MultiSelect = false
for i=1, 10 do
lb.items.add('Item no. '..i)
end
lb.itemIndex = 4
lb.OnCustomDrawItem = function(sender, itemIndex, OwnerDrawState)
if itemIndex == 4 then
local c = sender.getCanvas()
c.Brush.Color = 0xFF0000
c.fillRect(0,0, sender.Width, sender.Height)
c.Font.Color = 0x0000FF
c.textOut(0, 0, sender.Top + 2, lb.Items[4])
end
return true
end |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25808 Location: The netherlands
|
Posted: Fri Jan 24, 2020 3:47 am Post subject: |
|
|
here's a working listbox version:
| Code: |
f = createForm()
lb = createListBox(f)
lb.setSize(300,200)
lb.Style = 'lbOwnerDrawVariable'
--lb.Style = 'lbStandard'
lb.Font.Color = 31542 -- green
lb.Font.Name = 'Arial'
lb.Font.Pitch = 'fpVariable'
lb.Font.Quality = 'fqDraft'
lb.Options = 'lboDrawFocusRect'
lb.MultiSelect = false
for i=1, 10 do
lb.items.add('Item no. '..i)
end
lb.itemIndex = 4
lb.OnDrawItem = function(sender, index, rect, state)
local c = sender.Canvas
-- print(index..' = '..state..' : '..rect.Top..','..rect.Left..','..rect.Right..','..rect.Bottom)
if index == 4 then
c.Brush.Color = 0xFF00ff
c.Font.Color = 0x0000FF
else
c.Brush.Color = 0x00ffff
c.Font.Color = 0xff0000
end
if state:find("odSelected")~=nil then
c.Brush.Color=0
end
c.fillRect(rect.left,rect.Top, rect.Right, rect.Bottom)
c.textOut(0, 0, rect.Top, lb.Items[index])
end
|
_________________
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 |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri Jan 24, 2020 8:31 am Post subject: |
|
|
DB Thanks, for the work. Next, how if want make CE Listbox as shown on the attached image?. Using CE Lua script.
| Code: | f = createForm()
lb = createListBox(f)
lb.setSize(220,200)
lb.Style = 'lbOwnerDrawVariable'
--lb.Style = 'lbStandard'
lb.Font.Color = 31542 -- green
lb.Font.Name = 'Arial'
lb.Font.Pitch = 'fpVariable'
lb.Font.Quality = 'fqDraft'
lb.Options = 'lboDrawFocusRect'
lb.MultiSelect = false
b = createButton(f)
b.setPosition(230,10)
b.Caption = 'Update'
--for i=1, 10 do
-- lb.items.add('Item no. '..i)
--end
lb.OnDrawItem = function(sender, index, rect, state)
local c = sender.Canvas
local S
c.Brush.Color = sender.Items[index].Color
c.fillRect(rect.left,rect.Top, rect.Right, rect.Bottom)
S = sender.Items[index]
c.textOut(0, S, rect.Top, rect.Bottom) -- Must be [tfSingleLine, tfVerticalCenter])
end
b.OnClick = function(sender)
-- lb.Items.BeginUpdate;
lb.Clear()
for i=1, 10 do
lb.items.add('Item no. '..i)
-- lb.Items.AddObject(i.ToString, TObject(IfThen(Odd(i), clSkyBlue, clMoneyGreen)));
-- lb.Items.EndUpdate
end
end |
| Description: |
|
| Filesize: |
35.69 KB |
| Viewed: |
3211 Time(s) |

|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
| Back to top |
|
 |
cancandodo Advanced Cheater
Reputation: 0
Joined: 09 Mar 2012 Posts: 70
|
Posted: Sun Feb 02, 2020 6:06 pm Post subject: |
|
|
| Dark Byte wrote: | here's a working listbox version:
| Code: |
f = createForm()
lb = createListBox(f)
lb.setSize(300,200)
lb.Style = 'lbOwnerDrawVariable'
--lb.Style = 'lbStandard'
lb.Font.Color = 31542 -- green
lb.Font.Name = 'Arial'
lb.Font.Pitch = 'fpVariable'
lb.Font.Quality = 'fqDraft'
lb.Options = 'lboDrawFocusRect'
lb.MultiSelect = false
for i=1, 10 do
lb.items.add('Item no. '..i)
end
lb.itemIndex = 4
lb.OnDrawItem = function(sender, index, rect, state)
local c = sender.Canvas
-- print(index..' = '..state..' : '..rect.Top..','..rect.Left..','..rect.Right..','..rect.Bottom)
if index == 4 then
c.Brush.Color = 0xFF00ff
c.Font.Color = 0x0000FF
else
c.Brush.Color = 0x00ffff
c.Font.Color = 0xff0000
end
if state:find("odSelected")~=nil then
c.Brush.Color=0
end
c.fillRect(rect.left,rect.Top, rect.Right, rect.Bottom)
c.textOut(0, 0, rect.Top, lb.Items[index])
end
|
|
tks!!!
|
|
| 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
|
|