Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8665403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:28:29+00:00 2026-06-12T17:28:29+00:00

How can I draw over the desktop window to draw a circle animation on

  • 0

How can I draw over the desktop window to draw a circle animation on user clicks…

I already trying the code below, launching a Thread to draw the animation…

The code below works, but has some paint problems:

unit UMouseEmphasizer;

interface

implementation

uses
  Classes, Windows, Messages, Graphics, Forms;

type
  TEmphasizePointDrawer = class(TThread)
  private
    fPoint: TPoint;
    fCanvas: TCanvas;
  protected
    procedure Execute; override;
  public
    constructor Create(pt: TPoint); reintroduce;
    destructor Destroy; override;
  end;

constructor TEmphasizePointDrawer.Create(pt: TPoint);
begin
  fPoint := pt;
  fCanvas := TCanvas.Create;
  fCanvas.Handle := GetDCEx(0, 0, DCX_PARENTCLIP);
  inherited Create(True);
  FreeOnTerminate := True;
  Resume;
end;

destructor TEmphasizePointDrawer.Destroy;
begin
  ReleaseDC(0, fCanvas.Handle);
  fCanvas.Free;
  inherited;
end;

procedure TEmphasizePointDrawer.Execute;
const
  INFLATE_DELTA = 10;
var
  i: integer;
  r: TRect;
begin
  r := rect(0,0,0,0);
  with fCanvas do
  begin
    Brush.Style := bsClear;
    Pen.Style := psSolid;
    Pen.Color := clRed;
    Pen.Width := 2;

    for i := 0 to 2 do
    begin
      r := rect(
        fPoint.X - (i * INFLATE_DELTA),
        fPoint.Y - (i * INFLATE_DELTA),
        fPoint.X + (i * INFLATE_DELTA),
        fPoint.Y + (i * INFLATE_DELTA)
      );
      Ellipse(r);

      sleep(100);
    end;
  end;

  InflateRect(r, 2, 2);
  RedrawWindow(0, @R, 0, RDW_INVALIDATE or RDW_UPDATENOW or RDW_ALLCHILDREN);
end;

function MouseHookHandler(nCode: Integer; MsgID: WParam; Data: LParam): LResult; stdcall;
var
  pt: TPoint;
begin
  Result := 0;
  if nCode < 0 then
    Exit;

  pt := PMouseHookStruct(Data)^.pt;

  case MsgID of
    WM_LBUTTONUP:
      TEmphasizePointDrawer.Create(pt);
  end;
end;

var
  gHook: HHOOK=0;

procedure HookMouse; stdcall;
begin
  gHook := SetWindowsHookEx(WH_MOUSE, MouseHookHandler, HINSTANCE, 0);
end;

procedure UnhookMouse;
begin
  UnhookWindowsHookEx(gHook);
  gHook := 0;
end;

initialization
  HookMouse;

finalization
  UnhookMouse;

end.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:28:30+00:00Added an answer on June 12, 2026 at 5:28 pm

    I solved the problem with:

    procedure TEmphasizePointDrawer.Execute;
    const
      INFLATE_DELTA = 5;
      COUNT = 3;
      BORDER = 2;
    var
      i: integer;
      r: TRect;
    begin
      with fCanvas do
      begin
        Brush.Style := bsClear;
        Pen.Style := psSolid;
        Pen.Color := clRed;
        Pen.Width := BORDER;
    
        for i := COUNT downto 0 do
        begin
          if i < COUNT then
          begin
            InflateRect(r, BORDER, BORDER);
            RedrawWindow(0, @R, 0, RDW_INVALIDATE or RDW_UPDATENOW or RDW_ALLCHILDREN);
            sleep(0);
            BitBlt(Handle, r.Left, r.Top, (r.Right - r.Left), (r.Bottom - r.Top), Handle, r.Left, r.Top, SRCCOPY);
          end;
    
          r := rect(
            fPoint.X - (i * INFLATE_DELTA),
            fPoint.Y - (i * INFLATE_DELTA),
            fPoint.X + (i * INFLATE_DELTA),
            fPoint.Y + (i * INFLATE_DELTA)
          );
    
          InflateRect(r, BORDER, BORDER);
          RedrawWindow(0, @R, 0, RDW_INVALIDATE or RDW_UPDATENOW or RDW_ALLCHILDREN);
          sleep(0);
          BitBlt(Handle, r.Left, r.Top, (r.Right - r.Left), (r.Bottom - r.Top), Handle, r.Left, r.Top, SRCCOPY);
    
          InflateRect(r, -BORDER, -BORDER);
          Ellipse(r);
    
          sleep(50);
        end;
      end;
    
      r := rect(
        fPoint.X - (COUNT * INFLATE_DELTA) - BORDER,
        fPoint.Y - (COUNT * INFLATE_DELTA) - BORDER,
        fPoint.X + (COUNT * INFLATE_DELTA) + BORDER,
        fPoint.Y + (COUNT * INFLATE_DELTA) + BORDER
      );
      RedrawWindow(0, @R, 0, RDW_INVALIDATE or RDW_UPDATENOW or RDW_ALLCHILDREN);
    end;
    
    function MouseHookHandler(nCode: Integer; MsgID: WParam; Data: LParam): LResult; stdcall;
    var
      pt: TPoint;
    begin
      // draw only when over my application forms!!!
      if (nCode < 0) or (FindControl(GetForegroundWindow()) = nil) then
      begin
        Result := CallNextHookEx(gHook, nCode, MsgID, Data);
        Exit;
      end;
    
      pt := PMouseHookStruct(Data)^.pt;
    
      case MsgID of
        WM_LBUTTONUP, WM_RBUTTONUP, WM_MBUTTONUP:
          TEmphasizePointDrawer.Create(pt);
    
      end;
      Result := 0;
    end;
    

    Thanks for the replies!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can draw a circle around a given point (x,y) with a command like
I have an area where the user can draw using a finger. This area
How can i draw horizontal zebra lines all over my form? 1px Black 1px
I want to draw polylines over and image loaded in an UIImageView. Can someone
How can I draw something on the Forms canvas and over controls on the
How do you create a transparent window that can be placed over another window
how can i draw a zero opacity rubber band over a windows form with
I am currently working on an app that can draw views over the statusbar.
I've been using the following tutorial to allow the user to draw over an
I am writing a Cocoa application for OS X, where the user can draw

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.