Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Label control - suppress GetFocus

G'day all,
I have some embedded command buttons in a worksheet. I want to emulate
'tool tip' functionality. I've been able to do this using the MouseMove
event so that text is diplayed in a label control when the mouse is
moved over one of the buttons. To suppress the tool tip when the mouse
moves off a button, I've position a single label control behind the
buttons and use the MouseMove event for that control to hide the tool
tip label.

This all works beautifully BUT if I click on the background label it
takes the focus and hides the buttons even though the Enabled property
is set to false and backstyle is set to transparent.

Does anybody know how I can stop it taking the focus? I'm doing this at
home at the moment on Excel97 but it will be used at work in Excel2K.

Any replies will be greatly appreciated.

cheers
peterDavey
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Label control - suppress GetFocus

Peter,
How do you give the focus to a label ?
Do you mean text box ?

NickHk

"Peter Davey" wrote in message
u...
G'day all,
I have some embedded command buttons in a worksheet. I want to emulate
'tool tip' functionality. I've been able to do this using the MouseMove
event so that text is diplayed in a label control when the mouse is
moved over one of the buttons. To suppress the tool tip when the mouse
moves off a button, I've position a single label control behind the
buttons and use the MouseMove event for that control to hide the tool
tip label.

This all works beautifully BUT if I click on the background label it
takes the focus and hides the buttons even though the Enabled property
is set to false and backstyle is set to transparent.

Does anybody know how I can stop it taking the focus? I'm doing this at
home at the moment on Excel97 but it will be used at work in Excel2K.

Any replies will be greatly appreciated.

cheers
peterDavey



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Label control - suppress GetFocus

that's a nice solution & works well.

I added this to the sheet code
Private Sub Label2_Click()
Label2.SendToBack
End Sub

now, as soon as you move off the label behind the button, the button
re-appears

"Peter Davey" wrote:

G'day all,
I have some embedded command buttons in a worksheet. I want to emulate
'tool tip' functionality. I've been able to do this using the MouseMove
event so that text is diplayed in a label control when the mouse is
moved over one of the buttons. To suppress the tool tip when the mouse
moves off a button, I've position a single label control behind the
buttons and use the MouseMove event for that control to hide the tool
tip label.

This all works beautifully BUT if I click on the background label it
takes the focus and hides the buttons even though the Enabled property
is set to false and backstyle is set to transparent.

Does anybody know how I can stop it taking the focus? I'm doing this at
home at the moment on Excel97 but it will be used at work in Excel2K.

Any replies will be greatly appreciated.

cheers
peterDavey

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Label control - suppress GetFocus

NickHK wrote:

Peter,
How do you give the focus to a label ?
Do you mean text box ?

NickHk

"Peter Davey" wrote in message
u...

G'day all,
I have some embedded command buttons in a worksheet. I want to emulate
'tool tip' functionality. I've been able to do this using the MouseMove
event so that text is diplayed in a label control when the mouse is
moved over one of the buttons. To suppress the tool tip when the mouse
moves off a button, I've position a single label control behind the
buttons and use the MouseMove event for that control to hide the tool
tip label.

This all works beautifully BUT if I click on the background label it
takes the focus and hides the buttons even though the Enabled property
is set to false and backstyle is set to transparent.

Does anybody know how I can stop it taking the focus? I'm doing this at
home at the moment on Excel97 but it will be used at work in Excel2K.

Any replies will be greatly appreciated.

cheers
peterDavey




Nick,
It's an embedded VBA label control that has MouseMove GetFocus and
LostFocus events. When I create it the default name is Label1
cheers
peterD

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Label control - suppress GetFocus

Peter,
I missed the "worksheet" bit.

NickHK

"Peter Davey" wrote in message
...
NickHK wrote:

Peter,
How do you give the focus to a label ?
Do you mean text box ?

NickHk

"Peter Davey" wrote in message
u...

G'day all,
I have some embedded command buttons in a worksheet. I want to emulate
'tool tip' functionality. I've been able to do this using the MouseMove
event so that text is diplayed in a label control when the mouse is
moved over one of the buttons. To suppress the tool tip when the mouse
moves off a button, I've position a single label control behind the
buttons and use the MouseMove event for that control to hide the tool
tip label.

This all works beautifully BUT if I click on the background label it
takes the focus and hides the buttons even though the Enabled property
is set to false and backstyle is set to transparent.

Does anybody know how I can stop it taking the focus? I'm doing this at
home at the moment on Excel97 but it will be used at work in Excel2K.

Any replies will be greatly appreciated.

cheers
peterDavey




Nick,
It's an embedded VBA label control that has MouseMove GetFocus and
LostFocus events. When I create it the default name is Label1
cheers
peterD





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Label control - suppress GetFocus

Patrick Molloy wrote:

that's a nice solution & works well.

I added this to the sheet code
Private Sub Label2_Click()
Label2.SendToBack
End Sub

now, as soon as you move off the label behind the button, the button
re-appears

"Peter Davey" wrote:


G'day all,
I have some embedded command buttons in a worksheet. I want to emulate
'tool tip' functionality. I've been able to do this using the MouseMove
event so that text is diplayed in a label control when the mouse is
moved over one of the buttons. To suppress the tool tip when the mouse
moves off a button, I've position a single label control behind the
buttons and use the MouseMove event for that control to hide the tool
tip label.

This all works beautifully BUT if I click on the background label it
takes the focus and hides the buttons even though the Enabled property
is set to false and backstyle is set to transparent.

Does anybody know how I can stop it taking the focus? I'm doing this at
home at the moment on Excel97 but it will be used at work in Excel2K.

Any replies will be greatly appreciated.

cheers
peterDavey

Thanks Patrick but I was hoping to find a solution to supress the
background label entirely as it might confuse the hell out of the users
when the buttons disappear. You may be interested in the full code below.

I've tried another solution that does away with the need for a
background label - it checks to see if the mouse is positioned in a
pre-defined margin (say 5 pixels in from the edge all round) within the
button in which case the tooltip is hidden otherwise displayed. The
problem I found was that it was unreliable if I moved the mouse too quickly.

cheers
peterD

Dim strCurrentControl As String

Private Sub cmdCopyToClipboard_MouseMove(ByVal Button As Integer, ByVal
Shift As Integer, ByVal X As Single, ByVal Y As Single)

If strCurrentControl < "cmdCopyToClipboard" Then
strCurrentControl = "cmdCopyToClipboard"
With lblToolTip
.Caption = "Copy to clipboard"
.Visible = True
End With
End If

End Sub

Private Sub lblBackground_Click()
lblBackground.Visible = False
End Sub

Private Sub lblBackground_MouseMove(ByVal Button As Integer, ByVal Shift
As Integer, ByVal X As Single, ByVal Y As Single)

If strCurrentControl < "lblBackground" Then
strCurrentControl = "lblBackground"
With lblToolTip
.Caption = ""
.Visible = False
End With
End If

End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the font for part of an axis label, not the whole label. amy45 Charts and Charting in Excel 2 April 5th 23 01:11 PM
2 Label Options - Forms Object vs Control Box Object Awrex Excel Discussion (Misc queries) 3 July 17th 09 07:10 PM
Is it possible to Link a Label control to a cell ? Ben Excel Worksheet Functions 0 July 9th 07 10:32 PM
How to rezize data label box in pie charts (label wraps to two lin rolliedogg Charts and Charting in Excel 1 October 18th 06 08:17 PM
OLEObject GetFocus Erich Neuwirth Excel Programming 1 August 11th 04 08:18 PM


All times are GMT +1. The time now is 12:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"