Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabled Text with the Etched/Sunken look

Status
Not open for further replies.

brailian

Programmer
Oct 11, 2001
11
US
I've noticed that the text of a disabled command button looks different from a disabled label or textbox. It turns a lighter shade of gray as opposed to a darker, and it gets an etched or sunken look to it. Does anyone know how I can make the text of a label look that way? Or, if the label is not capable, then can I create a custom ActX control that shows text like that?
 
Have you tried different option of the .appearance property of the label.

If none of those work for you, you could put your labels in text boxes, and then not apply for any edit. Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
it's easy enough to do for any control with a window handle (hWnd):
[tt]
Option Explicit
Private Declare Function DrawStateText Lib "user32" Alias "DrawStateA" (ByVal hDC As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lParam As String, ByVal wParam As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal un As Long) As Long

Private Const DSS_DISABLED = &H20
Private Const DST_PREFIXTEXT = &H2

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

Private Sub Command1_Click()
PrintDisabledText "Hello", Picture1, 5, 5
End Sub

Public Function PrintDisabledText(hStr As String, ctlOutput As Control, x As Long, y As Long)
' Skip if no hWnd
On Error Resume Next
DrawStateText GetDC(ctlOutput.hwnd), 0&, 0&, hStr, Len(hStr), x, y, 0&, 0&, DST_PREFIXTEXT Or DSS_DISABLED
On Error GoTo 0
End Function
[/bb]
Sadly, the label control doesn't have an hWnd. Mind you, it's parent will, and the label will be positioned within the parent - so some simple maths...
 
Try this. Paste two labels on the form- label0 and label1.
Set caption property of both labels to the same text. Make sure labels are of the same height and width(although width is irrelevant since you are going to set autosize property of both labels to true) and do not change any properties of the labels except for the ones mentioned below:

1. -Set background color property of label0 to &H00FFFFFF&(White)
2. -Set autosize property of label0 to True.
3. -Set backstyle property of label0 to 0-transparent
4. -Set foreground color property of label0 to &H80000010&-system color Button Shadow.
5. -Position label0 on your form
6. -Set background color property of label1 to &H8000000F&- system color Button Face.
7. -Set autosize property of label1 to True.
8. -Set backstyle property of label1 to 1-opaque
9. -Set foreground color property of label1to &H80000014&-system color Button Highlight.
10.- 5. -Position label1 on your form in such way that label1.Left=label0.Left+15, label1.Top=label0.Top+15. (These numbers are given for a form with Scalemode property set to 1-Twips).
11. Very Important. Make sure that label0 in higher in Z-Order than label1. You can either set Z-order at run time or at design time. At design time you can select label0 on your form. Then right click on it and choose Bring to Front.
Alternatively, you could select label1, right click on it and choose Send to Back. At run time use ZOrder method for either label. Pass Zorder method 0 to send to back or 1 to bring to front.
As you see these steps involve system colors. My computer has regular color scheme so it is working fine. See if it works for you.

Nikita
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top