Form_Resize
(Updated On: 16-Jun-2011)
Explanatory Notes
Six styles of
demo forms are included as follows:
(a) Simple controls - all free to float and resize.
(b) Simple controls - with certain controls having tag
property settings for locking their position and / or size.
(c) Combo box and list box.
(d) Nested subforms - Continuous.
(e) Nested subforms - Datasheet.
(f) Tab control having (i) Nested subforms and (ii) Option
group.
Tag property
settings for steering the behavior of individual controls are as follows (more
than one setting (separated by ;) can be included in the tag string):
(a) LockLeft: The control retains a fixed distance
from left edge of the form.
(b) LockRight: The control retains a fixed distance
from right edge of the form.
(c) LockTop: The control retains a fixed distance
from top edge of the form.
(d) LockBottom: The control retains a fixed distance
from bottom edge of the form.
(e) LockLeftRight: The control expands in such a
manner that its left edge retains the original distance
from left edge of the form, while its right edge retains the original distance
from right edge of the form.
(f) LockTopBottom: The control expands in such a
manner that its top edge retains the original distance from top edge of the
form, while its bottom edge retains the original distance from bottom edge of the
form.
(g) LockSize: The control retains its original size.
(h) LockWidth: The control retains its original
width.
(i) LockHeight: The control retains its original
height.
Demo forms have all been designed for a screen resolution of 800 x 600. On opening any of these forms, it resizes automatically to suit the screen resolution currently in force (if it happens to be different from the designed one).
Custom
Resizing:
If the user wishes to fine tune the displayed size of a
given form even further, it can be done by double clicking any blank area on
the main form (outermost parent form in case there are subforms). Depending
upon user's choice in the resultant pop up form, the form in question will
resize up or down by 5 percent.
The user is presented with the option to store the custom resized status of the form in question. If accepted, the form will henceforth open at the customized size, irrespective of screen resolution in force.
At any stage, the user can alter the default opening style of a form by double
clicking on its blank area, and then selecting any of the following options (the
intended change takes effect from next opening of the form onwards):
(a) Resize to suit current screen resolution - even if
custom resizing had been in force so far.
(b) Resize to customized zoom factor, irrespective of screen
resolution in force.
(c) Retain the original design size - irrespective of current status
of screen resolution.
Note:
In this sample db, whenever a demo form is opened, a
message box comes up showing the status (e.g. design resolution, current
screen resolution, whether the form has been resized as per current screen
resolution or whether it conforms to custom zoom level as set by the user). In
regular use, such a message on each opening of the form might seem too
intrusive.
If desired, the opening message can be skipped by de-selecting the check box
in main switchboard form (i.e. the start up form).
Usage:
Form resizing is accomplished via a self contained class
named C_ReSizeForm. Import this class along with form F_ZoomMaster
into your db. Also import
table T_Zoom and clear its
contents.
Sample code in VBA
module
of main form (this code is not to be placed in VBA module of a subform) is as follows (in
this sample case, the form
is originally designed for a screen resolution of 800 x 600):
'=============================
' Declarations section
Private fm As C_ReSizeForm
'--------------------------------------------
Private Sub Form_Open(Cancel As Integer)
Set fm = New C_ReSizeForm
fm.P_Init Me, 800, 600
' Note: Above
statements should be placed at the very
' beginning (before any other code) in form's open event.
' Caution: Filteration code if any (e.g. Me.Filter = "FilterString"
' Note: For proper clearance of
circular reference
' do not set fm to nothing in any event of real form.
' Let it be taken care of by VBA's garbage collection
' process. (Also see note in mfm's close event in
' class C_ReSizeForm)
'==============================
Note (For Best Results):
(a) AutoResize property of each form and subform should be set to No.
(b) For proper effect, independent forms should be
displayed in their restored status - not maximized. Statement DoCmd.Restore can be
placed in form's Activate event.
(c) As an abundant precaution, each label should be independent (Not captive to any
other control).
(d) For optimum display, preferably use Times New Roman Font.
(e) For bulk removal of custom resize settings for all
forms, simply delete the contents of table T_Zoom. With this step, all forms
(where resize class has been used) on opening, shall automatically resize to suit the screen resolution
currently in
force.
(f) Datasheet forms must have necessary code in the load
event, specifying the row height, font height and column widths as applicable at design stage resolution.
This is because, any run time manipulation of these properties tends to stick
over to next opening, leading to snowballing effect. Sample code in form's load event is given below:
'----------------------------------------------
Me.RowHeight = 300
Me.DatasheetFontHeight = 11
Me.Control1.ColumnWidth = 1000
Me.Control2.ColumnWidth = 1500
'----------------------------------------------
Version: Access
2003 file format.
References: DAO 3.6