diff --git a/ui.h b/ui.h index 9f421d37..5852bf6d 100644 --- a/ui.h +++ b/ui.h @@ -316,6 +316,7 @@ _UI_EXTERN void uiAreaScrollTo(uiArea *a, double x, double y, double width, doub // TODO should these be allowed on scrolling areas? // TODO decide which mouse events should be accepted; Down is the only one guaranteed to work right now // TODO what happens to events after calling this up to and including the next mouse up? +// TODO release capture? _UI_EXTERN void uiAreaBeginUserWindowMove(uiArea *a); _UI_EXTERN void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge); _UI_EXTERN uiArea *uiNewArea(uiAreaHandler *ah); diff --git a/windows/area.cpp b/windows/area.cpp index 17110d33..6d1bbeb9 100644 --- a/windows/area.cpp +++ b/windows/area.cpp @@ -98,6 +98,66 @@ void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height) // TODO } +void uiAreaBeginUserWindowMove(uiArea *a) +{ + HWND toplevel; + + // TODO restrict execution + // TODO release capture + toplevel = xxxx(a->hwnd); + if (toplevel == NULL) { + // TODO + return; + } + // see http://stackoverflow.com/questions/40249940/how-do-i-initiate-a-user-mouse-driven-move-or-resize-for-custom-window-borders-o#40250654 + SendMessageW(toplevel, WM_SYSCOMMAND, + SC_MOVE | 2, 0); +} + +void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge) +{ + HWND toplevel; + WPARAM wParam; + + // TODO restrict execution + // TODO release capture + toplevel = parentToplevel(a->hwnd); + if (toplevel == NULL) { + // TODO + return; + } + // see http://stackoverflow.com/questions/40249940/how-do-i-initiate-a-user-mouse-driven-move-or-resize-for-custom-window-borders-o#40250654 + wParam = SC_SIZE; + switch (edge) { + case uiWindowResizeEdgeLeft, + wParam |= 1; + break + case uiWindowResizeEdgeTop, + wParam |= 3; + break + case uiWindowResizeEdgeRight, + wParam |= 2; + break + case uiWindowResizeEdgeBottom, + wParam |= 6; + break + case uiWindowResizeEdgeTopLeft, + wParam |= 4; + break + case uiWindowResizeEdgeTopRight, + wParam |= 5; + break + case uiWindowResizeEdgeBottomLeft, + wParam |= 7; + break + case uiWindowResizeEdgeBottomRight: + wParam |= 8; + break + } + SendMessageW(toplevel, WM_SYSCOMMAND, + wParam, 0); +} + uiArea *uiNewArea(uiAreaHandler *ah) { uiArea *a;