By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,612 Members | 1,632 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,612 IT Pros & Developers. It's quick & easy.

Form size ???

P: n/a
My current screen resolution is set to 1024 x 768. My form size always comes
up as 1032 x 748.

I have tried the help sample
' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea

' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width, _
workingRectangle.Height)

' Set the location so the entire form is visible.
Me.Location = New System.Drawing.Point(0, 0)

the workingRectangle comes up as 1024 x 740. the Me.Size comes up as 1032 x
748 and location as -4 x -4

It doesn't matter what the StartPosition and AutoSize is set to. What gives?

I'm trying to use the Form Width to set a drawing Panel (PictDraw) to the
maximum width based on the the width being a multiple of 4. I guess I'll
have to use the SystemDrawing.Size(workingRectangle.Width) in the following
code. The Form margin is set to Single.

Index = Me.Width - 2
Index = Int(Index / 4)
Index = Index * 4
gScreen.HorPixels = Index
With PictDraw
X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
X1Y1.Y = 0
.Location = X1Y1
X2Y2.X = gScreen.HorPixels
X2Y2.Y = 450
.Size = X2Y2
End With

Any ideas as to why the form always comes up 1032 X748 ?

GalenS
Mar 30 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a
You should consider setting the location to be the location of the working
area rectangle, otherwise your form might not display properly on desktops
where the taskbar is along either the top or left edges. E.g.

Location = workingRectangle.Location
Size = workingRectangle.Size

When is the code that sets the size called? Is it called after
InitializeComponent? You could try handling the LocationChanged and
SizeChanged events of the form and see if they are raised when your code
sets the properties. It could be that some other code is changing the
properties after you, which means you'll see the events raised again.

--
Kevin Westhead

"Galen Somerville" <ga***@community.nospam> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
My current screen resolution is set to 1024 x 768. My form size always
comes up as 1032 x 748.

I have tried the help sample
' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea

' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width, _
workingRectangle.Height)

' Set the location so the entire form is visible.
Me.Location = New System.Drawing.Point(0, 0)

the workingRectangle comes up as 1024 x 740. the Me.Size comes up as 1032
x 748 and location as -4 x -4

It doesn't matter what the StartPosition and AutoSize is set to. What
gives?

<snip>

Mar 30 '06 #2

P: n/a
Maybe your Form's Minimum size is set to that?.. there is a property for
Minimum size.. check that...

VJ

"Galen Somerville" <ga***@community.nospam> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
My current screen resolution is set to 1024 x 768. My form size always
comes up as 1032 x 748.

I have tried the help sample
' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea

' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width, _
workingRectangle.Height)

' Set the location so the entire form is visible.
Me.Location = New System.Drawing.Point(0, 0)

the workingRectangle comes up as 1024 x 740. the Me.Size comes up as 1032
x 748 and location as -4 x -4

It doesn't matter what the StartPosition and AutoSize is set to. What
gives?

I'm trying to use the Form Width to set a drawing Panel (PictDraw) to the
maximum width based on the the width being a multiple of 4. I guess I'll
have to use the SystemDrawing.Size(workingRectangle.Width) in the
following code. The Form margin is set to Single.

Index = Me.Width - 2
Index = Int(Index / 4)
Index = Index * 4
gScreen.HorPixels = Index
With PictDraw
X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
X1Y1.Y = 0
.Location = X1Y1
X2Y2.X = gScreen.HorPixels
X2Y2.Y = 450
.Size = X2Y2
End With

Any ideas as to why the form always comes up 1032 X748 ?

GalenS

Mar 30 '06 #3

P: n/a
"Galen Somerville" <ga***@community.nospam> schrieb:
My current screen resolution is set to 1024 x 768. My form size always
comes up as 1032 x 748.


Form's cannot be larger than the desktop's working area.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 30 '06 #4

P: n/a
I forgot to mention that the sizing code is in Form_Load

GalenS

"Kevin Westhead" <ma***********@nospam.nospam> wrote in message
news:Oh**************@TK2MSFTNGP11.phx.gbl...
You should consider setting the location to be the location of the working
area rectangle, otherwise your form might not display properly on desktops
where the taskbar is along either the top or left edges. E.g.

Location = workingRectangle.Location
Size = workingRectangle.Size

When is the code that sets the size called? Is it called after
InitializeComponent? You could try handling the LocationChanged and
SizeChanged events of the form and see if they are raised when your code
sets the properties. It could be that some other code is changing the
properties after you, which means you'll see the events raised again.

--
Kevin Westhead

"Galen Somerville" <ga***@community.nospam> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
My current screen resolution is set to 1024 x 768. My form size always
comes up as 1032 x 748.

I have tried the help sample
' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea

' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width, _
workingRectangle.Height)

' Set the location so the entire form is visible.
Me.Location = New System.Drawing.Point(0, 0)

the workingRectangle comes up as 1024 x 740. the Me.Size comes up as 1032
x 748 and location as -4 x -4

It doesn't matter what the StartPosition and AutoSize is set to. What
gives?

<snip>


Mar 31 '06 #5

P: n/a
I know, that'swhy I asked the questions. I was basing my Panel width based
on Me.Width and the Panel always filled the screen with no Form border
showing. I set a breakpoint and it shows Me.Width as 1032.

That's when I added the workingRectangle code to try to correct it. Still
1032

GalenS

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eN**************@TK2MSFTNGP14.phx.gbl...
"Galen Somerville" <ga***@community.nospam> schrieb:
My current screen resolution is set to 1024 x 768. My form size always
comes up as 1032 x 748.


Form's cannot be larger than the desktop's working area.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 31 '06 #6

P: n/a
Galen,

I have the idea that you are doing the same problamatic things as was be
done in the VB versions from the previous milenium

Do you know the properties Dock and Anchor.

They will make your live probably much easier.

I hope this helps,

Cor
"Galen Somerville" <ga***@community.nospam> schreef in bericht
news:e8**************@TK2MSFTNGP12.phx.gbl...
My current screen resolution is set to 1024 x 768. My form size always
comes up as 1032 x 748.

I have tried the help sample
' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea

' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width, _
workingRectangle.Height)

' Set the location so the entire form is visible.
Me.Location = New System.Drawing.Point(0, 0)

the workingRectangle comes up as 1024 x 740. the Me.Size comes up as 1032
x 748 and location as -4 x -4

It doesn't matter what the StartPosition and AutoSize is set to. What
gives?

I'm trying to use the Form Width to set a drawing Panel (PictDraw) to the
maximum width based on the the width being a multiple of 4. I guess I'll
have to use the SystemDrawing.Size(workingRectangle.Width) in the
following code. The Form margin is set to Single.

Index = Me.Width - 2
Index = Int(Index / 4)
Index = Index * 4
gScreen.HorPixels = Index
With PictDraw
X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
X1Y1.Y = 0
.Location = X1Y1
X2Y2.X = gScreen.HorPixels
X2Y2.Y = 450
.Size = X2Y2
End With

Any ideas as to why the form always comes up 1032 X748 ?

GalenS

Mar 31 '06 #7

P: n/a
Cor

All controls have Anchor set. The control in question is a user control and
intitially it is a small square in an unused portion of screen.

When required it is sized at run time. I have found that the following code
cures my problem
With gScreen

..HorPixels = Screen.GetBounds(Rect).Width

..VerPixels = Screen.GetBounds(Rect).Height

End With

GalenS

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Galen,

I have the idea that you are doing the same problamatic things as was be
done in the VB versions from the previous milenium

Do you know the properties Dock and Anchor.

They will make your live probably much easier.

I hope this helps,

Cor
"Galen Somerville" <ga***@community.nospam> schreef in bericht
news:e8**************@TK2MSFTNGP12.phx.gbl...
My current screen resolution is set to 1024 x 768. My form size always
comes up as 1032 x 748.

I have tried the help sample
' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea

' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width, _
workingRectangle.Height)

' Set the location so the entire form is visible.
Me.Location = New System.Drawing.Point(0, 0)

the workingRectangle comes up as 1024 x 740. the Me.Size comes up as 1032
x 748 and location as -4 x -4

It doesn't matter what the StartPosition and AutoSize is set to. What
gives?

I'm trying to use the Form Width to set a drawing Panel (PictDraw) to the
maximum width based on the the width being a multiple of 4. I guess I'll
have to use the SystemDrawing.Size(workingRectangle.Width) in the
following code. The Form margin is set to Single.

Index = Me.Width - 2
Index = Int(Index / 4)
Index = Index * 4
gScreen.HorPixels = Index
With PictDraw
X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
X1Y1.Y = 0
.Location = X1Y1
X2Y2.X = gScreen.HorPixels
X2Y2.Y = 450
.Size = X2Y2
End With

Any ideas as to why the form always comes up 1032 X748 ?

GalenS


Mar 31 '06 #8

P: n/a
The point everyone has seemed to missed is that you have your form
maximized.

When a form is maximized the width of the form is the working area width +
the form left border width + the form right border width and the height of
the form is the working height is the working area height + the form top
border height + the form bottom border height. The position of the form is
0 - the form left border width, 0 - the form top border width.

This 'positioning' and 'sizing' means that a maximized form automatically
takes account of the position and size of the taskbar (if it is showing) no
matter where it actually positioned.

The upshot is, the portion of the maximized form that you can actually see
is the Title Bar and the client area - some of the client area may be
'reserved' for menubars, toolbars, statusbars and other controls that do not
form part of the client area depending on which VS version you are using.

It seems to me that you really want to position and size your user control
in relation to the client area and therefore you can use Me.ClientSize
property for this purpose without having to resort to convuluted maths.
"Galen Somerville" <ga***@community.nospam> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
Cor

All controls have Anchor set. The control in question is a user control
and intitially it is a small square in an unused portion of screen.

When required it is sized at run time. I have found that the following
code cures my problem
With gScreen

.HorPixels = Screen.GetBounds(Rect).Width

.VerPixels = Screen.GetBounds(Rect).Height

End With

GalenS

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Galen,

I have the idea that you are doing the same problamatic things as was be
done in the VB versions from the previous milenium

Do you know the properties Dock and Anchor.

They will make your live probably much easier.

I hope this helps,

Cor
"Galen Somerville" <ga***@community.nospam> schreef in bericht
news:e8**************@TK2MSFTNGP12.phx.gbl...
My current screen resolution is set to 1024 x 768. My form size always
comes up as 1032 x 748.

I have tried the help sample
' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea

' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width, _
workingRectangle.Height)

' Set the location so the entire form is visible.
Me.Location = New System.Drawing.Point(0, 0)

the workingRectangle comes up as 1024 x 740. the Me.Size comes up as
1032 x 748 and location as -4 x -4

It doesn't matter what the StartPosition and AutoSize is set to. What
gives?

I'm trying to use the Form Width to set a drawing Panel (PictDraw) to
the maximum width based on the the width being a multiple of 4. I guess
I'll have to use the SystemDrawing.Size(workingRectangle.Width) in the
following code. The Form margin is set to Single.

Index = Me.Width - 2
Index = Int(Index / 4)
Index = Index * 4
gScreen.HorPixels = Index
With PictDraw
X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
X1Y1.Y = 0
.Location = X1Y1
X2Y2.X = gScreen.HorPixels
X2Y2.Y = 450
.Size = X2Y2
End With

Any ideas as to why the form always comes up 1032 X748 ?

GalenS



Apr 2 '06 #9

P: n/a
Stephany

That explains why Me.Width doesn't work. I did end up using the Client area
width but I still do the math to get multiples of 4 pixels for the Panel.

Other than setting the Anchor points I'm more interested in getting the
whole program working properly before I worry about resizing all forms to
greater than 1024 x 768.

Thanks
GalenS

"Stephany Young" <noone@localhost> wrote in message
news:Ou**************@TK2MSFTNGP15.phx.gbl...
The point everyone has seemed to missed is that you have your form
maximized.

When a form is maximized the width of the form is the working area width +
the form left border width + the form right border width and the height of
the form is the working height is the working area height + the form top
border height + the form bottom border height. The position of the form is
0 - the form left border width, 0 - the form top border width.

This 'positioning' and 'sizing' means that a maximized form automatically
takes account of the position and size of the taskbar (if it is showing)
no matter where it actually positioned.

The upshot is, the portion of the maximized form that you can actually see
is the Title Bar and the client area - some of the client area may be
'reserved' for menubars, toolbars, statusbars and other controls that do
not form part of the client area depending on which VS version you are
using.

It seems to me that you really want to position and size your user control
in relation to the client area and therefore you can use Me.ClientSize
property for this purpose without having to resort to convuluted maths.
"Galen Somerville" <ga***@community.nospam> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
Cor

All controls have Anchor set. The control in question is a user control
and intitially it is a small square in an unused portion of screen.

When required it is sized at run time. I have found that the following
code cures my problem
With gScreen

.HorPixels = Screen.GetBounds(Rect).Width

.VerPixels = Screen.GetBounds(Rect).Height

End With

GalenS

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Galen,

I have the idea that you are doing the same problamatic things as was be
done in the VB versions from the previous milenium

Do you know the properties Dock and Anchor.

They will make your live probably much easier.

I hope this helps,

Cor
"Galen Somerville" <ga***@community.nospam> schreef in bericht
news:e8**************@TK2MSFTNGP12.phx.gbl...
My current screen resolution is set to 1024 x 768. My form size always
comes up as 1032 x 748.

I have tried the help sample
' Retrieve the working rectangle from the Screen class
' using the PrimaryScreen and the WorkingArea properties.
Dim workingRectangle As System.Drawing.Rectangle = _
Screen.PrimaryScreen.WorkingArea

' Set the size of the form slightly less than size of
' working rectangle.
Me.Size = New System.Drawing.Size(workingRectangle.Width, _
workingRectangle.Height)

' Set the location so the entire form is visible.
Me.Location = New System.Drawing.Point(0, 0)

the workingRectangle comes up as 1024 x 740. the Me.Size comes up as
1032 x 748 and location as -4 x -4

It doesn't matter what the StartPosition and AutoSize is set to. What
gives?

I'm trying to use the Form Width to set a drawing Panel (PictDraw) to
the maximum width based on the the width being a multiple of 4. I guess
I'll have to use the SystemDrawing.Size(workingRectangle.Width) in the
following code. The Form margin is set to Single.

Index = Me.Width - 2
Index = Int(Index / 4)
Index = Index * 4
gScreen.HorPixels = Index
With PictDraw
X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
X1Y1.Y = 0
.Location = X1Y1
X2Y2.X = gScreen.HorPixels
X2Y2.Y = 450
.Size = X2Y2
End With

Any ideas as to why the form always comes up 1032 X748 ?

GalenS



Apr 3 '06 #10

P: n/a
Is what you you are trying to achieve as follows:

1. Make the width of the panel the multiple of 4 pixels that is less than or
equal to the width of the client area

2. Make the height of the panel the multiple of 4 pixels that is less than
or equal to the height of the client area

3. Center the panel in the client area

If so then it is as simple as:

Panel.Size = New Size(Me.ClientSize.Width - (Me.ClientSize.Width Mod 4),
Me.ClientSize.Height - (Me.ClientSize.Height Mod 4)

Panel.Location = New Location((Me.ClientSize.Width - Panel.Width) / 2),
(Me.ClientSize.Height - Panel.Height) / 2)
"Galen Somerville" <ga***@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Stephany

That explains why Me.Width doesn't work. I did end up using the Client
area width but I still do the math to get multiples of 4 pixels for the
Panel.

Other than setting the Anchor points I'm more interested in getting the
whole program working properly before I worry about resizing all forms to
greater than 1024 x 768.

Thanks
GalenS

"Stephany Young" <noone@localhost> wrote in message
news:Ou**************@TK2MSFTNGP15.phx.gbl...
The point everyone has seemed to missed is that you have your form
maximized.

When a form is maximized the width of the form is the working area width
+ the form left border width + the form right border width and the height
of the form is the working height is the working area height + the form
top border height + the form bottom border height. The position of the
form is 0 - the form left border width, 0 - the form top border width.

This 'positioning' and 'sizing' means that a maximized form automatically
takes account of the position and size of the taskbar (if it is showing)
no matter where it actually positioned.

The upshot is, the portion of the maximized form that you can actually
see is the Title Bar and the client area - some of the client area may be
'reserved' for menubars, toolbars, statusbars and other controls that do
not form part of the client area depending on which VS version you are
using.

It seems to me that you really want to position and size your user
control in relation to the client area and therefore you can use
Me.ClientSize property for this purpose without having to resort to
convuluted maths.
"Galen Somerville" <ga***@community.nospam> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
Cor

All controls have Anchor set. The control in question is a user control
and intitially it is a small square in an unused portion of screen.

When required it is sized at run time. I have found that the following
code cures my problem
With gScreen

.HorPixels = Screen.GetBounds(Rect).Width

.VerPixels = Screen.GetBounds(Rect).Height

End With

GalenS

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
Galen,

I have the idea that you are doing the same problamatic things as was
be done in the VB versions from the previous milenium

Do you know the properties Dock and Anchor.

They will make your live probably much easier.

I hope this helps,

Cor
"Galen Somerville" <ga***@community.nospam> schreef in bericht
news:e8**************@TK2MSFTNGP12.phx.gbl...
> My current screen resolution is set to 1024 x 768. My form size always
> comes up as 1032 x 748.
>
> I have tried the help sample
> ' Retrieve the working rectangle from the Screen class
> ' using the PrimaryScreen and the WorkingArea properties.
> Dim workingRectangle As System.Drawing.Rectangle = _
> Screen.PrimaryScreen.WorkingArea
>
> ' Set the size of the form slightly less than size of
> ' working rectangle.
> Me.Size = New System.Drawing.Size(workingRectangle.Width, _
> workingRectangle.Height)
>
> ' Set the location so the entire form is visible.
> Me.Location = New System.Drawing.Point(0, 0)
>
> the workingRectangle comes up as 1024 x 740. the Me.Size comes up as
> 1032 x 748 and location as -4 x -4
>
> It doesn't matter what the StartPosition and AutoSize is set to. What
> gives?
>
> I'm trying to use the Form Width to set a drawing Panel (PictDraw) to
> the maximum width based on the the width being a multiple of 4. I
> guess I'll have to use the SystemDrawing.Size(workingRectangle.Width)
> in the following code. The Form margin is set to Single.
>
> Index = Me.Width - 2
> Index = Int(Index / 4)
> Index = Index * 4
> gScreen.HorPixels = Index
> With PictDraw
> X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
> X1Y1.Y = 0
> .Location = X1Y1
> X2Y2.X = gScreen.HorPixels
> X2Y2.Y = 450
> .Size = X2Y2
> End With
>
> Any ideas as to why the form always comes up 1032 X748 ?
>
> GalenS
>
>



Apr 3 '06 #11

P: n/a
The heigth is fixed.

In VB6 my Picturebox always filled the screen horizontally. Now I decided to
let the forms borders show. It's a single border so I assume we are looking
at

Panel.Size = New Size(Me.ClientSize.Width - ((Me.ClientSize.Width- 2) Mod
4)

Panel.Location = New Location((Me.ClientSize.Width - Panel.Width) / 2),
Iheigth)

GalenS

"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Is what you you are trying to achieve as follows:

1. Make the width of the panel the multiple of 4 pixels that is less than
or equal to the width of the client area

2. Make the height of the panel the multiple of 4 pixels that is less than
or equal to the height of the client area

3. Center the panel in the client area

If so then it is as simple as:

Panel.Size = New Size(Me.ClientSize.Width - (Me.ClientSize.Width Mod 4),
Me.ClientSize.Height - (Me.ClientSize.Height Mod 4)

Panel.Location = New Location((Me.ClientSize.Width - Panel.Width) / 2),
(Me.ClientSize.Height - Panel.Height) / 2)
"Galen Somerville" <ga***@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Stephany

That explains why Me.Width doesn't work. I did end up using the Client
area width but I still do the math to get multiples of 4 pixels for the
Panel.

Other than setting the Anchor points I'm more interested in getting the
whole program working properly before I worry about resizing all forms to
greater than 1024 x 768.

Thanks
GalenS

"Stephany Young" <noone@localhost> wrote in message
news:Ou**************@TK2MSFTNGP15.phx.gbl...
The point everyone has seemed to missed is that you have your form
maximized.

When a form is maximized the width of the form is the working area width
+ the form left border width + the form right border width and the
height of the form is the working height is the working area height +
the form top border height + the form bottom border height. The position
of the form is 0 - the form left border width, 0 - the form top border
width.

This 'positioning' and 'sizing' means that a maximized form
automatically takes account of the position and size of the taskbar (if
it is showing) no matter where it actually positioned.

The upshot is, the portion of the maximized form that you can actually
see is the Title Bar and the client area - some of the client area may
be 'reserved' for menubars, toolbars, statusbars and other controls that
do not form part of the client area depending on which VS version you
are using.

It seems to me that you really want to position and size your user
control in relation to the client area and therefore you can use
Me.ClientSize property for this purpose without having to resort to
convuluted maths.
"Galen Somerville" <ga***@community.nospam> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
Cor

All controls have Anchor set. The control in question is a user control
and intitially it is a small square in an unused portion of screen.

When required it is sized at run time. I have found that the following
code cures my problem
With gScreen

.HorPixels = Screen.GetBounds(Rect).Width

.VerPixels = Screen.GetBounds(Rect).Height

End With

GalenS

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
> Galen,
>
> I have the idea that you are doing the same problamatic things as was
> be done in the VB versions from the previous milenium
>
> Do you know the properties Dock and Anchor.
>
> They will make your live probably much easier.
>
> I hope this helps,
>
> Cor
>
>
> "Galen Somerville" <ga***@community.nospam> schreef in bericht
> news:e8**************@TK2MSFTNGP12.phx.gbl...
>> My current screen resolution is set to 1024 x 768. My form size
>> always comes up as 1032 x 748.
>>
>> I have tried the help sample
>> ' Retrieve the working rectangle from the Screen class
>> ' using the PrimaryScreen and the WorkingArea properties.
>> Dim workingRectangle As System.Drawing.Rectangle = _
>> Screen.PrimaryScreen.WorkingArea
>>
>> ' Set the size of the form slightly less than size of
>> ' working rectangle.
>> Me.Size = New System.Drawing.Size(workingRectangle.Width, _
>> workingRectangle.Height)
>>
>> ' Set the location so the entire form is visible.
>> Me.Location = New System.Drawing.Point(0, 0)
>>
>> the workingRectangle comes up as 1024 x 740. the Me.Size comes up as
>> 1032 x 748 and location as -4 x -4
>>
>> It doesn't matter what the StartPosition and AutoSize is set to. What
>> gives?
>>
>> I'm trying to use the Form Width to set a drawing Panel (PictDraw) to
>> the maximum width based on the the width being a multiple of 4. I
>> guess I'll have to use the SystemDrawing.Size(workingRectangle.Width)
>> in the following code. The Form margin is set to Single.
>>
>> Index = Me.Width - 2
>> Index = Int(Index / 4)
>> Index = Index * 4
>> gScreen.HorPixels = Index
>> With PictDraw
>> X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
>> X1Y1.Y = 0
>> .Location = X1Y1
>> X2Y2.X = gScreen.HorPixels
>> X2Y2.Y = 450
>> .Size = X2Y2
>> End With
>>
>> Any ideas as to why the form always comes up 1032 X748 ?
>>
>> GalenS
>>
>>
>
>



Apr 3 '06 #12

P: n/a
Nearly.

The ClientSize.Width is already the width of the portion of tyhe form
'inside' the borders, so the calculation is:

Panel.Size = New Size(Me.ClientSize.Width, IHeight)

Panel.Location = New Location(0, (Me.ClientSize.Height - Panel.Height) /
2)

Note that the location of the Panel is in relation to the top left of the
client area of the form, not the top left of the screen.
"Galen Somerville" <ga***@community.nospam> wrote in message
news:OK**************@tk2msftngp13.phx.gbl...
The heigth is fixed.

In VB6 my Picturebox always filled the screen horizontally. Now I decided
to let the forms borders show. It's a single border so I assume we are
looking at

Panel.Size = New Size(Me.ClientSize.Width - ((Me.ClientSize.Width- 2) Mod
4)

Panel.Location = New Location((Me.ClientSize.Width - Panel.Width) / 2),
Iheigth)

GalenS

"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Is what you you are trying to achieve as follows:

1. Make the width of the panel the multiple of 4 pixels that is less than
or equal to the width of the client area

2. Make the height of the panel the multiple of 4 pixels that is less
than or equal to the height of the client area

3. Center the panel in the client area

If so then it is as simple as:

Panel.Size = New Size(Me.ClientSize.Width - (Me.ClientSize.Width Mod 4),
Me.ClientSize.Height - (Me.ClientSize.Height Mod 4)

Panel.Location = New Location((Me.ClientSize.Width - Panel.Width) / 2),
(Me.ClientSize.Height - Panel.Height) / 2)
"Galen Somerville" <ga***@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Stephany

That explains why Me.Width doesn't work. I did end up using the Client
area width but I still do the math to get multiples of 4 pixels for the
Panel.

Other than setting the Anchor points I'm more interested in getting the
whole program working properly before I worry about resizing all forms
to greater than 1024 x 768.

Thanks
GalenS

"Stephany Young" <noone@localhost> wrote in message
news:Ou**************@TK2MSFTNGP15.phx.gbl...
The point everyone has seemed to missed is that you have your form
maximized.

When a form is maximized the width of the form is the working area
width + the form left border width + the form right border width and
the height of the form is the working height is the working area height
+ the form top border height + the form bottom border height. The
position of the form is 0 - the form left border width, 0 - the form
top border width.

This 'positioning' and 'sizing' means that a maximized form
automatically takes account of the position and size of the taskbar (if
it is showing) no matter where it actually positioned.

The upshot is, the portion of the maximized form that you can actually
see is the Title Bar and the client area - some of the client area may
be 'reserved' for menubars, toolbars, statusbars and other controls
that do not form part of the client area depending on which VS version
you are using.

It seems to me that you really want to position and size your user
control in relation to the client area and therefore you can use
Me.ClientSize property for this purpose without having to resort to
convuluted maths.
"Galen Somerville" <ga***@community.nospam> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
> Cor
>
> All controls have Anchor set. The control in question is a user
> control and intitially it is a small square in an unused portion of
> screen.
>
> When required it is sized at run time. I have found that the following
> code cures my problem
> With gScreen
>
> .HorPixels = Screen.GetBounds(Rect).Width
>
> .VerPixels = Screen.GetBounds(Rect).Height
>
> End With
>
> GalenS
>
>
>
> "Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
> news:ub**************@TK2MSFTNGP10.phx.gbl...
>> Galen,
>>
>> I have the idea that you are doing the same problamatic things as was
>> be done in the VB versions from the previous milenium
>>
>> Do you know the properties Dock and Anchor.
>>
>> They will make your live probably much easier.
>>
>> I hope this helps,
>>
>> Cor
>>
>>
>> "Galen Somerville" <ga***@community.nospam> schreef in bericht
>> news:e8**************@TK2MSFTNGP12.phx.gbl...
>>> My current screen resolution is set to 1024 x 768. My form size
>>> always comes up as 1032 x 748.
>>>
>>> I have tried the help sample
>>> ' Retrieve the working rectangle from the Screen class
>>> ' using the PrimaryScreen and the WorkingArea properties.
>>> Dim workingRectangle As System.Drawing.Rectangle = _
>>> Screen.PrimaryScreen.WorkingArea
>>>
>>> ' Set the size of the form slightly less than size of
>>> ' working rectangle.
>>> Me.Size = New System.Drawing.Size(workingRectangle.Width, _
>>> workingRectangle.Height)
>>>
>>> ' Set the location so the entire form is visible.
>>> Me.Location = New System.Drawing.Point(0, 0)
>>>
>>> the workingRectangle comes up as 1024 x 740. the Me.Size comes up as
>>> 1032 x 748 and location as -4 x -4
>>>
>>> It doesn't matter what the StartPosition and AutoSize is set to.
>>> What gives?
>>>
>>> I'm trying to use the Form Width to set a drawing Panel (PictDraw)
>>> to the maximum width based on the the width being a multiple of 4. I
>>> guess I'll have to use the
>>> SystemDrawing.Size(workingRectangle.Width) in the following code.
>>> The Form margin is set to Single.
>>>
>>> Index = Me.Width - 2
>>> Index = Int(Index / 4)
>>> Index = Index * 4
>>> gScreen.HorPixels = Index
>>> With PictDraw
>>> X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
>>> X1Y1.Y = 0
>>> .Location = X1Y1
>>> X2Y2.X = gScreen.HorPixels
>>> X2Y2.Y = 450
>>> .Size = X2Y2
>>> End With
>>>
>>> Any ideas as to why the form always comes up 1032 X748 ?
>>>
>>> GalenS
>>>
>>>
>>
>>
>
>



Apr 3 '06 #13

P: n/a
Nope
Me.ClientSize came out as 1,024 so I'm back to
Panel.Size = New Size(Me.ClientSize.Width - ((Me.ClientSize.Width- 2) Mod
4), 573)

and I want it at top of Client area so
Panel.Location = New Point((Me.ClientSize.Width - Panel.Width) / 2), 0)

GalenS

"Stephany Young" <noone@localhost> wrote in message
news:eg*************@TK2MSFTNGP10.phx.gbl...
Nearly.

The ClientSize.Width is already the width of the portion of tyhe form
'inside' the borders, so the calculation is:

Panel.Size = New Size(Me.ClientSize.Width, IHeight)

Panel.Location = New Location(0, (Me.ClientSize.Height - Panel.Height) /
2)

Note that the location of the Panel is in relation to the top left of the
client area of the form, not the top left of the screen.
"Galen Somerville" <ga***@community.nospam> wrote in message
news:OK**************@tk2msftngp13.phx.gbl...
The heigth is fixed.

In VB6 my Picturebox always filled the screen horizontally. Now I decided
to let the forms borders show. It's a single border so I assume we are
looking at

Panel.Size = New Size(Me.ClientSize.Width - ((Me.ClientSize.Width- 2) Mod
4)

Panel.Location = New Location((Me.ClientSize.Width - Panel.Width) / 2),
Iheigth)

GalenS

"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Is what you you are trying to achieve as follows:

1. Make the width of the panel the multiple of 4 pixels that is less
than or equal to the width of the client area

2. Make the height of the panel the multiple of 4 pixels that is less
than or equal to the height of the client area

3. Center the panel in the client area

If so then it is as simple as:

Panel.Size = New Size(Me.ClientSize.Width - (Me.ClientSize.Width Mod
4), Me.ClientSize.Height - (Me.ClientSize.Height Mod 4)

Panel.Location = New Location((Me.ClientSize.Width - Panel.Width) / 2),
(Me.ClientSize.Height - Panel.Height) / 2)
"Galen Somerville" <ga***@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Stephany

That explains why Me.Width doesn't work. I did end up using the Client
area width but I still do the math to get multiples of 4 pixels for the
Panel.

Other than setting the Anchor points I'm more interested in getting the
whole program working properly before I worry about resizing all forms
to greater than 1024 x 768.

Thanks
GalenS

"Stephany Young" <noone@localhost> wrote in message
news:Ou**************@TK2MSFTNGP15.phx.gbl...
> The point everyone has seemed to missed is that you have your form
> maximized.
>
> When a form is maximized the width of the form is the working area
> width + the form left border width + the form right border width and
> the height of the form is the working height is the working area
> height + the form top border height + the form bottom border height.
> The position of the form is 0 - the form left border width, 0 - the
> form top border width.
>
> This 'positioning' and 'sizing' means that a maximized form
> automatically takes account of the position and size of the taskbar
> (if it is showing) no matter where it actually positioned.
>
> The upshot is, the portion of the maximized form that you can actually
> see is the Title Bar and the client area - some of the client area may
> be 'reserved' for menubars, toolbars, statusbars and other controls
> that do not form part of the client area depending on which VS version
> you are using.
>
> It seems to me that you really want to position and size your user
> control in relation to the client area and therefore you can use
> Me.ClientSize property for this purpose without having to resort to
> convuluted maths.
>
>
> "Galen Somerville" <ga***@community.nospam> wrote in message
> news:es**************@TK2MSFTNGP10.phx.gbl...
>> Cor
>>
>> All controls have Anchor set. The control in question is a user
>> control and intitially it is a small square in an unused portion of
>> screen.
>>
>> When required it is sized at run time. I have found that the
>> following code cures my problem
>> With gScreen
>>
>> .HorPixels = Screen.GetBounds(Rect).Width
>>
>> .VerPixels = Screen.GetBounds(Rect).Height
>>
>> End With
>>
>> GalenS
>>
>>
>>
>> "Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
>> news:ub**************@TK2MSFTNGP10.phx.gbl...
>>> Galen,
>>>
>>> I have the idea that you are doing the same problamatic things as
>>> was be done in the VB versions from the previous milenium
>>>
>>> Do you know the properties Dock and Anchor.
>>>
>>> They will make your live probably much easier.
>>>
>>> I hope this helps,
>>>
>>> Cor
>>>
>>>
>>> "Galen Somerville" <ga***@community.nospam> schreef in bericht
>>> news:e8**************@TK2MSFTNGP12.phx.gbl...
>>>> My current screen resolution is set to 1024 x 768. My form size
>>>> always comes up as 1032 x 748.
>>>>
>>>> I have tried the help sample
>>>> ' Retrieve the working rectangle from the Screen class
>>>> ' using the PrimaryScreen and the WorkingArea properties.
>>>> Dim workingRectangle As System.Drawing.Rectangle = _
>>>> Screen.PrimaryScreen.WorkingArea
>>>>
>>>> ' Set the size of the form slightly less than size of
>>>> ' working rectangle.
>>>> Me.Size = New System.Drawing.Size(workingRectangle.Width, _
>>>> workingRectangle.Height)
>>>>
>>>> ' Set the location so the entire form is visible.
>>>> Me.Location = New System.Drawing.Point(0, 0)
>>>>
>>>> the workingRectangle comes up as 1024 x 740. the Me.Size comes up
>>>> as 1032 x 748 and location as -4 x -4
>>>>
>>>> It doesn't matter what the StartPosition and AutoSize is set to.
>>>> What gives?
>>>>
>>>> I'm trying to use the Form Width to set a drawing Panel (PictDraw)
>>>> to the maximum width based on the the width being a multiple of 4.
>>>> I guess I'll have to use the
>>>> SystemDrawing.Size(workingRectangle.Width) in the following code.
>>>> The Form margin is set to Single.
>>>>
>>>> Index = Me.Width - 2
>>>> Index = Int(Index / 4)
>>>> Index = Index * 4
>>>> gScreen.HorPixels = Index
>>>> With PictDraw
>>>> X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
>>>> X1Y1.Y = 0
>>>> .Location = X1Y1
>>>> X2Y2.X = gScreen.HorPixels
>>>> X2Y2.Y = 450
>>>> .Size = X2Y2
>>>> End With
>>>>
>>>> Any ideas as to why the form always comes up 1032 X748 ?
>>>>
>>>> GalenS
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Apr 3 '06 #14

P: n/a
Stephany

The actual code ended up as follows

PictDraw.Size = New Size((Int((Me.ClientSize.Width - 2) / 4)) * 4,
450)
PictDraw.Location = New Point(((Me.ClientSize.Width -
PictDraw.Width) / 2), 0)
gScreen.HorPixels = PictDraw.Width

GalenS

"Galen Somerville" <ga***@community.nospam> wrote in message
news:eU**************@tk2msftngp13.phx.gbl...
Nope
Me.ClientSize came out as 1,024 so I'm back to
Panel.Size = New Size(Me.ClientSize.Width - ((Me.ClientSize.Width- 2) Mod
4), 573)

and I want it at top of Client area so
Panel.Location = New Point((Me.ClientSize.Width - Panel.Width) / 2), 0)

GalenS

"Stephany Young" <noone@localhost> wrote in message
news:eg*************@TK2MSFTNGP10.phx.gbl...
Nearly.

The ClientSize.Width is already the width of the portion of tyhe form
'inside' the borders, so the calculation is:

Panel.Size = New Size(Me.ClientSize.Width, IHeight)

Panel.Location = New Location(0, (Me.ClientSize.Height - Panel.Height) /
2)

Note that the location of the Panel is in relation to the top left of the
client area of the form, not the top left of the screen.
"Galen Somerville" <ga***@community.nospam> wrote in message
news:OK**************@tk2msftngp13.phx.gbl...
The heigth is fixed.

In VB6 my Picturebox always filled the screen horizontally. Now I
decided to let the forms borders show. It's a single border so I assume
we are looking at

Panel.Size = New Size(Me.ClientSize.Width - ((Me.ClientSize.Width- 2)
Mod 4)

Panel.Location = New Location((Me.ClientSize.Width - Panel.Width) / 2),
Iheigth)

GalenS

"Stephany Young" <noone@localhost> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Is what you you are trying to achieve as follows:

1. Make the width of the panel the multiple of 4 pixels that is less
than or equal to the width of the client area

2. Make the height of the panel the multiple of 4 pixels that is less
than or equal to the height of the client area

3. Center the panel in the client area

If so then it is as simple as:

Panel.Size = New Size(Me.ClientSize.Width - (Me.ClientSize.Width Mod
4), Me.ClientSize.Height - (Me.ClientSize.Height Mod 4)

Panel.Location = New Location((Me.ClientSize.Width - Panel.Width) /
2), (Me.ClientSize.Height - Panel.Height) / 2)
"Galen Somerville" <ga***@community.nospam> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
> Stephany
>
> That explains why Me.Width doesn't work. I did end up using the Client
> area width but I still do the math to get multiples of 4 pixels for
> the Panel.
>
> Other than setting the Anchor points I'm more interested in getting
> the whole program working properly before I worry about resizing all
> forms to greater than 1024 x 768.
>
> Thanks
> GalenS
>
> "Stephany Young" <noone@localhost> wrote in message
> news:Ou**************@TK2MSFTNGP15.phx.gbl...
>> The point everyone has seemed to missed is that you have your form
>> maximized.
>>
>> When a form is maximized the width of the form is the working area
>> width + the form left border width + the form right border width and
>> the height of the form is the working height is the working area
>> height + the form top border height + the form bottom border height.
>> The position of the form is 0 - the form left border width, 0 - the
>> form top border width.
>>
>> This 'positioning' and 'sizing' means that a maximized form
>> automatically takes account of the position and size of the taskbar
>> (if it is showing) no matter where it actually positioned.
>>
>> The upshot is, the portion of the maximized form that you can
>> actually see is the Title Bar and the client area - some of the
>> client area may be 'reserved' for menubars, toolbars, statusbars and
>> other controls that do not form part of the client area depending on
>> which VS version you are using.
>>
>> It seems to me that you really want to position and size your user
>> control in relation to the client area and therefore you can use
>> Me.ClientSize property for this purpose without having to resort to
>> convuluted maths.
>>
>>
>> "Galen Somerville" <ga***@community.nospam> wrote in message
>> news:es**************@TK2MSFTNGP10.phx.gbl...
>>> Cor
>>>
>>> All controls have Anchor set. The control in question is a user
>>> control and intitially it is a small square in an unused portion of
>>> screen.
>>>
>>> When required it is sized at run time. I have found that the
>>> following code cures my problem
>>> With gScreen
>>>
>>> .HorPixels = Screen.GetBounds(Rect).Width
>>>
>>> .VerPixels = Screen.GetBounds(Rect).Height
>>>
>>> End With
>>>
>>> GalenS
>>>
>>>
>>>
>>> "Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
>>> news:ub**************@TK2MSFTNGP10.phx.gbl...
>>>> Galen,
>>>>
>>>> I have the idea that you are doing the same problamatic things as
>>>> was be done in the VB versions from the previous milenium
>>>>
>>>> Do you know the properties Dock and Anchor.
>>>>
>>>> They will make your live probably much easier.
>>>>
>>>> I hope this helps,
>>>>
>>>> Cor
>>>>
>>>>
>>>> "Galen Somerville" <ga***@community.nospam> schreef in bericht
>>>> news:e8**************@TK2MSFTNGP12.phx.gbl...
>>>>> My current screen resolution is set to 1024 x 768. My form size
>>>>> always comes up as 1032 x 748.
>>>>>
>>>>> I have tried the help sample
>>>>> ' Retrieve the working rectangle from the Screen class
>>>>> ' using the PrimaryScreen and the WorkingArea properties.
>>>>> Dim workingRectangle As System.Drawing.Rectangle = _
>>>>> Screen.PrimaryScreen.WorkingArea
>>>>>
>>>>> ' Set the size of the form slightly less than size of
>>>>> ' working rectangle.
>>>>> Me.Size = New System.Drawing.Size(workingRectangle.Width, _
>>>>> workingRectangle.Height)
>>>>>
>>>>> ' Set the location so the entire form is visible.
>>>>> Me.Location = New System.Drawing.Point(0, 0)
>>>>>
>>>>> the workingRectangle comes up as 1024 x 740. the Me.Size comes up
>>>>> as 1032 x 748 and location as -4 x -4
>>>>>
>>>>> It doesn't matter what the StartPosition and AutoSize is set to.
>>>>> What gives?
>>>>>
>>>>> I'm trying to use the Form Width to set a drawing Panel (PictDraw)
>>>>> to the maximum width based on the the width being a multiple of 4.
>>>>> I guess I'll have to use the
>>>>> SystemDrawing.Size(workingRectangle.Width) in the following code.
>>>>> The Form margin is set to Single.
>>>>>
>>>>> Index = Me.Width - 2
>>>>> Index = Int(Index / 4)
>>>>> Index = Index * 4
>>>>> gScreen.HorPixels = Index
>>>>> With PictDraw
>>>>> X1Y1.X = Int(Int((Me.Width - Index) ) / 2)
>>>>> X1Y1.Y = 0
>>>>> .Location = X1Y1
>>>>> X2Y2.X = gScreen.HorPixels
>>>>> X2Y2.Y = 450
>>>>> .Size = X2Y2
>>>>> End With
>>>>>
>>>>> Any ideas as to why the form always comes up 1032 X748 ?
>>>>>
>>>>> GalenS
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Apr 3 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.