Solved

Rotate Label in Visual Basic 6

Posted on 2009-05-13
3
610 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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