Recent

Author Topic: Form problem  (Read 12942 times)

user5

  • Sr. Member
  • ****
  • Posts: 419
Form problem
« on: April 09, 2015, 06:41:25 am »
This is a simple question but I don't know the answer and I need help.

When I click on the top border of my form, all the action that's taking place on the form pauses until I release the left mouse button.

Is there a way to stop this from happening?

munair

  • Hero Member
  • *****
  • Posts: 887
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Form problem
« Reply #1 on: April 09, 2015, 07:40:49 am »
Release the mouse button...
It's only logical.

user5

  • Sr. Member
  • ****
  • Posts: 419
Re: Form problem
« Reply #2 on: April 10, 2015, 02:05:25 am »
Your answer was rather specious and sarcastic. I wasn't asking how to temporarily allow the action on the form to resume, I was asking how to prevent the problem in the first place. My form displays a waveform and a needle that moves across the waveform as the sound file of that waveform plays.

It would be rather irritating to the user if the needle stops when he or she merely clicks on the top border while the sound file continues to play. Releasing the mouse button does allow the needle to continue but by then the sound file has finished and the damage has been done.

The only poor solution I've found is to temporarily not show the border but then the user can't move the form. When I play Windows Media Player, I can move its form around while the Blue Danube plays and that movement has no effect on the moving trackbar.

Don't get me wrong, I love Lazarus but if I can't get that quality with Lazarus then just say so. Art McGinnis

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Form problem
« Reply #3 on: April 10, 2015, 02:25:57 am »
Is the problem only with the waveform or with other animated controls?

I don't have Windows, I'm on Linux. I made a simple test with TTimer and TProgressBar. TTimer with interval 100ms increases Position of ProgressBar by one which make a animation. If I click a top border and move the form, animation goes on, it's not interrupted.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

lainz

  • Hero Member
  • *****
  • Posts: 4742
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: Form problem
« Reply #4 on: April 10, 2015, 02:44:10 am »
AFAIK Windows always worked that way. I'm running firefox just now writing this text and if I press the title bar all the emoticon animations are stopped.

WMP maybe is using a hack or something.

Signal

  • New Member
  • *
  • Posts: 41
Re: Form problem
« Reply #5 on: April 10, 2015, 02:56:46 am »
And I can confirm Blazzen's post regarding Linux. I have a similar test setup that runs a vertical line across a form driven by a 5 ms timer. Clicking on the form's title bar has no effect.

user5

  • Sr. Member
  • ****
  • Posts: 419
Re: Form problem
« Reply #6 on: April 10, 2015, 04:33:51 am »
Thanks for your inputs. I always appreciate helpful comments and I plan to continue using the great platform of Lazarus.

Before I incorporated my recent code, I was using TTimer to drive the needle and blaazen, you are quite correct that moving the form has no effect on the needle when using TTimer but I have found TTimer to be a bit inaccurate and the needle is unsurprisingly slowed down when running my program at the same time that another media program is running.

This means that I would have to have some kind of real time process that corrected the slowdown. With TTimer I do have a calibration menu selection that allows the user to recalibrate and speed up the needle if necessary but this is rather cumbersome so I recently wrote some code using GetTickCount instead of TTimer.

This new stuff is great in that it runs well even if other programs are running but it does present the problem of the needle stopping when the title bar is clicked on, no matter what waveform is showing, to answer your question. My next new subject post will have a question or two about GetTickCount.

I suppose all this is due to the fact that TTimer is an integral part of Lazarus while my code using GetTickCount is not but if I could find a way to solve this problem then I could have my cake and eat it too. Thanx.

user5

  • Sr. Member
  • ****
  • Posts: 419
Re: Form problem
« Reply #7 on: April 10, 2015, 05:09:17 am »
Just another comment about TTimer to explain my problems with it. I couldn't get TTimer to respond appropriately to the interval settings that I chose. No matter what intervals I chose, it either ran too fast or too slow so I eventually had to settle for the too-fast result, which meant that I had to then use a set of five slightly different delays to slow it down. While overall this resulted in a needle that ended up more or less where it should be, the needle was erratic and jerky as it moved over the waveform while the GetTickCount needle is perfectly smooth.

sam707

  • Guest
Re: Form problem
« Reply #8 on: April 10, 2015, 06:35:08 am »
http://wiki.freepascal.org/EpikTimer

might helps

Nanosecond resolution is supported on Intel Pentium versions with a Timestamp Counter.
Microsecond system clock is the default timebase.
« Last Edit: April 10, 2015, 06:38:53 am by sam707 »

user5

  • Sr. Member
  • ****
  • Posts: 419
Re: Form problem
« Reply #9 on: April 10, 2015, 07:01:13 am »
Thank you sam707. I've heard of the epiktimer but I've never used it. I don't have any other options right now so I guess that I'll have to try it if I can figure out how to use it. Thanks.

user5

  • Sr. Member
  • ****
  • Posts: 419
Re: Form problem
« Reply #10 on: April 10, 2015, 08:26:03 am »
I couldn't get the epiktimer component to install correctly.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Form problem
« Reply #11 on: April 10, 2015, 10:07:27 am »
Have you tried putting the code that updates the needle/waveform display in a separate thread from the main form's thread (the message processing controlled by the Application object)?

Graeme

  • Hero Member
  • *****
  • Posts: 1526
    • Graeme on the web
Re: Form problem
« Reply #12 on: April 10, 2015, 10:52:08 am »
I couldn't get the epiktimer component to install correctly.
What error do you get?

Use the latest EpikTimer from the code repository. Also, you don't need to "install" EpikTimer to use it. Simply add the path to the epiktimer.pas unit to your project, add the unit to the uses clause and instantiate an instance of TEpikTimer. Done.


Code: [Select]
  // field variable in your form or somewhere else
  FTimer: TEpikTimer;

  // somewhere in the startup code (eg: OnFormCreate)
  FTimer := TEpikTimer.Create(self);

  // use it!
  FTimer.Start;
  // do something to be timer
  FTimer.Stop;

For more details on usage, installation, code repository etc.
http://wiki.lazarus.freepascal.org/EpikTimer


On a side note:
EpikTimer is a component to do fine-grain timing  (elapsed time, stopwatch etc). It is not the same as TTimer which triggers an OnTimer event every x milliseconds.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

munair

  • Hero Member
  • *****
  • Posts: 887
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Form problem
« Reply #13 on: April 10, 2015, 10:56:31 am »
I didn't mean to be sarcastic. In your reply you were a lot more specific.
It's only logical.

Graeme

  • Hero Member
  • *****
  • Posts: 1526
    • Graeme on the web
Re: Form problem
« Reply #14 on: April 10, 2015, 11:08:58 am »
When I click on the top border of my form, all the action that's taking place on the form pauses until I release the left mouse button.
It might be a bug in LCL then. I just tested with fpGUI Toolkit under Windows 2000. I ran the fpGUI Sprite demo (\fpgui\examples\gui\sprites\) which is an alien ship flying around inside a window. I can drag the window around by clicking on the title bar and the animation still continues as normal.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

 

TinyPortal © 2005-2018