Clément 148 Posted February 26, 2019 Hello, I just hit a wall in my "Delphi Rio .1" project. I'm placing a few objects (TImage) on a Surface (TPaintBox) and when the mouse is over a TImage I wrote a routine to create a panel, move the TImage to this panel, send a Perform(WM_SYS_COMMAND, $F012, 0 ) and all is working beautifully! But I need to place Guidlines, similar to those in paint applications where an horizontal line and vertical line meet at the cursor position. Those guidelines will help the user align the controls in the surface. Once the perform message is sent ($F012), I no longer found a way to track the mouse position to display my guidelines. The lines just vanish for the duration of the drag and reappear when the drag is done. To illustrate I attached 3 images. The first one is the arrival, the second is just before dragging and the third is dragging. Is there anyway to solve this issue using $F012, or should I find another way to drag without any flicker TIA Share this post Link to post
Rollo62 536 Posted February 26, 2019 What is $F012 ? Do you mean $F120 ? https://docs.microsoft.com/de-de/windows/desktop/menurc/wm-syscommand Cant you store the last mouse positions before, and redraw the lines, or did the window move to another place ? Share this post Link to post
PeterBelow 238 Posted February 26, 2019 10 hours ago, Clément said: Hello, I just hit a wall in my "Delphi Rio .1" project. I'm placing a few objects (TImage) on a Surface (TPaintBox) and when the mouse is over a TImage I wrote a routine to create a panel, move the TImage to this panel, send a Perform(WM_SYS_COMMAND, $F012, 0 ) and all is working beautifully! But I need to place Guidlines, similar to those in paint applications where an horizontal line and vertical line meet at the cursor position. Those guidelines will help the user align the controls in the surface. Once the perform message is sent ($F012), I no longer found a way to track the mouse position to display my guidelines. The lines just vanish for the duration of the drag and reappear when the drag is done. To illustrate I attached 3 images. The first one is the arrival, the second is just before dragging and the third is dragging. Is there anyway to solve this issue using $F012, or should I find another way to drag without any flicker If you let the OS handle the drag your code is out of the picture until the drag ends, the OS uses an internal message loop to process mouse messages. The only way to hook into that would be a thread-specific message hook (see SetWindowsHookEx in the API docs). You may be better served to use the VCL drag support or handle the mouse yourself. Set the DoubleBuffered property of the paintbox to true, that should reduce the flicker. Share this post Link to post
Clément 148 Posted February 26, 2019 4 hours ago, PeterBelow said: If you let the OS handle the drag your code is out of the picture until the drag ends, the OS uses an internal message loop to process mouse messages. The only way to hook into that would be a thread-specific message hook (see SetWindowsHookEx in the API docs). You may be better served to use the VCL drag support or handle the mouse yourself. Set the DoubleBuffered property of the paintbox to true, that should reduce the flicker. Thanks Peter, I'll try to use SetWindowsHookEx. Share this post Link to post
Clément 148 Posted February 26, 2019 9 hours ago, Rollo62 said: What is $F012 ? Do you mean $F120 ? https://docs.microsoft.com/de-de/windows/desktop/menurc/wm-syscommand Cant you store the last mouse positions before, and redraw the lines, or did the window move to another place ? Hi, $F012 is undocumented constant for SC_DRAG. Share this post Link to post
Primož Gabrijelčič 223 Posted February 26, 2019 (edited) Some additional info can be found here: https://stackoverflow.com/questions/3976610/moving-a-caption-less-window-by-using-a-drag-area. Edited February 26, 2019 by Primož Gabrijelčič Share this post Link to post