Question

I need to allign a secondary form to the right border of other form.

When we compile and run a COMPILED application (not when running it from the IDE) with AERO enabled, this is what happens:

enter image description here

So thanks to the great asnwer of GJKH here : How to determine correctly the Non-Client Area Size for Aero?

...Now I can allign the secondary form to the right of the main form, But the secondary form stills unaligned a bit of pixels from the top:

enter image description here

This is the code I'm using:

 If Debugger.IsAttached Then
      Form2.Location = New Point(Me.Right, Me.Top)
 Else
      Form2.Location = New Point((Me.Location.X + (Me.Width + (Me.Width - Me.ClientSize.Width))), Me.Location.Y)
 End If
Was it helpful?

Solution

I put this in an event within Form1:

    Dim frm As New Form2

    frm.Show()

    frm.SetDesktopLocation(Me.Width + Me.DesktopLocation.X, Me.DesktopLocation.Y)

and form2 lined up immediately to the right of form1 with their tops lined up perfectly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top