473,408 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Button size

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
4 4014
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Skip Hollowell | last post by:
I am working on a menu bar for a site, and am using buttons in the bar (because the customer wants to use accessKeys for each selection, apparently it is too much work to click on them with a...
1
by: Paul Gobée | last post by:
What is the parent element of a button (IE6 on Win, transitional mode)? Is it the BODY, the browser default stylesheet, or something else? Contra "body is parent-element": - Buttons with no...
5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
3
by: Zürcher See | last post by:
Someone has implemented a Datagrid Button for the Windows.Form?
4
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
3
by: Wang | last post by:
Here is the code for a webcontrol, quite simple: ------------------------------------------------------------------------------------------------------------- <%@ Control Language="c#"...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
3
by: Neil Wallace | last post by:
Hi, This is an odd one. I've been struggling to get "double click" to work well for my controls. The same event handler works perfectly for buttons, but not for labels. Can anyone tell me...
3
by: shimajavar | last post by:
Hi all I have the following code: a line is growing up by clicking on "up" button, it has another button"start" which I want it to stop the process of growing the line...How can I make a button to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.