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

  • Home
  • SEARCH
  • 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 9003963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:47:31+00:00 2026-06-16T00:47:31+00:00

Calling WindowFromPoint within the MouseMove event of a TWinControl causes a MouseOver event at

  • 0

Calling WindowFromPoint within the MouseMove event of a TWinControl causes a MouseOver event at the point passed to WindowFromPoint. Is this a VCL bug? Anybody know if there is a workaround?

enter image description here

Here’s the demo code:

unit Unit7;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm7 = class(TForm)
    Button1: TButton;
    procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form7: TForm7;

implementation

{$R *.dfm}

procedure TForm7.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  WindowFromPoint(Point(Mouse.CursorPos.X, Mouse.CursorPos.Y - 40));
end;

end.

DFM:

object Form7: TForm7
  Left = 0
  Top = 0
  Caption = 'Form7'
  ClientHeight = 40
  ClientWidth = 116
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 24
    Top = 7
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnMouseMove = Button1MouseMove
  end
end

I’m using Delphi XE2 on Windows 7 Pro 64bit. I can also reproduce using Delphi 7.

  • 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-16T00:47:32+00:00Added an answer on June 16, 2026 at 12:47 am

    I tested this with a simplest C++ application and observed the same behavior, this is not a VCL bug (as David mentioned in the comments). It’s not related with mouse movements BTW, anytime you call WindowFromPoint passing a caption button’s coordinates, the peculiarity occurs. And it occurs only on the windows that belong to the thread that makes the call to the function.

    So, for a workaround, you can call WindowFromPoint from a thread. Simple example below, not really a background thread as the code waits for it to finish:

    type
      TGetWndThread = class(TThread)
      private
        FPoint: TPoint;
      protected
        procedure Execute; override;
        constructor Create(AOwner: TComponent; Point: TPoint);
      end;
    
    constructor TGetWndThread.Create(AOwner: TComponent; Point: TPoint);
    begin
      FPoint := Point;
      inherited Create;
    end;
    
    procedure TGetWndThread.Execute;
    begin
      ReturnValue := WindowFromPoint(FPoint);
    end;
    
    ..
    
    var
      Wnd: HWND;
      Thr: TGetWndThread;
    begin
      Thr := TGetWndThread.Create(nil, Point(Mouse.CursorPos.X, Mouse.CursorPos.Y - 40));
      Wnd := Thr.WaitFor;
      Thr.Free;
      .. // use Wnd
    

    It would make sense to test for the conditions which the bug is displayed (OS, themes..) and make the code conditional to avoid the overhead where unnecessary.

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

Sidebar

Related Questions

Calling Index view is giving me this very very annoying error . Can anybody
Calling getActionBar returns null . This has been frequently reported so I've made sure
Calling sanitize method on anything causes a missing method error in Rails 3 with
Calling index.php?pConta=1&pDataInicial=01-01-2000&pDataFinal=31-12-2000 I get this notices: [08-Oct-2009 17:30:35] PHP Notice: Undefined index: pConta in
Calling all cross-compatibility experts! Please check out this page on my site, as it
Calling IEnumSTATURL::Next within my application returns E_UNEXPECTED(0x8000FFFF) instead of S_OK . Sadly, that particular
Calling startActivityForResult gives me ActivityNotFoundException . I wanted to know that is it even
Calling channel.position on an ENTER_FRAME event, I notice that it's not being updated every
Calling this method: public static @Nonnull <TV, TG extends TV> Maybe<TV> something(final @Nonnull TG
Calling Virtual methods during construction and destruction causes a compiler error? I heard that

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.