943,709 Members | Top Members by Rank

Ad:
Mar 13th, 2009
0

Resizing forms

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
guest11 is offline Offline
59 posts
since Nov 2007
Mar 13th, 2009
0

Re: Resizing forms

you need to resize and rearrange the controls based on system resolution. You need to use X and Y coordinates of the screen.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Mar 13th, 2009
0

Re: Resizing forms

thanks for ur reply debasis.
Can you give me the example for that .
I have 108 controls on my form.
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
guest11 is offline Offline
59 posts
since Nov 2007
Mar 13th, 2009
0

Re: Resizing forms

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.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Option Explicit
  2. Dim lngOrigW As Long, lngOrigH As Long
  3.  
  4. Private Sub Form_Load()
  5. lngOrigW = Me.Width
  6. lngOrigH = Me.Height
  7. End Sub
  8.  
  9. Private Sub Form_Resize()
  10. On Error GoTo Resize_ERROR
  11. Dim ctl As Control, lngCurLeft As Long, lngCurTop As Long
  12. Dim lngNewLeft As Long, lngNewTop As Long, lngNewWidth As Long, lngNewHeight As Long
  13. Dim lngCurWidth As Long, lngCurHeight As Long
  14.  
  15. lngCurWidth = Me.Width
  16. Debug.Print 3, lngCurWidth
  17. lngCurHeight = Me.Height
  18. Debug.Print 4, lngCurHeight
  19.  
  20. For Each ctl In Controls
  21. Select Case TypeName(ctl)
  22. Case "CommandButton"
  23. lngCurLeft = ctl.Left
  24. lngNewLeft = (lngCurLeft * lngCurWidth) / lngOrigW
  25. ctl.Move lngNewLeft
  26. Case "Label"
  27. Case Else
  28. End Select
  29. Next
  30. lngOrigW = lngCurWidth
  31. lngOrigH = lngCurHeight
  32. Exit Sub
  33. Resize_ERROR:
  34.  
  35. End Sub
Last edited by hkdani; Mar 13th, 2009 at 4:47 pm.
Reputation Points: 49
Solved Threads: 44
Posting Pro in Training
hkdani is offline Offline
426 posts
since Nov 2007
Mar 14th, 2009
0

Re: Resizing forms

Hi,

Place the Image Control on the Form, Make its property :
Strech = True
and in Form's Re-Size Event Write this Code:

1.
Image1.Width = Me.Width
2.
Image1.Height = Me.Height - 300
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Connect 2 computers using Ethernet
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Need Help To Make First Letter Of All Words In A Textbox To Uppercase





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC