Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vertical label caption 4

Status
Not open for further replies.

rdavis

Programmer
Apr 29, 2002
157
US
Is there a way to show a caption for a label to be vertical instead of horizontal?

eg.

L instead of Label1
a
b
e
l
1

Thanks


Rob
 
you would of thought there would be a property for this, but i cant see it!!!

you can work around it by setting wordwrap to true and setting width really small (but thats not very neat looking)

or you could write a char at a time followed by vbCRLF

for i = 1 to len(yourstring)
str=mid(yourstring,i,1)
label1.caption=label1.caption & str & vbcrlf
next i

again not very nice!!

if there is an easyer way i would love to hear it [pc1]

good luck

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
That is what I was trying, but the captions that I want do not look very nice. I stopped playing with it last night, If I get a chance to play some more today I will.



Rob
 
I'm not sure we want to know what you got up to last night!

Carry on like this and you will go blind!

Big Al
 
We got a comedian here. I meant the program, where is you mind at?

Haha


Rob
 
Instead of using a label caption you could use a picture box or an image box - make a nice bmp (or whatever) save it and add it to your form through picturebox or image.
 
I've just had a go at using a Textbox.

Set Border Style to 0 and Font to the dreaded Courier.

It doesn't look brilliant but probably better than a Label.

Big Al
 
ADoozer,

Actually the way that you came up is the easiest way. Too bad I redisigned my form and I am not going to use the vertical label. But it is good to know for the future. Thanks



Rob
 
You might try setting Autosize to true and WordWrap to true. All you will have to to then is separate the characters by a space.

 
if you set autosize and wordwrap to true and type with spaces, it doesnt actualy cause a word wrap!!

it just autosizes horizontally with spaced out letters!!



If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
Heaton,
I tried that also, but separating the characters with vbcrlf was a better choice. You will run into problems with the letter 'i', etc.



Rob
 
Option Explicit

Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long

Private Const LF_FACESIZE = 32

Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As String * 32
End Type

Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long



Private Sub Command1_Click()
Dim myFont As LOGFONT
Dim hFont As Long
Dim hOldFont As Long
Dim OldGraphicsMode As Long

myFont.lfFaceName = "Ariel"
myFont.lfHeight = -24 ' font size
myFont.lfEscapement = -2700 ' Rotation in tenths of a degree
myFont.lfOrientation = -2700 ' orientation in tenths of a degree. Frankly irrelvant unless graphics mode is GM_ADVANCED

hFont = CreateFontIndirect(myFont)
hOldFont = SelectObject(Form1.hdc, hFont)
Form1.CurrentY = Form1.Height / 2
Form1.CurrentX = Form1.Width / 2
Form1.Print "Hello"

' Clean up
SelectObject Form1.hdc, hOldFont
DeleteObject hFont

End Sub

 
strongm,
like I said in a previous response, I redesigned my form, but that looks good (and will be saved for the future). Thanks



Rob
 
strongm,

I just tried pasting your code (VB5) while waiting for the traffic to ease outside my office.

It doesn't seem to do anything. I tried playing around with the 'myFont.lfEscapement' values to no avail.

Am I missing something.
 
works in VB6 SP5 running on 2k pro!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
bigalbigal,

check the scale mode of your form. The example happens to be designed to work in twips. I suspect that yours might be set to pixels...

or change these two lines:
[tt]
Form1.CurrentY = Form1.Height / 2
Form1.CurrentX = Form1.Width / 2
[/tt]
to:
[tt]
Form1.CurrentY = Form1.ScaleHeight / 2
Form1.CurrentX = Form1.ScaleWidth / 2
 
strongm,

Thanks for that but my form was set to twips so I tried:

Form1.CurrentY = Form1.ScaleHeight / 2
Form1.CurrentX = Form1.ScaleWidth / 2

Unfortunately that didn't make any difference.

No worries, I don't have a need for it right now, I was just going to tuck it away somewhere for the future.

Big AL
 
'Lable1 Properties
'Set AutoSize = True
'Set Alignment = 2-Center

Dim a As Integer
Dim temp As String
ReDim s(Len(Label1)) As String
For a = 0 To Len(Label1) - 1
s(a) = Mid$(Label1, a + 1, 1) & vbNewLine
temp = temp & s(a)
Next
Label1 = temp
 
There are third party activex's available on the web for vertical labels. I cant remeber where but!
 
Everyone,

I'm new to VB but a pro in Delphi and have used the LOGFONT to print rotated text and the rules are the same. The key is that only TrueType fonts can be displayed in this fashion. Probably if it didn't work, then change the font to a TrueType font and it will. You can tell windows to substitute a TrueType font all the time by setting the lfOutPrecision element to OUT_TT_ONLY_PRECIS.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top