Updating XDev's "Cross Platform Printing Example" graphics

I am trying to learn printing and a couple of articles in Xdev issue 7.4 in 2009 caught my eye.
It uses some old style graphics.
ColorButton is a Canvas
In the TextField.Selchange event there is this if statement

if me.SelTextColor<>ColorButton.graphics.foreColor then
  ColorButton.Graphics.ForeColor=me.SelTextColor
  ColorButton.Graphics.FillRect(1,1,colorButton.Graphics.Width-2,colorButton.Graphics.Height-2)
end if

The first line has a comparison of SelTextColor to foreColor or updated drawingcolor.

How can I do this comparison in 2022 code?

The next 2 line change colors on the button and should be done in the paint event. Is there another way than having a boolean to change the colors, like some extra event

This topic has advice on how to update old graphics code:

Updating code that used the Graphics property

In general you want to be using the Paint event on ColorButton to do the drawing. Perhaps add a computed property for the ForeColor and when it changes call Refresh to tell the Paint event to redraw things.