471,336 Members | 956 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 software developers and data experts.

Resize dialog

I am new in VB.Net, I need some help.

I want to resize my dialogs dynamically (so that a dialog made for
1280x1024 screens shows properly on 800x640 screen. I make the
calculation in the Handles MyBase.Load event sub Everything works fine,
except if the original screen exceeds the size of the new screen. Some
debugging shows that

frm.Height = CType((frm.Height - bgtl) * heightRatio + bgtl, Integer)

with

frm.Height = 798, bgtl = 22, heightRatio = 2.0

results 1036, instead of the 1574 (in a 1280 x 1024 screen) . Apparently
the set height is cut off artificially (I set Maximum Size 2000,2000,
w/o involving the case).

Is there any variable in form, where I can find the set size.

What is the reason to cut off my set?

Independent question: Why is the size and Location integer instead of
Single?

I am using VB.NET 2003 Professional edition on Windows XP Professional
Nov 21 '05 #1
5 5445
Hi,

I am not sure if you have to do calculations at all using .NET. You need to
design your dialog to fit in the smallest resolution, say, 800x600, and then
you decide which controls on your dialog can be expanded and in which
direction(s) when the dialog is resized. Then, you can use the Anchor and
Dock properties of controls and .NET does this automatically when the user
resizes your dialog. Initially you present the dialog to the user in the
original size, but if you set the SizeGripStyle of the form to true, a
visual clue is shown to the user in the bottom-right corner of the dialog
and he will realize that he can resize it. Then, when the user unloads the
dialog you save its size and you use it the next time.

About the other question, Size and Location are integers, no need for
decimals, and the capacity of an Integer in .NET (32 bits) is enough to hold
the value.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
"gilgames" <Gl***@netscape.net> escribió en el mensaje
news:vl*****************@newssvr31.news.prodigy.co m...
I am new in VB.Net, I need some help.

I want to resize my dialogs dynamically (so that a dialog made for
1280x1024 screens shows properly on 800x640 screen. I make the calculation
in the Handles MyBase.Load event sub Everything works fine, except if the
original screen exceeds the size of the new screen. Some debugging shows
that

frm.Height = CType((frm.Height - bgtl) * heightRatio + bgtl, Integer)

with

frm.Height = 798, bgtl = 22, heightRatio = 2.0

results 1036, instead of the 1574 (in a 1280 x 1024 screen) . Apparently
the set height is cut off artificially (I set Maximum Size 2000,2000, w/o
involving the case).

Is there any variable in form, where I can find the set size.

What is the reason to cut off my set?

Independent question: Why is the size and Location integer instead of
Single?

I am using VB.NET 2003 Professional edition on Windows XP Professional

Nov 21 '05 #2
"gilgames" <Gl***@netscape.net> wrote in message
news:vl*****************@newssvr31.news.prodigy.co m...
I want to resize my dialogs dynamically (so that a dialog made for
1280x1024 screens shows properly on 800x640 screen.
First problem - you're trying to work the wrong way around.
/Build/ on 8x6, /allow/ for bigger (if only because the numbers scale
/up/ far better than they scale down.

Secondly, VB.Net has some nice features for Anchor'ing and
Dock'ing controls together that make arranging your form far easier.
I just hope that VB.2005 gets them working properly with /inherited/
Forms!

Thirdly (and this is a personal observation) I /wouldn't/ want your
application to do this anyway. I run at higher resolutions so I can
get more applications side-by-side on the same screen real estate,
not to have a dialog that fills the screen at 8x6 /still/ fill the screen
at a higher resolution.
Is there any variable in form, where I can find the set size.
Oddly, the Size property (and MinimumSize and MaximumSize,
as well, if you want).
Independent question: Why is the size and Location integer
instead of Single?


Because .Net measures everything in Pixels and fractions of a
pixel are pretty meaningless, another reason to multiply up for
bigger screens, rather than deividing down for smaller ones.

HTH,
Phill W.
Nov 21 '05 #3
<<
I am not sure if you have to do calculations at all using .NET. You need
to design your dialog to fit in the smallest resolution, say, 800x600,
and then you decide which controls on your dialog can be expanded and in
which direction(s) when the dialog is resized.


I have vison problem. The opera browser provides an easy resolution: I
can resize the fonts on the loded page interactively.

I want to implement the same feature in VB net, I want people with worse
vision increase the size of the dialog until they see it properly. For
the same reason would I need the Single size type, not the length but
the precision is the problem: 1% change is not followed by integers
Nov 21 '05 #4
Gilgames,
As Carlos suggested I would design the form at the minimum size, the scale
it up.

Increasing a form by 1%, even with integers should be easy.

However!

Charles Petzold's book "Programming Microsoft Windows With Microsoft Visual
Basic .NET - Core Reference" from MS Press includes a sample on using the
Control.Scale method to dynamically change the size of all controls on the
form to a "fixed" size.

Simplifying Charles' example, if you want simple increase/decrease the
"zoom" factor try:

Private Sub ZoomIn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ZoomIn.Click
Scale(1.1F)
End Sub

Private Sub ZoomOut_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ZoomOut.Click
Scale(0.9F)
End Sub

Where ZoomIn & ZoomOut are buttons on your form, clicking ZoomIn will
increase the form by 10%, clicking ZoomOut will decrease the form by 10%.

I would recommend you review Charles' code if you want to zoom to fixed
amounts (such as zoom to 100%, or 120%)...

Hope this helps
Jay
"gilgames" <Gl***@netscape.net> wrote in message
news:n%******************@newssvr33.news.prodigy.c om...
<<
I am not sure if you have to do calculations at all using .NET. You need
to design your dialog to fit in the smallest resolution, say, 800x600, and
then you decide which controls on your dialog can be expanded and in which
direction(s) when the dialog is resized.


I have vison problem. The opera browser provides an easy resolution: I can
resize the fonts on the loded page interactively.

I want to implement the same feature in VB net, I want people with worse
vision increase the size of the dialog until they see it properly. For the
same reason would I need the Single size type, not the length but the
precision is the problem: 1% change is not followed by integers

Nov 21 '05 #5
Doh!
Also review Charles' code to see how to get the Font to scale as well...

Something like:

Private Sub ZoomIn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ZoomIn.Click
Zoom(1.1F)
End Sub

Private Sub ZoomOut_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ZoomOut.Click
Zoom(0.9F)
End Sub

Private Sub Zoom(ByVal ratio As Single)
Scale(ratio)
Font = New Font(Font.FontFamily, Font.Size * ratio)
End Sub
Hope this helps
Jay
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:u2*************@TK2MSFTNGP14.phx.gbl...
Gilgames,
As Carlos suggested I would design the form at the minimum size, the scale
it up.

Increasing a form by 1%, even with integers should be easy.

However!

Charles Petzold's book "Programming Microsoft Windows With Microsoft
Visual Basic .NET - Core Reference" from MS Press includes a sample on
using the Control.Scale method to dynamically change the size of all
controls on the form to a "fixed" size.

Simplifying Charles' example, if you want simple increase/decrease the
"zoom" factor try:

Private Sub ZoomIn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ZoomIn.Click
Scale(1.1F)
End Sub

Private Sub ZoomOut_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ZoomOut.Click
Scale(0.9F)
End Sub

Where ZoomIn & ZoomOut are buttons on your form, clicking ZoomIn will
increase the form by 10%, clicking ZoomOut will decrease the form by 10%.

I would recommend you review Charles' code if you want to zoom to fixed
amounts (such as zoom to 100%, or 120%)...

Hope this helps
Jay
"gilgames" <Gl***@netscape.net> wrote in message
news:n%******************@newssvr33.news.prodigy.c om...
<<
I am not sure if you have to do calculations at all using .NET. You need
to design your dialog to fit in the smallest resolution, say, 800x600,
and then you decide which controls on your dialog can be expanded and in
which direction(s) when the dialog is resized.
>>


I have vison problem. The opera browser provides an easy resolution: I
can resize the fonts on the loded page interactively.

I want to implement the same feature in VB net, I want people with worse
vision increase the size of the dialog until they see it properly. For
the same reason would I need the Single size type, not the length but the
precision is the problem: 1% change is not followed by integers


Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Alex Blekhman | last post: by
reply views Thread by Tony | last post: by
1 post views Thread by Lucas Dalmasso | last post: by
reply views Thread by Abubakar | last post: by
3 posts views Thread by CJMHotmail | last post: by
1 post views Thread by traviscoop | last post: by
5 posts views Thread by rahulnag22 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.