469,327 Members | 1,265 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

Text Orientation Question...

I am wondering if anyone knows if it is
possible to change the display orientation
of a label so that the text may be displayed
vertically rather than horizontally.

I have seen reference to API calls that can
draw text at various angles, but before I commit
to the research and learing curve time, I am
hoping that a simpler method may exist. Point me
in a direction if it exists!

Thanks,

-Steve.
Jul 17 '05 #1
5 6286
Unless you happen to find a custom control (OCX) that does it, API seems
tobe the only way to go.

Here's two places where you might be lucky and save yourself some time.

http://www.planet-source-code.com
and
http://www.vbaccelerator.com

hope this helps

--
Stéphane Richard
Senior Software and Technology Supervisor
http://www.totalweb-inc.com
For all your hosting and related needs
"Steve Gdula" <st********@yahoo.com> wrote in message
news:ca**************************@posting.google.c om...
I am wondering if anyone knows if it is
possible to change the display orientation
of a label so that the text may be displayed
vertically rather than horizontally.

I have seen reference to API calls that can
draw text at various angles, but before I commit
to the research and learing curve time, I am
hoping that a simpler method may exist. Point me
in a direction if it exists!

Thanks,

-Steve.

Jul 17 '05 #2
Thanks for the Links Stéphane, and YES API looks like
the way to I have to go.

After being dejected (cause I hate API calls) it turns
out it wasn't so tough after all.

For the benefit of all:

Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" _
(ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, _
ByVal W As Long, ByVal I As Long, ByVal u As Long, ByVal S As Long, _
ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long,
_
ByVal PAF As Long, ByVal F As String) As Long

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

Within the CreateFont Function the
4'th parameter 'E' meaning (escapement) is actually the angle
in units of tenths of degrees to rotate the text. The 5'th parameter
'O' meaning (orientation) is ignored from what I understand.

'-------------Sample code utilized with good results------------------
'Display text test
Dim lngNewFont As Long, lngOldFont As Long

'Create the LOGICAL Font 'Handle?'
lngNewFont = CreateFont(20, 0, -220, 0, FW_NORMAL, 0, 0, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, _
1, PROOF_QUALITY, VARIABLE_PITCH Or FF_ROMAN Or 4, "TimesNewRoman")

'Select new Font as current font, and store handle to previous font.
lngOldFont = SelectObject(frmMyForm.hdc, lngNewFont)

'Display the Text
frmBatesAnalyzer.CurrentX = 150
frmBatesAnalyzer.CurrentY = 300
frmBatesAnalyzer.Print "Sample Text"

'Reselect orig font.
lngNewFont = SelectObject(frmMyForm.hdc, lngOldFont)

'Free up un-necessary resourses
DeleteObject lngNewFont
'-------------------------------------------------------------------
All the Font Constants were easily available in the API viewer that
comes with the VB IDE.
Jul 17 '05 #3
On 22 Jul 2003 07:34:13 -0700, st********@yahoo.com (Steve Gdula)
wrote:
I am wondering if anyone knows if it is
possible to change the display orientation
of a label so that the text may be displayed
vertically rather than horizontally.

I have seen reference to API calls that can
draw text at various angles, but before I commit
to the research and learing curve time, I am
hoping that a simpler method may exist. Point me
in a direction if it exists!

Thanks,

-Steve.


I'm still a newbie at this stuff, but would this do what you want?

label1.caption="H" & vbcrlf & "E" & vbcrlf & "L" & vbcrlf & "L" &
vbcrlf & "O"

And draw the label vertically instead of horizontally on the form.

Tony!

Jul 17 '05 #4
Steve try this
1 form
1 label
this code

Option Explicit

Private Sub Form_Load()
Dim NumString As String
Dim StringLen As Long
Dim LoopChars As Long
Dim OutString As String
NumString = Label1.Caption
StringLen = Len(NumString)
For LoopChars = 1 To StringLen
OutString = OutString & (Mid$(NumString, LoopChars, 1) & vbNewLine)
Next LoopChars
Label1.Caption = OutString
Label1.AutoSize = True
End Sub

HTH
George
"Steve Gdula" <st********@yahoo.com> wrote in message
news:ca**************************@posting.google.c om...
I am wondering if anyone knows if it is
possible to change the display orientation
of a label so that the text may be displayed
vertically rather than horizontally.

I have seen reference to API calls that can
draw text at various angles, but before I commit
to the research and learing curve time, I am
hoping that a simpler method may exist. Point me
in a direction if it exists!

Thanks,

-Steve.

Jul 17 '05 #5
Thanks George and Tony for excellent ideas.

I failed to elaborate on my original message the
fact that not only did I need the information
displayed in a vertical format, but the characters
had to be rotated -90 degrees as well. Your suggestion
would stack the characters directly on top of one
another, but at their standard zero degree declination.

----- my original message --------------
I am wondering if anyone knows if it is
possible to change the display orientation
of a label so that the text may be displayed
vertically rather than horizontally.

----------------------------------------

Thanks for all help!

--Steve.
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bruce Adams | last post: by
7 posts views Thread by Santah | last post: by
6 posts views Thread by Andrew Thompson | last post: by
4 posts views Thread by Philip K | last post: by
8 posts views Thread by Michael Wiseley | last post: by
11 posts views Thread by Vishal Naidu | last post: by
6 posts views Thread by jcrouse | last post: by
5 posts views Thread by Stan McCann | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.