|
-
Jul 4th, 2000, 01:31 PM
#1
does anybody know a way to change the color of a label which is disabled (lbl.enabled=FALSE)?
I want to show a label on a picturebox, but a click on this label shall be recognised by the picturebox, theirfore I put the lbl.enable to FALSE. But I want the the old forecolor of the label.
-
Jul 4th, 2000, 01:35 PM
#2
_______
<?>
leave the label enabled and in it's click
event call the click event of the picture box
Call picBox_Click
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 4th, 2000, 03:00 PM
#3
Nice try,Joe
but I need the X and Y coordinates from the picturebox. Your solution will give X,Y relative to the Label.
-
Jul 4th, 2000, 06:44 PM
#4
Why don't you just hide the label? Or move it far off the picture box?
-
Jul 4th, 2000, 07:09 PM
#5
_______
<?>
let me see the code..I know a disabled item is grey
but perhaps there is a walk around.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 4th, 2000, 09:48 PM
#6
It's probably something like:
Code:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
CurrentX = X
CurrentY = Y
Text1.Text = CurrentX & ", " & CurrentY
End Sub
And when you move the mouse over the label, the coordinates do not read.
But if you hide the label, it will read those coordinates.
If you do not want to hide it or move it, here's another idea: Well, you have to move or hide it, but know where its coordinates are. So if the mouse moves there, it hides or moves it, and if the coordinates are different from where it is, unhide or move it back. This will probably require a Timer, or just use it in the Picture1_MouseMove event.
[Edited by Matthew Gates on 07-04-2000 at 10:51 PM]
-
Jul 5th, 2000, 02:57 AM
#7
Mathew, you got the problem.
Your solution to hide the label, in case the mouse moves over it, will not solve the changed color problem.
Maybe I have to to create a custom shape that includes the label. That way I would need to create shapes for all possible labels (the label text shall be time in hrs+min!!).
So i'm still searching.
-
Jul 5th, 2000, 03:09 AM
#8
Lively Member
What about...
Nice try,Joe
but I need the X and Y coordinates from the picturebox. Your solution will give X,Y relative to the Label.
Just use the mousedown event of the label, and add label.left to X, and label.Top to Y to get the Picture X and Y.
Code:
Picture1_MouseDown Button, Shift, Label1.Left + X, Label1.Top + Y
[Edited by Andrew Empson on 07-05-2000 at 04:12 AM]
Andrew Empson
vb6(ent) SP4
-
Jul 5th, 2000, 04:50 AM
#9
Frenzied Member
He Said Joe was Closest with just changing the colour and passing the event through, You Just Need To Make Some Modifications to the Coordinates of the Mouse Events.
Something Like This Will Do
Code:
Option Explicit
Dim boolLabelEnable As Boolean
Dim lngColours(-1 To 0) As Long 'Colours for label
Private Sub Form_Load()
lngColours(True) = vbRed 'You Can use any clours you want here, true is the Enabled Colour
lngColours(False) = vbBlue 'False is the Disabled Colour
LabelEnable = True 'Set The Labelenable property
End Sub
Private Property Get LabelEnable() As Boolean
LabelEnable = boolLabelEnable
End Property
Private Property Let LabelEnable(new_LabelEnable As Boolean)
Label1.ForeColor = lngColours(new_LabelEnable)
boolLabelEnable = new_LabelEnable
End Property
Private Sub Label1_Click()
If LabelEnable Then
'Label1_Click Code Here
Else
On Error Resume Next 'In Case We Don't Have a picture1_Click
Picture1_Click
On Error GoTo 0
End If
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If LabelEnable Then
'Label1_MouseDown Code Here
MsgBox X
Else
On Error Resume Next 'In Case We Don't Have a picture1_MouseDown
Picture1_MouseDown Button, Shift, Picture1.ScaleX(X, vbTwips, Picture1.ScaleMode) + Label1.Left, ScaleY(Y, vbTwips, Picture1.ScaleMode) + Label1.Height
On Error GoTo 0
End If
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If LabelEnable Then
'Label1_MouseMove Code Here
MsgBox X
Else
On Error Resume Next 'In Case We Don't Have a picture1_MouseMove
Picture1_MouseMove Button, Shift, Picture1.ScaleX(X, vbTwips, Picture1.ScaleMode) + Label1.Left, ScaleY(Y, vbTwips, Picture1.ScaleMode) + Label1.Height
On Error GoTo 0
End If
End Sub
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If LabelEnable Then
'Label1_MouseUp Code Here
MsgBox X
Else
On Error Resume Next 'In Case We Don't Have a picture1_MouseUp
Picture1_MouseUp Button, Shift, Picture1.ScaleX(X, vbTwips, Picture1.ScaleMode) + Label1.Left, ScaleY(Y, vbTwips, Picture1.ScaleMode) + Label1.Height
On Error GoTo 0
End If
End Sub
Hope this helps
If it wasn't for this sentence I wouldn't have a signature at all.
-
Jul 5th, 2000, 07:10 PM
#10
I see..you don't want the label to be moved or hidden at all. Sorry bout that. I was thinking of solutions. But Sam looks like he has found it.
-
Jul 9th, 2000, 10:21 AM
#11
Another solution to change the Disabled Text colour is to use the SetSysColors API.
When you load the Form, all disabled Text will be coloured blue and when you unload it, it will be changed back to it's original colour.
Code:
Private Declare Function SetSysColors Lib "user32" (ByVal nChanges As Long, lpSysColor As Long, lpColorValues As Long) As Long
Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Const COLOR_GRAYTEXT = 17
Private Sub Form_Load()
'Get the current colour of Grayed Text
LastColour = GetSysColor(COLOR_GRAYTEXT)
'Change the colour to Blue
SetSysColors 1, COLOR_GRAYTEXT, vbBlue
End Sub
Private Sub Form_Unload(Cancel As Integer)
'When the Form unloads, change the colour back to the original colour
SetSysColors 1, COLOR_GRAYTEXT, LastColour
End Sub
-
Jul 9th, 2000, 03:03 PM
#12
Thanks
Thanks for all the good ideas.
I think I wil go for the solution to call the image_mousemove event from the label_mousemove event.
The remaining problem for me is to correctly hand over the
coordinates from the label (standard pixel's) to the image
(user-scale).
I still get wiser,each day.
-
Jul 10th, 2000, 04:14 PM
#13
I made it!
in order to get the correct mouse x and y values of an picturebox, while moving the mouse over a label, use:
Private Sub Label_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Call Picture_MouseMove(Button, Shift, (Label.Left + X * (Picture.ScaleWidth / Picture.Width)), (Label.Top - Y * (Picture.ScaleHeight / Picture.Height)))
End Sub
This assumes your UserScale is increasing from left to right and from top to bottom!
Sorry, but I don't know whow to use the code print (yet!).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|