Mouse move message for child window are intercepted by parent, how to get them in child window's callback - callback

I was writing an plugin of Adobe Illustrator. The Illustator UI has many non-modal dialogs (floating panels) in main window. I want to deal with the WM_MOUSEMOVE message of one panel. So I find the handle of the panel and use SetWindowLongPtr() to set a CALLBACK function of that panel, and use SetCapture() function to let it capture the mouse. But in the callback WM_MOUSEMOVE messages didn't come, however I use SPY++ to watch the panel and all WM_MOUSEMOVE messages were there. So I guess that the host application does something (maybe mouse hook?) to get the mouse messages and doesn't hand them to the panel's callback function.
What can I do to know where the host application intercepts the messages? It seems host will change the cursor when mouse moves to somewhere, how can I prevent it from setting the cursor?

Related

Catching window state change by custom system buttons

I'm developing custom system buttons - minimize, maximize and close window. It's working OK, but also I want to catch changing window state for Maximize / Restore down button. For example, when user double click on window title, window maximized and corresponding button should automatically repaint for "Restore down" state.
As I know, there is WM_SYSCOMMAND message for Form which notify for window state change. And we can get parent form for button (by GetParentForm()). So how to tie it all together? Or maybe you suggests something else?
Button inherits by TCustomControl.

Delphi How can I detect a click event anywhere on a form including other components

I have a TEdit in a Delphi VCL form app (contained in a TFrame instance, if it matters). After a user indicates they are finished editing, by clicking elsewhere on the form, the caret and focus remain on this control until I click on another control, which then takes the focus. However, I want the TEdit to loose focus regardless of where the user clicks. I expect I can use ActiveControl := nil to end focus on the selected control, but I am uncertain where to invoke it.
What I want is for the focus to leave the selected control without necessarily having to transfer it to another control. I could end focus in the form's OnClick event, but that will not work if the user selects any of the other controls (also contained in frames) on my form, since the form's OnClick event is not triggered. It seems inelegant and tedious to provide separate OnClick events for each additional item on the form.
What is the global solution to achieve this behavior?
Try using the TApplication(Events).OnMessage event to look for WM_LBUTTONDOWN messages.
You can use the VCL's FindVCLWindow() or FindDragTarget() function (both in the Vcl.Controls unit) to see if there is a TWinControl located at the click coordinates. Or simpler, you can use the VCL's FindControl() function (also in the Vcl.Controls unit) to get an TWinControl directly from the message's target HWND.
If no control exists under the mouse, or if the control is not focusable (its CanFocus() method returns False), then set ActiveControl=nil. Otherwise, do nothing, and let the clicked control take focus on its own when the message is processed.

WPF MouseEnter does not fire when MouseButton is Pressed

In short: If any mouse button is Pressed when the mouse enters a WPF window, all mouse events are ignored regardless of whether the mouse is captured by any process.
The Challenge
Create two WPF 4.5 projects. In the first one, add a Border with a MouseDown handler. Inside that handler, do everything you can think of to release mouse capture:
this.ReleaseMouseCapture();
element.ReleaseMouseCapture(); // "sender"
Mouse.Capture(null);
while (Mouse.Captured != null)
Mouse.Captured.ReleaseMouseCapture();
ReleaseCapture(); //Win32.ReleaseCapture()
In the other project, add a MouseEnter handler to the default grid that will change its Background.
Start them both up, MouseDown on the border and "drag" to the other window. Until you release the mouse button, the second Window's background will not change.
What's really annoying is that if you stay within the first window, the attempts to "uncapture" the mouse appear to work. Add another element in the first window with a MouseEnter handler, and it will fire just fine. This implies that WPF doesn't know or care about cross-process capture. It just ignores events if any mouse button is in the Pressed state when the mouse first enters an application.
Anyone know if it's possible to have WPF elements respond to mouse events when the mouse was pressed before entering them?

hide cursor in mouse move handler and show it on mouse up

I'm developing a schematic editor, i need to hide the cursor when the middle key is down and moving, and show it again when the mouse up event occurs to implement an user friendly zooming system. The hide and show methods works fine when they are called from outside these event handlers, bud does not work when then called within the event handler!

Get click position on a canvas in a handler of a context-menu

I have an Eclipse RCP-Application, where a menu-contribution is registered, so that a context-menu will automatically be shown, when the user right-clicks on a special canvas in a defined view.
Now in some handlers I want to be able, to get the mouse coordinates, where the user clicked on the canvas, when the context-menu was shown. These handlers will be executed by commands, defined in this context-menu.
The ExecutionEvent in the execute-method of the handler doesn't provide this information.
How do I get the cursor position, the user clicked, to open the context-menu?
If the context menu is opened via a mouse event, then ExecutionEvent.getTrigger() will be the SWT MouseDown event, which includes the correct coordinates.