Brent shares a demo that shows how to allow the user to drag a popup window. A popup has no titlebar, so it requires a little extra coding to make this possible.
Brent has released this code into the public domain with the following explanation.
This demo works by trapping a left-drag inside the GRAPHICBOX, then tricks the dialog window into believing you are dragging its (non-existent) title bar. The benefit of using this technique (over calling the MoveWindow API inside a similar event handler) is that this automatically takes into account the user's preference for "show window contents while dragging."
Demo
NoMainWinWindowWidth=400WindowHeight=300UpperLeftX=(DisplayWidth-WindowWidth)/2UpperLeftY=(DisplayHeight-WindowHeight)/2GraphicBox#demo.gfx,0,0,WindowWidth,WindowHeightStyleBits#demo.gfx,0, _WS_BORDER,0,0Open"Demo"For Dialog_Popup As#demo
#demo "TrapClose demo.Close"#demo.gfx "When leftButtonMove demo.gfx.leftButtonMove"#demo.gfx "Down; Fill ButtonFace; BackColor ButtonFace"#demo.gfx "\\\ Try dragging me around!"#demo.gfx "\\ Press Alt+F4 to close."#demo.gfx "Flush"WaitSub demo.Close demo$
Close#demo$
EndEndSubSub demo.gfx.leftButtonMove demo.gfx$, X, Y
demo$ =Word$(demo.gfx$,1,".")CallDLL#user32,"ReleaseCapture", _
r Asvoid
hWnd =HWnd(#demo$)CallDLL#user32,"SendMessageA", _
hWnd AsULong, _
_WM_NCLBUTTONDOWN AsULong, _
_HTCAPTION AsLong, _
0AsLong, _
r AsLongEndSub
Dragging a Popup Window
-Originally published in NL #143
Brent shares a demo that shows how to allow the user to drag a popup window. A popup has no titlebar, so it requires a little extra coding to make this possible.
Brent has released this code into the public domain with the following explanation.
This demo works by trapping a left-drag inside the GRAPHICBOX, then tricks the dialog window into believing you are dragging its (non-existent) title bar. The benefit of using this technique (over calling the MoveWindow API inside a similar event handler) is that this automatically takes into account the user's preference for "show window contents while dragging."
Demo