Center an MDI Child Form Within the Parent
useful when you need to center an MDI child form within the parent windo
AI
KI-Zusammenfassung: 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.
Quellcode
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
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine