Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi. In my VB .NET program I have a form that's size property is set to 270, 150, but since I upgraded my program from 6.0 it shows up really big at runtime--3/4 the size of the screen. The size property is still set to 270 X 150, and in the .NET design environment it looks right. What more is there to setting the size of a form?

 

Thanks.

  • *Experts*
Posted
Is there any code in the Load or Resize event that is setting the size of your form to use twips (roughly 1/15th of a pixel on most displays) from VB6? Since Twips no longer exist in VB.NET, using them would cause your form to be much larger than normal.
Posted

Nope... in fact this is all the code in the form:

ption Strict Off
Option Explicit On
Friend Class frmAbout
Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
Public Sub New()
	MyBase.New()
	If m_vb6FormDefInstance Is Nothing Then
		If m_InitializingDefInstance Then
			m_vb6FormDefInstance = Me
		Else
			Try 
				'For the start-up form, the first instance created is the default instance.
				If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
					m_vb6FormDefInstance = Me
				End If
			Catch
			End Try
		End If
	End If
	'This call is required by the Windows Form Designer.
	InitializeComponent()
	'This form is an MDI child.
	'This code simulates the VB6 
	' functionality of automatically
	' loading and showing an MDI
	' child's parent.
	Me.MDIParent = DairyPredictor.frmMDI.DefInstance.DefInstance
	DairyPredictor.frmMDI.DefInstance.DefInstance.Show
	'The MDI form in the VB6 project had its
	'AutoShowChildren property set to True
	'To simulate the VB6 behavior, we need to
	'automatically Show the form whenever it
	'is loaded.  If you do not want this behavior
	'then delete the following line of code
	'UPGRADE_NOTE: Remove the next line of code to stop form from automatically showing. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2018"'
	Me.Show
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
	If Disposing Then
		If Not components Is Nothing Then
			components.Dispose()
		End If
	End If
	MyBase.Dispose(Disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
Public ToolTip1 As System.Windows.Forms.ToolTip
Public WithEvents tmrHelpPause As System.Windows.Forms.Timer
Public WithEvents imgCow As System.Windows.Forms.PictureBox
Public WithEvents cmdOK As System.Windows.Forms.Button
   Public WithEvents lblDescription As System.Windows.Forms.Label
Public WithEvents lblTitle As System.Windows.Forms.Label
Public WithEvents Line1 As Microsoft.VisualBasic.Compatibility.VB6.LabelArray
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
       Me.components = New System.ComponentModel.Container
       Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmAbout))
       Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
       Me.tmrHelpPause = New System.Windows.Forms.Timer(Me.components)
       Me.imgCow = New System.Windows.Forms.PictureBox
       Me.cmdOK = New System.Windows.Forms.Button
       Me.lblDescription = New System.Windows.Forms.Label
       Me.lblTitle = New System.Windows.Forms.Label
       Me.Line1 = New Microsoft.VisualBasic.Compatibility.VB6.LabelArray(Me.components)
       CType(Me.Line1, System.ComponentModel.ISupportInitialize).BeginInit()
       Me.SuspendLayout()
       '
       'tmrHelpPause
       '
       Me.tmrHelpPause.Enabled = True
       Me.tmrHelpPause.Interval = 10000
       '
       'imgCow
       '
       Me.imgCow.BackColor = System.Drawing.SystemColors.Control
       Me.imgCow.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
       Me.imgCow.Cursor = System.Windows.Forms.Cursors.Default
       Me.imgCow.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
       Me.imgCow.ForeColor = System.Drawing.SystemColors.ControlText
       Me.imgCow.Image = CType(resources.GetObject("imgCow.Image"), System.Drawing.Image)
       Me.imgCow.Location = New System.Drawing.Point(8, 8)
       Me.imgCow.Name = "imgCow"
       Me.imgCow.RightToLeft = System.Windows.Forms.RightToLeft.No
       Me.imgCow.Size = New System.Drawing.Size(41, 41)
       Me.imgCow.TabIndex = 3
       '
       'cmdOK
       '
       Me.cmdOK.BackColor = System.Drawing.SystemColors.Control
       Me.cmdOK.Cursor = System.Windows.Forms.Cursors.Default
       Me.cmdOK.DialogResult = System.Windows.Forms.DialogResult.Cancel
       Me.cmdOK.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
       Me.cmdOK.ForeColor = System.Drawing.SystemColors.ControlText
       Me.cmdOK.Location = New System.Drawing.Point(96, 96)
       Me.cmdOK.Name = "cmdOK"
       Me.cmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No
       Me.cmdOK.Size = New System.Drawing.Size(76, 23)
       Me.cmdOK.TabIndex = 0
       Me.cmdOK.Text = "OK"
       '
       'lblDescription
       '
       Me.lblDescription.BackColor = System.Drawing.SystemColors.Control
       Me.lblDescription.Cursor = System.Windows.Forms.Cursors.Default
       Me.lblDescription.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
       Me.lblDescription.ForeColor = System.Drawing.Color.Black
       Me.lblDescription.Location = New System.Drawing.Point(16, 64)
       Me.lblDescription.Name = "lblDescription"
       Me.lblDescription.RightToLeft = System.Windows.Forms.RightToLeft.No
       Me.lblDescription.Size = New System.Drawing.Size(248, 14)
       Me.lblDescription.TabIndex = 1
       Me.lblDescription.Text = "Created by Matthew McMahon and Justin Poirier"
       '
       'lblTitle
       '
       Me.lblTitle.BackColor = System.Drawing.SystemColors.Control
       Me.lblTitle.Cursor = System.Windows.Forms.Cursors.Default
       Me.lblTitle.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
       Me.lblTitle.ForeColor = System.Drawing.Color.Black
       Me.lblTitle.Location = New System.Drawing.Point(64, 16)
       Me.lblTitle.Name = "lblTitle"
       Me.lblTitle.RightToLeft = System.Windows.Forms.RightToLeft.No
       Me.lblTitle.Size = New System.Drawing.Size(112, 32)
       Me.lblTitle.TabIndex = 2
       Me.lblTitle.Text = "Dairy Predictorv1.0"
       '
       'frmAbout
       '
       Me.AcceptButton = Me.cmdOK
       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
       Me.BackColor = System.Drawing.SystemColors.Control
       Me.CancelButton = Me.cmdOK
       Me.ClientSize = New System.Drawing.Size(266, 127)
       Me.Controls.Add(Me.imgCow)
       Me.Controls.Add(Me.cmdOK)
       Me.Controls.Add(Me.lblDescription)
       Me.Controls.Add(Me.lblTitle)
       Me.Cursor = System.Windows.Forms.Cursors.Default
       Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
       Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
       Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
       Me.Location = New System.Drawing.Point(361, 220)
       Me.MaximizeBox = False
       Me.MinimizeBox = False
       Me.Name = "frmAbout"
       Me.RightToLeft = System.Windows.Forms.RightToLeft.No
       Me.ShowInTaskbar = False
       Me.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultBounds
       Me.Text = "Dairy Predictor"
       CType(Me.Line1, System.ComponentModel.ISupportInitialize).EndInit()
       Me.ResumeLayout(False)

   End Sub
#End Region 
#Region "Upgrade Support "
Private Shared m_vb6FormDefInstance As frmAbout
Private Shared m_InitializingDefInstance As Boolean
Public Shared Property DefInstance() As frmAbout
	Get
		If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
			m_InitializingDefInstance = True
			m_vb6FormDefInstance = New frmAbout()
			m_InitializingDefInstance = False
		End If
		DefInstance = m_vb6FormDefInstance
	End Get
	Set
		m_vb6FormDefInstance = Value
	End Set
End Property
#End Region 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''                                                                   ''''''''''
''''''''' This form is just the "About" window accessed from the File menu  ''''''''''
'''''''''                                                                   ''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub cmdOK_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdOK.Click
	Me.Close()
End Sub
Private Sub frmAbout_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
	Me.Text = "About Dairy Predictor v 1.0"
	lblTitle.Text = "Dairy Predictor v 1.0"
End Sub

Private Sub Timer1_Timer()
	Me.Close()
End Sub
End Class

Posted

Here's the layout properties and their values... I can't see why any of them would make this happen:

 

AutoScale: true

AutoScroll: false

AutoScrollMargin: 0,0

AutoScrollMinSize: 0,0

DockPadding:

All: 0

Left: 0

Top: 0

Right: 0

Bottom: 0

Location: 0,0

MaximumSize: 0,0

MinimumSize: 0,0

Size: 272, 152

StartPosition: WindowsDefault

WindowState: Normal

 

I've tried setting AutoScale to both true and false, and neither changes this.

 

This is the wierdest thing, I've tried everything. This is killing me.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...