Results 1 to 6 of 6

Thread: [RESOLVED] How to move Form using Title bar without interrupting Processing

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Resolved [RESOLVED] How to move Form using Title bar without interrupting Processing

    I'm working on a real-time application that accepts incoming sound data and plays it back async. This app is in a constant loop reading in the sound data and playing it back using Winsock to receive the data from the server. The problem is if a user mouse down on the title bar and moves the Form the playback is interrupted until user releases the mouse. After user releases the mouse the playback continues but it is now out of sync with the sending of the sound data.

    I think that if I subclass the app and capture the mouse down on the title bar I can still allow the user to move his Form without interrupting the playback and getting out of sync.

    Here is my subclassing code. All I need are the steps to allow Form movement and not interrupt processing

    Form Code


    Code:
      '
      '
    Private Sub cmdStartSubclassing_Click()
     MainOldWindPoc = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddressOf MainWndProc)
    End Sub
    
    Private Sub cmdStopSubclassing_Click()
     SetWindowLong Me.hwnd, GWL_WNDPROC, MainOldWindPoc
    End Sub
      '
      '

    Module Code

    Code:
    Option Explicit
    
    Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
     (ByVal hwnd As Long, _
      ByVal nIndex As Long, _
      ByVal dwNewLong As Long) As Long
    
    Public Const WM_SYSCOMMAND As Long = &H112
    
    Public MainOldWindPoc As Long
    
    Public defWndProc As Long
    
    Public Const GWL_WNDPROC& = (-4)
    
    Public Function MainWndProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
     Dim handled As Long
     
     handled = False
        
     Select Case uMsg
       Case WM_SYSCOMMAND
         '
         ' Don't know what to do here
         '
         handled = False
     End Select
        
     If Not handled Then
       MainWndProc = CallWindowProc(MainOldWindPoc, hwnd, uMsg, wParam, lParam)
     End If
    End Function


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,263

    Re: How to move Form using Title bar without interrupting Processing

    I'd rather put the processing code into an activex-dll, since that one gets its own thread from windows
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How to move Form using Title bar without interrupting Processing

    Quote Originally Posted by Zvoni View Post
    I'd rather put the processing code into an activex-dll, since that one gets its own thread from windows
    DLLs run in-process unless you use them with a proxy (not too practical in VB6). So no, they do not "get a thread" at all but run on the calling thread.

    An ActiveX EXE runs out of process, perhaps that's what you were trying to say. These are easy to create using VB6 but to make use of them for independent worker threads takes some finessing.

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,263

    Re: How to move Form using Title bar without interrupting Processing

    Dilettante, whooops! You're right, of course.
    Sorry for the confusion.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  5. #5
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How to move Form using Title bar without interrupting Processing

    Use Timer(s) instead of Loop(s), put a very small interval.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How to move Form using Title bar without interrupting Processing

    @Max

    I'm using your second EXE suggestion

    http://www.vbforums.com/showthread.p...&is_resolved=2


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

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