Author Topic: Three position switch changes size upon form restore from a minimize (SOLVED).  (Read 2094 times)

Larry J

  • Newbie
  • *
  • Posts: 8
    • View Profile
Hello and thanks for looking!

I am using the standard "Three Position Switch" with the small legend plate in my VB2013 HMI.  The functionality works great.  No problems there.  The problem is appearance.  When a minimize of the form occurs and then subsequently a restore occurs, the switch has significantly increased in size pushing over underneath other controls.  I can find no way to prevent this yet.  The setting for the switch size in the properties is 226,331.  Also when returning focus to the control, the outline is larger on one axis than the other.  I have attached a screenshots of the outline and after a restore.

Does anyone have any ideas or have you seen this before?

Windows 7 64bit SP1
VS2013 in VB
Advanced HMI V3.98
« Last Edit: April 20, 2015, 06:02:53 AM by Larry J »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5320
    • View Profile
    • AdvancedHMI
Re: Three position switch changes size upon form restore from a minimize.
« Reply #1 on: April 09, 2015, 07:37:53 AM »
Try this for a quick work around until I can take a look at the code:

    Private Sub MainForm_GotFocus(sender As Object, e As EventArgs) Handles Me.GotFocus
        SelectorSwitch3Pos1.Width = 100
    End Sub


Right click the MainForm->View Code then put the above code in.

Larry J

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Three position switch changes size upon form restore from a minimize.
« Reply #2 on: April 09, 2015, 11:30:47 AM »
Thank you for the prompt reply Archie.

I did as you instructed.  The subroutine never gets called.  So that workaround is not functioning.  I even tried some other code inside the sub such as MsgBox etc. and none of it gets called on restore.

I did try this:

Code: [Select]
Private Sub Form1_Activated(sender As System.Object, e As System.EventArgs) Handles MyBase.Activated
    If WindowState = FormWindowState.Normal Then
        SelectorSwitch3Pos.Width = 100
    End If
End Sub

That makes the switch even larger.  it takes up the whole right half of the form at that point.  So then I tried a value of 10 instead of 100 and the result was the same...

Thank you.

Godra

  • Hero Member
  • *****
  • Posts: 1446
    • View Profile
Re: Three position switch changes size upon form restore from a minimize.
« Reply #3 on: April 09, 2015, 08:00:16 PM »
The outline seems to show the switch with a Large LegendPlate and the size of 226,331 also confirms that.

If you switch to Small LegendPlate but never try to adjust the size of the switch manually, it still keeps the Large size and the outline, while when the form is restored the switch actually sets the proper size of its Small LegendPlate which should have a proper outline as well (squarish).

Quick workaround would be to try to resize the switch manually with its Small LegendPlate. Ratio seems to be locked so be patient while resizing it.

Do the same if switching back to Large LegendPlate.
« Last Edit: April 09, 2015, 08:03:31 PM by Godra »

Larry J

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Three position switch changes size upon form restore from a minimize.
« Reply #4 on: April 09, 2015, 09:21:13 PM »
Thanks for the reply.

I hear what you are saying, but doesn't the large legend plate only affect the height and not the width?

I changed to the small legend plate and then did perform a resize.  You are correct, there is a ratio lock.  I found a happy medium when I sized it manually.  By manually, I mean I typed the pixel count into the properties (value, value) and did not use the mouse (cursor).

The program launches and runs just fine with no size anomalies until... A minimize and then restore occurs. Both height and width have then changed.  Why? 

I look forward to the solution when we find it together.   


Larry J

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Three position switch changes size upon form restore from a minimize.
« Reply #5 on: April 09, 2015, 09:47:20 PM »
OK, so here is what I have learned further...

The problem is not present if the "Anchor" property is left at default of Top, Left... 

If the property is changed to anything else,  the problem returns.....  YAY!  :)  At least we have narrowed it down farther.  For my purposes I can leave the anchor property at default and solve my issue. 

I am sure that Archie wants to research this further and I look forward to his findings and solution.  Once again, for me this is solved.  I am standing by....   :)

Larry J

  • Newbie
  • *
  • Posts: 8
    • View Profile
I have done more testing on this this morning.  I must have had the anchor set to two opposite sides when I was having this problem.  i.e. top and bottom, or right and left, etc.  This obviously is not going to work... 

So, to sum up if the anchor property is set to NOT MORE THAN TWO of the four points AND those points are NOT opposite each other, there is no problem.  Otherwise, there is a sizing issue on restore.

Thanks for all of your input.  Again, for me this is now solved.  I hope this post helps someone in the future!



« Last Edit: April 10, 2015, 07:48:09 AM by Larry J »