I have created a window using CreateWindowEx that is borderless and has no caption. I would like to be able to move the window by left-click + hold the mouse over the client area of that window (that is to be able to drag it).
I have added the following code to the WindProc of this window:
static LRESULT hittest;
...
case WM_LBUTTONDBLCLK:
DestroyWindow(hWnd);
break;
case WM_NCHITTEST:
hittest = DefWindowProc(hWnd, message, wParam, lParam);
if (hittest == HTCLIENT)
return HTCAPTION;
else
return hittest;
break;
...
Although the previous code let me drag the window correctly I have lost the ability to process any other mouse events (like double clicking, clcik, etc.). Whithout the case WM_NCHITTEST statement the window does let to close the window by double clicking on it; but, if I add the case WM_NCHITTEST then the WM_LBUTTONDBLCLK is never sent to the window.
What I intend to do is:
- Being able to drag the window from anywhere inside it's client area.
- Spawn an application (via ShellExcecuteEx) when the user clicks on an image (drawn) inside the windows's client area.
- Close the window when the user double-clicks on anywhere inside the window's client area.
Is there a way to enable the drag without loosing mouse message processing? I have read a bit about Mouse Capturing but I have not been able to successfully implement that.
Are threre any tutorials or docs I can take a look at as to implement the desired behaviour I am looking for?
Aqua-Soft Forums