LCD Control

I’ve been lookin for easy way to embed font to project because I want to make LCD panel lookalike. Since that was not possible I decide to make LCD control. Well, try to make. Because I’m no professional coder, my code is propably as bad as my english. But anyway, I’m going to make it public now and show the world my skill level as coder. Please be gentle with me :slight_smile:
In mac and linux this works fine, but in windows it flickers. If I make it use GDI+ it looks nicer, but flickers more.
Please tell me what I’m doing totally wrong and how I should do it better.
So here it is:
Sample codes open-event has pretty much every property You can change. And slider change value.


very nice actually :slight_smile:

just try it out… very cool indeed…

Hello @Jukka Leino

I believe I can help you fix the flickering on Windows.
However I can’t access Dropbox because it is blocked here at my work.

Would you mind sending the project by email to



What I would suggest is changing Value to a computed property. Move the drawing code from paint to a new method (ie CCLcd.render). In that method, draw into a buffer picture (ie CCLcd.bufferImage) rather than the control’s graphics. At the end of that method, call me.invalidate. In the paint event just draw the buffer to g. I believe that will fix your flicker. Then you can also call the render method from anywhere the display will change BackColor.set Scale.set etc… Also then you will not need to call invalidate when you change a value from outside (ie slider.ValueChanged)

Looks very nice btw.

I could see this in an audio mixing console app or the like.

I changed as suggested. I didn’t understand everything but anyway, it draws not to buffer, and paint use buffer. I also made methods that change properties, I don’t know if that was wise. And I don’t know what exactly is that computed property, but seemd to work :slight_smile:
And, btw. one thing I do not understand, what is difference between self and me.
Windows still flickers…

if u r in a window with controls, ‘me’ referring to the current control and ‘self’ referring to windows unless u r in the event handler in the window, then me is the same as self.

I like this a lot! Great work Jukka :slight_smile:

I did some modification here… Moved it to a canvas and changed the digits to strings… that allowed me to add a - for negative values. You could also add decimal points for floating point numbers. I turned on doublebuffer and am seeing no flicker in win32. If you need the embedwithin functionality, you could make a container and just add the canvas to it. Otherwise you could create instances in code via control arrays. There are some minor tweaks… I didn’t comment as I made changes though :-/

just notice on the new version, resize didn’t do anything on Mac OSX Mavericks. But i do notice the white/grey canvas behind the lower right corner LCD does not show up anymore

Actually a better way in my canvas based version would be to add an open event handler with

#if TargetWin32 then me.DoubleBuffer=true #else me.DoubleBuffer=false #endif

Than way you don’t get the grey edge under OSX

Pretty much same as Jrmie Leroy told me to do :slight_smile:
I changed also to Canvas Class since it was ContainerControl that cause flicker in windows.
but I didn’t know how to make resize with that.
here what I did:
Thank You very much, I’ll read your code and learn by it!


Pretty cool that it extends digits!
Can You please comment this somehow, I’m totally lost here: :slight_smile:

if RenderedImage=nil or RenderedImage.Width<>round(Digits*148*scale) or RenderedImage.Height<>me.Height then RenderedImage=new Picture(Digits*148*scale,me.Height,32) end if


Make sure if you use invalidate or refresh you pass false as you don’t want to erase the background each time (which can also cause flicker on Windows).

me.invalidate( false )


Thanks to Jim and Jrmie. I now have LCD Panel lookalike that is Flicker free in windows also.
I changed Jims code so that if I put digitcount, it’s not dynamic, otherwise it is.
I also try to add some error if value don’t fit to digits.
Learned a lot and still learning!
Thanks again and have fun with lcd panel :slight_smile:


[quote=49968:@Jukka Leino]retty cool that it extends digits!
Can You please comment this somehow, I’m totally lost here: :slight_smile:

if RenderedImage=nil or RenderedImage.Width<>round(Digits148scale) or RenderedImage.Height<>me.Height then
RenderedImage=new Picture(Digits148scale,me.Height,32)
end if


Sure, this is just a check to make sure that the drawing buffer (RenderedImage) exists and that if it exists it is the correct size for the drawing we need. Otherwise it creates a new image at the needed dimensions.

Ok, Thanks.
Btw, there is now dots also in LCD panel, just have to figure out how to move ForeColorOff to ForeColorOn…

Hi, again.
Value is now Double and it supports decimals. I’m on fire!

[quote=50167:@Jukka Leino]Hi, again.
Value is now Double and it supports decimals. I’m on fire![/quote]

Love the enthusiasm :slight_smile:

Nice control too!

Well done Jukka, looks great.