Article ID: 111899 - Last Review: October 11, 2006 - Revision: 2.2 Controls in Dialog Box May "Snap" to Preset ValuesThis article was previously published under Q111899 On This PageSYMPTOMS
In Microsoft Excel, when you use Visual Basic commands to adjust the
dimensions of controls in custom dialog boxes by manipulating the Top,
Left, Height, and Width properties of the controls, the controls will
always "snap" to certain numbers. For example, if you change the Left
property of a control, it will always snap to a multiple of 0.75.
CAUSE
This behavior occurs because of the design of the custom dialog box system.
MORE INFORMATION
"Snapping" occurs when a control is placed in a certain position that is
not precisely supported in a custom dialog box. For example, the Left
property of a control always snaps to the next lowest multiple of 0.75. If
you change the Left property of a control to any of the following values,
the Left property will then snap to the indicated value:
When <Control>.Left It snaps is set to this value to this value ---------------------------------------- 0 0 0.25 0 0.50 0 0.75 0.75 1.00 0.75 1.25 0.75 1.50 1.50 In addition, if one property is changed by snapping, it may affect other related properties. For example, in the Visual Basic code example below, an edit box is initially created with a Top value of 50 and a Height value of 15. The Top value initially snaps to 49.5; however, when the Height value snaps, the Top value is changed to 47.25, even though 49.5 is a valid Top value. The Left and Width values are similarly related. The final Top, Left, Height, and Width values will always be valid, but you may observe controls moving slightly because of snapping. Listed here are the guidelines that Microsoft Excel uses when determining how a property of a control will be snapped. Note: The values may vary slightly in Microsoft Excel 97 from those listed below, but the behavior is the same.
Control Type Units Snapped to
-----------------------------------------------------------------------
ALL CONTROLS The Left property of all controls snaps to the
nearest multiple of 0.75 less than or equal to the
indicated value.
The Top property of all controls snaps to the
nearest multiple of 0.75 less than or equal to the
indicated value.
Edit Boxes The Height property of edit boxes and labels use
and Labels the following table to determine the true Height
value:
Height Set to Height Snaps to
-------------------------------
0.00 - 18.50 13.50
18.75 - 28.25 23.25
28.50 - 38.00 33.00
38.25 - 47.75 42.75
For subsequent ranges, add 9.75 for each range.
The Width property of edit boxes and labels snaps to
the nearest multiple of 0.75 less than or equal to
the indicated value.
Buttons The Height property of buttons snaps to the nearest
multiple of 0.75 less than or equal to the indicated
value, but no less than 15.75.
The Width property of buttons snaps to the nearest
multiple of 0.75 less than or equal to the indicated
value, but no less than 3.00.
Dialog Box Frame All properties of a dialog frame snap to the nearest
multiple of 0.75 less than or equal to the indicated
value.
Group Boxes The Height property of group boxes snaps to the
nearest multiple of .75 less than or equal to the
indicated value, but no less than 18.75.
The Width property of group boxes snaps to the
nearest multiple of 0.75 less than or equal to the
indicated value, but no less than 23.25.
Check Boxes The Height property of check boxes is always 16.50.
The Width property of check boxes snaps to the
nearest multiple of 0.75 less than or equal to the
indicated value, but no less than 23.25.
Option Buttons The Height property of option buttons is always
16.50.
The Width property of option buttons snaps to the
nearest multiple of 0.75 less than or equal to the
indicated value, but no less than 23.25.
List Boxes The Height property of list boxes uses the following
table to determine the true Height value:
Height Set to Height Snaps to
-------------------------------
0.00 - 26.75 21.75
27.00 - 36.50 31.50
36.75 - 46.25 41.25
46.50 - 56.00 51.00
For subsequent ranges, add 9.75 for each range.
The Width property of list boxes snaps to the
nearest multiple of 0.75 less than or equal to the
indicated value, but no less than 12.00.
Drop-Down Lists The Height property of drop-down lists is always
15.00.
The Width property of drop-down lists snaps to the
nearest multiple of 0.75 less than or equal to the
indicated value, but no less than 12.00.
Drop-Down Edit The Height property of drop-down edit boxes is always
Boxes 13.50.
The Width property of drop-down edit boxes snaps to
the nearest multiple of 0.75 less than or equal to
the indicated value, but no less than 12.00.
Scroll Bars The Height property of scroll bars snaps to the
nearest multiple of 0.75 less than or equal to the
indicated value, but no less than 12.00.
The Width property of scroll bars is always 12.00.
Spinners The Height property of spinners snaps to the nearest
multiple of 0.75 less than or equal to the indicated
value, but no less than 13.50.
The Width property of spinners is always 9.00.
Visual Basic Code ExampleMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following subroutine creates a new dialog sheet, adds an edit box to it, changes the Top, Left, Height, and Width properties of the edit box, and then displays what the various properties have snapped to.
Original Setting Snaps To
Top 50 47.25
Left 70 69.75
Height 15 13.5
Width 80 79.5
The properties of the edit box have snapped to values appropriate for an edit box. Note that the Top property has been "over-snapped" because of the substantial change in the Height property. | Article Translations
|

Back to the top
