Jump to content
Clément

Dragging a control with $F012

Recommended Posts

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

img1.png

img2.png

img3.png

Share this post


Link to post
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×