Recent

Author Topic: Reaction to moving the mouse outside the component while the mouse is pressed  (Read 749 times)

sibedir

  • Newbie
  • Posts: 4
If I place a ScrollBox on the form, then when you press and hold the mouse button within the boundaries of the ScrollBox, the ScrollBox continues to respond to mouse movement outside the boundaries of the ScrollBox in the same way.
But if I dynamically create
Code: Pascal  [Select][+][-]
  1. MyControl := TMyWinControl.Create(Form1);
  2. MyControl.OnMouseMove := @ScrollBox1MouseMove;
my component
Code: Pascal  [Select][+][-]
  1.   TMyWinControl = class(TScrollingWinControl)
  2.   published
  3.     property OnMouseMove;
  4.   end;
on the form, then the effect disappears.

Can you please tell me what ensures the response to mouse movement outside the component boundary?

P.S.: Sorry for my English

Thaddy

  • Hero Member
  • *****
  • Posts: 15198
  • Censorship about opinions does not belong here.
OnMouseEnter OnMouseLeave.
Of course the national anthem of the U.S.A. was written by Jimi Hendrix, didn't you know that?

sibedir

  • Newbie
  • Posts: 4
But I didn't assign OnMouseEnter and OnMouseLeave handlers to ScrollBox. At the same time, OnMouseMove for ScrollBox also works abroad.

sibedir

  • Newbie
  • Posts: 4
Oh, looks like I figured it out.
When creating control need to do
Code: Pascal  [Select][+][-]
  1. MyControl.ControlStyle := ControlStyle + [csCaptureMouse];

jamie

  • Hero Member
  • *****
  • Posts: 6380
before you get to far,  you may want to look at TCustomControl as the base
« Last Edit: June 16, 2024, 07:36:30 pm by jamie »
The only true wisdom is knowing you know nothing

sibedir

  • Newbie
  • Posts: 4
before you get to far,  you may want to look at TCustomControl as the base
I got you. I’ll read about TCustomControl. Thanks for the advice.
For now I'm just experimenting. But if I’m going to make my own component, then you’re right. It is better to immediately follow the general rules for compatibility and not to step on long-known rakes.

 

TinyPortal © 2005-2018