Solved

How to put a pgm for  a screen 17" on a14"

Posted on 2000-02-25
13
286 Views
Last Modified: 2013-11-26
I developped a pgm. on a 17"'s screen. I put it on a 14"'s screen. I'm not able to see all a form and another one some controls are over others.
I don't know if i need scrollBars or resize the windows.
What we do for this? code if possible.
Thank's.
0
Comment
Question by:dosyl
  • 9
  • 4
13 Comments
 
LVL 7

Accepted Solution

by:
tward earned 200 total points
ID: 2559203
Here are the required project files to create an OCX that you can put on every form that you want to resize:

****BEGIN RESIZER.VBP****
Type=Control
UserControl=Resizer.ctl
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\SYSTEM\STDOLE2.TLB#OLE Automation
Startup="(None)"
HelpFile=""
Title="MSI Resizer Control"
ExeName32="Resizer.ocx"
Command32=""
Name="msiResizer"
HelpContextID="0"
CompatibleMode="2"
CompatibleEXE32="Resizer.ocx"
VersionCompatible32="1"
MajorVer=1
MinorVer=3
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionComments=""
VersionCompanyName=""
VersionFileDescription="Visual Basic Control Resizing OCX"
VersionLegalCopyright=""
VersionProductName="Resizer Control"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=1
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
****  END RESIZER.VBP****

****BEGIN RESIZER.CTL****
VERSION 5.00
Begin VB.UserControl Resizer
   ClientHeight    =   480
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   495
   InvisibleAtRuntime=   -1  'True
   ScaleHeight     =   480
   ScaleWidth      =   495
   ToolboxBitmap   =   "Resizer.ctx":0000
   Begin VB.Image Image1
      Height          =   480
      Left            =   0
      Picture         =   "Resizer.ctx":0182
      Top             =   0
      Width           =   480
   End
End
Attribute VB_Name = "Resizer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

' if True, also fonts are resized '
Public ResizeFont As Boolean

' if True, form's height/width ratio is preserved '
Public KeepRatio As Boolean

Private Type TControlInfo
       
       ctrl As Control
       Left As Single
       Top As Single
       Width As Single
       Height As Single
       FontSize As Single
       
End Type

Private Type TAllowChanges
 
       AllowChangeTop As Boolean
       AllowChangeLeft As Boolean
       AllowChangeWidth As Boolean
       AllowChangeHeight As Boolean
       
End Type

' this array holds the original position  '
' and size of all controls on parent form '
Dim Controls() As TControlInfo

' a reference to the parent form '
Private WithEvents ParentForm As Form
Attribute ParentForm.VB_VarHelpID = -1

' parent form's size at load time '
Private ParentWidth As Single
Private ParentHeight As Single

' ratio of original height/width '
Private HeightWidthRatio As Single

Private Function CheckForChanges(ByVal TagToUse As String) As TAllowChanges
 
  Dim ChangesToAllow As TAllowChanges
 
  ChangesToAllow.AllowChangeTop = True
  ChangesToAllow.AllowChangeLeft = True
  ChangesToAllow.AllowChangeWidth = True
  ChangesToAllow.AllowChangeHeight = True
   
  If TagToUse <> "" Then
   
    If UCase(Left(TagToUse, 9)) = "MSIRESIZE" Then
     
      ChangesToAllow.AllowChangeTop = False
      ChangesToAllow.AllowChangeLeft = False
      ChangesToAllow.AllowChangeWidth = False
      ChangesToAllow.AllowChangeHeight = False
   
      If Mid(TagToUse, 10, 1) = "Y" Then
     
        ChangesToAllow.AllowChangeLeft = True
       
      End If
     
      If Mid(TagToUse, 11, 1) = "Y" Then
     
        ChangesToAllow.AllowChangeTop = True
       
      End If
     
      If Mid(TagToUse, 12, 1) = "Y" Then
     
        ChangesToAllow.AllowChangeWidth = True
       
      End If
     
      If Mid(TagToUse, 13, 1) = "Y" Then
     
        ChangesToAllow.AllowChangeHeight = True
       
      End If
     
    End If
   
  End If
 
  CheckForChanges = ChangesToAllow
 
End Function

Private Sub ParentForm_Load()

  ' the ParentWidth variable works as a flag '
  ParentWidth = 0
 
  ' save original ratio '
  HeightWidthRatio = ParentForm.Height / ParentForm.Width
 
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
 
  ResizeFont = PropBag.ReadProperty("ResizeFont", False)
  KeepRatio = PropBag.ReadProperty("KeepRatio", False)
 
  If Ambient.UserMode = False Then
   
    Exit Sub
 
  End If
 
  ' store a reference to the parent form and start receiving events '
  Set ParentForm = Parent
 
End Sub
Private Sub UserControl_Resize()
 
  ' refuse to resize '
  Image1.Move 0, 0
  UserControl.Width = Image1.Width
  UserControl.Height = Image1.Height
 
End Sub

''''''''''''''''''''''''''''''''''''''''''''
' trap the parent form's Resize event      '
' this include the very first resize event '
' that occurs soon after form's load       '
''''''''''''''''''''''''''''''''''''''''''''
Private Sub ParentForm_Resize()
 
  If ParentWidth = 0 Then
   
    Rebuild
 
  Else
   
    Refresh
 
  End If
 
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' save size and position of all controls on parent form                  '
' you should manually invoke this method each time you add a new control '
' to the form (through Load method of a control array)                   '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Rebuild()
 
  ' rebuild the internal table
  Dim i As Integer
  Dim ctrl As Control
 
'  Dim Changes As TAllowChanges
 
  ' this is necessary for controls that don't support
  ' all properties (e.g. Timer controls)
  On Error Resume Next
   
  If Ambient.UserMode = False Then
   
    Exit Sub
   
  End If
   
  ' save a reference to the parent form, and its initial size
  Set ParentForm = UserControl.Parent
  ParentWidth = ParentForm.ScaleWidth
  ParentHeight = ParentForm.ScaleHeight
   
  ' read the position of all controls on the parent form
  ReDim Controls(ParentForm.Controls.Count - 1) As TControlInfo
   
  For i = 0 To ParentForm.Controls.Count - 1
     
     Set ctrl = ParentForm.Controls(i)
       
'     Changes = CheckForChanges(ctrl)
     
     With Controls(i)
                 Set .ctrl = ctrl
                     
'                     If Changes.AllowChangeLeft = True Then
                       .Left = ctrl.Left
'                     End If
'                     If Changes.AllowChangeTop = True Then
                       .Top = ctrl.Top
'                     End If
'                     If Changes.AllowChangeTop = True Then
                       .Width = ctrl.Width
'                     End If
'                     If Changes.AllowChangeTop = True Then
                       .Height = ctrl.Height
'                     End If
                     .FontSize = ctrl.Font.Size
     End With
       
  Next
 
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' update size and position of controls on parent form '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Refresh()
 
  Dim i As Integer
  Dim ctrl As Control
  Dim minFactor As Single
  Dim widthFactor As Single
  Dim heightFactor As Single
 
  Dim Changes As TAllowChanges
   
  ' inhibits recursive calls if KeepRatio = True '
  Static executing As Boolean
 
  If executing Then
   
    Exit Sub
   
  End If
   
  If Ambient.UserMode = False Then
   
    Exit Sub
   
  End If
   
  If KeepRatio Then
   
    executing = True
   
    ' we must keep original ratio '
    ParentForm.Height = HeightWidthRatio * ParentForm.Width
    executing = False
 
  End If
   
  ' this is necessary for controls that don't support '
  ' all properties (e.g. Timer controls)              '
  On Error Resume Next

  widthFactor = ParentForm.ScaleWidth / ParentWidth
  heightFactor = ParentForm.ScaleHeight / ParentHeight
 
  ' take the lesser of the two '
  If widthFactor < heightFactor Then
   
    minFactor = widthFactor
 
  Else
   
    minFactor = heightFactor
 
  End If
   
  ' this is a regular resize '
  For i = 0 To UBound(Controls)
       
     Changes = CheckForChanges(Controls(i).ctrl.Tag)
     
     With Controls(i)
           
                     ' the change of font must occur *before* the resizing '
                     ' to account for companion scrollbar of listbox '
                     ' and other similar controls '
                     If ResizeFont Then
                       
                       .ctrl.Font.Size = .FontSize * minFactor
                     
                     End If
                     
                     ' move and resize the controls - we can't use a Move '
                     ' method because some controls do not support the change '
                     ' of all the four properties (e.g. Height with comboboxes) '
                     If Changes.AllowChangeLeft = True Then
                       
                       .ctrl.Left = .Left * widthFactor
                     
                     End If
                     
                     If Changes.AllowChangeTop = True Then
                       
                       .ctrl.Top = .Top * heightFactor
                     
                     End If
                     
                     If Changes.AllowChangeWidth = True Then
                       
                       .ctrl.Width = .Width * widthFactor
                     
                     End If
                     
                     If Changes.AllowChangeHeight = True Then
                       
                       .ctrl.Height = .Height * heightFactor
                     
                     End If
     End With
 
  Next
 
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
 
  Call PropBag.WriteProperty("ResizeFont", ResizeFont, False)
  Call PropBag.WriteProperty("KeepRatio", KeepRatio, False)

End Sub
****  END RESIZER.CTL****
0
 
LVL 1

Author Comment

by:dosyl
ID: 2559541
tward
Is it always this ActiveX everybody use?
If yes what is the name of the.ocx?
0
 
LVL 7

Expert Comment

by:tward
ID: 2559867
No it is not always an ActiveX control that people use.

Someone here could probably give you some code to go into the Form_Resize Event.

I have seen the code and then decided that it would be cleaner to place this ActiveX OCX on each form that I want to resize controls on.

The control is call RESIZER.OCX and it is something that I made from Code that was in the Visual Basic Programmer's Journal.

All you should have to do (if you have VB5 or VB6) is save the above files as I have them named and then open the .vbp file and compile it.  This project will create RESIZER.OCX which you can then pick from the Components Menu option.  The Component will be called msiResizer.

If this doesn't work for you let me know, I can zip the whole thing, including the compiled OCX and you can then use it.
0
 
LVL 1

Author Comment

by:dosyl
ID: 2560068
Thank's i'll look this and i'll give news to you.
0
 
LVL 1

Author Comment

by:dosyl
ID: 2561148
Tward
    I'm not able to load it. I copied and pasted the code in notepad; and when i load it i have full errors.
My e-mail is dosyl@sympatico.ca
Thank's
0
 
LVL 1

Author Comment

by:dosyl
ID: 2561349
Tward
  I found the errors :
1. I don't have the picture of Image1.Picture.
2. I don't have the ToolBoxBitmap, i know this is not necessary but interesting.
3. The bad one : I'm not able to put the Propery  Public to True, then i'm not able to put it in another project.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Expert Comment

by:tward
ID: 2561544
1.  It can be any picture.
2.  It can be any picture.
3.  You don't put it in another project.  It is it's own project, compile it and then you should be able to include msiResize (from the Components menu option) and then draw it on the forms that you want resized.
0
 
LVL 1

Author Comment

by:dosyl
ID: 2565367
In msiResizer properties, in the tab General i put : (ActiveX Control); in Project Type and in the Start Object i put (None). Is it good?
After when i wanted to create the ocx i had always the error message: No public UseControl Object detected. I put the UserControl's property Public to True and i was able to save the .Ocx, was it right?
Can you send the images for .Picture and .ToolBoxBitmap i'll not need to make them. I'll increase the points when all will work.
0
 
LVL 7

Expert Comment

by:tward
ID: 2565420
You should have been able to use the .VBP file that is above without any changes.

I sent you the code for the whole project.

0
 
LVL 1

Author Comment

by:dosyl
ID: 2572871
Adjusted points to 200
0
 
LVL 1

Author Comment

by:dosyl
ID: 2572872
Tward suggests: if you have a big form that you can not make smaller; TAKE TabStrips control.
Thank you tward for all.
0
 
LVL 1

Author Comment

by:dosyl
ID: 2572879
Tward suggests: if you have a big form that you can not make smaller; TAKE TabStrips control.
Thank you tward for all.
0
 
LVL 1

Author Comment

by:dosyl
ID: 2572881
Tward suggests: if you have a big form that you can not make smaller; TAKE TabStrips control.
Thank you tward for all.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now