?
Solved

How to get the cursor to hide and show as in Windows Media Player?

Posted on 2003-02-26
7
Medium Priority
?
239 Views
Last Modified: 2010-04-04
Hi...

I want to know how it's possible to hide the cursor, show it when the mouse is moved for 3 seconds and then hide it again. Exactly as in the Windows Media Player Full screen mode...

thanks in advance,
Kees van Bemmel.
0
Comment
Question by:wim11
6 Comments
 
LVL 4

Accepted Solution

by:
cjm30305 earned 300 total points
ID: 8027990
Create a form with a button on it.  Do not name anything and copy this code into your Unit file.  The single button will inherit the default property when you click the enter key.  Cheers mate.

// Begin code..
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Mouse: TCursor;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormShow(Sender: TObject);
begin
  Form1.WindowState := wsMaximized;
  Mouse := Screen.Cursor;
  Screen.Cursor := crNone;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Screen.Cursor := Mouse;
end;

end.
// EOF
0
 
LVL 1

Expert Comment

by:keashF
ID: 8028037
use the Windows API function

showcursor( show : boolean )

to show or hide the mouse cursor.

what you do next depends on where you want to track the mouse cursor:

*) on one of your forms you can use the onmousemove event and use gettickcount (returns the number of milliseconds the computer is running) to save the time. perhaps a timer will also do it...

*) if you ant to capture the mouse input systemwide you'll have to install a mouse hook using SetWindowsHookEx there are already threads about how to do this...

cu
keashF
0
 
LVL 4

Expert Comment

by:cjm30305
ID: 8028039
Sorry here you go mate.  Add a timer instead of a button.

// Begin code...
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    procedure FormShow(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Mouse: TCursor;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormShow(Sender: TObject);
begin
  Form1.WindowState := wsMaximized;
  Mouse := Screen.Cursor;
  Screen.Cursor := crNone;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Screen.Cursor := Mouse;
  Timer1.Interval := 3000;
  Timer1.Enabled := True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Enabled := False;
  Screen.Cursor := crNone;
end;

end.

// EOF

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:luisseixas
ID: 8028712
 Place a timer on your form.
  Every time the mouse moves, make time=0 and cursor:=YourCursor;
  When times=3000 (means your mouse doesn't move for 3 seconds), make cursor:=crNone;
0
 

Expert Comment

by:CleanupPing
ID: 9317050
wim11:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 10

Expert Comment

by:kacor
ID: 9981542
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to accept cjm30305's answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question