Detect mouse movement in FormMouseMove handler when pointer isover form controls lazarus / 31-LCL ---------------------------------------------------------------------- j111 · 2012-05-03 10:03 Hello. I need to detect mouse movement in FormMouseMove event for all form globally even mouse pointer is over form controls. For keyboard event it is posible by using KeyPreview property of the form. What should i do to catch mouse events globally? ---------------------------------------------------------------------- KpjComp · 2012-05-03 10:13 mouse.CursorPos ---------------------------------------------------------------------- User137 · 2012-05-03 10:16 Quote from: KpjComp on May 03, 2012, 12:13:02 pmmouse.CursorPosThat goes along with a TTimer or thread then. ---------------------------------------------------------------------- KpjComp · 2012-05-03 10:28 Quote from: User137 on May 03, 2012, 12:16:54 pmThat goes along with a TTimer or thread then. TTimer should be fine,  Thread probably not a good idea. edit: Unless you Syncrhonized within the Thread of course. ---------------------------------------------------------------------- Martin_fr · 2012-05-03 10:39 Application.UserInput (or similar) search UserInput in ide/sourceeditor.pp (trunk / snapshot) ---------------------------------------------------------------------- j111 · 2012-05-03 11:59 So. The following code works great, but how to recognize only mouse events with Msg param of MyInput procedure. procedure TForm1.FormCreate(Sender: TObject); begin   Application.AddOnUserInputHandler(@MyInput, True); end;  procedure TForm1.MyInput(Sender: TObject; Msg: Cardinal); begin     Form1.caption := IntToStr(Mouse.CursorPos.X)+':'+IntToStr(Mouse.CursorPos.Y); end; ---------------------------------------------------------------------- KpjComp · 2012-05-03 12:18 if Msg = LM_MOUSEMOVE ---------------------------------------------------------------------- Martin_fr · 2012-05-03 18:30 On windows (windows only, use IFDEF) also WM_NCMOUSEMOVE That is used, if the mouse is over the window border, or if the form itself has scrollbars, over the scrollbar.... To test, if it is over your windows     if PtInRect(form.BoundsRect, Mouse.CursorPos) then ---------------------------------------------------------------------- j111 · 2012-05-04 08:54 With this code i hightligth controls when mouse move over them. And main goal of the job is drop files from Dolphin to application. Unfortunately OnDropFiles event disables mouse tracking and I cant visually indicate mouse movement while dragging selected files over form. ---------------------------------------------------------------------- User137 · 2012-05-04 11:38 You can use the PtInRect() method above for each valid control on form. Going through the array in a loop. ---------------------------------------------------------------------- j111 · 2012-05-04 13:10 Why user input frozen while dragging files on a form? UserInputHandler continue working only after files was dropped. ---------------------------------------------------------------------- Martin_fr · 2012-05-04 13:18 What about the OnDragOver event? I haven't tested, it may only fire over the form, not over the children. But then Code: [Select]For i:- 0 to form.ControlCount-1 do form.controls[i].OnDragOver := form.OnDragOver; ---------------------------------------------------------------------- j111 · 2012-05-04 13:30 I'v tried. As a result OnDragOver fires when Automatic drag mode is set ON and nothing happens while dragging files. This is very similar to WM_DROPFILES message for windows - program can recognize that files were dragged only when files were droped. On Windows in this case possible to use OLE drag and drop where are possibilities to control all proccess from start to drop. But I dont known such mechanism on Linux.