Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

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!
0
Sankar_V
Asked:
Sankar_V
  • 4
  • 4
  • 4
  • +2
1 Solution
 
puranik_pCommented:
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.
using..

form.height = multiplyingfactor * Screen.Height
0
 
RemCommented:
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.
=====================================
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
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
      Else
         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
   Next
   
   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)
      Else
         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
   Next
   
   frm.AutoRedraw = nSaveRedraw
   
End Sub

0
 
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

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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

Rem
0
 
puranik_pCommented:
sankar_v,
you should appriciate the help from the experts by giving A grade. I feel answer given by Rem is more than satisfying your requirement.
0
 
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!
0
 
RemCommented:
Never mind Sankar-V, I'm not playing for the points.
Just thought it was a bit weird.
Rem
0
 
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!

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

C U

Rem
0
 
puranik_pCommented:
post a request (question) at
http://www.experts-exchange.com/Community_Support/
with 0 points.
An EE moderator will take care of this.
0
 
Computer101Commented:
Grade changed as requested

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

0
 
puranik_pCommented:
anytime. :-)
0
 
taverny2Commented:
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

Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 4
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now