Results 1 to 5 of 5

Thread: Show Window

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Posts
    1

    Post

    How do i make a windows show its contents while being dragged, without setting the windows property "show windows contents while dragging" to true. i notice programs like winamp are able to do this...is it possible in vb to do for my program

    many thanks

  2. #2
    Member
    Join Date
    Oct 1999
    Location
    Richmond, Virginia
    Posts
    41

    Post

    There is an API method to do this - someone asked this question here before. Not sure what the answer was - search through the messages of about 1.5 weeks ago to find it.


    ------------------
    TheLeeMan



  3. #3
    Member
    Join Date
    Jun 1999
    Location
    Singapore
    Posts
    32

    Post

    The reason why the window contents are shown when the form is being dragged, is that the window dragging is not handled by Windows. You could try searching VB-World for "How to move a form without a title bar". This method moves the window instead of dragging it, and Windows does not hide the contents.

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Try This:

    In a Module..
    Code:
    Private Type POINTAPI
            x As Long
            y As Long
    End Type
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    
    Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
    Public Const GWL_WNDPROC = (-4)
    Private Const WM_NCLBUTTONDOWN = &HA1
    Private Const WM_MOVING = &H216
    
    Public lPrevWnd As Long
    
    Public Function SubClassedWindow(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Static tStart As POINTAPI
        Dim tPos As POINTAPI
        If Msg = WM_NCLBUTTONDOWN Then
            Call GetCursorPos(tStart)
            tStart.x = tStart.x - Form1.ScaleX(Form1.Left, vbTwips, vbPixels)
            tStart.y = tStart.y - Form1.ScaleY(Form1.Top, vbTwips, vbPixels)
        ElseIf Msg = WM_MOVING Then
            Call GetCursorPos(tPos)
            Form1.Move Form1.ScaleX(tPos.x - tStart.x, vbPixels, vbTwips), Form1.ScaleY(tPos.y - tStart.y, vbPixels, vbTwips)
        End If
        SubClassedWindow = CallWindowProc(lPrevWnd, hwnd, Msg, wParam, lParam)
    End Function
    In the Form..
    Code:
    Private Sub Form_Load()
        lPrevWnd = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf SubClassedWindow)
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
        Call SetWindowLong(hwnd, GWL_WNDPROC, lPrevWnd)
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  5. #5
    Junior Member
    Join Date
    Jan 1999
    Posts
    30

    Post

    I got an example. Witch allso snaps. The downside is that you can't use windows' titlebar. You'll have to make a fake one.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width