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.
InitializeCompo nent()
'Add any initialization after the InitializeCompo nent() 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.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er
'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.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.OK = New System.Windows. Forms.Button
Me.Title = New System.Windows. Forms.Label
Me.SuspendLayou t()
'
'OK
'
Me.OK.Anchor = CType((System.W indows.Forms.An chorStyles.Bott om Or
System.Windows. Forms.AnchorSty les.Right), System.Windows. Forms.AnchorSty les)
Me.OK.BackColor = System.Drawing. Color.Salmon
Me.OK.Cursor = System.Windows. Forms.Cursors.H and
Me.OK.DialogRes ult = System.Windows. Forms.DialogRes ult.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.AnchorSty les.Top
Me.Title.Font = New System.Drawing. Font("Microsoft Sans Serif",
14.25!, System.Drawing. FontStyle.Bold, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))
Me.Title.ForeCo lor = System.Drawing. Color.Goldenrod
Me.Title.Locati on = New System.Drawing. Point(168, 32)
Me.Title.Name = "Title"
Me.Title.Size = New System.Drawing. Size(408, 40)
Me.Title.TabInd ex = 0
Me.Title.Text = "Project Program Manager .Net"
Me.Title.TextAl ign = System.Drawing. ContentAlignmen t.TopCenter
'
'BaseForm
'
Me.AutoScaleBas eSize = 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.D efault
Me.ForeColor = System.Drawing. Color.White
Me.FormBorderSt yle = System.Windows. Forms.FormBorde rStyle.None
Me.Name = "BaseForm"
Me.StartPositio n =
System.Windows. Forms.FormStart Position.Center Screen
Me.ResumeLayout (False)
End Sub
#End Region
Private Sub BaseForm_Load(B yVal sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Draw Form
Me.FormBorderSt yle = FormBorderStyle .None
OnBaseFormLoad( )
Dim p As New System.Drawing. Drawing2D.Graph icsPath
Dim CurveSize As Int32 = 250
p.StartFigure()
p.AddArc(New Rectangle(0, 0, CurveSize, CurveSize), 180, 90)
p.AddLine(Curve Size, 0, Me.Width - CurveSize, 0)
p.AddArc(New Rectangle(Me.Wi dth - CurveSize, 0, CurveSize,
CurveSize), -90, 90)
p.AddLine(Me.Wi dth, CurveSize, Me.Width, Me.Height - CurveSize)
p.AddArc(New Rectangle(Me.Wi dth - CurveSize, Me.Height - CurveSize,
CurveSize, CurveSize), 0, 90)
p.AddLine(Me.Wi dth - 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_MouseD own(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseDow n
Dim xOffset As Integer
Dim yOffset As Integer
If e.Button = MouseButtons.Le ft Then
xOffset = -e.X - SystemInformati on.FrameBorderS ize.Width
yOffset = -e.Y - SystemInformati on.CaptionHeigh t - _
SystemInformati on.FrameBorderS ize.Height
mouseOffset = New Point(xOffset, yOffset)
isMouseDown = True
End If
End Sub
Private Sub BaseForm_MouseU p(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.Le ft Then
isMouseDown = False
End If
End Sub
Private Sub oldbtest_MouseM ove(ByVal sender As Object, _
ByVal e As MouseEventArgs) Handles MyBase.MouseMov e
If isMouseDown Then
Dim mousePos As Point = Control.MousePo sition
mousePos.Offset (mouseOffset.X, mouseOffset.Y)
Location = mousePos
End If
End Sub
Private Sub OK_Click(ByVal sender As Object, ByVal e As
System.EventArg s) 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.PaintEven tArgs) Handles OK.Paint
Dim p As New Drawing2D.Graph icsPath
p.AddEllipse(Ne w 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.StartPositio n = FormStartPositi on.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.
InitializeCompo nent()
'Add any initialization after the InitializeCompo nent() 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.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er
'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.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.Enterprise = New System.Windows. Forms.Button
Me.ProgramCente r = New System.Windows. Forms.Button
Me.ProjectCente r = New System.Windows. Forms.Button
Me.EnterpriseTe xt = 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.WeeklyProces s = New System.Windows. Forms.Button
Me.TextBox5 = New System.Windows. Forms.TextBox
Me.SuspendLayou t()
'
'Enterprise
'
Me.Enterprise.F ont = New System.Drawing. Font("Microsoft Sans Serif",
12.0!, System.Drawing. FontStyle.Bold, System.Drawing. GraphicsUnit.Po int,
CType(0, Byte))
Me.Enterprise.F oreColor = System.Drawing. Color.White
Me.Enterprise.L ocation = New System.Drawing. Point(72, 104)
Me.Enterprise.N ame = "Enterprise "
Me.Enterprise.S ize = New System.Drawing. Size(192, 56)
Me.Enterprise.T abIndex = 2
Me.Enterprise.T ext = "Enterprise "
'
'ProgramCenter
'
Me.ProgramCente r.Font = New System.Drawing. Font("Microsoft Sans
Serif", 12.0!, System.Drawing. FontStyle.Bold,
System.Drawing. GraphicsUnit.Po int, CType(0, Byte))
Me.ProgramCente r.ForeColor = System.Drawing. Color.White
Me.ProgramCente r.Location = New System.Drawing. Point(72, 168)
Me.ProgramCente r.Name = "ProgramCen ter"
Me.ProgramCente r.Size = New System.Drawing. Size(192, 56)
Me.ProgramCente r.TabIndex = 3
Me.ProgramCente r.Text = "Program Center"
'
'ProjectCenter
'
Me.ProjectCente r.Font = New System.Drawing. Font("Microsoft Sans
Serif", 12.0!, System.Drawing. FontStyle.Bold,
System.Drawing. GraphicsUnit.Po int, CType(0, Byte))
Me.ProjectCente r.ForeColor = System.Drawing. Color.White
Me.ProjectCente r.Location = New System.Drawing. Point(72, 232)
Me.ProjectCente r.Name = "ProjectCen ter"
Me.ProjectCente r.Size = New System.Drawing. Size(192, 56)
Me.ProjectCente r.TabIndex = 4
Me.ProjectCente r.Text = "Project Center"
'
'EnterpriseText
'
Me.EnterpriseTe xt.AutoSize = False
Me.EnterpriseTe xt.BackColor = System.Drawing. Color.Teal
Me.EnterpriseTe xt.BorderStyle =
System.Windows. Forms.BorderSty le.None
Me.EnterpriseTe xt.Location = New System.Drawing. Point(280, 125)
Me.EnterpriseTe xt.Multiline = True
Me.EnterpriseTe xt.Name = "EnterpriseText "
Me.EnterpriseTe xt.Size = New System.Drawing. Size(408, 32)
Me.EnterpriseTe xt.TabIndex = 5
Me.EnterpriseTe xt.Text = "Report on, add, edit and maintain groups
of Programs"
'
'TextBox1
'
Me.TextBox1.Aut oSize = False
Me.TextBox1.Bac kColor = System.Drawing. Color.Teal
Me.TextBox1.Bor derStyle = System.Windows. Forms.BorderSty le.None
Me.TextBox1.Loc ation = New System.Drawing. Point(280, 192)
Me.TextBox1.Mul tiline = True
Me.TextBox1.Nam e = "TextBox1"
Me.TextBox1.Siz e = New System.Drawing. Size(408, 32)
Me.TextBox1.Tab Index = 6
Me.TextBox1.Tex t = "Report on, add, edit and maintain Programs of
Projects"
'
'TextBox2
'
Me.TextBox2.Aut oSize = False
Me.TextBox2.Bac kColor = System.Drawing. Color.Teal
Me.TextBox2.Bor derStyle = System.Windows. Forms.BorderSty le.None
Me.TextBox2.Loc ation = New System.Drawing. Point(280, 255)
Me.TextBox2.Mul tiline = True
Me.TextBox2.Nam e = "TextBox2"
Me.TextBox2.Siz e = New System.Drawing. Size(408, 32)
Me.TextBox2.Tab Index = 7
Me.TextBox2.Tex t = "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.Po int,
CType(0, Byte))
Me.Options.Fore Color = System.Drawing. Color.White
Me.Options.Loca tion = New System.Drawing. Point(72, 424)
Me.Options.Name = "Options"
Me.Options.Size = New System.Drawing. Size(192, 56)
Me.Options.TabI ndex = 8
Me.Options.Text = "Options"
'
'TextBox3
'
Me.TextBox3.Aut oSize = False
Me.TextBox3.Bac kColor = System.Drawing. Color.Teal
Me.TextBox3.Bor derStyle = System.Windows. Forms.BorderSty le.None
Me.TextBox3.Loc ation = New System.Drawing. Point(280, 382)
Me.TextBox3.Mul tiline = True
Me.TextBox3.Nam e = "TextBox3"
Me.TextBox3.Siz e = New System.Drawing. Size(408, 32)
Me.TextBox3.Tab Index = 9
Me.TextBox3.Tex t = "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.Po int,
CType(0, Byte))
Me.Tools.ForeCo lor = System.Drawing. Color.White
Me.Tools.Locati on = New System.Drawing. Point(72, 296)
Me.Tools.Name = "Tools"
Me.Tools.Size = New System.Drawing. Size(192, 56)
Me.Tools.TabInd ex = 10
Me.Tools.Text = "Tools"
'
'TextBox4
'
Me.TextBox4.Aut oSize = False
Me.TextBox4.Bac kColor = System.Drawing. Color.Teal
Me.TextBox4.Bor derStyle = System.Windows. Forms.BorderSty le.None
Me.TextBox4.Loc ation = New System.Drawing. Point(280, 319)
Me.TextBox4.Mul tiline = True
Me.TextBox4.Nam e = "TextBox4"
Me.TextBox4.Siz e = New System.Drawing. Size(488, 32)
Me.TextBox4.Tab Index = 11
Me.TextBox4.Tex t = "Tools to create consoildated projects, Maintain
Calendars, Change pay rate tables" & _
" and more"
'
'WeeklyProcess
'
Me.WeeklyProces s.Font = New System.Drawing. Font("Microsoft Sans
Serif", 12.0!, System.Drawing. FontStyle.Bold,
System.Drawing. GraphicsUnit.Po int, CType(0, Byte))
Me.WeeklyProces s.ForeColor = System.Drawing. Color.White
Me.WeeklyProces s.Location = New System.Drawing. Point(72, 360)
Me.WeeklyProces s.Name = "WeeklyProc ess"
Me.WeeklyProces s.Size = New System.Drawing. Size(192, 56)
Me.WeeklyProces s.TabIndex = 12
Me.WeeklyProces s.Text = "Weekly Process"
'
'TextBox5
'
Me.TextBox5.Aut oSize = False
Me.TextBox5.Bac kColor = System.Drawing. Color.Teal
Me.TextBox5.Bor derStyle = System.Windows. Forms.BorderSty le.None
Me.TextBox5.Loc ation = New System.Drawing. Point(280, 448)
Me.TextBox5.Mul tiline = True
Me.TextBox5.Nam e = "TextBox5"
Me.TextBox5.Siz e = New System.Drawing. Size(304, 32)
Me.TextBox5.Tab Index = 13
Me.TextBox5.Tex t = "Set options for Projects and PPM.Net"
'
'MainMenu
'
Me.AutoScaleBas eSize = 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.WeeklyProce ss)
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.EnterpriseT ext)
Me.Controls.Add (Me.ProjectCent er)
Me.Controls.Add (Me.ProgramCent er)
Me.Controls.Add (Me.Enterprise)
Me.Controls.Add (Me.TextBox5)
Me.Name = "MainMenu"
Me.Controls.Set ChildIndex(Me.T extBox5, 0)
Me.Controls.Set ChildIndex(Me.E nterprise, 0)
Me.Controls.Set ChildIndex(Me.P rogramCenter, 0)
Me.Controls.Set ChildIndex(Me.P rojectCenter, 0)
Me.Controls.Set ChildIndex(Me.E nterpriseText, 0)
Me.Controls.Set ChildIndex(Me.T extBox1, 0)
Me.Controls.Set ChildIndex(Me.T extBox2, 0)
Me.Controls.Set ChildIndex(Me.O ptions, 0)
Me.Controls.Set ChildIndex(Me.T extBox3, 0)
Me.Controls.Set ChildIndex(Me.T ools, 0)
Me.Controls.Set ChildIndex(Me.T extBox4, 0)
Me.Controls.Set ChildIndex(Me.W eeklyProcess, 0)
Me.ResumeLayout (False)
End Sub
#End Region
Private Sub Enterprise_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles Enterprise.Clic k
MessageBox.Show ("Enterprise Form", "Menu", MessageBoxButto ns.OK,
MessageBoxIcon. Information)
End Sub
Private Sub ProgramCenter_C lick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles ProgramCenter.C lick
MessageBox.Show ("Program Form", "Menu", MessageBoxButto ns.OK,
MessageBoxIcon. Information)
End Sub
Private Sub ProjectCenter_C lick(ByVal sender As Object, ByVal e As
System.EventArg s) Handles ProjectCenter.C lick
MessageBox.Show ("Project Form", "Menu", MessageBoxButto ns.OK,
MessageBoxIcon. Information)
End Sub
' Private Sub MainMenu_Paint( ByVal sender As Object, ByVal e As
System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint
' Me.Size = New Size(800, 500)
' End Sub
Private Sub MainMenu_Load(B yVal sender As Object, ByVal e As
System.EventArg s) 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.StartPositio n = FormStartPositi on.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******** ******@TK2MSFTN GP10.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******** ******@TK2MSFTN GP12.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