Base form first then inherited form: thanks.
Imports System.Windows.Forms
Imports System.Drawing
Public Class BaseForm
Inherits System.Windows.Forms.Form
Private mouseOffset As Point
Private isMouseDown As Boolean = False
Const fWidth = 500
Const fHeight = 500
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
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
'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.
Friend WithEvents OK As System.Windows.Forms.Button
Friend WithEvents Title As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.OK = New System.Windows.Forms.Button
Me.Title = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'OK
'
Me.OK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or
System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.OK.BackColor = System.Drawing.Color.Salmon
Me.OK.Cursor = System.Windows.Forms.Cursors.Hand
Me.OK.DialogResult = System.Windows.Forms.DialogResult.OK
Me.OK.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.OK.ForeColor = System.Drawing.Color.White
Me.OK.Location = New System.Drawing.Point(600, 320)
Me.OK.Name = "OK"
Me.OK.TabIndex = 1
Me.OK.Text = "OK"
'
'Title
'
Me.Title.Anchor = System.Windows.Forms.AnchorStyles.Top
Me.Title.Font = New System.Drawing.Font("Microsoft Sans Serif",
14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Title.ForeColor = System.Drawing.Color.Goldenrod
Me.Title.Location = New System.Drawing.Point(168, 32)
Me.Title.Name = "Title"
Me.Title.Size = New System.Drawing.Size(408, 40)
Me.Title.TabIndex = 0
Me.Title.Text = "Project Program Manager .Net"
Me.Title.TextAlign = System.Drawing.ContentAlignment.TopCenter
'
'BaseForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.CadetBlue
Me.ClientSize = New System.Drawing.Size(760, 584)
Me.Controls.Add(Me.Title)
Me.Controls.Add(Me.OK)
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.ForeColor = System.Drawing.Color.White
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Name = "BaseForm"
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub BaseForm_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Draw Form
Me.FormBorderStyle = FormBorderStyle.None
OnBaseFormLoad()
Dim p As New System.Drawing.Drawing2D.GraphicsPath
Dim CurveSize As Int32 = 250
p.StartFigure()
p.AddArc(New Rectangle(0, 0, CurveSize, CurveSize), 180, 90)
p.AddLine(CurveSize, 0, Me.Width - CurveSize, 0)
p.AddArc(New Rectangle(Me.Width - CurveSize, 0, CurveSize,
CurveSize), -90, 90)
p.AddLine(Me.Width, CurveSize, Me.Width, Me.Height - CurveSize)
p.AddArc(New Rectangle(Me.Width - CurveSize, Me.Height - CurveSize,
CurveSize, CurveSize), 0, 90)
p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)
p.AddArc(New Rectangle(0, Me.Height - CurveSize, CurveSize,
CurveSize), 90, 90)
p.CloseFigure()
Me.Region = New Region(p)
Me.BackColor = Color.Teal
p.Dispose()
End Sub
Private Sub BaseForm_MouseDown(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseDown
Dim xOffset As Integer
Dim yOffset As Integer
If e.Button = MouseButtons.Left Then
xOffset = -e.X - SystemInformation.FrameBorderSize.Width
yOffset = -e.Y - SystemInformation.CaptionHeight - _
SystemInformation.FrameBorderSize.Height
mouseOffset = New Point(xOffset, yOffset)
isMouseDown = True
End If
End Sub
Private Sub BaseForm_MouseUp(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseUp
' Changes the isMouseDown field so that the form does
' not move unless the user is pressing the left mouse button.
If e.Button = MouseButtons.Left Then
isMouseDown = False
End If
End Sub
Private Sub oldbtest_MouseMove(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseMove
If isMouseDown Then
Dim mousePos As Point = Control.MousePosition
mousePos.Offset(mouseOffset.X, mouseOffset.Y)
Location = mousePos
End If
End Sub
Private Sub OK_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles OK.Click
Me.DialogResult = DialogResult.OK
Me.Close()
End Sub
Private Sub OK_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles OK.Paint
Dim p As New Drawing2D.GraphicsPath
p.AddEllipse(New Rectangle(30, 30, 42, 40))
With OK
.Region = New Region(p)
.BackColor = Color.CadetBlue
.ForeColor = Color.White
.Size = New Size(100, 100)
End With
OnOKPaint()
p.Dispose()
End Sub
Protected Overridable Sub OnOKPaint()
Me.Location = New Point(Me.Width - 115, Me.Height - 115)
End Sub
Protected Overridable Sub OnBaseFormLoad()
Me.StartPosition = FormStartPosition.CenterScreen
Me.Size = New Size(800, 500)
OnOKPaint()
End Sub
End Class
Inherited Form
Public Class MainMenu
Inherits Net.BaseForm
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Me.Size = New Size(750, 500)
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
'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.
Friend WithEvents ProgramCenter As System.Windows.Forms.Button
Friend WithEvents ProjectCenter As System.Windows.Forms.Button
Friend WithEvents Enterprise As System.Windows.Forms.Button
Friend WithEvents EnterpriseText As System.Windows.Forms.TextBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Options As System.Windows.Forms.Button
Friend WithEvents Tools As System.Windows.Forms.Button
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents WeeklyProcess As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.Enterprise = New System.Windows.Forms.Button
Me.ProgramCenter = New System.Windows.Forms.Button
Me.ProjectCenter = New System.Windows.Forms.Button
Me.EnterpriseText = New System.Windows.Forms.TextBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Options = New System.Windows.Forms.Button
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Tools = New System.Windows.Forms.Button
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.WeeklyProcess = New System.Windows.Forms.Button
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Enterprise
'
Me.Enterprise.Font = New System.Drawing.Font("Microsoft Sans Serif",
12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Enterprise.ForeColor = System.Drawing.Color.White
Me.Enterprise.Location = New System.Drawing.Point(72, 104)
Me.Enterprise.Name = "Enterprise"
Me.Enterprise.Size = New System.Drawing.Size(192, 56)
Me.Enterprise.TabIndex = 2
Me.Enterprise.Text = "Enterprise"
'
'ProgramCenter
'
Me.ProgramCenter.Font = New System.Drawing.Font("Microsoft Sans
Serif", 12.0!, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ProgramCenter.ForeColor = System.Drawing.Color.White
Me.ProgramCenter.Location = New System.Drawing.Point(72, 168)
Me.ProgramCenter.Name = "ProgramCenter"
Me.ProgramCenter.Size = New System.Drawing.Size(192, 56)
Me.ProgramCenter.TabIndex = 3
Me.ProgramCenter.Text = "Program Center"
'
'ProjectCenter
'
Me.ProjectCenter.Font = New System.Drawing.Font("Microsoft Sans
Serif", 12.0!, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ProjectCenter.ForeColor = System.Drawing.Color.White
Me.ProjectCenter.Location = New System.Drawing.Point(72, 232)
Me.ProjectCenter.Name = "ProjectCenter"
Me.ProjectCenter.Size = New System.Drawing.Size(192, 56)
Me.ProjectCenter.TabIndex = 4
Me.ProjectCenter.Text = "Project Center"
'
'EnterpriseText
'
Me.EnterpriseText.AutoSize = False
Me.EnterpriseText.BackColor = System.Drawing.Color.Teal
Me.EnterpriseText.BorderStyle =
System.Windows.Forms.BorderStyle.None
Me.EnterpriseText.Location = New System.Drawing.Point(280, 125)
Me.EnterpriseText.Multiline = True
Me.EnterpriseText.Name = "EnterpriseText"
Me.EnterpriseText.Size = New System.Drawing.Size(408, 32)
Me.EnterpriseText.TabIndex = 5
Me.EnterpriseText.Text = "Report on, add, edit and maintain groups
of Programs"
'
'TextBox1
'
Me.TextBox1.AutoSize = False
Me.TextBox1.BackColor = System.Drawing.Color.Teal
Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.TextBox1.Location = New System.Drawing.Point(280, 192)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(408, 32)
Me.TextBox1.TabIndex = 6
Me.TextBox1.Text = "Report on, add, edit and maintain Programs of
Projects"
'
'TextBox2
'
Me.TextBox2.AutoSize = False
Me.TextBox2.BackColor = System.Drawing.Color.Teal
Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.TextBox2.Location = New System.Drawing.Point(280, 255)
Me.TextBox2.Multiline = True
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(408, 32)
Me.TextBox2.TabIndex = 7
Me.TextBox2.Text = "Report on, add, edit and maintain individual
Projects"
'
'Options
'
Me.Options.Font = New System.Drawing.Font("Microsoft Sans Serif",
12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Options.ForeColor = System.Drawing.Color.White
Me.Options.Location = New System.Drawing.Point(72, 424)
Me.Options.Name = "Options"
Me.Options.Size = New System.Drawing.Size(192, 56)
Me.Options.TabIndex = 8
Me.Options.Text = "Options"
'
'TextBox3
'
Me.TextBox3.AutoSize = False
Me.TextBox3.BackColor = System.Drawing.Color.Teal
Me.TextBox3.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.TextBox3.Location = New System.Drawing.Point(280, 382)
Me.TextBox3.Multiline = True
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(408, 32)
Me.TextBox3.TabIndex = 9
Me.TextBox3.Text = "Run the weekly process on all Projects"
'
'Tools
'
Me.Tools.Font = New System.Drawing.Font("Microsoft Sans Serif",
12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Tools.ForeColor = System.Drawing.Color.White
Me.Tools.Location = New System.Drawing.Point(72, 296)
Me.Tools.Name = "Tools"
Me.Tools.Size = New System.Drawing.Size(192, 56)
Me.Tools.TabIndex = 10
Me.Tools.Text = "Tools"
'
'TextBox4
'
Me.TextBox4.AutoSize = False
Me.TextBox4.BackColor = System.Drawing.Color.Teal
Me.TextBox4.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.TextBox4.Location = New System.Drawing.Point(280, 319)
Me.TextBox4.Multiline = True
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(488, 32)
Me.TextBox4.TabIndex = 11
Me.TextBox4.Text = "Tools to create consoildated projects, Maintain
Calendars, Change pay rate tables" & _
" and more"
'
'WeeklyProcess
'
Me.WeeklyProcess.Font = New System.Drawing.Font("Microsoft Sans
Serif", 12.0!, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.WeeklyProcess.ForeColor = System.Drawing.Color.White
Me.WeeklyProcess.Location = New System.Drawing.Point(72, 360)
Me.WeeklyProcess.Name = "WeeklyProcess"
Me.WeeklyProcess.Size = New System.Drawing.Size(192, 56)
Me.WeeklyProcess.TabIndex = 12
Me.WeeklyProcess.Text = "Weekly Process"
'
'TextBox5
'
Me.TextBox5.AutoSize = False
Me.TextBox5.BackColor = System.Drawing.Color.Teal
Me.TextBox5.BorderStyle = System.Windows.Forms.BorderStyle.None
Me.TextBox5.Location = New System.Drawing.Point(280, 448)
Me.TextBox5.Multiline = True
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(304, 32)
Me.TextBox5.TabIndex = 13
Me.TextBox5.Text = "Set options for Projects and PPM.Net"
'
'MainMenu
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.AutoScroll = True
Me.BackColor = System.Drawing.Color.Teal
Me.ClientSize = New System.Drawing.Size(800, 500)
Me.Controls.Add(Me.WeeklyProcess)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.Tools)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.Options)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.EnterpriseText)
Me.Controls.Add(Me.ProjectCenter)
Me.Controls.Add(Me.ProgramCenter)
Me.Controls.Add(Me.Enterprise)
Me.Controls.Add(Me.TextBox5)
Me.Name = "MainMenu"
Me.Controls.SetChildIndex(Me.TextBox5, 0)
Me.Controls.SetChildIndex(Me.Enterprise, 0)
Me.Controls.SetChildIndex(Me.ProgramCenter, 0)
Me.Controls.SetChildIndex(Me.ProjectCenter, 0)
Me.Controls.SetChildIndex(Me.EnterpriseText, 0)
Me.Controls.SetChildIndex(Me.TextBox1, 0)
Me.Controls.SetChildIndex(Me.TextBox2, 0)
Me.Controls.SetChildIndex(Me.Options, 0)
Me.Controls.SetChildIndex(Me.TextBox3, 0)
Me.Controls.SetChildIndex(Me.Tools, 0)
Me.Controls.SetChildIndex(Me.TextBox4, 0)
Me.Controls.SetChildIndex(Me.WeeklyProcess, 0)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Enterprise_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Enterprise.Click
MessageBox.Show("Enterprise Form", "Menu", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Sub
Private Sub ProgramCenter_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ProgramCenter.Click
MessageBox.Show("Program Form", "Menu", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Sub
Private Sub ProjectCenter_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ProjectCenter.Click
MessageBox.Show("Project Form", "Menu", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Sub
' Private Sub MainMenu_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Me.Size = New Size(800, 500)
' End Sub
Private Sub MainMenu_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
OnBaseFormLoad()
End Sub
Protected Overrides Sub OnOKPaint()
Me.OK.Location = New Point(Me.Width - 120, Me.Height - 120)
End Sub
Protected Overloads Sub OnBaseFormLoad()
Me.StartPosition = FormStartPosition.CenterScreen
Me.Size = New Size(800, 500)
End Sub
End Class
--
Rod Gill
Project MVP
Visit
www.msproject-systems.com for Project Companion Tools and more
"Beth Massi [Architect MVP]" <bm****@comcast.net> wrote in message
news:eF**************@TK2MSFTNGP10.phx.gbl...
Hey that's pretty funky! I've dealt with compiler and parser problems
before, but not this. Can you show us the source code for the base class
and the inherited class so we can try and duplicate the problem here?
-B
"Rod Gill" <rod AT project-systems DOT co DOT nz> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl... Hi,
I have a form that when opened in the designer appears of the screen. The
form selector can't be dragged (or resized) and if I scroll right and
down to centralise it the form simply jumps further away, completely
leaving the selector box area.
Any ideas? VS 2003 and VB.Net
This is a simple application at the moment but the form is inherited from
a base form. The solution consists of a base form and two forms that
inherit the baseform. No other functionality at this stage. The solution
builds and runs as expected the only problem is the designer for both
inherited forms. A new form when inserted behaves as expected, but a new
inherited form also skips off screen in the designer.
The base form has one label control and one OK button.
--
Rod Gill