Changing Screen Resolution!

HI Every Body!

I always use to have my screen resoultion at 1024x768!

when my compiled programs are installed on other machines which have 800x600! some controls are not visible!

my requirement is just when my program is started, what ever may be the resolution it should change to 1024x768!
And when i quit my program it should restore the previous screen resolution!

pls help me regarding this!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

first thing to mention is not all the monitors support this resolution.
second, not all the people like to work with this resolution. Some still like the 800X600.

so.., the better option is to size your form accordingly.

form.height = multiplyingfactor * Screen.Height
Changing the formsize isn't enough. Your controls will be out of the visible scope.
Copy the code below, and save it as a class (class_Elastic).
I don't remember who wrote this class initially, but it works ok.
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
Attribute VB_Name = "class_Elastic"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' * This class allows dynamical resizing of forms and controls
' * Assumes:1. Don't be stupid
' *         2. Add a form declaration 'Private El as New class_Elastic'
' *         3. Insert string as 'El.init Me' (formload event)
' *         4. Insert string as 'El.FormResize Me' (Resize event)

Option Explicit
Private nFormHeight      As Integer
Private nFormWidth       As Integer
Private nNumOfControls   As Integer
Private nTop()           As Integer
Private nLeft()          As Integer
Private nHeight()        As Integer
Private nWidth()         As Integer
Private nFontSize()      As Integer
Private nRightMargin()   As Integer
Private bFirstTime       As Boolean

Public Sub Init(frm As Form, Optional nWindState As Variant)
   Dim i          As Integer
   Dim bWinMax    As Boolean
   bWinMax = Not IsMissing(nWindState)
   nFormHeight = frm.Height
   nFormWidth = frm.Width
   nNumOfControls = frm.Controls.Count - 1
   bFirstTime = True
   ReDim nTop(nNumOfControls)
   ReDim nLeft(nNumOfControls)
   ReDim nHeight(nNumOfControls)
   ReDim nWidth(nNumOfControls)
   ReDim nFontSize(nNumOfControls)
   ReDim nRightMargin(nNumOfControls)
   On Error Resume Next
   For i = 0 To nNumOfControls
      If TypeOf frm.Controls(i) Is Line Then
         nTop(i) = frm.Controls(i).Y1
         nLeft(i) = frm.Controls(i).X1
         nHeight(i) = frm.Controls(i).Y2
         nWidth(i) = frm.Controls(i).X2
         nTop(i) = frm.Controls(i).Top
         nLeft(i) = frm.Controls(i).Left
         nHeight(i) = frm.Controls(i).Height
         nWidth(i) = frm.Controls(i).Width
         nFontSize(i) = frm.FontSize
         nRightMargin(i) = frm.Controls(i).RightMargin
      End If
   bFirstTime = True
End Sub

Public Sub FormResize(frm As Form)
   Dim i             As Integer
   Dim nCaptionSize  As Integer
   Dim dRatioX       As Double
   Dim dRatioY       As Double
   Dim nSaveRedraw   As Long
   On Error Resume Next
   nSaveRedraw = frm.AutoRedraw
   frm.AutoRedraw = True
   If bFirstTime Then
      bFirstTime = False
      Exit Sub
   End If
   If frm.Height < nFormHeight / 2 Then frm.Height = nFormHeight / 2
   If frm.Width < nFormWidth / 2 Then frm.Width = nFormWidth / 2
   nCaptionSize = 400
   dRatioY = 1# * (nFormHeight - nCaptionSize) / (frm.Height - nCaptionSize)
   dRatioX = 1# * nFormWidth / frm.Width
   On Error Resume Next ' for comboboxes, timers and other controls that cannot be resized
   For i = 0 To nNumOfControls
      If TypeOf frm.Controls(i) Is Line Then
         frm.Controls(i).Y1 = Int(nTop(i) / dRatioY)
         frm.Controls(i).X1 = Int(nLeft(i) / dRatioX)
         frm.Controls(i).Y2 = Int(nHeight(i) / dRatioY)
         frm.Controls(i).X2 = Int(nWidth(i) / dRatioX)
         frm.Controls(i).Top = Int(nTop(i) / dRatioY)
         frm.Controls(i).Left = Int(nLeft(i) / dRatioX)
         frm.Controls(i).Height = Int(nHeight(i) / dRatioY)
         frm.Controls(i).Width = Int(nWidth(i) / dRatioX)
         frm.Controls(i).FontSize = Int(nFontSize(i) / dRatioX) + Int(nFontSize(i)
/ dRatioX) Mod 2
         frm.Controls(i).RightMargin = Int(nRightMargin(i) / dRatioY)
      End If
   frm.AutoRedraw = nSaveRedraw
End Sub


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sankar_VAuthor Commented:
Sorry for the delay as iam out of office!

Any how thanx for ur help and for responding my question!

it works for me!

Thanx a lot and sorry again for my delay1

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

You're welcome.
Just a small question; what kind of "answer" would have earned an A grade?

you should appriciate the help from the experts by giving A grade. I feel answer given by Rem is more than satisfying your requirement.
Sankar_VAuthor Commented:
Sorry Rem & Puranik!

I selected Excellent from the options!

As i did that in a hurry, some think had happen wrong!

Please tell me hw can i change this!

Sorry again.....i just noticed this by seeing ur comments!
Never mind Sankar-V, I'm not playing for the points.
Just thought it was a bit weird.
Sankar_VAuthor Commented:
But Rem u had helped me.....

Pls tell me hw can i transfer!

U may not be palying for points......But i should give u the full points!

If you insist, I really don't know.
Ask EE directly.


post a request (question) at
with 0 points.
An EE moderator will take care of this.
Grade changed as requested

E-E Admin
Sankar_VAuthor Commented:
Thanks Puranik for giving me the link!

anytime. :-)
I rem ,
I tried your code , but I think I am doing something wrong.
I paste the code into a class file , but nothing happen. do I have to do something else ?
I am kind of lost with the declaration

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.