Advertisement
Java_Volume1 Complete Applications #89362

Center an MDI Child Form Within the Parent

useful when you need to center an MDI child form within the parent windo

AI

AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

소스 코드
original-source
Sub CenterChild (Parent As Form, Child As Form)
  Dim iTop As Integer
  Dim iLeft As Integer
  If Parent.WindowState <> 0 Then Exit Sub
  iTop = ((Parent.Height - Child.Height) \ 2)
  iLeft = ((Parent.Width - Child.Width) \ 2)
  Child.Move iLeft, iTop ' (This is more efficient than setting Top and Left properties)
End Sub


The next thing you will need to do is actually call the CenterChild procedure. I have placed the call to CenterChild within the child window's Form_Click event procedure. 

Sub Form_Click ()
  CenterChild MDIForm1, Form1
End Sub
Upload
Upload
원본 댓글 (3)
Wayback Machine에서 복구됨