home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Module1"
- ' Docking tutorial brought to you by Nod Programming, Inc.
- ' Docking coded by Mike Lansing 'cheese'
- '
- ' email: nodprogramminginc@email.com
- ' url: http://come.to/NodProgrammingInc
- '
- ' Code is free to use. Please notify me if you made any good changes to this code.
- ' This could be helpful for others. I spent my time on this for you, so please share
- ' with others. Be a giver not a taker.
-
- Public turk As Integer
-
- Public Type RECT
- Left As Long
- Top As Long
- Right As Long
- Bottom As Long
- End Type
-
- Public Type POINTAPI
- X As Long
- Y As Long
- End Type
- ' Window Setting Constants
- Public Const WS_BORDER = &H800000
- Public Const WS_NOBORDER = &H6000000
- Public Const WS_EX_WINDOWEDGE = &H100
- Public Const WS_THICKFRAME = &H40000
- ' Misc Constants
- Public Const GWL_STYLE = (-16)
- Public Const GWL_HWNDPARENT = (-8)
- Public Const COLOR_ACTIVECAPTION = 2
- Public Const SM_CXDLGFRAME = 7
- Public Const SM_CYDLGFRAME = 8
-
- Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
- Public Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
- Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
- Public Declare Function DrawFocusRect Lib "user32" (ByVal hdc As Long, lpRect As RECT) As Long
- Public Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
- Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
- Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
- Public tpoint As POINTAPI
- Public temp As POINTAPI
- Public dpoint As POINTAPI
- Public fbox As RECT
- Public tbox As RECT
- Public oldbox As RECT
- Public TwipsPerPixelX
- Public TwipsPerPixelY
- Public Moving As Boolean ' Window Control Constants
- Public DockSetting As Integer
- Public DockOption
- Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Public Sub BeginFRDrag(X As Single, Y As Single)
- Dim tDc As Long
- Dim sDc As Long
- Dim d As Long
- ' convert points to POINTAPI struct
- dpoint.X = X
- dpoint.Y = Y
- ' get screen area of toolbar
- GetWindowRect frmToolbar.hwnd, fbox 'screen Rect of toolbar
- TwipsPerPixelX = Screen.TwipsPerPixelX
- TwipsPerPixelY = Screen.TwipsPerPixelY
- ' get point of mousedown in screen coordinates
- temp = dpoint
- ClientToScreen frmToolbar.hwnd, temp
- sDc = GetDC(ByVal 0)
- DrawFocusRect sDc, fbox
- d = ReleaseDC(0, sDc)
- oldbox = fbox
- Moving = True
- End Sub
- Public Sub DoFRDrag(X As Single, Y As Single)
- If Moving = True Then
- Dim tDc As Long
- Dim sDc As Long
- Dim d As Long
- tpoint.X = X
- tpoint.Y = Y
- ClientToScreen frmToolbar.hwnd, tpoint
- tbox.Left = (fbox.Left + tpoint.X / TwipsPerPixelX) - temp.X / TwipsPerPixelX
- tbox.Top = (fbox.Top + tpoint.Y / TwipsPerPixelY) - temp.Y / TwipsPerPixelY
- tbox.Right = (fbox.Right + tpoint.X / TwipsPerPixelX) - temp.X / TwipsPerPixelX
- tbox.Bottom = (fbox.Bottom + tpoint.Y / TwipsPerPixelY) - temp.Y / TwipsPerPixelY
- sDc = GetDC(ByVal 0)
- DrawFocusRect sDc, oldbox
- DrawFocusRect sDc, tbox
- d = ReleaseDC(0, sDc)
- oldbox = tbox
- End If
- End Sub
- Public Sub EndFRDrag(X As Single, Y As Single)
- If Moving = True Then
- Dim tDc As Long
- Dim sDc As Long
- Dim d As Long
- Dim newleft As Single
- Dim newtop As Single
- sDc = GetDC(ByVal 0)
- DrawFocusRect sDc, oldbox
- d = ReleaseDC(0, sDc)
- newleft = X + fbox.Left * TwipsPerPixelX - dpoint.X
- newtop = Y + fbox.Top * TwipsPerPixelY - dpoint.Y
- frmToolbar.Move newleft, newtop
- Moving = False
- End If
- End Sub
-
-