* * *

Author Topic: [SOLVED]InitMouse results huge CPU load when -WG is enabled  (Read 1264 times)

CM630

  • Hero Member
  • *****
  • Posts: 795
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
[SOLVED]InitMouse results huge CPU load when -WG is enabled
« on: January 12, 2018, 03:10:51 pm »
I just found that an app of mine eats 25% of the CPU when Win32 GUI application (-WG) is marked in Options for Projects.
This happens when my app is doing nothing.
I unchecked -WG and CPU usage dropped to 0%.
I found that I have InitMouse; in   .FormCreate(Sender: TObject); After removing it and with -WG checked CPU usage stays low.
This happens in Lazarus 1.8.0, win 7.

Is it me doing something wrong and how am I to cure this?
« Last Edit: January 16, 2018, 02:01:10 pm by CM630 »
Лазар 1,8,0;W7 64bit or XP 32bit;FPC3,0,4;rev 56594

jamie

  • Hero Member
  • *****
  • Posts: 651
Re: InitMouse results huge CPU load when -WG is enabled
« Reply #1 on: January 12, 2018, 11:43:32 pm »
I have never heard of that mouse call...

 Just leave it out, it must be part of some old code you didn't remove?

molly

  • Hero Member
  • *****
  • Posts: 2343
Re: InitMouse results huge CPU load when -WG is enabled
« Reply #2 on: January 12, 2018, 11:58:17 pm »
If it concerns this initmouse then please remove it.

It is to be used for console applications, and only when you require mouse functionality, from overview unit mouse:
Quote
The Mouse unit implements a platform independent mouse handling interface. It is implemented identically on all platforms supported by Free Pascal and can be enhanced with custom drivers, should this be needed. It is intended to be used only in text-based screens, for instance in conjunction with the keyboard and video unit. No support for graphical screens is implemented, and there are (currently) no plans to implement this.

CM630

  • Hero Member
  • *****
  • Posts: 795
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: InitMouse results huge CPU load when -WG is enabled
« Reply #3 on: January 15, 2018, 02:44:44 pm »
It is me who put InitMouse in the code, but I do not remember why and when. Probably, because it is shown in this Wiki example. Now I did remove it when -WG=False.
Thanks!
« Last Edit: January 15, 2018, 02:47:18 pm by CM630 »
Лазар 1,8,0;W7 64bit or XP 32bit;FPC3,0,4;rev 56594

molly

  • Hero Member
  • *****
  • Posts: 2343
Re: InitMouse results huge CPU load when -WG is enabled
« Reply #4 on: January 15, 2018, 03:34:55 pm »
It's pretty simple:
If you require to receive the mouse character coordinates from the console window inside your Lazarus application then you would call InitMouse/DoneMouse and in case you do not use the console window for user-interaction then the use of this unit (and corresponding mouse functionality) is pretty much useless.

Don't confuse Lazarus with text-mode console. Lazarus has it's own methods to receive mouse coordinates  :)

CM630

  • Hero Member
  • *****
  • Posts: 795
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: [SOLVED]InitMouse results huge CPU load when -WG is enabled
« Reply #5 on: January 16, 2018, 02:02:41 pm »
Thanks.
If something starts making troubles I will seek for other LazRoutines. I suppose I was looking to find out position of the mouse on the entire screen...
Лазар 1,8,0;W7 64bit or XP 32bit;FPC3,0,4;rev 56594

Thaddy

  • Hero Member
  • *****
  • Posts: 5786
Re: [SOLVED]InitMouse results huge CPU load when -WG is enabled
« Reply #6 on: January 16, 2018, 04:08:04 pm »
Thanks.
If something starts making troubles I will seek for other LazRoutines. I suppose I was looking to find out position of the mouse on the entire screen...
Which is very easy and many answers have been given on this forum in the past. (for win32)
recommends {$macro on}{$define Silly:=ObjFpc}

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus