Recent

Author Topic: How do you make this go?  (Read 1386 times)

TRon

  • Hero Member
  • *****
  • Posts: 535
Re: How do you make this go?
« Reply #15 on: August 10, 2020, 02:27:47 am »
I think the issue is that you need a Picture loaded of the same size as the drawing surface to start with.
 Without this there is no drawing surface size.. the Canvas has none...
I can't recall that ever being a requirement on windows.... (Delphi to be specific).

however...
Quote
I just set the Picture.Bitmap.SetSize(Width,Height); in the FormOnCreate and that creates a black background image.
... that seem to be the trick.

Quote
Then the OnPaint seems to be getting called..
Indeed, I am able to confirm.... and only once (instead of twice)  :)

Thank you jamie !

jamie

  • Hero Member
  • *****
  • Posts: 3507
Re: How do you make this go?
« Reply #16 on: August 10, 2020, 02:39:35 am »
That's no problem..

Hey, I don't drink that much but I do play a lot of tennis so if you are ever in this area I can show you how I bang my balls around!  :)
The only true wisdom is knowing you know nothing

TRon

  • Hero Member
  • *****
  • Posts: 535
Re: How do you make this go?
« Reply #17 on: August 10, 2020, 02:42:58 am »
Hey, I don't drink that much but I do play a lot of tennis so if you are ever in this area I can show you how I bang my balls around!  :)
Nutbush ?  :D

TRon

  • Hero Member
  • *****
  • Posts: 535
Re: How do you make this go?
« Reply #18 on: August 10, 2020, 02:47:14 am »
@JLWest:
In case you have experienced the same issue that I had, then you can 'fix' that by changing your FormCreate event to read:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height);
  4.   Timer1Timer(Nil);
  5. end;

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: How do you make this go?
« Reply #19 on: August 10, 2020, 04:50:20 am »
I get a black box.

Image is 90X90
Timer is enabled and set to 1000
OnTimer event is set to Timer1Timer

Changed OnCreate to
    Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height);
   Timer1Timer(Nil);
 
                                     
Just a black box is all I get.

FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

TRon

  • Hero Member
  • *****
  • Posts: 535
Re: How do you make this go?
« Reply #20 on: August 10, 2020, 04:57:16 am »
@JLWest
Could you post your project .lfm file ?

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: How do you make this go?
« Reply #21 on: August 10, 2020, 05:03:18 am »
@Winni Because  you only gave me a png of the butt ugliest clock in the world I guess I'll have to make i,440 copies of it with the hands covering a 24hr period and just go thru a giant if statement.

if Now := l2:01 then begin
  Clock1200.visible := False;
  Clock1201.Visible := True;
ect.
ect..
end if;

Hi!

I don't know what you gonna do.
Are some procedures  not connected to some events?

The code is part of my  self made alarm clock and it works since years.
Exact the way it is shown by me an JLWest.
And it survided fpc and Lazarus updates.

Just made a screenshot to convince you.
No PaintBox, no update - just as I wrote it.

Winni
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: How do you make this go?
« Reply #22 on: August 10, 2020, 05:04:46 am »
@JLWest
Could you post your project .lfm file ?

Yea, As soon as I make 1239  copies of winni's clock.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: How do you make this go?
« Reply #23 on: August 10, 2020, 05:08:09 am »
Here you go.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

TRon

  • Hero Member
  • *****
  • Posts: 535
Re: How do you make this go?
« Reply #24 on: August 10, 2020, 05:09:43 am »
Yea, As soon as I make 1239  copies of winni's clock.
I am focusing on the code you showed. That draws a hour, minutes and seconds line using different colours.

There is no need for (additional) images in order for that code to work. It is however a small image, and is using some odd colours.

It is about the basic principle of calculating the positions and drawing of the clock-hands.

I even got it working in transparency mode now, so we should be able to get it working for you as well.

TRon

  • Hero Member
  • *****
  • Posts: 535
Re: How do you make this go?
« Reply #25 on: August 10, 2020, 05:14:09 am »
Here you go.
1. Open your project
2. click on the image, so that it gets selected in the object inspector.
3. in the object inspector, click on the events tab
4. search for the event OnPaint
5. double click the event, a new event will be added to your code
6. copy your code from your (old) function Image1Paint into the new event function
7. remove the old image1paint code/function
8. save your project
9. compile and run your project

Does it now work for you ?


JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: How do you make this go?
« Reply #26 on: August 10, 2020, 05:51:22 am »
I got a black box with 3 green dots.I can't tell if anything is moving. Maybe.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

TRon

  • Hero Member
  • *****
  • Posts: 535
Re: How do you make this go?
« Reply #27 on: August 10, 2020, 05:55:09 am »
Good, we are getting there  :)

There is something moving but I do not blame in case you are unable to see that properly. The seconds clock-hand is a single line of pixels (one pixel width) in red.

I've attached my project that increases the size of the clock a little, still using a single pixel width line for the seconds clock-hand though.

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: How do you make this go?
« Reply #28 on: August 10, 2020, 06:01:00 am »
Yea, got it.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

JLWest

  • Hero Member
  • *****
  • Posts: 845
Re: How do you make this go?
« Reply #29 on: August 10, 2020, 06:10:45 am »
TRon, it's not to bad. The clock without a frame.

Ok here is what I will do.

Create a listbox and put about 20 airport records in the listbox.

Then I'll post it on my GDrive.

and give you, winni and handako a link.

Have you read the other post where handako has a working prototye of a clock.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

 

TinyPortal © 2005-2018