Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Overlaying labels with text

Posted on 1998-10-13
17
Medium Priority
?
275 Views
Last Modified: 2010-04-30
I need to put some text on a form so that it goes across two adjacent label controls.  Te text is to be printed letter by letter going vertically down the centre of the labels.  Can anyone suggest a way to do this given the way VB layers print text and controls
0
Comment
Question by:Taranadilla
[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
  • 7
  • 4
  • 3
  • +2
17 Comments
 
LVL 6

Expert Comment

by:clifABB
ID: 1439708
I'm not sure I understand exactly what you mean.
Would setting the BackStyle of the labels to transparent help?

Can you explain a bit more what you are trying to do?
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1439709
Taranadilla,
It looked to me you want to print some text vertically.
Here is the code to do that.
Regards
Dalin



       1. In the form's General declaration area, add:
       Private Type LOGFONT
         lfHeight As Long
         lfWidth As Long
         lfEscapement As Long
         lfOrientation As Long
         lfWeight As Long
         lfItalic As Byte
         lfUnderline As Byte
         lfStrikeOut As Byte
         lfCharSet As Byte
         lfOutPrecision As Byte
         lfClipPrecision As Byte
         lfQuality As Byte
         lfPitchAndFamily As Byte
       ' lfFaceName(LF_FACESIZE) As Byte 'THIS WAS DEFINED IN API-CHANGES MY OWN
         lfFacename As String * 33
       End Type

       Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) 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


       ' 2. Add the function
       Private Function fRotateText(ByVal theText As String, ByVal theSize As Integer, ByVal theAngle As Integer, ByVal theX As Long, ByVal
       theY As Long) As Boolean

       'Name:      fText90D
       'Author:    Dalin Nie
       'Date:      2/18/98
       'Purpose:   Print a 90 degree text in the form
       'Pass In:   TheText-- the text you want to print
       '           theSize:   Size of the font
       '           theAngle:  How many degree's you want to rotate
       '           theX, theY, Where you wnat your text
       'Return:    Boolean


         On Error GoTo Trap
         Dim F As LOGFONT, hPrevFont As Long, hFont As Long, FontName As String
         Dim FONTSIZE As Integer
         FONTSIZE = theSize

         F.lfEscapement = 10 * theAngle 'rotation angle, in tenths
         FontName = "Arial Black" + Chr$(0) 'null terminated
         F.lfFacename = FontName
         F.lfHeight = (theSize * -20) / Screen.TwipsPerPixelY
         hFont = CreateFontIndirect(F)
         hPrevFont = SelectObject(Me.hdc, hFont)
         CurrentX = theX
         CurrentY = theY
         Print theText
         
       '  Clean up, restore original font
         hFont = SelectObject(Me.hdc, hPrevFont)
         DeleteObject hFont
         fRotateText = True
         
         Exit Function

       Trap:

       End Function

       ' add a label, name it lable On, set backstyle to transparent
       ' add a command button,

       Private Sub Command1_Click()
       Call fRotateText("My Text", 12, 90, Label1.Left, Label1.Top + Label1.Height)
       End Sub


0
 

Author Comment

by:Taranadilla
ID: 1439710
I don't actually want to rotate the type.  What I have is a series of columns, each with a shaded part up to a percentage of the total height.  In order to easily identify a click event on a particular column I have used labels instead of just drawing the columns, but now I can't print a short description down each label because the label control always overlay print controls on the form and the text goes to the back.

The text should go down vertically like:

T
A
R
A
N
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Expert Comment

by:mark2150
ID: 1439711
You can make a text box look just like a label by turning off the border, etc. Set your alignment to centered and multiline to true. Then feed in your text as in:

Text1.Text = "T" & vbCRLF & "A" & vbCRLF & "R" ...

While in the development environment set the ZOrder to bring it to the front.

M


0
 
LVL 9

Expert Comment

by:Dalin
ID: 1439712
You can set the text box's multiline property to true and have the width to be one letter wide, you will get that.
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1439713
after open the question, someone called me so I did not see the posted answer, sorry.

0
 

Author Comment

by:Taranadilla
ID: 1439714
This would have been a good answer but the reason I am trying to print over the top of the labels is that the text needs to be independant of the labels lying below it.  I will attemp to explain why but its a difficult concept to describe without a diagram:-

When you lie two labels (or text boxes) together and the text needs to follow on from one to the other without any interruption there is a problem that if the one label finshes part way through a letter then you might end up with half an "A" - and A with the legs cut off.  You then start the text again on the label/textbox adjoining it and it is impossible to start with just the legs of an "A" you need to start from the top with a whole character.

This is why I am trying to overlay text using the forms print property, but the way VB seems to work is to always put the controls on top.  I am really looking for a way of changing this.
0
 

Author Comment

by:Taranadilla
ID: 1439715
see above comment
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1439716
Have you checked the autosize feature of the label? This might solve your cut-off problems.
0
 

Author Comment

by:Taranadilla
ID: 1439717
I am unable to size the labels at convenient sizes for the text - the two labels together have to be a given height and this height is divided between them at any possible percentage. therefore I cant use the autosize property
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1439718
So the two labels together have a fixed height.
Are you able to change the height of each label?
0
 

Author Comment

by:Taranadilla
ID: 1439719
The labels together make a fixed height.  One is coloured the other not.  Together they form a partly filled box - the coloured part is to represent a percentage of the total height - it can be any percentage - in other words I have no control over deciding the height of either of the two parts of the box
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 600 total points
ID: 1439720
This is why I said that you need to set the ZOrder property to put the text box in the Front. The labels, being in the back, will be rendered *first* and then overlain by the text box. This should give you the effect you're after.

M

0
 

Author Comment

by:Taranadilla
ID: 1439721
Sorry to sound dim but does this mean you can have a text box that is totally  transparent except for its text?

ie would I be able to see the two labels underneath, which is the effect I want

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1439722
Believe so. Give it a shot.
0
 

Author Comment

by:Taranadilla
ID: 1439723
I can find backstyle property on label controls but not text box controls.  I have therefore
tried setting the backstyle of the labels to transparent and am getting some very unpredictable results.

The first time I (at run-time) load a pair of labels on the form they overwrite any text on the form that is behind them.  If I load a second pair of labels the text behind the original pair of labels becomes visible and the text behind the second pair of labels is obscured.  If I load another set of labels the text behind the second  pair of labels becomes visible but the new set obscure the text behind them

Is this something to do with the Zorder?  I looked this up in the help but am none the wiser - it seemed to say you could only change the display order of things on the same level as each other.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1439724
You can use "bring to front" to control order that controls render in.

M

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…
Suggested Courses

604 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