This is either straightforward or not possible.
Is it possible (and if so how) to set a Static control so that the text displayed is centred vertically ??
TIA
Simon
Rebus HR UK Ltd
Just create a static say 16 wide and 120 deep. Go into the text properties and enter say
t
e
s
t
i
n
g
and set the justification to centre. You now have what we think you are describing.
World Leaders in all things RevSoft
Simon,
Or do you mean something like this
------------------------ | | | | | the text | | of the static | | | | | ------------------------with equal amounts of space above and beneath the text?
- Oystein -
Thanks for the quick response.
I mean like Oystein has specified, so that on a one line text control with a height of 25, and a text/font height of 15, there would be a space of 5 above and below.
Simon
Simon,
Two alternatives that I can think of:
(1)
GDI.
(2)
A handler that
(a) gets the font of the static
(b) gets the static's width
© perhaps calculates exactly how much of that width is available for the text. There might be some unavailable margin at each side, and you want to get the available width exactly right before the next step, in case the text wraps over several lines
(d) uses the TEXTRECT Utility to find out how many pixels high the text is when shown with the static's font and within the aforementioned width
(e) shrinks the height of the static so the text just fits vertically
(f) changes the vertical position of the static so the new, smaller version is centered relative to the old version
(g) size two extra pieces of text-less static to make up for the shrinkage.
- Oystein -
Thanks Oystein,
I've already had one go by placing an unbordered text field on top of the first in the centre - this works OK but I wondered if there was a better method.
I think for a text field GDI is probably a bit OTT
Simon
Simon,
Wait a minute - could there be some style you could manipulate…
- Oystein -
Thats what I was hoping, but I can't find anything obvious …
Simon
Simon,
If it's not possible with a static it might be possible with a different control that can show text. If you can set that other control to read-only and change its appearance so it looks like a static…
- Oystein -
FWIW, we coded a HTML Font Dialog Box for S/Web - we used this approach when displaying the chosen font in the dialog - works really nice. You just alter the size and position of the *static* to make the text look like it's centered vertically within a given area.
World leaders in all things RevSoft
I who thought I'd patent my idea of shrink-wrapping statics. No such luck.
![]()
- Oystein -
You should be able to do this by just having a normal static control, of the height you require, and then manually modify the SIZE property so that the controls Y pos is adjusted by the amount require to offset the control vertically.
This would be something like THIS in your create event:
SIZE=.STATIC-]SIZE
SIZE=SIZE+(SIZE/2)-5
.STATIC-]SIZE=SIZE
The -5 is for a a little vertical lift for the text height and will depend on the font used.
Colin
Colin,
My text control approach can also handle multi-line text, and text or font that is set programmatically.
- Oystein -