Board index » delphi » Screen Savers: Screen as BMP / MouseMove event

Screen Savers: Screen as BMP / MouseMove event

Being amazed at how good Delphi is at diverse types of Windows
programs, I decided to try and write a screen saver, but have one
problem and one question:

The Question:
How do I retrieve the image of the whole screen (the desktop) and put
it in a TBitmap so that I can do all sorts of weird and wonderful
things with it?

The Problem:
I've trapped the OnMouseClick event to Close the app which works fine,
but the OnMouseMove event just closes the app as soon as it's run.
Ccan anybody explain?

Many thanks in advance,

Fleur Darkins

 

Re:Screen Savers: Screen as BMP / MouseMove event


In article <4ooq0d$...@newsgate.dircon.co.uk>
           p...@dircon.co.uk "Fleur Darkins" writes:

Quote
> Being amazed at how good Delphi is at diverse types of Windows
> programs, I decided to try and write a screen saver, but have one
> problem and one question:

> The Question:
> How do I retrieve the image of the whole screen (the desktop) and put
> it in a TBitmap so that I can do all sorts of weird and wonderful
> things with it?

Can't help you there.

Quote
> The Problem:
> I've trapped the OnMouseClick event to Close the app which works fine,
> but the OnMouseMove event just closes the app as soon as it's run.
> Ccan anybody explain?

Try using a timer to enable the check code 1/2 a second after the
saver is initialised & running. I know it's a kludge, but it may
be the only way.

--
Daniel Silverstone

Re:Screen Savers: Screen as BMP / MouseMove event


Quote
> The Problem:
> I've trapped the OnMouseClick event to Close the app which works fine,
> but the OnMouseMove event just closes the app as soon as it's run.
> Ccan anybody explain?

Try this:

Make sure that you check to see if the mouse has actually
moved.  
Like so:

var  {globals}
  mousemoveonce:bool;
  omousex,omousey: integer;

procedure Tmform.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if mousemoveonce =false then
  begin
    mousemoveonce:=true;
    oMousex:=x;
    oMousey:=y;
  end
  else if (oktoclose and ((oMousex <> x) or (OMousey <> y))) then  
halt;

also, be sure to set mousemoveonce to false in the FormCreate method.

It's sloppy but it works.

Travis

tmetc...@graphicmedia.com

Re:Screen Savers: Screen as BMP / MouseMove event


Quote
> In article <4ooq0d$...@newsgate.dircon.co.uk>
>            p...@dircon.co.uk "Fleur Darkins" writes:

> > The Question:
> > How do I retrieve the image of the whole screen (the desktop) and put

I can't tell you exactly how to do that, however in windows, if you press the print screen button
the current screen is copied to the clipboard as a bitmap.  You may want to research this area and
see how it's done.  (It may be a Windows API call...)

--
Shawn Riggins
Shawn_Rigg...@ccm.fm.intel.com

Re:Screen Savers: Screen as BMP / MouseMove event


In article: <4ooq0d$...@newsgate.dircon.co.uk>  p...@dircon.co.uk (Fleur Darkins) writes:

Quote

> Being amazed at how good Delphi is at diverse types of Windows
> programs, I decided to try and write a screen saver, but have one
> problem and one question:

> The Question:
> How do I retrieve the image of the whole screen (the desktop) and put
> it in a TBitmap so that I can do all sorts of weird and wonderful
> things with it?

From memory: Try a window handle (HWND) of zero, get a device context
from this and copy the screen image from it.

--
Chris Isbell               Southampton, England
ch...@kenda.co.uk (work)   ch...@isbell.demon.co.uk (home)
+44 1703 869922            +44 1703 465367

Other Threads