Dragging a form without a title bar: please help 
Author Message
 Dragging a form without a title bar: please help

Hi

I'm writing an application in which a child form appears inside some
other window. The child form doesn't have a title bar, but I still want
the user to be able to drag it as if it had.

I know there's a window message wm_nchittest which does something like
that. But according to Dan Appleman's book it can't be used in VB.

Does anyone know a solution.

Sascha

Sascha W. Felix



Mon, 30 Oct 2000 03:00:00 GMT  
 Dragging a form without a title bar: please help

The thing about NC_HITTEST is right. You have to intercept this message to
enable dragging of caption-less windows. That means you have to do
subclassing. I recommend using the free subclassing control from
http://www.softcircuits.com/sw_tools.htm or you could do it manually. There
was a recent article by F. Balena in VBPJ some months ago about NC_HITTEST
and subclassing.
Niels,


Quote:
>Hi

>I'm writing an application in which a child form appears inside some
>other window. The child form doesn't have a title bar, but I still want
>the user to be able to drag it as if it had.

>I know there's a window message wm_nchittest which does something like
>that. But according to Dan Appleman's book it can't be used in VB.

>Does anyone know a solution.

>Sascha

>Sascha W. Felix




Mon, 30 Oct 2000 03:00:00 GMT  
 Dragging a form without a title bar: please help

On Thu, 14 May 1998 08:35:04 +0200, "Sascha W. Felix"

Quote:

>Hi

>I'm writing an application in which a child form appears inside some
>other window. The child form doesn't have a title bar, but I still want
>the user to be able to drag it as if it had.

>I know there's a window message wm_nchittest which does something like
>that. But according to Dan Appleman's book it can't be used in VB.

>Does anyone know a solution.

>Sascha

>Sascha W. Felix


In declaration section:
Dim m_DragMode As Boolean
Dim m_DragX As Single
Dim m_DragY As Single

in your form:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    m_DragMode = True
    m_DragX = X
    m_DragY = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    If Me.WindowState = vbMaximized Or Me.WindowState = vbMinimized
Then Exit Sub

    If m_DragMode Then
        Me.Move Me.Left + X - m_DragX, Me.Top + Y - m_DragY
    End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    m_DragMode = False
End Sub

//Jonas (http://Surf.to/VbArea)



Mon, 30 Oct 2000 03:00:00 GMT  
 Dragging a form without a title bar: please help


Quote:
>I'm writing an application in which a child form appears inside some
>other window. The child form doesn't have a title bar, but I still want
>the user to be able to drag it as if it had.

>I know there's a window message wm_nchittest which does something like
>that. But according to Dan Appleman's book it can't be used in VB.

Actually, I think you can use WM_NCHITTEST but there are some restrictions
depending on the OS.  For another work-around take a look at
http://home.earthlink.net/~butlerbob/vb/screen/mandrag.htm


Mon, 30 Oct 2000 03:00:00 GMT  
 Dragging a form without a title bar: please help

I'm not sure what the difference is between a child form and any other kind
of form with respect to dragging it around kicking and screaming but I tend
to do the following....

Somewhere declare the following API calls....

    Declare Sub ReleaseCapture Lib "user32" ()
    Declare Function SendMessageA Lib "user32" _
      (ByVal hWnd As Long, _
       ByVal wMsg As Long, _
       ByVal wParem As Long, _
       lParem As Any) As Long

To move the form by *any* control, in the controls MouseDown event add the
following...

    Dim Ret&
    Call ReleaseCapture
    Ret& = SendMessageA(Me.hWnd, &H112, &HF012, 0)

FOR EXAMPLE:

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)

    Dim Ret&
    Call ReleaseCapture
    Ret& = SendMessageA(Me.hWnd, &H112, &HF012, 0)

End Sub

You can add this to a "fake" title bar, label, picturebox, whatever and it
will move the whole form. I don't know if this is what you meant, I'm only
trying to help out.

Richard "Flexman" Hawley, Leeds, England

Longbow 2, 404th KamiKali Squadron
http://www.longbow.co.uk/lb2/                ICQ: 5276356



Thu, 02 Nov 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. drag move title without title bar?

2. Dragging a form without any title bar?

3. Drag form without title bar

4. Dragging Without a Title Bar?

5. How to know when the user has moved the form by dragging the title bar

6. I need a FORM without an ICON in the title bar

7. Moving a Form Without a title bar [vb3]

8. Moving a form without a title bar

9. Getting the height of the form (without title bar)

10. form move without title bar

11. Moving a FORM in VB4 without using the TITLE Bar

12. VB4: Form Without a Title Bar?

 

 
Powered by phpBB® Forum Software