Home > Software engineering >  MDI child window relative to the parent window initialization position is always changing
MDI child window relative to the parent window initialization position is always changing

Time:09-28

Program is VS2010 development, there are two interface is a parent form (form1) is a child form ((child1Form)
Parent form to open the child form code is as follows:
Declare the Function SetParent Lib "user32" Alias "SetParent (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Long
Private Sub Button1_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles for. Click
SetParent (child1Form. Handle Me. Handle)
Child1Form. Top=Me. Top
Child1Form. Left=Me. Left
Child1Form. The Show ()
End Sub
When a parent form in different position of the screen, the child form the relative position of the parent form is changing all the time, feel the code above was useless,,,,,,,,,,

CodePudding user response:

What a mess, and MDI has special properties!
 
'MDI parent form'Private Sub Button1_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles for. Click
Child1Form. MdiParent=Me 'father and son association'
Child1Form. The Show () 'explicit formula form'
End Sub

Private Sub Form1_Load (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles MyBase. Load
Me. Panel1. The Dock=DockStyle. Left 'button to put on Panel1, Panel1 to Dock'
Me. IsMdiContainer=True 'set to MDI parent form'
End Sub

CodePudding user response:

Put parentheses. Handle instead. WHD
  • Related