?
Solved

Changing Screen Resolution!

Posted on 2003-02-18
14
Medium Priority
?
210 Views
Last Modified: 2010-04-07
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
Comment
Question by:Sankar_V
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 4
  • +2
14 Comments
 
LVL 14

Expert Comment

by:puranik_p
ID: 7979991
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
 
LVL 3

Accepted Solution

by:
Rem earned 100 total points
ID: 7980101
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
 
LVL 1

Author Comment

by:Sankar_V
ID: 8005919
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

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

Rem
0
 
LVL 14

Expert Comment

by:puranik_p
ID: 8015252
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
 
LVL 1

Author Comment

by:Sankar_V
ID: 8015727
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
 
LVL 3

Expert Comment

by:Rem
ID: 8015744
Never mind Sankar-V, I'm not playing for the points.
Just thought it was a bit weird.
Rem
0
 
LVL 1

Author Comment

by:Sankar_V
ID: 8023243
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
 
LVL 3

Expert Comment

by:Rem
ID: 8023452
If you insist, I really don't know.
Ask EE directly.

C U

Rem
0
 
LVL 14

Expert Comment

by:puranik_p
ID: 8023677
post a request (question) at
http://www.experts-exchange.com/Community_Support/
with 0 points.
An EE moderator will take care of this.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 8039262
Grade changed as requested

Computer101
E-E Admin
0
 
LVL 1

Author Comment

by:Sankar_V
ID: 8046179
Thanks Puranik for giving me the link!

0
 
LVL 14

Expert Comment

by:puranik_p
ID: 8055253
anytime. :-)
0
 

Expert Comment

by:taverny2
ID: 8349456
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question