Solved

Rotate Label in Visual Basic 6

Posted on 2009-05-13
3
600 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
Comment Utility
0
 
LVL 1

Author Comment

by:Terry Rogers
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

772 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

10 Experts available now in Live!

Get 1:1 Help Now