|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Thu Jun 08, 2017 5:47 am Post subject: CE6.7 - OnCustomDraw and OnPaint event? |
|
|
How to use OnCustomDraw and OnPaint? Can anyone provide some examples? Thanks.
_________________
**************
A simple example is better then ten links. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Thu Jun 08, 2017 6:39 am Post subject: |
|
|
OnPaint gets called whenever something gets painted. You can do that to do some of your own painting with the canvas. E.g draw some line, a picture, some text, just a few pixels, up to you
OnCustomDraw:
Code: |
OnCustomDraw: function(Sender, {Top, Left, Bottom, Right}, DefaultDraw Optional): NewDefaultDraw
OnCustomDrawItem: function(Sender, ListItem, {cdsSelected=true/false(nil), cdsGrayed=true/false(nil), cdsDisabled, cdsChecked, cdsFocused, cdsDefault, cdsHot, cdsMarked, cdsIndeterminate}, DefaultDraw Optional): NewDefaultDraw
OnCustomDrawSubItem: function(Sender, ListItem, SubItemIndex, {cdsSelected=true/false(nil), cdsGrayed=true/false(nil), cdsDisabled, cdsChecked, cdsFocused, cdsDefault, cdsHot, cdsMarked, cdsIndeterminate}, DefaultDraw Optional): NewDefaultDraw
|
These get called when the listview is about to draw a line.
the DrawItem is for the main item, DrawSubItem for the secondary items
You can then draw your own text in the listview, like adding images, or what not and then return false to tell it not to draw,
or what is likely more common, just change the canvas's font color to something else, and then return true to let the normal drawing happen, but then with a modified color
if I get time i'll make an example
_________________
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 |
|
|
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Thu Jun 08, 2017 7:38 am Post subject: |
|
|
Dark Byte wrote: | OnPaint gets called whenever something gets painted. You can do that to do some of your own painting with the canvas. E.g draw some line, a picture, some text, just a few pixels, up to you
OnCustomDraw:
Code: |
OnCustomDraw: function(Sender, {Top, Left, Bottom, Right}, DefaultDraw Optional): NewDefaultDraw
OnCustomDrawItem: function(Sender, ListItem, {cdsSelected=true/false(nil), cdsGrayed=true/false(nil), cdsDisabled, cdsChecked, cdsFocused, cdsDefault, cdsHot, cdsMarked, cdsIndeterminate}, DefaultDraw Optional): NewDefaultDraw
OnCustomDrawSubItem: function(Sender, ListItem, SubItemIndex, {cdsSelected=true/false(nil), cdsGrayed=true/false(nil), cdsDisabled, cdsChecked, cdsFocused, cdsDefault, cdsHot, cdsMarked, cdsIndeterminate}, DefaultDraw Optional): NewDefaultDraw
|
These get called when the listview is about to draw a line.
the DrawItem is for the main item, DrawSubItem for the secondary items
You can then draw your own text in the listview, like adding images, or what not and then return false to tell it not to draw,
or what is likely more common, just change the canvas's font color to something else, and then return true to let the normal drawing happen, but then with a modified color
if I get time i'll make an example |
Thanks. I would love an example about colored texts in listview.
_________________
**************
A simple example is better then ten links. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Thu Jun 08, 2017 7:47 am Post subject: |
|
|
maybe you'll like this then
Code: |
s=createForm()
lv=createListView(s)
lv.ViewStyle='vsReport'
lv.RowSelect=true
lv.HideSelection=false
c=lv.Columns.add()
c.Caption='C1';
c=lv.Columns.add()
c.Caption='C2';
c=lv.Columns.add()
c.Caption='C3';
for i=1,10 do
l=lv.Items.add()
l.Caption='bla'..i;
l.SubItems.add('line '..i)
l.SubItems.add('i*2='..i*2)
end
lv.OnCustomDrawItem=function(sender, ListItem, state, DefaultDraw)
if ListItem.Index % 2 == 0 then
sender.canvas.font.color=0x0000ff
else
sender.canvas.font.color=0x00ff00
end
return true
end
lv.OnCustomDrawSubItem=function(sender, ListItem, SubItemIndex, state, DefaultDraw)
if ListItem.Index % 3 == 0 then
if SubItemIndex % 2 == 0 then
sender.canvas.font.color=0xff0000
else
sender.canvas.font.color=0x00ffff
end
else
sender.canvas.font.color=0xffff00
end
return true
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 |
|
|
Dr.Disrespect Grandmaster Cheater Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Thu Jun 08, 2017 8:18 am Post subject: |
|
|
Dark Byte wrote: | maybe you'll like this then
Code: |
s=createForm()
lv=createListView(s)
lv.ViewStyle='vsReport'
lv.RowSelect=true
lv.HideSelection=false
c=lv.Columns.add()
c.Caption='C1';
c=lv.Columns.add()
c.Caption='C2';
c=lv.Columns.add()
c.Caption='C3';
for i=1,10 do
l=lv.Items.add()
l.Caption='bla'..i;
l.SubItems.add('line '..i)
l.SubItems.add('i*2='..i*2)
end
lv.OnCustomDrawItem=function(sender, ListItem, state, DefaultDraw)
if ListItem.Index % 2 == 0 then
sender.canvas.font.color=0x0000ff
else
sender.canvas.font.color=0x00ff00
end
return true
end
lv.OnCustomDrawSubItem=function(sender, ListItem, SubItemIndex, state, DefaultDraw)
if ListItem.Index % 3 == 0 then
if SubItemIndex % 2 == 0 then
sender.canvas.font.color=0xff0000
else
sender.canvas.font.color=0x00ffff
end
else
sender.canvas.font.color=0xffff00
end
return true
end
|
|
Thanks, DB! It works like a charm.
Edit:
Is it possible to only paint the text of a single cell?
_________________
**************
A simple example is better then ten links. |
|
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
|
|