|
-
Jul 6th, 2004, 01:04 AM
#1
Thread Starter
Junior Member
windows forms
hi,
i'm a fresh vb.net programmer. i'm facing a problem with the form's as well as it's control's size on screen resolution changes.
in minimum resolution my form size becomes high and not fit to the screen.
How can i make it fit to screen in all screen resolutions.
anybody overcome this prob, pls help me soon.
sanjas
-
Jul 6th, 2004, 01:51 AM
#2
Fanatic Member
-
Jul 6th, 2004, 02:08 AM
#3
Thread Starter
Junior Member
Originally posted by brown monkey
windowstate.maximized?
Window state is normal.
-
Jul 6th, 2004, 05:13 AM
#4
Hyperactive Member
I think B.M was suggesting and not asking for something
Anyway I have the same problem to face. It's not urgent for me but I tried to solve it for about an hour. It's quite easy to resize form and controls as you need, but fontsize for text is a little critical. It's very difficult to obtain the same filling effect....so I will follow this thread with great interest!
Live long and prosper (Mr. Spock)
-
Jul 6th, 2004, 07:14 AM
#5
PowerPoster
Hi,
Unless someone comes up with an automatic method:
Make sure that the control placed at the corner of the form is anchored to that corner, e.g. top,left; top, right; bottom, left; bottom, right.
then note the position of all other controls by reference to those anchored controls by setting variables in the load event to contain the relative control position as a percentage deviation from the anchored controls. You can also use this reasoning to alter the size and fonts of the controls as well.
Then in the Activated event
VB Code:
me.desktopbounds=screen.primaryscreen.workingarea
and recode the positions/sizes/font sizes of the controls using the variable percentages stored at load time.
I have not tested this but will later today.
Hi alextyx,
When you said it was easy to resize the form AND the controls what did you mean?
Last edited by taxes; Jul 6th, 2004 at 07:29 AM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 6th, 2004, 11:33 AM
#6
Hyperactive Member
Hi taxes, if I don't wrongly remember,.... perhaps....(I tried many weeks ago and I have a certain age, my memory is weak ) the Scale method for Forms. The basic idea was to change the size of forms in the same ratio of 'actual resolution/ previous resolution' (not necessarily on the whole screen area). The problem was to adapt font size to have exactly the same percentage of control filled. I believe to remember that test was made with a form with labels,textbox and button, but it was an hour or two of work, so I didn't test many details. I will try again, when I will have a bit of time to spend on this. If someone else, solves problem before, it's also better
Live long and prosper (Mr. Spock)
-
Jul 6th, 2004, 12:20 PM
#7
Hyperactive Member
I did a quick test with a form containing 3 button and a textbox that I use also to decide the ratio of enlargement or reduction of form.
This the code of the enlarge button:
VB Code:
Private Sub BtnScala_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAllarga.Click
Me.Scale(Double.Parse(Me.TextBox1.Text))
Dim Grande As Single = Me.TextBox1.Font.Size
Dim Famiglia As System.Drawing.FontFamily = Me.TextBox1.Font.FontFamily
Dim FN As New Font(Famiglia, Grande * Double.Parse(Me.TextBox1.Text))
Me.TextBox1.Font = FN
End Sub
If someone has more time to test it deeply....anyway the problem of font remains. I can change it, but I can't obtain exactly the same result, perhaps because font is scaled in some (a few) values?
Good job. I'm very interesting in results, also if I have more urgent problem to solve now.
Live long and prosper (Mr. Spock)
-
Jul 6th, 2004, 06:46 PM
#8
PowerPoster
Hi,
The following code will keep the controls in the proportionate positions on the resizing of the form, and will also resize controls proportionately.
Form Scope
VB Code:
Dim dHeight, dWidth As Double
Dim arrTemp(100, 4) As Double
In the Load event of the form
VB Code:
dHeight = Me.Height
dWidth = Me.Width
Dim ctl As Control
Dim iCount As Integer = 0
For Each ctl In Me.Controls
arrTemp(iCount, 0) = CDbl(ctl.Left)
arrTemp(iCount, 1) = CDbl(ctl.Top)
arrTemp(iCount, 2) = CDbl(ctl.Width)
arrTemp(iCount, 3) = CDbl(ctl.Height)
iCount = iCount + 1
Next
In the Activated event of the form
VB Code:
Me.DesktopBounds = Screen.PrimaryScreen.WorkingArea
Dim dHeightProportion As Double = Me.Height / dHeight
Dim dWidthProportion As Double = Me.Width / dWidth
Dim ctl As Control
Dim icount As Integer = 0
For Each ctl In Controls
ctl.Left = CInt(arrTemp(icount, 0) * dWidthProportion)
ctl.Top = CInt(arrTemp(icount, 1) * dHeightProportion)
ctl.Width = CInt(arrTemp(icount, 2) * dWidthProportion)
ctl.Height = CInt(arrTemp(icount, 3) * dHeightProportion)
icount = icount + 1
Next
Now I'll experiment with font resizing.
Last edited by taxes; Jul 6th, 2004 at 07:50 PM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 6th, 2004, 07:34 PM
#9
PowerPoster
Hi,
Cracked it
The full code in the form activated event should be;
VB Code:
Me.DesktopBounds = Screen.PrimaryScreen.WorkingArea
Dim dHeightProportion As Double = Me.Height / dHeight
Dim dWidthProportion As Double = Me.Width / dWidth
Dim ctl As Control
Dim icount As Integer = 0
Dim sFont As Single
For Each ctl In Controls
ctl.Left = CInt(arrLeft(icount, 0) * dWidthProportion)
ctl.Top = CInt(arrLeft(icount, 1) * dHeightProportion)
ctl.Width = CInt(arrLeft(icount, 2) * dWidthProportion)
ctl.Height = CInt(arrLeft(icount, 3) * dHeightProportion)
sFont = CInt(ctl.Font.Size * CInt(dWidthProportion))
With ctl
.Font = New Font(.Font.Name, sFont, .Font.Style, _
.Font.Unit)
End With
icount = icount + 1
Next
By the way, do NOT anchor the controls to ANY side of the form.
Last edited by taxes; Jul 6th, 2004 at 07:48 PM.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 7th, 2004, 12:12 AM
#10
Thread Starter
Junior Member
hi,
thanks for the care.i applied the code , but the problem still remains there.
if i create the appln on 1024*768 resolution,the controls go beyond screen on 800*600.if the statusbar is docked to bottom then it remains in the bottom.otherwise its location is fixed ie goes down in 800*600 so that we cant view.
If , the appln is created on 800*600 and opened on 1024*768 , the controls without docking remain in the same position as earlier-here becomes small and not adjust with resolution.
sanjays
-
Jul 7th, 2004, 03:56 AM
#11
Hyperactive Member
Thanks Taxes, I'll try your way to solve problem, too. Did you try 'Scale'? It seems good except for font problem. Anyway I think you are doing something to resize controls when form is resized by the user and so Scale method should not be good for you. My attempt was to change Form size by settings (.ini file) in order to match the actual resolution and then let form locked on its new size. Scale method seems good also if I have to test it more and with many controls. It keep all in the right proportion, just as someone should expect. Font size is not always perfect. Sometimes you can see a different effect (little difference anyway) in filling controls, but if you don't want a perfect result it could be happily used, I think.
Live long and prosper (Mr. Spock)
-
Jul 7th, 2004, 04:57 AM
#12
PowerPoster
Hi sanjays,
I have not tried it, but have you considered using an MDI, setting the MDI to full screen (It will automatically have scroll bars). All the other forms, if Childs, should then remain in view - I think
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|