transfer focus from a label to picturebox

alanyap
04-02-2002, 08:00 PM
i am putting a LABEL contained inside a PICTUREBOX and coded some things in picturebox_mousedown(...) sub

I want to disable the LABEL so that clicking on the label invoke PICTUREBOX_mousedown(...) sub (I don't want the LABEL to get the focus)

ATTEMPT #1
----------------
so i simply set the LABEL.enabled = false
it works alright BUT the LABEL grayed out instead of using my preferred color (forecolor property) . I dont want that.


ATTEMPT #2
----------------
set the LABEL.enabled = true and add this code

sub LABEL_mousedown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

call PICTUREBOX_mousedown(Index , Button , Shift, X , Y )

end sub

not working also!

ATTEMPT #3 (a feeble and desperate one!)
-------------------------------------------------------
set the LABEL.enabled = true and add this code

sub LABEL_click()

PICTUREBOX.setfocus

end sub

NOT WORKING ALSO! Anyone... can u pls help me? thanks!

Thinker
04-02-2002, 08:13 PM
Labels can't get focus. Your attempt #2 is the closest thing. I
notice you have an index property in the label mousedown, and
are including that in the picturebox mousedown. Do you have
two control arrays, one of pictureboxes, and one of labels? If so,
is there a one to one correspondence between labels and picboxes.

Squirm
04-03-2002, 03:23 AM
Unless the label is positioned at the exact top and left of the picturebox, you'll need to alter the X and Y values since they will be relative the the label instead of the picturebox.

You have to add the Label's .Left property to the X value, and .Top property to the Y value.

tcstudio
04-04-2002, 02:17 PM
Private Sub Form_Load()
Me.Label1.Caption = "Hello"
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call Picture1_MouseDown(0, 0, 0, 0)
End Sub
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call Picture1_MouseUp(0, 0, 0, 0)
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label1.Caption = "Bye"
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Label1.Caption = "Hello"
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum