Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

How to save the form width and height in a variable?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tinus - 16 Sep 2004 22:21 GMT
Hello,

What is the best method for saving the width and height of a form?
What event can I use best for this?

In other words, where to put the code: frmWidth = Form1.Width;

Thanks,
Tinus
Imran Koradia - 16 Sep 2004 22:30 GMT
probably in the SizeChanged event of the form. This is fired whenever the
Size property changes - either width or height. That way you'll have the
current width and height of the form in your variables.

Imran.

> Hello,
>
[quoted text clipped - 5 lines]
> Thanks,
> Tinus
Joey Callisay - 17 Sep 2004 10:52 GMT
Yet I don't see the need for another variable if the form's dimensions are
already available.

> probably in the SizeChanged event of the form. This is fired whenever the
> Size property changes - either width or height. That way you'll have the
[quoted text clipped - 11 lines]
> > Thanks,
> > Tinus
Tinus - 17 Sep 2004 11:01 GMT
But if I want to calculate the difference between before and after a resize?

Tinus
> Yet I don't see the need for another variable if the form's dimensions are
> already available.
[quoted text clipped - 14 lines]
> > > Thanks,
> > > Tinus
Joey Callisay - 17 Sep 2004 11:29 GMT
Then use the OnSizeChange event handler.
Get the difference first before updating your previous dimension variables.

> But if I want to calculate the difference between before and after a resize?
>
[quoted text clipped - 18 lines]
> > > > Thanks,
> > > > Tinus
Tinus - 18 Sep 2004 16:14 GMT
But how do I calculate (get) the difference without storing the original
width/heigth before the resize?

Am I overlooking something or ....

Tinus
> Then use the OnSizeChange event handler.
> Get the difference first before updating your previous dimension variables.
[quoted text clipped - 24 lines]
> > > > > Thanks,
> > > > > Tinus
Mick Doherty - 18 Sep 2004 18:43 GMT
What do you want to do with the original size?

Here's one solution in VB that will give both Old and Current Size in one
variable.

\\\
Structure FormSize
   Public OldSize As Size
   Public CurrentSize As Size
   Public Sub New(ByVal Old As Size, ByVal Current As Size)
       OldSize = Old
       CurrentSize = Current
   End Sub
End Structure

Private MyFormSize As New FormSize(Size.Empty, MyBase.Size)

Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
   MyBase.OnResize(e)
   MyFormSize = New FormSize(MyFormSize.CurrentSize, Me.Size)
End Sub
///

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> But how do I calculate (get) the difference without storing the original
> width/heigth before the resize?
[quoted text clipped - 35 lines]
>> > > > > Thanks,
>> > > > > Tinus

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.