Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "Mike Williams" Newsgroups: comp.lang.basic.visual.misc Subject: Re: Actual VB question! Date: Sat, 18 Jun 2011 22:55:36 +0100 Organization: A noiseless patient Spider Lines: 52 Message-ID: References: <4df52b72$1@dnews.tpgi.com.au> <4dfbf00c@dnews.tpgi.com.au> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit Injection-Date: Sat, 18 Jun 2011 21:55:26 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="m1AhZuvAAr9qtnIn50zThw"; logging-data="29253"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GCdEAI5EK7xwzFGeQLtIsohgFeXBTMKA=" In-Reply-To: <4dfbf00c@dnews.tpgi.com.au> X-Newsreader: Microsoft Windows Mail 6.0.6002.18197 Cancel-Lock: sha1:aw2Loyaam460cU2BlziFFSxZVrc= X-Priority: 3 X-MSMail-Priority: Normal X-MIMEOLE: Produced By Microsoft MimeOLE V6.0.6002.18463 Xref: x330-a1.tempe.blueboxinc.net comp.lang.basic.visual.misc:275 "StrandElectric" wrote in message news:4dfbf00c@dnews.tpgi.com.au... > When I select a control and then go Format > Align > Middles I get as far > as Align and then all the options are greyed out. As John has already said, Format Align is not for aligning text within a control and you instead need to adjust the Label's Top property with respect to the TextBox's Top property. However, it is best to do this at runtime rather than at design time because the required value is not always 45 twips and it can vary from system to system (often 45 Twips but sometimes 30 or 36 Twips and occasionally some other value) so you are better off doing it in code. The required offset can be calculated as follows: Option Explicit Private Declare Function SendMessage Lib "user32" _ Alias "SendMessageA" (ByVal hwnd As Long, _ ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long Private Declare Function GetSystemMetrics _ Lib "user32.dll" (ByVal nIndex As Long) As Long Private Const EM_GETRECT = &HB2 Private Const SM_CYEDGE = 46 Private LabelOffsetY As Single Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Sub Form_Load() Dim r1 As RECT, Y3DBorder As Long ' get pixel thickness of TextBox top 3D border Y3DBorder = GetSystemMetrics(SM_CYEDGE) ' get pixel offset from top of a TextBox client area to top of Character cells SendMessage Text1.hwnd, EM_GETRECT, 0, r1 ' calculate total offset in Twips LabelOffsetY = Me.ScaleY(r1.Top + Y3DBorder, _ vbPixels, Text1.Container.ScaleMode) End Sub You can then use the value of LabelOffsetY to adjust the position of each Label with respect to the position of its associated TextBox, for example: Label1.Top = Text1.Top + LabelOffsetY Mike