0

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
Community
  • 1
  • 1
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417

1 Answers1

1

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.

Richard
  • 455
  • 6
  • 15
  • thanks but that works only when debugging the app but not when manually launching the compiled application from outside the VS IDE (like opening the "\bin" folder from windows explorer and double-click on the compiled app), I've tested it. – ElektroStudios Apr 27 '13 at 03:17
  • Worked for me every time even outside the IDE. I tried this on VS2005 and VS2010 on two different computers running two different operating systems (Server 2003 and Win7Pro). Perhaps update .Net? – Richard Apr 27 '13 at 12:03
  • I have Win7 x64 with FW4.5, can you tell me the arquitecture of your win7 and the version of FW to test it? – ElektroStudios Apr 27 '13 at 16:38
  • I have Win7 x64 with FW4.0. I changed my target FW in VS to other FW's and still have had no issues. Will install FW4.5 and let you know. – Richard Apr 28 '13 at 22:53
  • I installed FW4.5, but interestingly I was not able to set my target FW in VS to 4.5. Is this only possible in VS2012? Anyway, I still haven't had any trouble with any of the other frameworks. – Richard Apr 28 '13 at 23:41