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 


Combo box with pictures?
Goto page 1, 2  Next
 
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 May 15, 2023 4:02 am    Post subject: Combo box with pictures? Reply with quote

How to make a combo box with pictures? I want to do something like on the screenshot below:

If this is not possible, then how to draw a circle with different colors and without or with changing the color of the text?
I would also like to see examples of such Canvas methods: drawFocusRect, textRect, setPixel, floodFill, gradientFill, copyRect, stretchDraw.



3---.JPG
 Description:
 Filesize:  18.07 KB
 Viewed:  3383 Time(s)

3---.JPG


Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon May 15, 2023 9:44 pm    Post subject: Reply with quote

Use an image list and draw combobox canvas with the images from the image list. Anyhow, I don't know how to do that because I am beginner in CE Lua script. So, this is just a suggestion.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 72

PostPosted: Tue May 16, 2023 5:46 am    Post subject: Reply with quote

https://forum.cheatengine.org/viewtopic.php?t=616655
this lua have input ico.The gui is very well .
If you are familiar with it, you can copy the code you need from this lua
The code seems to be like this

Code:


views.icons = icon_list;
views.iconsId = { -- encoded images, might be better to simply load from table file or directory.. but for portability this suits. source: https://www.iconarchive.com/show/blue-bits-icons-by-icojam.1.html
file_changed    = icon_list.add(png_to_bmp("
file_unchanged    = icon_list.add(png_to_bmp("
new_file       = icon_list.add(png_to_bmp("
open_file      = icon_list.add(png_to_bmp("
close_file       = icon_list.add(png_to_bmp("
save_file       = icon_list.add(png_to_bmp("
move_left       = icon_list.add(png_to_bmp("
move_right       = icon_list.add(png_to_bmp("
prev_view       = icon_list.add(png_to_bmp("
next_view       = icon_list.add(png_to_bmp("
new_view       = icon_list.add(png_to_bmp("
zoom_out       = icon_list.add(png_to_bmp("
zoom_in       = icon_list.add(png_to_bmp("
search_file    = icon_list.add(png_to_bmp("
execute       = icon_list.add(png_to_bmp("
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Tue May 16, 2023 7:25 am    Post subject: Re: Combo box with pictures? Reply with quote

Razi wrote:
I would also like to see examples of such Canvas methods: drawFocusRect, textRect, setPixel, floodFill, gradientFill, copyRect, stretchDraw.


Sometimes we want the answer to the problem, but then you never really learn anything. It would be wise to heed the advice given, try a few things and see the result. Only then you will actually learn something, unless of course your only aim is to have people write the code for you.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Tue May 16, 2023 9:21 am    Post subject: Reply with quote

Corroder wrote:
Anyhow, I don't know how to do that because I am beginner in CE Lua script.


For some reason I didn't believe it. Smile Twisted Evil

Here is an idea:
Code:
function loadUrl(link)
  local int=getInternet()
  s=int.getURL(link)
  int.destroy()
  return s
end

function crtPict25(link1)
logostr22=loadUrl(link1)
local ss22=createStringStream(logostr22)
p=createPicture()
p.loadFromStream(ss22)
ss22.destroy()
return p
end

greenboll=crtPict25([[https://i.hizliresim.com/nbeibjw.png]])
redboll=crtPict25([[https://i.hizliresim.com/5fovypg.png]])
blueboll=crtPict25([[https://i.hizliresim.com/foy25pq.png]])
silverboll=crtPict25([[https://i.hizliresim.com/a3ga54z.png]])
--  Using the above functions if the pictures are attached in the table.
-- I just added it for example.

function createScrollBox(Parent)
local box = createComponentClass('TScrollBox', Parent)
 box.Parent = Parent
 return box
end

local pTbl = {}

-----------------------
if pageFrm1 then pageFrm1.Destroy() pageFrm1=nil end
DP1=getScreenDPI()/96
pageFrm1=createForm()
pageFrm1.height=189*DP1 pageFrm1.width=170*DP1 pageFrm1.left=313*DP1 pageFrm1.top=123*DP1
pageFrm1.PopupMode=0 pageFrm1.caption="pageFrm1"
pageFrm1.Position="poDesktopCenter" pageFrm1.BorderStyle="bsSingle"  pageFrm1.ShowInTaskBar="stAlways"
-------------------------
----------------------- pTbl.sBtn1 ----- 
pTbl.sBtn1=createButton(pageFrm1)
pTbl.sBtn1.height=21*DP1 pTbl.sBtn1.width=150*DP1 pTbl.sBtn1.left=10*DP1 pTbl.sBtn1.top=5*DP1
pTbl.sBtn1.Font.Style="fsBold" pTbl.sBtn1.Caption="Index Function"
-----------------------
----------------------- pTbl.sBox1 ----- 
pTbl.sBox1=createScrollBox(pageFrm1)
pTbl.sBox1.AutoSize=false
pTbl.sBox1.height=150*DP1 pTbl.sBox1.width=150*DP1 pTbl.sBox1.left=10*DP1 pTbl.sBox1.top=31*DP1
pTbl.sBox1.Font.Style="fsBold" pTbl.sBox1.HorzScrollBar.Visible=false
pTbl.sBox1.Color=0xffffff pTbl.sBox1.VertScrollBar.Increment=8
pTbl.sBox1.VertScrollBar.Tracking=true
-----------------------
pnlIndex=1
sctPnl=""
sctIndex=0
local pgtbl1 = {}

function clrPnl()
  for i,k in pairs(pgtbl1) do
  --print(i,k)
   k1=(i):sub(1,4)
   if k1=="iPnl" then
     pgtbl1[i].Color=0xffffff
     pgtbl1[i].Font.Color=0
   end
  end
end

function sBox1Add(box,cpt,pct,x)
cptSpc="          "
pgtbl1["iPnl"..x]=createPanel(box)
pgtbl1["iPnl"..x].Name="iPnl"..x
pgtbl1["iPnl"..x].AutoSize=false
pgtbl1["iPnl"..x].height=22*DP1 pgtbl1["iPnl"..x].width=150*DP1
--if pnlIndex==1 then
 pgtbl1["iPnl"..x].top=tonumber(pnlIndex) * 25 - 25
pgtbl1["iPnl"..x].left=1*DP1
pgtbl1["iPnl"..x].caption=cptSpc..cpt
pgtbl1["iPnl"..x].alignment="taLeftJustify"
pgtbl1["iPnl"..x].Font.Style="fsBold"
pgtbl1["iPnl"..x].BevelOuter="bvNone"
-----------------------
----------------------- pTbl.iPict1 ----- 
pgtbl1["iPict"..x]=createImage(pgtbl1["iPnl"..x])
pgtbl1["iPict"..x].AutoSize=false
pgtbl1["iPict"..x].height=20*DP1 pgtbl1["iPict"..x].width=20*DP1
pgtbl1["iPict"..x].left=1*DP1 pgtbl1["iPict"..x].top=1*DP1
pgtbl1["iPict"..x].Picture=pct
pgtbl1["iPict"..x].stretch=true
-----------------------
 pgtbl1["iPnl"..x].OnMouseDown=function()
  clrPnl()
  pgtbl1["iPnl"..x].Color=0xA1470D
  pgtbl1["iPnl"..x].Font.Color=0xffffff
  sctIndex=tonumber(x)
  sctPnl=pgtbl1["iPnl"..x].Name
 end
pnlIndex=tonumber(pnlIndex) + 1
end

sBox1Add(pTbl.sBox1,"Item silver 1",silverboll,1) -- pgtbl1.iPnl1
sBox1Add(pTbl.sBox1,"Item silver 2",silverboll,2) -- pgtbl1.iPnl2
sBox1Add(pTbl.sBox1,"Item silver 3",silverboll,3)
sBox1Add(pTbl.sBox1,"Item Blue 4",blueboll,4)
sBox1Add(pTbl.sBox1,"Item Blue 5",blueboll,5)
sBox1Add(pTbl.sBox1,"Item Blue 6",blueboll,6)
sBox1Add(pTbl.sBox1,"Item Green 7",greenboll,7)
sBox1Add(pTbl.sBox1,"Item Green 8",greenboll,8) -- pgtbl1.iPnl8
sBox1Add(pTbl.sBox1,"Item Green 9",greenboll,9)
sBox1Add(pTbl.sBox1,"Item Red 10",redboll,10)
sBox1Add(pTbl.sBox1,"Item Red 11",redboll,11)
sBox1Add(pTbl.sBox1,"Item Red 12",redboll,12)
pTbl.sBox1.VertScrollBar.Page=100
pTbl.sBox1.VertScrollBar.Page=1

pgtbl1.iPnl1.OnClick=function()
  print(sctPnl)
  print(sctIndex)
end

pgtbl1.iPnl2.OnClick=function()
  print(sctPnl)
  print(sctIndex)
end

pgtbl1.iPnl3.OnClick=function()
  print(sctPnl)
  print(sctIndex)
end

pTbl.sBtn1.OnClick=function()
 if sctIndex==0 then
  print("Not selected page!")
 elseif sctIndex==1 then
  print("Page index: "..sctIndex.."\nPage name: "..sctPnl)
 else
  print("Page index: "..sctIndex.."\nPage name: "..sctPnl)
 end
end


( For those who can't see the picture at first glance! )



ek1.PNG
 Description:
 Filesize:  6.91 KB
 Viewed:  3286 Time(s)

ek1.PNG



_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue May 16, 2023 3:52 pm    Post subject: This post has 1 review(s) Reply with quote

here's the "official" way to do it: (Just stealing some stuff from AylinCE here)

Code:

function loadUrl(link)
  local int=getInternet()
  s=int.getURL(link)
  int.destroy()
  return s
end

function crtPict25(link1)
  logostr22=loadUrl(link1)
  local ss22=createStringStream(logostr22)
  p=createPNG()
  p.loadFromStream(ss22)
  ss22.destroy()
  return p
end

--these pictures are overkill, but ok...
greenboll=crtPict25([[https://i.hizliresim.com/nbeibjw.png]])
redboll=crtPict25([[https://i.hizliresim.com/5fovypg.png]])
blueboll=crtPict25([[https://i.hizliresim.com/foy25pq.png]])
silverboll=crtPict25([[https://i.hizliresim.com/a3ga54z.png]])

local ilist={}
ilist[1]=greenboll
ilist[2]=redboll
ilist[3]=blueboll
ilist[4]=silverboll


DP1=getScreenDPI()/96

f=createForm()
f.Width=DP1*200
f.Height=DP1*200
cb=createComboBox(f)
cb.Items.add('item [b][u]1[/b][/u]')
cb.Items.add('item [b][u]2[/b][/u]')
cb.Items.add('item [b][s]3[/b][/s]')
cb.Style='csOwnerDrawFixed' --fixed height entries
cb.ItemHeight=DP1*32
cb.Width=DP1*190



cb.OnDrawItem=function(sender, index, rect, state)
  grec=rect;
  sender.canvas.brush.Color=(math.random(255) << 16) | (math.random(255) << 8) | math.random(255)
  --sender.canvas.brush.Style='bsSolid'
  sender.canvas.fillRect(rect.Left, rect.Top, rect.Right, rect.Bottom)

  sr={}
  sr.Left=0
  sr.Top=rect.Top
  sr.Right=rect.Bottom-rect.Top
  sr.Bottom=rect.Bottom

  local graphic=ilist[math.random(4)] --pic a random image
  sender.canvas.stretchDraw(sr, graphic)

  sender.canvas.Font.Color=(math.random(255) << 16) | (math.random(255) << 8) | math.random(255)

  sender.canvas.Font.Size=14+math.random(7)
  sender.canvas.textRect(rect,rect.Left+DP1*33,rect.Top,sender.items[index])

 -- printf("index=%d, state=%s",index, state)
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
View user's profile Send private message MSN Messenger
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Tue May 16, 2023 4:21 pm    Post subject: Reply with quote

Corroder wrote:
Use an image list and draw combobox canvas with the images from the image list. Anyhow, I don't know how to do that because I am beginner in CE Lua script. So, this is just a suggestion.

Smile Didn't found examples here or on the CE wiki, only this topic has similar example: Load Image From ImageList. And all this is easier said than done. Even you have created topics and asked questions about ImageList, then I will even more so ask questions. Smile

LeFiXER wrote:
Sometimes we want the answer to the problem, but then you never really learn anything. It would be wise to heed the advice given, try a few things and see the result.

I tried before asking and here is the result: (form with combobox created in the form designer, ComboBox Style property: csOwnerDrawFixed)
Code:
function UDF1_FormActivate(sender)
local ComboBox1 = UDF1.CEComboBox1
  ComboBox1.Items.Clear()
  ComboBox1.Items.Add('Default')
  ComboBox1.Items.Add('Red')
  ComboBox1.Items.Add('Green')
  ComboBox1.Items.Add('Blue')
  ComboBox1.Items.Add('Random Color')
end

function UDF1_CEComboBox1Change(sender)
local ComboBox1 = UDF1.CEComboBox1
  if ComboBox1.ItemIndex == 0 then
    UDF1.Color=clDefault
  elseif ComboBox1.ItemIndex == 1 then
    UDF1.Color=clRed
  elseif ComboBox1.ItemIndex == 2 then
    UDF1.Color=clGreen
  elseif ComboBox1.ItemIndex == 3 then
    UDF1.Color=clBlue
  elseif ComboBox1.ItemIndex == 4 then
    UDF1.Color=math.random(0xffffff)
  end
end

function UDF1_CEComboBox1DrawItem(sender, index, rect, state)
local ComboBox1 = UDF1.CEComboBox1

  ComboBox1.Canvas.fillRect(rect)
ComboBox1.Canvas.textRect(rect, 27, rect.Top, ComboBox1.Items[index])

  ComboBox1.Canvas.Pen.Color=clBlack
      if index == 0 then
        ComboBox1.Canvas.Brush.Color = clDefault
      elseif index == 1 then
        ComboBox1.Canvas.Brush.Color = clRed
      elseif index == 2 then
        ComboBox1.Canvas.Brush.Color = clGreen
      elseif index == 3 then
        ComboBox1.Canvas.Brush.Color = clBlue
      elseif index == 4 then
        ComboBox1.Canvas.Brush.Color = math.random(0xffffff)
      end
ComboBox1.Canvas.ellipse(rect.Left + 4,rect.Top + 1,rect.Left + 15,rect.Bottom - 1)
end

I'm interested in the textRect method in the combo box, because when text is selected in the combo box, the text line under selection disappears and after selection, the text also disappears, screenshots below: (Is this a bug or am I doing something wrong?)

AylinCE wrote:
Here is an idea:
For those who can't see the picture at first glance

Images are not displayed. How to add them? Table-> Add file?
Have you tried the same with the combobox and Style property: csOwnerDrawFixed, does everything display correctly?



1.JPG
 Description:
 Filesize:  8.36 KB
 Viewed:  3217 Time(s)

1.JPG



2.JPG
 Description:
 Filesize:  5.16 KB
 Viewed:  3219 Time(s)

2.JPG


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue May 16, 2023 6:08 pm    Post subject: Reply with quote

you should check if state contains the text "odSelected" and if so draw the background as blue, or adjust the font color. As right now the default font color for selected text is white.

(ComboBox1.Canvas.fillRect(rect) isn't valid, ce lua has no support for this version yet. You have to provide it with x1,y1,x2,y2)

_________________
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
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Tue May 16, 2023 6:13 pm    Post subject: Reply with quote

Razi wrote:
[...

My apologies. I didn't see your attempt before. I hope there are no hard feelings. The code you posted works well for me. Although, the text is almost unreadable in the combobox.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue May 16, 2023 9:21 pm    Post subject: Reply with quote

Quote:
Didn't found examples here or


reference : https://wiki.lazarus.freepascal.org/TComboBox

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Wed May 17, 2023 2:56 am    Post subject: Reply with quote

LeFiXER wrote:
My apologies. I didn't see your attempt before. I hope there are no hard feelings. The code you posted works well for me. Although, the text is almost unreadable in the combobox.

You didn't say anything bad Smile

Dark Byte wrote:
(ComboBox1.Canvas.fillRect(rect) isn't valid, ce lua has no support for this version yet. You have to provide it with x1,y1,x2,y2)

Everything works well, thanks.

Corroder wrote:
reference : https://wiki.lazarus.freepascal.org/TComboBox

Found this example and converted it to lua before creating the topic, but not everything worked well, but now everything works well.

Code:
local ComboBox1 = UDF1.CEComboBox1
  ComboBox1.Items.Clear()
  ComboBox1.Items.Add('Default')
  ComboBox1.Items.Add('Red')
  ComboBox1.Items.Add('Green')
  ComboBox1.Items.Add('Blue')
  ComboBox1.Items.Add('Random Color')

function UDF1_CEComboBox1Change(sender)
--local ComboBox1 = UDF1.CEComboBox1
  if ComboBox1.ItemIndex == 0 then
    UDF1.Color=clDefault
  elseif ComboBox1.ItemIndex == 1 then
    UDF1.Color=clRed
  elseif ComboBox1.ItemIndex == 2 then
    UDF1.Color=clGreen
  elseif ComboBox1.ItemIndex == 3 then
    UDF1.Color=clBlue
  elseif ComboBox1.ItemIndex == 4 then
    UDF1.Color=math.random(0xffffff)
  end
end

  function FillColorfulRect(aCanvas, Left, Top, Right, Bottom)
    for y=Top, Bottom - 1 do
      aCanvas.Pen.Color=math.random(0xffffff)
      aCanvas.line(Left, y, Right, y)
    end
  end

function UDF1_CEComboBox1DrawItem(sender, index, rect, state)
--local ComboBox1 = UDF1.CEComboBox1

  ComboBox1.Canvas.Pen.Color=clBlack
  ComboBox1.Canvas.fillRect(rect.Left,rect.Top,rect.Right,rect.Bottom)
  ComboBox1.Canvas.textRect(rect, 27, rect.Top, ComboBox1.Items[index])

    if index == 4 then
      FillColorfulRect(ComboBox1.Canvas, rect.Left + 1, rect.Top + 1, rect.Left + 19, rect.Bottom - 1)
    else
      if index == 0 then
        ComboBox1.Canvas.Brush.Color = clDefault
      elseif index == 1 then
        ComboBox1.Canvas.Brush.Color = clRed
      elseif index == 2 then
        ComboBox1.Canvas.Brush.Color = clGreen
      elseif index == 3 then
        ComboBox1.Canvas.Brush.Color = clBlue
      end
      ComboBox1.Canvas.ellipse(rect.Left + 4,rect.Top + 1,rect.Left + 15,rect.Bottom - 1)
    end
end

Need to try with ImageList now.
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Wed May 17, 2023 8:42 am    Post subject: Reply with quote

items images ..

Code:
function loadUrl(link)
  local int=getInternet()
  s=int.getURL(link)
  int.destroy()
  return s
end

function crtPict25(link1)
  logostr22=loadUrl(link1)
  local ss22=createStringStream(logostr22)
  p=createPNG()
  p.loadFromStream(ss22)
  ss22.destroy()
  return p
end

--these pictures are overkill, but ok...
greenboll=crtPict25([[https://i.hizliresim.com/nbeibjw.png]])
redboll=crtPict25([[https://i.hizliresim.com/5fovypg.png]])
blueboll=crtPict25([[https://i.hizliresim.com/foy25pq.png]])
silverboll=crtPict25([[https://i.hizliresim.com/a3ga54z.png]])

-- or image load: ( Table >> Add file )
-- silverboll.loadFromStream(findTableFile("your_Image_name.png").stream)
-- blueboll.loadFromStream(findTableFile("your_Image_name.png").stream)
local ilist={}
ilist[1]=redboll
ilist[2]=greenboll
ilist[3]=blueboll
ilist[4]=silverboll

DP1=getScreenDPI()/96

f=createForm()
f.Width=DP1*200
f.Height=DP1*200
cb=createComboBox(f)
cb.Width=DP1*160
cb.left=DP1*20
cb.Font.Size=DP1*12

local ComboBox1 = cb
ComboBox1.Style='csOwnerDrawFixed'
  ComboBox1.Clear()

ComboBox1.OnChange=function(sender)
--local ComboBox1 = UDF1.CEComboBox1
  if ComboBox1.ItemIndex == 0 then
    f.Color=clDefault
  elseif ComboBox1.ItemIndex == 1 then
    f.Color=clRed
  elseif ComboBox1.ItemIndex == 2 then
    f.Color=clGreen
  elseif ComboBox1.ItemIndex == 3 then
    f.Color=clBlue
  elseif ComboBox1.ItemIndex == 4 then
    f.Color=math.random(0xffffff)
  end
end

  function FillColorfulRect(aCanvas, Left, Top, Right, Bottom)
    for y=Top, Bottom - 1 do
      aCanvas.Pen.Color=math.random(0xffffff)
      aCanvas.line(Left, y, Right, y)
    end
  end

 ComboBox1.OnDrawItem=function(sender, index, rect, state)
  ComboBox1.Canvas.Pen.Color=clBlack
  ComboBox1.Canvas.fillRect(rect.Left,rect.Top,rect.Right,rect.Bottom)
  ComboBox1.Canvas.textRect(rect, 27, rect.Top, ComboBox1.Items[index])

sr={}
  sr.Left=4
  sr.Top=rect.Top
  sr.Right=rect.Bottom-rect.Top
  sr.Bottom=rect.Bottom

    if index == 4 then
      FillColorfulRect(ComboBox1.Canvas, rect.Left + 1, rect.Top + 1, rect.Left + 19, rect.Bottom - 1)
    else
      if index == 0 then
      graphic=ilist[4]
      sender.canvas.stretchDraw(sr, graphic)
        --ComboBox1.Canvas.Brush.Color = clDefault
      elseif index == 1 then
      graphic=ilist[1]
      sender.canvas.stretchDraw(sr, graphic)
        --ComboBox1.Canvas.Brush.Color = clRed
      elseif index == 2 then
      graphic=ilist[2]
      sender.canvas.stretchDraw(sr, graphic)
        --ComboBox1.Canvas.Brush.Color = clGreen
      elseif index == 3 then
      graphic=ilist[3]
      sender.canvas.stretchDraw(sr, graphic)
        --ComboBox1.Canvas.Brush.Color = clBlue
      end
      --ComboBox1.Canvas.ellipse(rect.Left + 4,rect.Top + 1,rect.Left + 15,rect.Bottom - 1)
    end
end

  ComboBox1.Items.Add('Default')
  ComboBox1.Items.Add('Red')
  ComboBox1.Items.Add('Green')
  ComboBox1.Items.Add('Blue')
  ComboBox1.Items.Add('Random Color')



ek1.PNG
 Description:
 Filesize:  3.25 KB
 Viewed:  3026 Time(s)

ek1.PNG



_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Wed May 17, 2023 9:41 am    Post subject: Reply with quote

Razi wrote:
Now need to try with ImageList.


I was able to use an imagelist quite successfully,
Code:

local bmpPic = createBitmap(12,12) -- 12,12 are the width/height parameters
bmpPic.PixelFormat = 'pf8bit'
--bmpPic.Canvas.gradientFill(0, 0, 12, 12, 0x0000FF, 0x000055, 0) -- In case you want to create a gradient bitmap programmatically, also works.
bmpPic.loadFromFile(path_to_bitmap_file)
bmpPic.TransparentColor = 0xFF00FF -- Magenta 255,0,255 is the transparent colour
bmpPic.Transparent = true

local imgList = createImageList()
imgList.add(bmpPic)


In the combobox OnDrawItem event function:
Code:

cb.OnDrawItem = function(sender, index, rect, state)
                            sender.Canvas.fillRect(rect)
                            il.draw(sender.Canvas, rect.Left + 1, rect.Top + 1, 0)
                            sender.Canvas.textRect(rect, rect.Left + il.width + 3, rect.Top + 1, sender.Items[index])
                          end
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Wed May 17, 2023 11:24 am    Post subject: Reply with quote

( Try my last code above. It is the ultimate blending. )

I guess Dark Byte's image insertion code is better.
Code:
 blueboll.loadFromStream(findTableFile("your_Image_name.png").stream)

 ComboBox1.OnDrawItem=function(sender, index, rect, state)
  sr={}
  sr.Left=4
  sr.Top=rect.Top
  sr.Right=rect.Bottom-rect.Top
  sr.Bottom=rect.Bottom

      if index == 0 then
       graphic=blueboll --ilist[4]
       sender.canvas.stretchDraw(sr, graphic)
      end
 end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Wed May 17, 2023 5:31 pm    Post subject: Reply with quote

AylinCE wrote:
( Try my last code above. It is the ultimate blending. )

It works with image load: ( Table -> Add file )
It does not work with links, most likely because my default browser (Chrome v.49) does not see these images.
I will try to optimize the code to reduce the number of lines and make the code more understandable for beginners.
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
Goto page 1, 2  Next
Page 1 of 2

 
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