By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

Button size

P: n/a
I have a form, on that form I have standard size buttons with no text
in them, they are all in line with one another and exactly the same
distance apart. Why then, can anyone tell me, do they look like they
are different sizes?

If you do not beleive me try it yourself, the button that I used
properties war:

Left 1cm
Top 1cm
Width 0.6cm
Height 0.6cm

And I left the caption property blank. Once you have created the
button, copy it, then paste it 7 times, so you have a form with eight
buttons. The first, fourth, and seventh look bigger than the others.
I have seen this happen on a range of different monitors. Any got an
explaination?

Thanks,

Nick

Jul 21 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Nick 'The Database Guy' wrote:
Why then, can anyone tell me, do they look like they
are different sizes?
FWIW, I've had similar experiences occasionally. I've had to fiddle
around with the snap to grid and resizing the buttons with handles. It
was puzzling.
I have seen this happen on a range of different monitors. Any got an
explaination?
Nope! 8)
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Jul 21 '06 #2

P: n/a
Hi Nick,

All dimensions in Access are expressed in twips (1/40 of an inch).
Converting cm to twips gives a rounding error.
Finally, the twips have to be converted to the pixels of your screen,
with again a rounding error. This can lead to a row of buttons where
systematically some buttons have 1 screen pixel more or less than the
others.

HBInc.
Nick 'The Database Guy' wrote:
I have a form, on that form I have standard size buttons with no text
in them, they are all in line with one another and exactly the same
distance apart. Why then, can anyone tell me, do they look like they
are different sizes?

If you do not beleive me try it yourself, the button that I used
properties war:

Left 1cm
Top 1cm
Width 0.6cm
Height 0.6cm

And I left the caption property blank. Once you have created the
button, copy it, then paste it 7 times, so you have a form with eight
buttons. The first, fourth, and seventh look bigger than the others.
I have seen this happen on a range of different monitors. Any got an
explaination?

Thanks,

Nick
Jul 22 '06 #3

P: n/a
I was able to emulate what you describe.

I think HBInc is on the right track, but with the wrong dimensions.

It seems that when we set Windows to use small fonts it equates 15
twips to a pixel and when we set it to large fonts, 12.

So, I am thinking if we set our control dimensions tomutiples of 12 or
15 as per Windows then there will be no rounding (we have already done
this) and control sizes will be standard.

I thinkwe must use code to get at the dimesnion in TWIPs however.

The code below is very immature. It's a first try at making control
dimensions multiples of 15 or 12 TWIPS as required. Of course, after
running itone will have to do some realignment. As it is new, I
strongly suggest that it be run in a copy of your mission-critical
database.

Apologies if someone else has done this before. I am unaware.

Option Explicit

Private Declare Function GetDC& Lib "user32" _
(ByVal WindowHandle&)
Private Declare Function ReleaseDC& Lib "user32" _
(ByVal WindowHandle&, ByVal WindowDeviceHandle&)
Private Declare Function GetDeviceCaps& Lib "gdi32" _
(ByVal WindowHandle&, ByVal Index&)

Private Const LOGPIXELSX& = &H5A
Private Const LOGPIXELSY& = &H5A
Private Const TWIPSPERINCH& = 1440

Public Function TwipsPerPixel()
Dim aTwipsPerPixel$(0 To 1)
Dim DesktopWindow&
Dim DesktopWindowDeviceHandle&
DesktopWindowDeviceHandle = GetDC(DesktopWindow)
aTwipsPerPixel(0) = TWIPSPERINCH \
GetDeviceCaps(DesktopWindowDeviceHandle, LOGPIXELSX)
aTwipsPerPixel(1) = TWIPSPERINCH \
GetDeviceCaps(DesktopWindowDeviceHandle, LOGPIXELSY)
ReleaseDC DesktopWindow, DesktopWindowDeviceHandle
TwipsPerPixel = aTwipsPerPixel
End Function
Public Sub StandardizeControlDimensions(ByVal FormName$)
Dim frm As Form
Dim ctl As Control
Dim aTwipsPerPixel As Variant
aTwipsPerPixel = TwipsPerPixel()
On Error GoTo StandardizeControlDimensionsErr
Echo 0
DoCmd.OpenForm FormName, acDesign
Set frm = Forms(FormName)
For Each ctl In frm.Controls
ctl.Height = (Round(ctl.Height / aTwipsPerPixel(1), 0) *
aTwipsPerPixel(1))
ctl.Width = Round(ctl.Width / aTwipsPerPixel(0), 0) *
aTwipsPerPixel(0)
' just to check the first few times we use it
Debug.Print ctl.Name, ctl.Height, ctl.Width
Next ctl
StandardizeControlDimensionsExit:
Echo -1
DoCmd.Close acForm, FormName, acSaveYes
Exit Sub
StandardizeControlDimensionsErr:
With Err
MsgBox .Description, vbCritical, "Error # " & .Number
End With
Resume StandardizeControlDimensionsExit
End Sub

Sub test()
StandardizeControlDimensions "Form1"
End Sub

Jul 23 '06 #4

P: n/a
Hi,

Unfortunately I did some mistyping in my last message.
There are 1440 twips in an inch.

Thanks James.

HBInc.
hbinc wrote:
Hi Nick,

All dimensions in Access are expressed in twips (1/40 of an inch).
Converting cm to twips gives a rounding error.
Finally, the twips have to be converted to the pixels of your screen,
with again a rounding error. This can lead to a row of buttons where
systematically some buttons have 1 screen pixel more or less than the
others.

HBInc.
Nick 'The Database Guy' wrote:
I have a form, on that form I have standard size buttons with no text
in them, they are all in line with one another and exactly the same
distance apart. Why then, can anyone tell me, do they look like they
are different sizes?

If you do not beleive me try it yourself, the button that I used
properties war:

Left 1cm
Top 1cm
Width 0.6cm
Height 0.6cm

And I left the caption property blank. Once you have created the
button, copy it, then paste it 7 times, so you have a form with eight
buttons. The first, fourth, and seventh look bigger than the others.
I have seen this happen on a range of different monitors. Any got an
explaination?

Thanks,

Nick
Jul 23 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.