Solved

msResize.ocx  - Start up Forms under MDIForm...

Posted on 1998-12-11
8
372 Views
Last Modified: 2012-06-21
I Want Start up my forms under mdiForm using the msResize.OCX for resizing fonts,controls etc...
I fixed the forms with "not sizeble" for users but it did not work...
0
Comment
Question by:agf
  • 4
  • 3
8 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1449540
Use this class instead :

'****************************************************************
' Name: class_Elastic
' Description:This class can change size and location of controls
'  on your form
' 1. Resize form
' 2. Change screen resolution

' By: Mikhail Shmukler
'
' Inputs:None
' Returns:None
' Assumes:1. Add Elastic.cls
'2. Add declaration 'private clsElastic as New class_Elastic'
'3. Insert string like 'clsElastic.init Me' (formload event)
'4. Insert string like 'clsElastic.FormResize Me' (Resize event)
'5. Press 'F5' and resize form ....
'
'****************************************************************

Option Explicit
Private iFormHeight      As Integer
Private iFormWidth       As Integer
Private iNumOfControls   As Integer
Private iTop()           As Integer
Private iLeft()          As Integer
Private iHeight()        As Integer
Private iWidth()         As Integer
Private iFontSize()      As Integer
Private iRightMargin()   As Integer
Private bFirstTime       As Boolean

Sub Init(FormName As Form, Optional WindState)
   
   Dim I         As Integer
   Dim WinMax    As Boolean
   
   WinMax = Not IsMissing(WindState)
   
   iFormHeight = FormName.Height
   iFormWidth = FormName.Width
   iNumOfControls = FormName.Controls.Count - 1
   bFirstTime = True
   ReDim iTop(iNumOfControls)
   ReDim iLeft(iNumOfControls)
   ReDim iHeight(iNumOfControls)
   ReDim iWidth(iNumOfControls)
   ReDim iFontSize(iNumOfControls)
   
   ReDim iRightMargin(iNumOfControls)
   On Error Resume Next
   For I = 0 To iNumOfControls
      If TypeOf FormName.Controls(I) Is Line Then
         iTop(I) = FormName.Controls(I).Y1
         iLeft(I) = FormName.Controls(I).X1
         iHeight(I) = FormName.Controls(I).Y2
         iWidth(I) = FormName.Controls(I).X2
      Else
         iTop(I) = FormName.Controls(I).Top
         iLeft(I) = FormName.Controls(I).Left
         iHeight(I) = FormName.Controls(I).Height
         iWidth(I) = FormName.Controls(I).Width
         iFontSize(I) = FormName.FontSize
         iRightMargin(I) = FormName.Controls(I).RightMargin
      End If
   Next
   
   If WinMax Or FormName.WindowState = 2 Then ' maxim
      FormName.Height = Screen.Height
      FormName.Width = Screen.Width
   Else
      FormName.Height = FormName.Height * Screen.Height / 7290
      FormName.Width = FormName.Width * Screen.Width / 9690
   End If
   
   bFirstTime = True
   
End Sub


Sub FormResize(FormName As Form)
   
   Dim I             As Integer
   Dim Inc           As Integer
   Dim CaptionSize   As Integer
   Dim RatioX        As Double
   Dim RatioY        As Double
   Dim SaveRedraw    As Long
   
   On Error Resume Next
   SaveRedraw = FormName.AutoRedraw
   
   FormName.AutoRedraw = True
   
   If bFirstTime Then
      bFirstTime = False
      Exit Sub
   End If
   
   If FormName.Height < iFormHeight / 2 Then FormName.Height = iFormHeight / 2
   
   If FormName.Width < iFormWidth / 2 Then FormName.Width = iFormWidth / 2
   CaptionSize = 400
   RatioY = 1# * (iFormHeight - CaptionSize) / (FormName.Height - CaptionSize)
   RatioX = 1# * iFormWidth / FormName.Width
   On Error Resume Next ' for comboboxes, timeres and other nonsizible controls
   
   For I = 0 To iNumOfControls
     
      If TypeOf FormName.Controls(I) Is Line Then
         FormName.Controls(I).Y1 = Int(iTop(I) / RatioY)
         FormName.Controls(I).X1 = Int(iLeft(I) / RatioX)
         FormName.Controls(I).Y2 = Int(iHeight(I) / RatioY)
         FormName.Controls(I).X2 = Int(iWidth(I) / RatioX)
      Else
         FormName.Controls(I).Top = Int(iTop(I) / RatioY)
         FormName.Controls(I).Left = Int(iLeft(I) / RatioX)
         FormName.Controls(I).Height = Int(iHeight(I) / RatioY)
         FormName.Controls(I).Width = Int(iWidth(I) / RatioX)
         FormName.Controls(I).FontSize = Int(iFontSize(I) / RatioX) + Int(iFontSize(I) / RatioX) Mod 2
         FormName.Controls(I).RightMargin = Int(iRightMargin(I) / RatioY)
      End If
     
   Next
   
   FormName.AutoRedraw = SaveRedraw
   
End Sub

0
 
LVL 14

Expert Comment

by:waty
ID: 1449541
Use this class instead :

'****************************************************************
' Name: class_Elastic
' Description:This class can change size and location of controls
'  on your form
' 1. Resize form
' 2. Change screen resolution

' By: Mikhail Shmukler
'
' Inputs:None
' Returns:None
' Assumes:1. Add Elastic.cls
'2. Add declaration 'private clsElastic as New class_Elastic'
'3. Insert string like 'clsElastic.init Me' (formload event)
'4. Insert string like 'clsElastic.FormResize Me' (Resize event)
'5. Press 'F5' and resize form ....
'
'****************************************************************

Option Explicit
Private iFormHeight      As Integer
Private iFormWidth       As Integer
Private iNumOfControls   As Integer
Private iTop()           As Integer
Private iLeft()          As Integer
Private iHeight()        As Integer
Private iWidth()         As Integer
Private iFontSize()      As Integer
Private iRightMargin()   As Integer
Private bFirstTime       As Boolean

Sub Init(FormName As Form, Optional WindState)
   
   Dim I         As Integer
   Dim WinMax    As Boolean
   
   WinMax = Not IsMissing(WindState)
   
   iFormHeight = FormName.Height
   iFormWidth = FormName.Width
   iNumOfControls = FormName.Controls.Count - 1
   bFirstTime = True
   ReDim iTop(iNumOfControls)
   ReDim iLeft(iNumOfControls)
   ReDim iHeight(iNumOfControls)
   ReDim iWidth(iNumOfControls)
   ReDim iFontSize(iNumOfControls)
   
   ReDim iRightMargin(iNumOfControls)
   On Error Resume Next
   For I = 0 To iNumOfControls
      If TypeOf FormName.Controls(I) Is Line Then
         iTop(I) = FormName.Controls(I).Y1
         iLeft(I) = FormName.Controls(I).X1
         iHeight(I) = FormName.Controls(I).Y2
         iWidth(I) = FormName.Controls(I).X2
      Else
         iTop(I) = FormName.Controls(I).Top
         iLeft(I) = FormName.Controls(I).Left
         iHeight(I) = FormName.Controls(I).Height
         iWidth(I) = FormName.Controls(I).Width
         iFontSize(I) = FormName.FontSize
         iRightMargin(I) = FormName.Controls(I).RightMargin
      End If
   Next
   
   If WinMax Or FormName.WindowState = 2 Then ' maxim
      FormName.Height = Screen.Height
      FormName.Width = Screen.Width
   Else
      FormName.Height = FormName.Height * Screen.Height / 7290
      FormName.Width = FormName.Width * Screen.Width / 9690
   End If
   
   bFirstTime = True
   
End Sub


Sub FormResize(FormName As Form)
   
   Dim I             As Integer
   Dim Inc           As Integer
   Dim CaptionSize   As Integer
   Dim RatioX        As Double
   Dim RatioY        As Double
   Dim SaveRedraw    As Long
   
   On Error Resume Next
   SaveRedraw = FormName.AutoRedraw
   
   FormName.AutoRedraw = True
   
   If bFirstTime Then
      bFirstTime = False
      Exit Sub
   End If
   
   If FormName.Height < iFormHeight / 2 Then FormName.Height = iFormHeight / 2
   
   If FormName.Width < iFormWidth / 2 Then FormName.Width = iFormWidth / 2
   CaptionSize = 400
   RatioY = 1# * (iFormHeight - CaptionSize) / (FormName.Height - CaptionSize)
   RatioX = 1# * iFormWidth / FormName.Width
   On Error Resume Next ' for comboboxes, timeres and other nonsizible controls
   
   For I = 0 To iNumOfControls
     
      If TypeOf FormName.Controls(I) Is Line Then
         FormName.Controls(I).Y1 = Int(iTop(I) / RatioY)
         FormName.Controls(I).X1 = Int(iLeft(I) / RatioX)
         FormName.Controls(I).Y2 = Int(iHeight(I) / RatioY)
         FormName.Controls(I).X2 = Int(iWidth(I) / RatioX)
      Else
         FormName.Controls(I).Top = Int(iTop(I) / RatioY)
         FormName.Controls(I).Left = Int(iLeft(I) / RatioX)
         FormName.Controls(I).Height = Int(iHeight(I) / RatioY)
         FormName.Controls(I).Width = Int(iWidth(I) / RatioX)
         FormName.Controls(I).FontSize = Int(iFontSize(I) / RatioX) + Int(iFontSize(I) / RatioX) Mod 2
         FormName.Controls(I).RightMargin = Int(iRightMargin(I) / RatioY)
      End If
     
   Next
   
   FormName.AutoRedraw = SaveRedraw
   
End Sub

0
 

Author Comment

by:agf
ID: 1449542
Waty, I test Your solution but the forms under MDIForm are resizing greater than was design. For example: I create them in resolution 800X600 and small fonts, but , When I configured Large fonts, was generated a problem. All fonts and Controls are displaying wrongs,unproporcional... Can You send me a source code
fixing fonts for all controls in project when it Starts ?
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 2

Expert Comment

by:JiaH
ID: 1449543
"No sizable" only used to don't let user resize use mouse, but you can use code to resize it or call it's resize event procedure.
0
 

Author Comment

by:agf
ID: 1449544
If the project was design with small fonts, and the user modify
for large fonts all the forms will display unproporcional, ok ?
Please,
Can You send me a source code fixing fonts for all controls in project when it Starts ?
 
 
 
   
 


 

0
 
LVL 14

Expert Comment

by:waty
ID: 1449545
Unluckly, I don' have code to do that, but by modifying the class I gave you, you could do it easily.
0
 

Author Comment

by:agf
ID: 1449546
Waty, thank you ! I will try...
0
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1449547
'****************************************************************
' Name: class_Elastic
' Description:This class can change size and location of controls
'  on your form
' 1. Resize form
' 2. Change screen resolution

' By: Mikhail Shmukler
'
' Inputs:None
' Returns:None
' Assumes:1. Add Elastic.cls
'2. Add declaration 'private clsElastic as New class_Elastic'
'3. Insert string like 'clsElastic.init Me' (formload event)
'4. Insert string like 'clsElastic.FormResize Me' (Resize event)
'5. Press 'F5' and resize form ....
'
'****************************************************************

Option Explicit
Private iFormHeight      As Integer
Private iFormWidth       As Integer
Private iNumOfControls   As Integer
Private iTop()           As Integer
Private iLeft()          As Integer
Private iHeight()        As Integer
Private iWidth()         As Integer
Private iFontSize()      As Integer
Private iRightMargin()   As Integer
Private bFirstTime       As Boolean

Sub Init(FormName As Form, Optional WindState)
   
   Dim I         As Integer
   Dim WinMax    As Boolean
   
   WinMax = Not IsMissing(WindState)
   
   iFormHeight = FormName.Height
   iFormWidth = FormName.Width
   iNumOfControls = FormName.Controls.Count - 1
   bFirstTime = True
   ReDim iTop(iNumOfControls)
   ReDim iLeft(iNumOfControls)
   ReDim iHeight(iNumOfControls)
   ReDim iWidth(iNumOfControls)
   ReDim iFontSize(iNumOfControls)
   
   ReDim iRightMargin(iNumOfControls)
   On Error Resume Next
   For I = 0 To iNumOfControls
      If TypeOf FormName.Controls(I) Is Line Then
         iTop(I) = FormName.Controls(I).Y1
         iLeft(I) = FormName.Controls(I).X1
         iHeight(I) = FormName.Controls(I).Y2
         iWidth(I) = FormName.Controls(I).X2
      Else
         iTop(I) = FormName.Controls(I).Top
         iLeft(I) = FormName.Controls(I).Left
         iHeight(I) = FormName.Controls(I).Height
         iWidth(I) = FormName.Controls(I).Width
         iFontSize(I) = FormName.FontSize
         iRightMargin(I) = FormName.Controls(I).RightMargin
      End If
   Next
   
   If WinMax Or FormName.WindowState = 2 Then ' maxim
      FormName.Height = Screen.Height
      FormName.Width = Screen.Width
   Else
      FormName.Height = FormName.Height * Screen.Height / 7290
      FormName.Width = FormName.Width * Screen.Width / 9690
   End If
   
   bFirstTime = True
   
End Sub


Sub FormResize(FormName As Form)
   
   Dim I             As Integer
   Dim Inc           As Integer
   Dim CaptionSize   As Integer
   Dim RatioX        As Double
   Dim RatioY        As Double
   Dim SaveRedraw    As Long
   
   On Error Resume Next
   SaveRedraw = FormName.AutoRedraw
   
   FormName.AutoRedraw = True
   
   If bFirstTime Then
      bFirstTime = False
      Exit Sub
   End If
   
   If FormName.Height < iFormHeight / 2 Then FormName.Height = iFormHeight / 2
   
   If FormName.Width < iFormWidth / 2 Then FormName.Width = iFormWidth / 2
   CaptionSize = 400
   RatioY = 1# * (iFormHeight - CaptionSize) / (FormName.Height - CaptionSize)
   RatioX = 1# * iFormWidth / FormName.Width
   On Error Resume Next ' for comboboxes, timeres and other nonsizible controls
   
   For I = 0 To iNumOfControls
       
      If TypeOf FormName.Controls(I) Is Line Then
         FormName.Controls(I).Y1 = Int(iTop(I) / RatioY)
         FormName.Controls(I).X1 = Int(iLeft(I) / RatioX)
         FormName.Controls(I).Y2 = Int(iHeight(I) / RatioY)
         FormName.Controls(I).X2 = Int(iWidth(I) / RatioX)
      Else
         FormName.Controls(I).Top = Int(iTop(I) / RatioY)
         FormName.Controls(I).Left = Int(iLeft(I) / RatioX)
         FormName.Controls(I).Height = Int(iHeight(I) / RatioY)
         FormName.Controls(I).Width = Int(iWidth(I) / RatioX)
         FormName.Controls(I).FontSize = Int(iFontSize(I) / RatioX) + Int(iFontSize(I) / RatioX) Mod 2
         FormName.Controls(I).RightMargin = Int(iRightMargin(I) / RatioY)
      End If
       
   Next
   
   FormName.AutoRedraw = SaveRedraw
   
End Sub


0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

773 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