Using swapmousebutton true to allow right click dragging of a window

I am required to somehow allow a window to be moved using a right click drag option. I have done this via some sneeky code which I don't really like but it works.

Currently I am trapping the WM_NCRBUTTONDOWN message and setting a bool to say that I am in move mode, resetting this variable when the WM_NCRBUTTONUP is received. While in moving mode I am checking for WMNCMouseMove and moving the form myself. As this is slow to keep up with quick mouse movements I also set a timer to do the same using the GetCursorPos.

I have recently discovered the SwapMouseButton function and this does exactly what I want. However there is a but! I need to swap it conditionally and only when the user has right clicked the CAPTION area of a window.

So I swap the mouse buttons round when I receive the WM_NCRBUTTONDOWN and reset on WM_NCRBUTTONUP. However this will work on subsequent clicks provided the WM_NCRBUTTONUP never reset it. This I think is because the clicking event has already happened so is to late to swap which is why it works for subsequent right click hits but not the right click and drag which caused the swapping of the mouse!

Can anybody see a way around this. Baring in mind that I need the left click functionality for the close, minimize, maximise buttons etc. Right click onyl for the moving!

Please Help!!!!!

*I have posted a similar question before but this is different so have raised a new post.

Thanks, Joe
Topic archived. No new replies allowed.