borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2013 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (Block Keyboard Input) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Sideways/Vertical Text
Poster Message
X3ndou
Level: Graduate

Registered: 31-08-2004
Posts: 9

icon Sideways/Vertical Text

My program takes data from the user's input and puts it into a form which is printed.  I want to make it print on the side, vertically, though.  Is there any way to easily make a label sidways/vertical?

By the way, thanks to everyone who replied to my last post.

Thank you,
X3ndou

[Edited by X3ndou on 31-08-2004 at 09:29 PM GMT]

31-08-2004 at 09:29 PM
View Profile Send Email to User Show All Posts | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 435
icon Re: Sideways/Vertical Text

Hi X3ndou,

I do not use VB.OLD (versions before .NET) anymore but I think I remember seeing somewhere here a 3D label control. If I am not mistaken it was written by our very own admin. I also think it had a means of allowing you to specify its orientation (veritcal|horizontal).

There is also the all versatile Win32 API. Cannot recall the exact functions offhand, but they must have been along the lines of DrawText etc.

You will need to get a DC (device context) of your form and then do the writing yourself onto theis dc using these API functions. I am leaving my computer for a while but I will try to look into it further (by probably a search) when I get back.

You may want to look into GDI while you're at it. Happy coding

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

31-08-2004 at 10:54 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
X3ndou
Level: Graduate

Registered: 31-08-2004
Posts: 9
icon Re: Sideways/Vertical Text

I use VB5, and when I try to open the sample project included in the 3d text zip file an error comes up.

http://www.uploadthis.com/images/24/118.JPG

Is this because I us VB5?

Thanks,
X3ndou

[Edited by X3ndou on 31-08-2004 at 11:04 PM GMT]

31-08-2004 at 10:59 PM
View Profile Send Email to User Show All Posts | Quote Reply
pc888
Level: Graduate

Registered: 02-01-2004
Posts: 12
icon Re: Sideways/Vertical Text

I am not experienced with vb.old either.  

However, in VB.net, you could 'draw' your text using GDI routine onto a background of your choice, and I assume using UNICODE characters.  Since it will be your own code, you could write left to right, right to left, top to bottom, etc.
It is surprising that no one has not already come up with something.

01-09-2004 at 12:06 AM
View Profile Send Email to User Show All Posts | Quote Reply
fabulous
Level: VB Guru


Registered: 03-08-2002
Posts: 435
icon Re: Sideways/Vertical Text

Hi X3,

If I remember correctly, 'Retained' is a project option that was introduced in VB6's .vbp files and was not available in VB5. For this reason, some of the projects you make in VB6 will not open in VB5 and you might have to build the project manually by creating a new project and then adding modules, forms and classes to it by pointing to the existing ones.

pc888, the reason I have not supplied any code in .NET is because .NET and .OLD are way different. VB.NET is not what I would call an upgrade to the previous version. It is a total departure from the way you would code, many things that were unique to VB alone in the days of .OLD have now been changed and something as simple as events on controls could give someone some headaches when they first start out. As to why no one has come up with anything, I suspect that one of the gurus who still have a copy of vb.OLD will have a look at this later and come up with something. My reply was meant as a guidline so that he could look in some direction and maybe solve the problem on his own.

Happy coding

____________________________
My boss is a Jewish Carpenter (Jesus Christ)


Brain Bench Certified VB.NET Developer

01-09-2004 at 03:47 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1137
icon Re: Sideways/Vertical Text

Hi

Try this link to a link

http://www.andreavb.com/forum/viewtopic.php?TopicID=1216&page=0#3807


Steve  

01-09-2004 at 11:53 AM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1652
icon Re: Sideways/Vertical Text

TO draw some rotated text, next API's are all you need

CreateFont - created font will be used on forms/pictureboxes - objects that have device context

SelectObject - here you select created font to be default font on the device context

And then all yuo need is to set current position on the form

CurrentX=10
CurrentY=10

Print YourText


After all is done select old font to be the default font on form, and delete font you have created to free resources

With more math, you could also draw curved text using this API's

____________________________
If you find the answer helpful, please mark this topic as solved.

01-09-2004 at 12:58 PM
View Profile Send Email to User Show All Posts | Quote Reply
MikeG
Level: Sage

Registered: 21-02-2003
Posts: 56
icon Re: Sideways/Vertical Text

This code will add vertical text to a form.


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

Const ANSI_CHARSET As Long = 0
Const FF_DONTCARE As Long = 0
Const CLIP_LH_ANGLES As Long = &H10
Const CLIP_DEFAULT_PRECIS As Long = 0
Const OUT_TT_ONLY_PRECIS As Long = 7
Const PROOF_QUALITY As Long = 2
Const TRUETYPE_FONTTYPE As Long = &H4
Const p_WIDTH As Long = 12
Const p_HEIGHT As Long = 12

Private Sub RotateText(TheText As String, TheAngle As Long)
    Dim NewFont As Long
    Dim OldFont As Long
    NewFont = CreateFont(p_HEIGHT, p_WIDTH, TheAngle, 0, FF_DONTCARE, 0, 0, 0, ANSI_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_LH_ANGLES Or CLIP_DEFAULT_PRECIS, PROOF_QUALITY, TRUETYPE_FONTTYPE, "Arial")
    OldFont = SelectObject(Me.hdc, NewFont)

    Print TheText

    NewFont = SelectObject(Me.hdc, OldFont)
    DeleteObject NewFont
End Sub

Private Sub Form_Load()
    Dim TheAngle As Long
    Me.Show
    CurrentX = 300
    CurrentY = 150
    TheAngle = -900
    RotateText "This is a test", TheAngle 'angle in tenths of a degree  'PUT YOUR TEXT HERE
End Sub




[Edited by MikeG on 01-09-2004 at 11:36 AM GMT]

01-09-2004 at 07:23 PM
View Profile Send Email to User Show All Posts | Quote Reply
lordkevin
Level: Trainee

Registered: 26-12-2012
Posts: 1
icon Re: Sideways/Vertical Text

Thanks for the nice post dear...

____________________________
lord

26-12-2012 at 11:28 AM
View Profile Send Email to User Show All Posts | Quote Reply
michaeljee
Level: Trainee

Registered: 01-03-2013
Posts: 1
icon Re: Sideways/Vertical Text

Nice surprise about this shorter form. Can you tell us what it is you are talking/writing about?
Has any info. about this shorter form been posted before (and i just missed it)?

____________________________
michaeljee

01-03-2013 at 11:25 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Sideways/Vertical Text
Next Topic (Block Keyboard Input) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2013 Andrea Tincaniborder