Professional Documents
Culture Documents
ResizingFormsWithClass SK
ResizingFormsWithClass SK
I
N the December 2000 issue, I wrote an article There’s also no font substitution code, so fonts need to be
evaluating three resizing tools (“Everything About True Type fonts in order for them to resize properly. I’m
Resizing Controls”). In that article, I made reference pleased to see that these limitations are discussed openly.
to the coverage of the resizing problem in the Access It’s disappointing to discover a product’s faults several
Developer’s Handbook. Shortly after the article was hours or days into a development project.
published, Ken Getz, one of the book’s authors and a For my previous article, I’d sent the vendors a
respected speaker and Access authority, asked me to battery of questions. I submitted the same battery to
evaluate the resizing tool that the book discusses. Ken’s Ken, and I was happy to obtain responses to all of my
tool comes with the Access 2000 Developer’s Handbook and questions. Available with this month’s Source Code file at
can be downloaded from www.developershandbook.com www.smartaccessnewsletter.com is a transcript of the
for free. Ken’s product is attractive not only because it’s responses Ken sent me (I’ve also included the responses
free and effective but because of its clever use of classes to from Peter’s Software, the only other company to respond
control the resizing process. to all of my questions).
Ken has produced a resizing product for Access 2000
and Access 97 that not only has the capacity to resize Testing
forms and their controls but also has the ability to restrict Ken, as with the other resizing product suppliers, has you
controls in resizing or moving in relation to the form. place code in the Open event procedure of the form that
Under the hood, the tool is a well-constructed product you want to resize. Unlike the other controls, though, you
that encapsulates the concepts of object-oriented design don’t have to put code in the form’s Resize event. Ken
(at least, as far as Access will allow). The product is well- uses WithEvents to catch events fired by the form and
supported with documentation explaining the underlying catch the Resize event for you. This makes for much less
theory, its application, and the tool’s limitations. coding on your behalf.
When products are free, I’m initially skeptical of a The main catch with using WithEvents event sinks is
product’s quality and ask the obvious question: “What’s that you must have the HasModule property set to True
the catch?” Well, there isn’t any real catch—or any on the form, and any code you want to use separately on
question of the tool’s quality. The only catch is that if the Open and Resize events must be marked as an [Event
you don’t purchase the Access 2000 Developer’s Handbook, Procedure]. Otherwise, the Event call you try to apply will
you don’t get the source code. Of course, I’d highly be eradicated (this is documented in Ken’s notes as well).
recommend that every serious Access developer have the In the December 2000 article, I built a test harness for
version of the Access Developer’s Handbook (by Litwin, the controls that used a common procedure to open my
Getz, and Gilbert) that’s appropriate for the version of sample forms. That procedure applied a class using
Access that they’re developing with (versions exist for WithEvents in a similar fashion to Ken’s, allowing me to
Access 2.0 and up). apply resizing code to every form without having to code
At present, the downloadable resizer tool is available each form. The same class, albeit with modifications, was
for Access 2000 (with source) and Access 97 (in MDE used with success on this product. If you have many
format) only. It isn’t a tough task to convert the Access forms in your application or need to retrofit to an existing
2000 program back to Access 97 if you need the source on application, this approach saves many hours of coding
that platform, although you’ll need to grasp some of the and reduces your margin for error.
newer language facilities such as Enum and Friend. Initially, however, I couldn’t get a stable environment
The tool’s documentation is an Adobe Acrobat PDF for resizing using this approach (NT’s Dr. Watson kept on
file, which explains what resizing has to deal with in producing access violation errors). I thought the code was
terms of screen resolutions and fonts, how to apply the crashing because both routines were using WithEvents
Test results
In my December 2000 review, the
three controls I tested worked on
very basic form layouts but failed on
forms with even low levels of
complexity. The following areas were
particularly weak:
• Option groups placed on tab
forms lost their shape as the
option buttons pushed out the
borders during resizing.
• The sizing operation in complex
forms, when rapidly resized,
couldn’t keep up.
• On popup and modal forms, the
resize event didn’t seem to fire Figure 1. Multiple option groups on tab forms aren’t a problem.
All of these properties can be set Figure 2. The same form showing Size and Float in action.
FontSize = FontSize(ctl)
Suggestions
As with the other controls that I tested, there are
enhancements that I’d like to see. These enhancements
are minor, as the product has been well thought-out and
needs very little in the way of improvement.
• Font substitution code would take care of those
people who find it difficult to design with scalable
fonts. This would be especially useful for those who
have inherited projects that originate from Access 1
and 2. Font sizing code for all of the ActiveX controls
supplied by Microsoft in the Developer’s edition
should be available.
• There should be a proportional setting for the forms.
It would be a desirable feature for me to have this for
my own applications, where the forms are heavily
loaded with grids and other controls.
• It would be useful to scale popup forms to the size of
the Access application. I had a situation where the
client had a resolution of 1280x1024, and he wanted
the application to remain at an equivalent size of
800x600. I could do this by setting the application to
800x600 at startup. The main problem is that the
popup forms scaled to the 1280x1024 resolution and
not proportionally to the application size.