Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #244 > unrolled thread

Actual VB question!

Started by"StrandElectric" <Strand@dummyspit>
First post2011-06-13 07:11 +1000
Last post2011-06-18 22:55 +0100
Articles 18 — 10 participants

Back to article view | Back to comp.lang.basic.visual.misc


Contents

  Actual VB question! "StrandElectric" <Strand@dummyspit> - 2011-06-13 07:11 +1000
    Re: Actual VB question! GS <gs@somewhere.net> - 2011-06-12 18:53 -0400
      Re: Actual VB question! Jason Keats <jkeats@melbpcDeleteThis.org.au> - 2011-06-13 12:34 +1000
    Re: Actual VB question! "Ivar" <ivar.ekstromer000@ntlworld.com> - 2011-06-13 00:58 +0100
    Re: Actual VB question! Dee Earley <dee.earley@icode.co.uk> - 2011-06-13 09:19 +0100
    Re: Actual VB question! Eric Coleman <eric@strategon.com> - 2011-06-17 10:04 -0500
      Re: Actual VB question! "StrandElectric" <Strand@dummyspit> - 2011-06-18 10:23 +1000
        Re: Actual VB question! john@jeasonNoSpam.cix.co.uk (John K.Eason) - 2011-06-18 12:20 +0100
          Re: Actual VB question! "StrandElectric" <Strand@dummyspit> - 2011-06-19 05:04 +1000
          Re: Actual VB question! "StrandElectric" <Strand@dummyspit> - 2011-06-19 06:29 +1000
            Re: Actual VB question! john@jeasonNoSpam.cix.co.uk (John K.Eason) - 2011-06-19 00:26 +0100
            Re: Actual VB question! ralph <nt_consulting64@yahoo.net> - 2011-06-18 21:41 -0500
              Re: Actual VB question! john@jeasonNoSpam.cix.co.uk (John K.Eason) - 2011-06-19 12:22 +0100
                Re: Actual VB question! ralph <nt_consulting64@yahoo.net> - 2011-06-19 10:51 -0500
                  Re: Actual VB question! john@jeasonNoSpam.cix.co.uk (John K.Eason) - 2011-06-20 12:07 +0100
          Re: Actual VB question! Deanna Earley <dee.earley@icode.co.uk> - 2011-06-20 09:56 +0100
            Re: Actual VB question! john@jeasonNoSpam.cix.co.uk (John K.Eason) - 2011-06-20 12:10 +0100
        Re: Actual VB question! "Mike Williams" <Mike@WhiskyAndCoke.com> - 2011-06-18 22:55 +0100

#244 — Actual VB question!

From"StrandElectric" <Strand@dummyspit>
Date2011-06-13 07:11 +1000
SubjectActual VB question!
Message-ID<4df52b72$1@dnews.tpgi.com.au>
vb6

I have a problem where the text or caption line up near the top (vertically) 
of the textbox or label. Also captions on the labels and text in the text 
boxes does not quite line up. I'd like to have them more in the middle 
vertically and aligned properly. (I am of course OK for horizontal placeing 
(left right centre)). Is there some control property I should be tweaking? 
Apols for such a basic question. 

[toc] | [next] | [standalone]


#245

FromGS <gs@somewhere.net>
Date2011-06-12 18:53 -0400
Message-ID<it3ftn$cvd$1@dont-email.me>
In reply to#244
It happens that StrandElectric formulated :
> vb6
>
> I have a problem where the text or caption line up near the top (vertically) 
> of the textbox or label. Also captions on the labels and text in the text 
> boxes does not quite line up. I'd like to have them more in the middle 
> vertically and aligned properly. (I am of course OK for horizontal placeing 
> (left right centre)). Is there some control property I should be tweaking? 
> Apols for such a basic question.

Font size would be 1 place to look. Control Height would be another.

-- 
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

[toc] | [prev] | [next] | [standalone]


#247

FromJason Keats <jkeats@melbpcDeleteThis.org.au>
Date2011-06-13 12:34 +1000
Message-ID<wGeJp.6456$aH5.1690@viwinnwfe02.internal.bigpond.com>
In reply to#245
GS wrote:
> It happens that StrandElectric formulated :
>> vb6
>>
>> I have a problem where the text or caption line up near the top
>> (vertically) of the textbox or label. Also captions on the labels and
>> text in the text boxes does not quite line up. I'd like to have them
>> more in the middle vertically and aligned properly. (I am of course OK
>> for horizontal placeing (left right centre)). Is there some control
>> property I should be tweaking? Apols for such a basic question.
>
> Font size would be 1 place to look. Control Height would be another.
>

To get finer control of object placement using Ctrl + Arrow keys, you 
should look at Tools > Options > General and try modifying the width and 
height of the Grid Units or unticking "Align Controls to Grid".

[toc] | [prev] | [next] | [standalone]


#246

From"Ivar" <ivar.ekstromer000@ntlworld.com>
Date2011-06-13 00:58 +0100
Message-ID<PmcJp.10597$w86.9257@newsfe22.ams2>
In reply to#244
If it's just a few controls then set the TextBox or Label Border and 
appearance properties to 0 and place them in a picturebox as you want them 
and set the picturebox properties to how you want them to appear
If it's a lot of controls then look in to wrapping the Textbox or label in a 
user control.
The label and textbox controls don't expose the methods you are looking for 
on their own via VB, don't look to good via API either.


"StrandElectric" <Strand@dummyspit> wrote in message 
news:4df52b72$1@dnews.tpgi.com.au...
> vb6
>
> I have a problem where the text or caption line up near the top 
> (vertically) of the textbox or label. Also captions on the labels and text 
> in the text boxes does not quite line up. I'd like to have them more in 
> the middle vertically and aligned properly. (I am of course OK for 
> horizontal placeing (left right centre)). Is there some control property I 
> should be tweaking? Apols for such a basic question.
>
> 

[toc] | [prev] | [next] | [standalone]


#250

FromDee Earley <dee.earley@icode.co.uk>
Date2011-06-13 09:19 +0100
Message-ID<it4h6c$6hq$2@speranza.aioe.org>
In reply to#244
On 12/06/2011 22:11, StrandElectric wrote:
> vb6
>
> I have a problem where the text or caption line up near the top (vertically)
> of the textbox or label. Also captions on the labels and text in the text
> boxes does not quite line up. I'd like to have them more in the middle
> vertically and aligned properly. (I am of course OK for horizontal placeing
> (left right centre)). Is there some control property I should be tweaking?
> Apols for such a basic question.

Just adjust the Top property to suit your requirements.
Note that the position can vary slightly based on Windows theme, font 
sizes, phase of moon, etc :)

-- 
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

[toc] | [prev] | [next] | [standalone]


#270

FromEric Coleman <eric@strategon.com>
Date2011-06-17 10:04 -0500
Message-ID<itfqe1$e3a$1@speranza.aioe.org>
In reply to#244
On 6/12/2011 4:11 PM, StrandElectric wrote:
> vb6
>
> I have a problem where the text or caption line up near the top (vertically)
> of the textbox or label. Also captions on the labels and text in the text
> boxes does not quite line up. I'd like to have them more in the middle
> vertically and aligned properly. (I am of course OK for horizontal placeing
> (left right centre)). Is there some control property I should be tweaking?
> Apols for such a basic question.
>
>


Select the controls you want to align, and then from the the "Format" 
menu, select "Align" -> "Middles"

There is a lot of neat stuff in the Format menu.  Also, you can right 
click on the toolbar and add the "Form Editor" toolbar.  It can also be 
customized to add more of the formatting controls that aren't present.

[toc] | [prev] | [next] | [standalone]


#271

From"StrandElectric" <Strand@dummyspit>
Date2011-06-18 10:23 +1000
Message-ID<4dfbf00c@dnews.tpgi.com.au>
In reply to#270
"Eric Coleman" <eric@strategon.com> wrote in message 
news:itfqe1$e3a$1@speranza.aioe.org...
> On 6/12/2011 4:11 PM, StrandElectric wrote:
>> vb6
>>
>> I have a problem where the text or caption line up near the top 
>> (vertically)
>> of the textbox or label. Also captions on the labels and text in the text
>> boxes does not quite line up. I'd like to have them more in the middle
>> vertically and aligned properly. (I am of course OK for horizontal 
>> placeing
>> (left right centre)). Is there some control property I should be 
>> tweaking?
>> Apols for such a basic question.
>>
>>
>
>
> Select the controls you want to align, and then from the the "Format" 
> menu, select "Align" -> "Middles"
>
> There is a lot of neat stuff in the Format menu.  Also, you can right 
> click on the toolbar and add the "Form Editor" toolbar.  It can also be 
> customized to add more of the formatting controls that aren't present.

Experimenting now Eric. When I select a control and then go Format > Align > 
Middles, as you suggested, I get as far as Align and then all the options 
are greyed out. I will continue to try. 

[toc] | [prev] | [next] | [standalone]


#272

Fromjohn@jeasonNoSpam.cix.co.uk (John K.Eason)
Date2011-06-18 12:20 +0100
Message-ID<memo.20110618122028.400W@jeason.cix.co.uk>
In reply to#271
In article <4dfbf00c@dnews.tpgi.com.au>, Strand@dummyspit (StrandElectric) wrote:

> *From:* "StrandElectric" <Strand@dummyspit>
> *Date:* Sat, 18 Jun 2011 10:23:35 +1000
> 
> "Eric Coleman" <eric@strategon.com> wrote in message 
> news:itfqe1$e3a$1@speranza.aioe.org...
> > On 6/12/2011 4:11 PM, StrandElectric wrote:
> >> vb6
> >>
> >> I have a problem where the text or caption line up near the top 
> >> (vertically)
> >> of the textbox or label. Also captions on the labels and text in 
> the text
> >> boxes does not quite line up. I'd like to have them more in the 
> middle
> >> vertically and aligned properly. (I am of course OK for 
> horizontal >> placeing
> >> (left right centre)). Is there some control property I should be 
> >> tweaking?
> >> Apols for such a basic question.
> >>
> >
> > Select the controls you want to align, and then from the the 
> > "Format" menu, select "Align" -> "Middles"
> >
> > There is a lot of neat stuff in the Format menu.  Also, you can 
> > right click on the toolbar and add the "Form Editor" toolbar.  It 
> > can also be customized to add more of the formatting controls 
> > that aren't present.
> 
> Experimenting now Eric. When I select a control and then go Format 
> > Align > Middles, as you suggested, I get as far as Align and then 
> all the options are greyed out. I will continue to try. 

That option is for aligning controls on a form, not for aligning text within a
control (which isn't natively possible for vertical alignment).
To vertically align a label relative to a single-line text box, I've found that
the Top property of the label control needs to be 45 points larger than the textbox
Top property (assuming the desktop is using  the default settings, and using
'Classic view in Windows).

Regards
       John

[toc] | [prev] | [next] | [standalone]


#273

From"StrandElectric" <Strand@dummyspit>
Date2011-06-19 05:04 +1000
Message-ID<4dfcf6d5@dnews.tpgi.com.au>
In reply to#272
"John K.Eason" <john@jeasonNoSpam.cix.co.uk> wrote in message 
news:memo.20110618122028.400W@jeason.cix.co.uk...
> In article <4dfbf00c@dnews.tpgi.com.au>, Strand@dummyspit (StrandElectric) 
> wrote:
>
>> *From:* "StrandElectric" <Strand@dummyspit>
>> *Date:* Sat, 18 Jun 2011 10:23:35 +1000
>>
>> "Eric Coleman" <eric@strategon.com> wrote in message
>> news:itfqe1$e3a$1@speranza.aioe.org...
>> > On 6/12/2011 4:11 PM, StrandElectric wrote:
>> >> vb6
>> >>
>> >> I have a problem where the text or caption line up near the top
>> >> (vertically)
>> >> of the textbox or label. Also captions on the labels and text in
>> the text
>> >> boxes does not quite line up. I'd like to have them more in the
>> middle
>> >> vertically and aligned properly. (I am of course OK for
>> horizontal >> placeing
>> >> (left right centre)). Is there some control property I should be
>> >> tweaking?
>> >> Apols for such a basic question.
>> >>
>> >
>> > Select the controls you want to align, and then from the the
>> > "Format" menu, select "Align" -> "Middles"
>> >
>> > There is a lot of neat stuff in the Format menu.  Also, you can
>> > right click on the toolbar and add the "Form Editor" toolbar.  It
>> > can also be customized to add more of the formatting controls
>> > that aren't present.
>>
>> Experimenting now Eric. When I select a control and then go Format
>> > Align > Middles, as you suggested, I get as far as Align and then
>> all the options are greyed out. I will continue to try.
>
> That option is for aligning controls on a form, not for aligning text 
> within a
> control (which isn't natively possible for vertical alignment).
> To vertically align a label relative to a single-line text box, I've found 
> that
> the Top property of the label control needs to be 45 points larger than 
> the textbox
> Top property (assuming the desktop is using  the default settings, and 
> using
> 'Classic view in Windows).
>
> Regards
>       John

Thanks John. Makes sense. I'll try it! 

[toc] | [prev] | [next] | [standalone]


#274

From"StrandElectric" <Strand@dummyspit>
Date2011-06-19 06:29 +1000
Message-ID<4dfd0a96@dnews.tpgi.com.au>
In reply to#272
"John K.Eason" <john@jeasonNoSpam.cix.co.uk> wrote in message

> To vertically align a label relative to a single-line text box, I've found 
> that
> the Top property of the label control needs to be 45 points larger than 
> the textbox
> Top property (assuming the desktop is using  the default settings, and 
> using
> 'Classic view in Windows).
>
> Regards
>       John

HI John. Terrific!  I have tried that and for the first time my applications 
look attractive. Previously I tried moving the controls around in an attempt 
to align  label text with textbox text, and of course they always sprang to 
the grid!  You have ended years of frustration. Can I buy you a beer? 

[toc] | [prev] | [next] | [standalone]


#276

Fromjohn@jeasonNoSpam.cix.co.uk (John K.Eason)
Date2011-06-19 00:26 +0100
Message-ID<memo.20110619002603.2556A@jeason.cix.co.uk>
In reply to#274
In article <4dfd0a96@dnews.tpgi.com.au>, Strand@dummyspit (StrandElectric) wrote:

> *From:* "StrandElectric" <Strand@dummyspit>
> *Date:* Sun, 19 Jun 2011 06:29:05 +1000
> 
> "John K.Eason" <john@jeasonNoSpam.cix.co.uk> wrote in message
> 
> > To vertically align a label relative to a single-line text box, 
> > I've found that the Top property of the label control needs to be 45
> > points larger than the textbox Top property (assuming the desktop is
> > using  the default settings, and using 'Classic view in Windows).
> >
> > Regards
> >       John
> 
> HI John. Terrific!  I have tried that and for the first time my 
> applications look attractive. Previously I tried moving the 
> controls around in an attempt to align  label text with textbox 
> text, and of course they always sprang to the grid!  You have ended 
> years of frustration.

You could always turn the grid off and drag them manually, but it rather depends
how steady your hand is when dragging controls around! :^)
As Mike says, it would be safer to do it in code if there's any chance of running
on a non-default system, but all my programs are for my use only, so I don't
bother.
 
> Can I buy you a beer? 

That could be tricky as a) you appear to live in Australia and I'm in the UK, and
b) I'm teetotal. I'll accept an e-beer and imagine it's a cup of coffee if you like
though! :^)

Regards
       John

[toc] | [prev] | [next] | [standalone]


#277

Fromralph <nt_consulting64@yahoo.net>
Date2011-06-18 21:41 -0500
Message-ID<ntnqv6tcsnla510vt8h5f52947gotpp6ef@4ax.com>
In reply to#274
On Sun, 19 Jun 2011 06:29:05 +1000, "StrandElectric"
<Strand@dummyspit> wrote:


>
>HI John. Terrific!  I have tried that and for the first time my applications 
>look attractive. Previously I tried moving the controls around in an attempt 
>to align  label text with textbox text, and of course they always sprang to 
>the grid!  You have ended years of frustration. Can I buy you a beer? 
>

Memories.

I remember like yesterday the day I was rebuilding data entry forms. I
was carefully deleting controls on one form and positioning and
resizing a new control on another, one by one. A VB veteran looking
over my shoulder said, why don't you select them then copy 'n paste?
Doph!

-ralph
<g>

[toc] | [prev] | [next] | [standalone]


#278

Fromjohn@jeasonNoSpam.cix.co.uk (John K.Eason)
Date2011-06-19 12:22 +0100
Message-ID<memo.20110619122239.1584A@jeason.cix.co.uk>
In reply to#277
In article <ntnqv6tcsnla510vt8h5f52947gotpp6ef@4ax.com>, nt_consulting64@yahoo.net
(ralph) wrote:

> *From:* ralph <nt_consulting64@yahoo.net>
> *Date:* Sat, 18 Jun 2011 21:41:52 -0500
> 
> On Sun, 19 Jun 2011 06:29:05 +1000, "StrandElectric"
> <Strand@dummyspit> wrote:
> 
> >HI John. Terrific!  I have tried that and for the first time my 
> applications >look attractive. Previously I tried moving the 
> controls around in an attempt >to align  label text with textbox 
> text, and of course they always sprang to >the grid!  You have 
> ended years of frustration. Can I buy you a beer? >
> 
> Memories.
> 
> I remember like yesterday the day I was rebuilding data entry 
> forms. I
> was carefully deleting controls on one form and positioning and
> resizing a new control on another, one by one. A VB veteran looking
> over my shoulder said, why don't you select them then copy 'n paste?
> Doph!
> 
> -ralph
> <g>

Ho yus! Then you found all the indexes of control arrays had been re-ordered...
:^(

Regards
       John

[toc] | [prev] | [next] | [standalone]


#279

Fromralph <nt_consulting64@yahoo.net>
Date2011-06-19 10:51 -0500
Message-ID<4j6sv6535dc0rjm8st93ipnjn2jaf7ocgb@4ax.com>
In reply to#278
On Sun, 19 Jun 2011 12:22 +0100 (BST), john@jeasonNoSpam.cix.co.uk
(John K.Eason) wrote:

>In article <ntnqv6tcsnla510vt8h5f52947gotpp6ef@4ax.com>, nt_consulting64@yahoo.net
>(ralph) wrote:
>
>> *From:* ralph <nt_consulting64@yahoo.net>
>> *Date:* Sat, 18 Jun 2011 21:41:52 -0500
>> 
>> On Sun, 19 Jun 2011 06:29:05 +1000, "StrandElectric"
>> <Strand@dummyspit> wrote:
>> 
>> >HI John. Terrific!  I have tried that and for the first time my 
>> applications >look attractive. Previously I tried moving the 
>> controls around in an attempt >to align  label text with textbox 
>> text, and of course they always sprang to >the grid!  You have 
>> ended years of frustration. Can I buy you a beer? >
>> 
>> Memories.
>> 
>> I remember like yesterday the day I was rebuilding data entry 
>> forms. I
>> was carefully deleting controls on one form and positioning and
>> resizing a new control on another, one by one. A VB veteran looking
>> over my shoulder said, why don't you select them then copy 'n paste?
>> Doph!
>> 
>> -ralph
>> <g>
>
>Ho yus! Then you found all the indexes of control arrays had been re-ordered...
>:^(
>

Thankfully, the same colleague also introduced me to the wonderful
world of Addons.

-ralph
<g>

[toc] | [prev] | [next] | [standalone]


#281

Fromjohn@jeasonNoSpam.cix.co.uk (John K.Eason)
Date2011-06-20 12:07 +0100
Message-ID<memo.20110620120755.484B@jeason.cix.co.uk>
In reply to#279
In article <4j6sv6535dc0rjm8st93ipnjn2jaf7ocgb@4ax.com>, nt_consulting64@yahoo.net
(ralph) wrote:

> *From:* ralph <nt_consulting64@yahoo.net>
> *Date:* Sun, 19 Jun 2011 10:51:06 -0500
> 
> On Sun, 19 Jun 2011 12:22 +0100 (BST), john@jeasonNoSpam.cix.co.uk
> (John K.Eason) wrote:

> >Ho yus! Then you found all the indexes of control arrays had been 
> re-ordered...
> >:^(
> >
> 
> Thankfully, the same colleague also introduced me to the wonderful
> world of Addons.
> 
> -ralph
> <g>

 Yes. They do come in useful occasionally, especially MZ-Tools!

Regards
       John

[toc] | [prev] | [next] | [standalone]


#280

FromDeanna Earley <dee.earley@icode.co.uk>
Date2011-06-20 09:56 +0100
Message-ID<itn1vs$tno$1@speranza.aioe.org>
In reply to#272
On 18/06/2011 12:20, John K.Eason wrote:
> ...the Top property of the label control needs to be 45 points larger...

Minor point, but it's a twip. A point is 20x larger than a twip (and not 
evenly divisible by pixels by default)

:p

-- 
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

[toc] | [prev] | [next] | [standalone]


#282

Fromjohn@jeasonNoSpam.cix.co.uk (John K.Eason)
Date2011-06-20 12:10 +0100
Message-ID<memo.20110620121001.484C@jeason.cix.co.uk>
In reply to#280
In article <itn1vs$tno$1@speranza.aioe.org>, dee.earley@icode.co.uk (Deanna Earley)
wrote:

> *From:* Deanna Earley <dee.earley@icode.co.uk>
> *Date:* Mon, 20 Jun 2011 09:56:30 +0100
> 
> On 18/06/2011 12:20, John K.Eason wrote:
> > ...the Top property of the label control needs to be 45 points 
> > larger...
> 
> Minor point, but it's a twip. A point is 20x larger than a twip 
> (and not evenly divisible by pixels by default)
> 
> :p
> 
> -- 
> Dee Earley (dee.earley@icode.co.uk)
> i-Catcher Development Team
> http://www.icode.co.uk/icatcher/

 Yep. My error.

Regards
       John

[toc] | [prev] | [next] | [standalone]


#275

From"Mike Williams" <Mike@WhiskyAndCoke.com>
Date2011-06-18 22:55 +0100
Message-ID<itj6se$si5$1@dont-email.me>
In reply to#271
"StrandElectric" <Strand@dummyspit> 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

 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.basic.visual.misc


csiph-web