Title Bar and Drag/Drop 
Author Message
 Title Bar and Drag/Drop

I have a Form (call it Big) filling the screen.  I also have a small
Form (call it frmSource) which is always on top of Big.  frmSource is
to have menus but no caption bar or Control Box.  I don't want the
title bar to show on frmSource.  I also want frmSource to have
drag-drop capabilities and show the outline of the form during
dragging.  Currently frmSource has drag-drop, but no outline.

1.  How do I write the code to allow menus and exclude the title bar
on frmSource.

2.  How do I write the code to show the outline for frmSource during
dragging of frmSource.

3.  The code for keeping frmSource on top is from MS VB4 Developers
Workshop Book by John Craig.  Which lines of code can I eliminate?

Thanx    

The Code for frmSource is shown below.

===================================
VERSION 4.00
Begin VB.Form FrmSource
   BackColor       =   &H00FF80FF&
   Caption         =   "Form1"
   ClientHeight    =   2715
   ClientLeft      =   2070
   ClientTop       =   3150
   ClientWidth     =   5910
   Height          =   3120
   Left            =   2010
   LinkTopic       =   "Form1"
   ScaleHeight     =   2715
   ScaleWidth      =   5910
   Top             =   2805
   Width           =   6030
End
Attribute VB_Name = "FrmSource"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
            'Set the Windows Flags
Private Const swp_nosize = &H1
Private Const swp_nomove = &H2
Private Const swp_nozorder = &H4
Private Const swp_noredraw = &H8
Private Const swp_noactivate = &H10
Private Const swp_framechanged = &H20
Private Const swp_showwindow = &H40
Private Const swp_hidewindow = &H80
Private Const swp_nocopybits = &H100
Private Const swp_noownerzorder = &H200
Private Const swp_drawframe = swp_framechanged
Private Const swp_noreposition = swp_noownerzorder
Private Const hwnd_top = 0
Private Const hwnd_bottom = 1
Private Const hwnd_topmost = -1
Private Const hwnd_notopmost = -2
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As
Long, ByVal hWndInsertAfter As Long, _
      ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As
Long, ByVal wFlags As Long) As Long

Private Sub Form_Load()
FrmSource.Caption = "FrmSource"   'NameOfGame
SetWindowPos hwnd, hwnd_topmost, 0, 0, 0, 0, swp_nomove Or swp_nosize
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
DragX = X
DragY = Y
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If DragX < 0 Then
      Left = Left - X - DragX
Else
      Left = Left + X - DragX
End If
If DragY < 0 Then
      Top = Top - Y - DragY
Else
      Top = Top + Y - DragY
End If
If Left < 0 Then Left = 0
If Top < 0 Then Top = 0
If Left + Width > Screen.Width Then Left = Screen.Width - Width
If Top + Height > Screen.Height Then Top = Screen.Height - Height
End Sub

Private Sub mnuExit_Click()
End
End Sub



Sun, 20 Dec 1998 03:00:00 GMT  
 Title Bar and Drag/Drop


Quote:
>1.  How do I write the code to allow menus and exclude the title bar
>on frmSource.

You must use pop-up menus.

Quote:
>2.  How do I write the code to show the outline for frmSource during
>dragging of frmSource.

' API to send messages around the place
Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg
As Integer, ByVal wParam As Integer, lParam As Any) As Long
' API that will release the things I captured (??)
Declare Sub ReleaseCapture Lib "User" ()
' Constants used for moving controls with SendMessage
Global Const WM_NCLBUTTONDOWN = &HA1
Global Const HTCAPTION = 2

Sub Form_MouseDown (...)

   If Button = 1 Then
      Dim Returnval%
      ReleaseCapture
      Returnval% = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
   End If

End Sub

--
VB Info: http://www.sn.no/~balchen/vb/visual.htm
FAQ: http://www.sn.no/~balchen/vb/faq.htm
Knowledge Base: http://www.sn.no/~balchen/vb/kb.htm



Mon, 21 Dec 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. drag move title without title bar?

2. Change Font in title bar of mdi child/Hide title bar

3. Change Font in title bar of mdi child/Hide title bar

4. Dragging a form without any title bar?

5. Drag form without title bar

6. Dragging a form without a title bar: please help

7. Dragging Without a Title Bar?

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

9. Dropping the Title Bar

10. drop the title bar!

11. adding a title to the title bar

12. Title only in title bar of msgbox

 

 
Powered by phpBB® Forum Software