ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cancel Click on label control (https://www.excelbanter.com/excel-programming/406501-cancel-click-label-control.html)

Adrian Turner

Cancel Click on label control
 
I have a label on a worksheet (bordering an image placed on top). I want to
be able to cancel the click event. If the label is clicked it seems to bring
itself to the front. I have tried sending back etc , checking got focus...
nothing seems to work. I thought it would be simple, but...

Any help would be appreciated.

Adrian

John Bundy

Cancel Click on label control
 
Have you tried going into properties and setting Enabled=Flase? That might do
it, i'm not sure if it will affect the look of the picture. Mine does not do
what you mentioned unless i misunderstood. xl2003
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Adrian Turner" wrote:

I have a label on a worksheet (bordering an image placed on top). I want to
be able to cancel the click event. If the label is clicked it seems to bring
itself to the front. I have tried sending back etc , checking got focus...
nothing seems to work. I thought it would be simple, but...

Any help would be appreciated.

Adrian


Adrian Turner

Cancel Click on label control
 
John, thanks for your response. Setting enabled or locked makes no difference.
I'm trying to create a thumbnail menu system with hover over effects. I
basically have 3 layers. Layer 1 has one state of image. Layer 2 is the label
which is taller and wider then both the images and finally layer 3 the other
state of the image. With a small amount of code I have the effect I want, but
if they click the exposed area of the label it causes the problem I am
experiencing. Does not make sense. Have tried all the obvious things....
properties, focus, zorder etc I thought I would look at the event, expecting
the cancel to be easy. I could look at API's but there must be a way to do it
in excel, surely ?

Thanks Again

Adrian



"John Bundy" wrote:

Have you tried going into properties and setting Enabled=Flase? That might do
it, i'm not sure if it will affect the look of the picture. Mine does not do
what you mentioned unless i misunderstood. xl2003
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Adrian Turner" wrote:

I have a label on a worksheet (bordering an image placed on top). I want to
be able to cancel the click event. If the label is clicked it seems to bring
itself to the front. I have tried sending back etc , checking got focus...
nothing seems to work. I thought it would be simple, but...

Any help would be appreciated.

Adrian


Jialiang Ge [MSFT]

Cancel Click on label control
 
Hello Adrian,

I am sorry that I do not have a clear picture of the issue base on the
description. Do you mean the Label control in UserForm of Excel worksheet
by "Label"? What is the "Layer"? As far as I know, userforms have three
drawing layers. When we add a control to a userform, it gets added to one
of the top two layers, depending on the type of control. The three layers
are identified as follows:

1. The userform background and its scrollbar
2. The Label, CheckBox, ComboBox, CommandButton, Image, OptionButton,
RefEdit, ScrollBar, SpinButton, TabStrip, ToggleButton and TextBox controls
3. The Frame, ListBox, MultiPage and other ActiveX controls

Controls in layer 2 can overlap each other, but will always be drawn behind
controls in layer 3, whereas all the controls in layer 3 can overlap each
other. Fortunately, layer 3 includes the Frame control, so if we want to
draw any of the other controls on top of a layer 3 control, we can put it
inside a frame. Within a layer, we can arrange our controls' z-order using
the Format Order menu items.

But the three layers mentioned in the issue description do not sound to be
the ones above. I am also not clear about the term "state of image". Is it
possible for you to send a sample to my mailbox
, remove '.removeme'), and I will research to
see how to fix the issue after I get the sample.

Thanks,
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Adrian Turner

Cancel Click on label control
 
I will try to explain....

I want a hover effect menu system within an excel worksheet.
I inserted the 'off' state of the image as a picture, then added a label and
placed over the top of this image(the label is wider and taller), then the
'on' state of the image as another picture. Total 3 layers. A small piece of
code now monitors position of mouse and gives the effect of a hover over.
This works fine. If they click wither image everything is still ok. If they
click within the label which borders the images they disappear and the label
comes to the front. moving off the label puts it all back again, but I do not
want this effect. I need to stop the label click event (or come up with
another way to do a hover over. I looked and could not find anything). I Hope
this is a bit clearer. I can send the file if you can provide me with an
email address that will accept it. Thanks, Adrian

"Jialiang Ge [MSFT]" wrote:

Hello Adrian,

I am sorry that I do not have a clear picture of the issue base on the
description. Do you mean the Label control in UserForm of Excel worksheet
by "Label"? What is the "Layer"? As far as I know, userforms have three
drawing layers. When we add a control to a userform, it gets added to one
of the top two layers, depending on the type of control. The three layers
are identified as follows:

1. The userform background and its scrollbar
2. The Label, CheckBox, ComboBox, CommandButton, Image, OptionButton,
RefEdit, ScrollBar, SpinButton, TabStrip, ToggleButton and TextBox controls
3. The Frame, ListBox, MultiPage and other ActiveX controls

Controls in layer 2 can overlap each other, but will always be drawn behind
controls in layer 3, whereas all the controls in layer 3 can overlap each
other. Fortunately, layer 3 includes the Frame control, so if we want to
draw any of the other controls on top of a layer 3 control, we can put it
inside a frame. Within a layer, we can arrange our controls' z-order using
the Format Order menu items.

But the three layers mentioned in the issue description do not sound to be
the ones above. I am also not clear about the term "state of image". Is it
possible for you to send a sample to my mailbox
, remove '.removeme'), and I will research to
see how to fix the issue after I get the sample.

Thanks,
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



Jialiang Ge [MSFT]

Cancel Click on label control
 
Hello Adrian,

My mailbox is '. It is appreciated that you are going
to send the sample to me.

Thanks
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Jialiang Ge [MSFT]

Cancel Click on label control
 
Hello Adrian,

Thank you for the sample xls. I have reproduced the issue that the Label
turns Opaque when it's clicked. Based on my discussion with the Excel
product team, this is a by-design behavior that Transparent controls do not
remain transparent after gaining focus. This is a result of our
semi-windowless control implementation. It uses Label.BackColor to draw the
background after the label is clicked. We are striving to find out some
workarounds, and I hope I can get back to you with a good news as soon as
possible.

Considering this issue is caused by design, it is my pleasure to help send
a wish to our product designers via internal channel. You are also welcome
to add your supplements to make Microsoft products easier and more powerful
to use by submitting a ticket in
https://connect.microsoft.com/VisualStudio
As we strive to capture any and all product feedback so as to ensure that
we are continuously developing Microsoft products to meet customer needs,
feedback such as yours is always taken very seriously.

In addition, here is a small suggestion for your current implementation of
the hover effect.

In the current implementation, the images' zorder will be updated every
time when users move their mouse over the controls. So the mouse icon turns
'busy', which means the CPU is busy with the updating. I'd suggest that we
add a variable to indicate the current status, and update the image zorder
only when necessary. Below is the vba code for your reference:

Private showingImage2 As Boolean

Private Sub Image2_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If showingImage2 Then
Image1.Visible = True
ActiveSheet.Shapes("Image1").ZOrder (msoBringToFront)
Image2.Visible = False
showingImage2 = False
End If
End Sub

Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Not showingImage2 Then
Image2.Visible = True
ActiveSheet.Shapes("Image2").ZOrder (msoBringToFront)
Image1.Visible = False
showingImage2 = True
End If
End Sub

Hope it helps

Regards,
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Jialiang Ge [MSFT]

Cancel Click on label control
 
Hello Adrian,

Thank you for your patience. We find several workarounds for you:

Wordaround 1.

Add the following code into Sheet1

Private Sub Label1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
Label1.Visible = False
Label1.Visible = True
End Sub

Click event on any control (not necessarily transparent), puts the control
in focus and covers the controls on top of it. The behavior of the label is
by design.
This workaround makes the label flicker a little bit but the image control
is retained on top.

Workaround 2.

We can consider making the click event of the label run the same code as
the click event of the image.

Please have a try and let me know if it works for your situation. Feel free
to let me know if you have any other questions or concerns. We will spare
no effort to help you.

Regards,
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



All times are GMT +1. The time now is 10:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com