Recent

Author Topic: Porting TAnalogMeter v.2.12  (Read 9977 times)

henk86

  • New member
  • *
  • Posts: 8
Porting TAnalogMeter v.2.12
« on: January 29, 2014, 03:14:09 am »
Hi,
I ported this component with the tool "convert delphi unit to lazarus unit". If I drop this component on a form it shows up blank, back ground color. If I resize the component it becomes visible. If I run the program it is again not visible. I can solve this by resizing it by the program.
Besides this the component works well.
I use Lazarus 1.2RC2.

Anybody any idea?

the component can be found here: http://www.torry.net/pages.php?id=502

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Porting TAnalogMeter v.2.12
« Reply #1 on: January 29, 2014, 04:27:42 am »
1) there is an analogwhatever already in lcl it will come out along with lazarus 1.2 its in the industrial package.
2) with out any code its impossible to tell what is wrong.

I assume that it has to do with the default background color which is cldefault by default, in that case just set the parentcolor to true and see what happens or it overrides the erasebackground handler and draws nothing in which case lcl will draw a black background for some reason make sure that you call inherited in there or remove it.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

henk86

  • New member
  • *
  • Posts: 8
Re: Porting TAnalogMeter v.2.12
« Reply #2 on: January 29, 2014, 05:00:36 am »
Hi taazz,
1) I was aware of this component but the one I ported is more suited for what I need.
2) Added the code.

Parent color was already true and changing it to false doesn't change the behavior. Before resize the component is completely invisible, same color as background. Only in design mode it hides the dots.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Porting TAnalogMeter v.2.12
« Reply #3 on: January 29, 2014, 05:43:22 am »
its a pain. It doesn't respect any of the rules of widget painting it needs a lot of work before I can see where the problem is. The problem is that it calls all those drawXXXXXXface clearXXXXface and paint procedures outside the paint process making it impossible to know where the problem is exactly. For starters try to avoid calling those directly replace those calls with a call to invalidate, after that make sure that drawxxxxxFace and friends are called correctly when they are needed and see if that solves the problem. I'll take a closer look later today after I have made those changes my self too.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

henk86

  • New member
  • *
  • Posts: 8
Re: Porting TAnalogMeter v.2.12
« Reply #4 on: January 29, 2014, 06:31:23 am »
taazz,

Thank you for the quick response, I was hoping for a more simple solution. I'm programming only as a hobby but I'll try if I can do something with your remarks.
I agree the code is a pain.

added the lpi file.


taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Porting TAnalogMeter v.2.12
« Reply #5 on: January 29, 2014, 09:30:03 pm »
OK, spend some time on it there where a few changes but nothing as extreme as I was expecting. The author is using internally bitmaps to do all the drawing and then bitblt it to the controls DC that made things easier, everything seems to work for me you should try it and see if it works for your needs too. It does require a bit of clean up but I'm going to stop here for now.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

henk86

  • New member
  • *
  • Posts: 8
Re: Porting TAnalogMeter v.2.12
« Reply #6 on: January 30, 2014, 05:35:08 am »
Thank you for your time it works like a charm.
I did find another annoying fault in it, when I set "ShowTicksScale" to true it didn't show up in runtime. This properly because the default was set to false while the property's default was true.

With clean up do you mean the syntax or the code or both?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Porting TAnalogMeter v.2.12
« Reply #7 on: January 30, 2014, 05:47:17 am »
I don't know what you mean by "the syntax" but when I say clean up I mean the code for example WMSize has only a call to inherited as it is so just delete it completely, it will be faster, the default and "true default" discrepancy you just found for ShowTicksScale is an other example of code clean up. You just have to make sure that no unnecessary code is left over from the delphi version and all t are crossed and the i are dotted etc, you know, the smaller details that change nothing in the existing feature list but it will make it more stable or even faster in some occasions. And then you have to make sure that the code is formatted similar with the rest of your libraries so it doesn't look out of place.
« Last Edit: January 30, 2014, 05:51:10 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

henk86

  • New member
  • *
  • Posts: 8
Re: Porting TAnalogMeter v.2.12
« Reply #8 on: January 30, 2014, 06:03:37 am »
Understood, I'll have a close look at it and post it back when finished.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Porting TAnalogMeter v.2.12
« Reply #9 on: January 30, 2014, 09:20:25 am »
Lines 873-874 and 878-880 referring to vColor can be removed.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Porting TAnalogMeter v.2.12
« Reply #10 on: January 30, 2014, 09:23:05 am »
oops my bad those are debug left overs from me just remove them.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

henk86

  • New member
  • *
  • Posts: 8
Re: Porting TAnalogMeter v.2.12
« Reply #11 on: February 01, 2014, 03:43:20 am »
Cleaned up.
Removed some unnecessary code and comments.
It compiles now without warnings.

 

TinyPortal © 2005-2018