Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2007
Posts: 58
Reputation: guest11 is an unknown quantity at this point 
Solved Threads: 2
guest11 guest11 is offline Offline
Junior Poster in Training

Resizing forms

 
0
  #1
Mar 13th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,125
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 129
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Resizing forms

 
0
  #2
Mar 13th, 2009
you need to resize and rearrange the controls based on system resolution. You need to use X and Y coordinates of the screen.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 58
Reputation: guest11 is an unknown quantity at this point 
Solved Threads: 2
guest11 guest11 is offline Offline
Junior Poster in Training

Re: Resizing forms

 
0
  #3
Mar 13th, 2009
thanks for ur reply debasis.
Can you give me the example for that .
I have 108 controls on my form.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Resizing forms

 
0
  #4
Mar 13th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 481
Reputation: abu taher is an unknown quantity at this point 
Solved Threads: 24
abu taher's Avatar
abu taher abu taher is offline Offline
Posting Pro in Training

Re: Resizing forms

 
0
  #5
Mar 14th, 2009
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
I like sword. Attack or Defense.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC