Results 1 to 5 of 5

Thread: Move child window with parent...

  1. #1

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Question Move child window with parent...

    Hello,

    Need some help real quick. I have a parent Window (form) that loads a single non-modal child Window. My problem is that when I move the parent window, whether with mouse or keyboard, I want the child Window to move also with it`s parent. It should be such that the child seems to follow the parent one.

    So if any of you have any idea about how I could detect a form move or any sample code in that direction would be much appreciated.Thanx...
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  2. #2
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    Hi,

    The EventVB.ApiWindow class implements a Form Move event. It does this by subclassing the form and trapping the WM_MOVE message.

    To use this:
    Code:
    Option Explicit
    
    Dim WithEvents vbLink As EventVB.APIFunctions
    Dim WithEvents vbWnd As EventVB.ApiWindow
    
    Private Sub Form_Load()
    
    Set vbLink = New EventVB.APIFunctions
    
    Set vbWnd = New ApiWindow
    vbWnd.hWnd = Me.hWnd
    vbLink.SubclassedWindows.Add vbWnd
    
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    
    vbLink.SubclassedWindows.Remove vbWnd
    
    End Sub
    
    Private Sub vbWnd_Move(ByVal x As Long, ByVal y As Long, Cancel As Boolean)
    
    Me.Caption = "(" & x & "," & y & ") Location"
    
    End Sub
    HTH,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  3. #3

    Thread Starter
    Hyperactive Member vbud's Avatar
    Join Date
    Jan 2002
    Location
    Mru 20 17S, 57 33E Goal: Get out of the BOX Status: In The Shadows!!! Target Posts: 3,000,000,000
    Posts
    378

    Unhappy

    That would have been fine but the company for which I`m working for does not want to use any third party Dlls so I need the piece of code that can allow me do that....
    >!v!<
    Free your mind, stop thinking
    http://inspirone.blogspot.com

    Please rate this post if it helped you

  4. #4
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    See the source code.

    Extract...
    Code:
    Public Event Move(ByVal x As Long, ByVal y As Long)
    
    '.......in subclass procedure.....
        If wMsg = WM_MOVE Then
            x = LoWord(lParam)
            y = HiWord(lParam)
            RaiseEvent Move(x, y)
    
    '..utility functions.....
    '\\ --[LoWord]------------------------------------------------------------------
    '\\ Returns the low word component of a long value
    '\\ Parameters:
    '\\   dw - The long of which we need the LoWord
    '\\
    '\\ --------------------------------------------------------------------------------
    '\\ (c) 2001 - Merrion Computing.  All rights  to use, reproduce or publish this code reserved
    '\\ Please check http://www.merrioncomputing.com for updates.
    '\\ --------------------------------------------------------------------------------
    Public Function LoWord(dw As Long) As Integer
      If dw And &H8000& Then
          LoWord = &H8000 Or (dw And &H7FFF&)
       Else
          LoWord = dw And &HFFFF&
       End If
    End Function
    
    '\\ --[HiWord]-------------------------------------------------------------------
    '\\ Returns the high word component of a long value
    '\\ Parameters:
    '\\   dw - The long of which we need the HiWord
    '\\
    '\\ --------------------------------------------------------------------------------
    '\\ (c) 2001 - Merrion Computing.  All rights  to use, reproduce or publish this code reserved
    '\\ Please check http://www.merrioncomputing.com for updates.
    '\\ --------------------------------------------------------------------------------
    Public Function HiWord(dw As Long) As Integer
     If dw And &H80000000 Then
          HiWord = (dw \ 65535) - 1
     Else
        HiWord = dw \ 65535
     End If
    End Function
    HTH,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  5. #5
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    ..alternatively, you could steer your company towards a code subscription ? It is likely that this will save them a great deal of time and money in the long run.
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

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