Solved

Rotate Label in Visual Basic 6

Posted on 2009-05-13
3
612 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

617 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