Solved

Rotate Label in Visual Basic 6

Posted on 2009-05-13
3
603 Views
Last Modified: 2012-05-06
I would like to rotate a text box in visual basic 6. It seems there is no method by default with the Label control to rotate it, is there anything else I can do to achieve rotated text printed on a form?
0
Comment
Question by:Terry Rogers
3 Comments
 
LVL 46

Accepted Solution

by:
tbsgadi earned 275 total points
ID: 24374524
0
 
LVL 1

Author Comment

by:Terry Rogers
ID: 24374581
That is only of limited help. I dont see how to change the font, the font size, the font colour or where the text is written on the form.
0
 
LVL 16

Assisted Solution

by:HooKooDooKu
HooKooDooKu earned 75 total points
ID: 24374899
There is no way to rotate a label.  Period.
That leaves you with two choises:
1. Buy a third party ocx that includes rotatable labels.
2. Use API function calls to draw the text yourself.

The code that tbsgadi pointed you to shows you the second option.  It gives you all the power in the "Windows" world to change font name, font style, font size.  This is because the code is using API functions to print text directly.  You can even change the font color, but that requires additional API functions not shown to manipulate properties of the Me.hdc.

But in any case, unless you want to pursue the 1st option, that means all these "properties" (size, style, color) is going to have to be something you deal with yourself (i.e. hard code in the logic or create a class, control, or UDT to store and work with these properties).

In this particular case, the font size was placed in a const pWIDTH and pHEIGHT (note, the values in the example are poor values as height is usually closer to twice the size of the width for a typical font, and you can also use a "default" width by setting with to zero).  The font type was hard coded in the CreateFont() function call to "Arial", the font rotation was passed as a parameter to the RotateText() Sub, and the position was set by setting the Form's CurrentX, CurrentY properties and getting the text printed using the "Print" method.  Now some of that could have been done differently using other API functions (such as TextOut() where you speicfy the X,Y position) but that's getting into even more API functions.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now