| | |
Resizing forms
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2007
Posts: 58
Reputation:
Solved Threads: 2
hi all,
N good morning!
I am developing an application in vb. I had developed my application on my PC in 1024*768 screen resolution. When i rum my application in the same screen resolution then it runs properly but when i run my application on 800 * 600 sreen resolution then my some controls on form are not visible to user.
I try to solve this problem by using picture box and putting all controls on picture box but then also some controls are not visible to me.
Can anybody help me in solving this problem as soon as possible?
Thanks in advance.
Regards
Guest11
N good morning!
I am developing an application in vb. I had developed my application on my PC in 1024*768 screen resolution. When i rum my application in the same screen resolution then it runs properly but when i run my application on 800 * 600 sreen resolution then my some controls on form are not visible to user.
I try to solve this problem by using picture box and putting all controls on picture box but then also some controls are not visible to me.
Can anybody help me in solving this problem as soon as possible?
Thanks in advance.
Regards
Guest11
This code is just for one of the aspects: the left position. But the principle is the same for the top position. And if you want, the height and the width.
Use ratios to find the value that you need. In each situation, you need 4 values. One value has to be calculated.
On loading you can extract the original height and width of your form. And on a resize event, you can extract the new size and width of your form.
The values that you might want to change are the left, the top, the width, and height positions of your controls. You don't need a picture box to manage your controls. The new top, left, height, and width positions can be calculated with ratios based on its previous position.
Here's one formula for finding the new left position using ratios:
CurrentLeft / CurrentWidth = NewLeft/NewWidth
Use the same principle for calculating a new top position, height, etc.
Use ratios to find the value that you need. In each situation, you need 4 values. One value has to be calculated.
On loading you can extract the original height and width of your form. And on a resize event, you can extract the new size and width of your form.
The values that you might want to change are the left, the top, the width, and height positions of your controls. You don't need a picture box to manage your controls. The new top, left, height, and width positions can be calculated with ratios based on its previous position.
Here's one formula for finding the new left position using ratios:
CurrentLeft / CurrentWidth = NewLeft/NewWidth
Use the same principle for calculating a new top position, height, etc.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Dim lngOrigW As Long, lngOrigH As Long Private Sub Form_Load() lngOrigW = Me.Width lngOrigH = Me.Height End Sub Private Sub Form_Resize() On Error GoTo Resize_ERROR Dim ctl As Control, lngCurLeft As Long, lngCurTop As Long Dim lngNewLeft As Long, lngNewTop As Long, lngNewWidth As Long, lngNewHeight As Long Dim lngCurWidth As Long, lngCurHeight As Long lngCurWidth = Me.Width Debug.Print 3, lngCurWidth lngCurHeight = Me.Height Debug.Print 4, lngCurHeight For Each ctl In Controls Select Case TypeName(ctl) Case "CommandButton" lngCurLeft = ctl.Left lngNewLeft = (lngCurLeft * lngCurWidth) / lngOrigW ctl.Move lngNewLeft Case "Label" Case Else End Select Next lngOrigW = lngCurWidth lngOrigH = lngCurHeight Exit Sub Resize_ERROR: End Sub
Last edited by hkdani; Mar 13th, 2009 at 4:47 pm.
![]() |
Similar Threads
- Forms in MDI Tab not resizing properly (C#)
- Web Design/development: combining speed and quality (Post your Resume)
- Small problem face me (C#)
- Resizing UserControl forms...or something like that. (C#)
- Resizing text fields (JavaScript / DHTML / AJAX)
- How to: Resize MDI container on a form (VB.NET)
- JTables (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Connect 2 computers using Ethernet
- Next Thread: Need Help To Make First Letter Of All Words In A Textbox To Uppercase
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






