Results 1 to 4 of 4

Thread: Form Question

  1. #1
    Guest

    Talking

    Hi all:
    when we resize the MDI parent form, we want to resize the MDI child form also, but how can we know which child form is visible at that time?
    Thanks

  2. #2
    Member
    Join Date
    Aug 1999
    Location
    Houston
    Posts
    48
    You probably have to loop thru all of the child MDIs and see if the .visible property is true.

    If ChildForm1.Visible=True Then MsgBox "this child window is visible"

    Or something to that effect.

    -lp

  3. #3
    Guest
    I like complicated APIs sometimes, for they are cleaner in the job.

    Code:
    'NOTE: Option Compare Text is not needed, but since I thought it was lonely, I brought it up.
    Option Explicit
    Option Compare Text
    Option Base 1
    Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
    (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
    ByVal lpsz2 As String) As Long
    
    Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _
    (ByVal hwnd As Long) As Long
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
    (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
    
    Private Sub MDIForm_Click()
      Dim strs() As String, vis() As Boolean, hwd() As Long
      Dim hwndw As Long, lt As Long, hwdold As Long
      Dim ctc As Long
      ReDim strs(ctc) As String
      ReDim vis(ctc) As Boolean
      ReDim hwd(ctc) As Long
      hwdold = vbNull
      
    SupP:
        hwndw = FindWindowEx(Me.hwnd, hwdold, vbNull, vbNull)
        If hwndw = vbNull Then GoTo SubP
        lt = GetWindowTextLength(hwndw)
        ctc = ctc + 1
        ReDim strs(ctc) As String
        ReDim vis(ctc) As Boolean
        ReDim hwd(ctc) As Long
        GetWindowText Me.hwnd, strs(ctc), ln
        vis(ctc) = IsWindowVisible(hwndw)
        hwd(ctc) = hwndw
        hwdold = hwndw
    GoTo SupP
    
    SubP:
    End Sub
    API

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You could also use the Forms collection to do the resize.
    Add code simular to this in the Resize event of the MDI form.
    Code:
    Private Sub MDIForm_Resize()
        Dim frm As Form
        For Each frm In Forms
            If frm.Name <> Me.Name Then
                If frm.MDIChild = True Then
                    'do the resizing here
                    frm.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
                End If
            End If
        Next
    End Sub
    Best regards

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