Home > Software engineering >  How to build a form in other software free form drag
How to build a form in other software free form drag

Time:10-05

How to build A form A, this form in other software window B freely drag on, like VB project manager, when A near B edges together, left edge is suspended,
I don't know that right, anyway, is to achieve the same effect as VB project manager

CodePudding user response:

a, target
You don't have any window to Dock, the Dock) go, always have a goal, use API FindWindow () to obtain the target window handle,

2, way
A) if the internal dock like project manager, basically not reality: software couldn't identify the docking window, not adjusted layout, no use,
B) if the target window up and down or so close to the dock "external", it is possible,
Download the subclass code single class module, leaner version, the author is PctGL (VB6.0 by use of code)
Make a little change can
 Private Sub oSubClass_GetWindowMessage (Result As Long, ByVal cHwnd As Long, ByVal Message As Long, ByVal wParam As Long, ByVal lParam As Long) 
The Select Case Message
Case WM_MOVING 'drag the form'
Dim rc As the RECT
'be drag form location'
Call CopyMemory (rc, ByVal lParam, Len (rc))
Label1. Caption="(" & amp; Rc. Left & amp; ", "& amp; Rc. Top & amp; ") - (" & amp; Rc. Right & amp; ", "& amp; Rc. Bottom & amp;
")"
'compared to the position of the target window, if you need to depend on, here you can change coordinates,'
'here is on the left side of the fixed in the case of x=100'
Rc. Right=100 + (rc) Right - rc) Left)
Rc. Left=100
Call CopyMemory (ByVal lParam, rc, Len (rc))
End the Select
Result=oSubClass. CallDefaultWindowProc (cHwnd, Message, wParam, lParam)
End Sub


3, synchronous
After entering the dock state, after moving to also want to follow a moving target window,
Across processes subclassing difficulty is too high, a timer kept for the position of the target window, change to follow a moving,

CodePudding user response:

Use A setparent set to B child window, meanwhile A can only mobile in B, drag to where you want to drag...

But don't understand what you said is what circumstance,

CodePudding user response:

Topc008 thank Tiger_Zhao to train of thought, back, my results as Code in VB Code explorer, dock can be specified on the form
  • Related