Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
|
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 1st, 2005, 06:48 PM
Registered User
 
Join Date: Jun 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default ToolTip for Controls having Enable=False property

I have a form with several Button controls, and a ToolTip for each control. When a control has the Enable=True property, its ToolTip displays correctly. However, when a control has the Enable=False property, its ToolTip does not display.

How can I get the ToolTip to display when its control has the Enable=False property?

Jim.
 
Old May 2nd, 2005, 10:21 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You can't.

An alternative that you might want to explore is to leave the button enabled, but in its Click event have a line of code that wards off execution under the circumstance you now disable the button.

For instance, if you now have:
Code:
    If gDisableIt = True Then
        Me.btnPrint.Enabled = False
    End If
    at the top of the Click event add:
Code:
    If gDisableIt = True Then
Code:
        Exit Sub
    End If
    When a control is disabled, it is effectively removed from Windows’ loop through which controls, etc., get serviced.
 
Old May 2nd, 2005, 12:24 PM
Registered User
 
Join Date: Jun 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian:

Thanks for your reply.

Years ago I did something in VB6 that allowed a ToolTip to show when the control is disabled, but I have no record of exactly how I managed it. It was something like defining a transparent Label of the same size and position of the control, and including the ToolTip in the label. I tried this in VB.NET but was unable to get the Label to be transparent and show the underlying Text of the control.

Any ideas?

Jim.
 
Old May 2nd, 2005, 04:40 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

It is bothersome, but something that I have done on web pages to get similar responses is to call a procedure from the from's mousemove event.

In that procedure, define the area of the form that you want to respond, and test whether the mouse is in that area. If so, show a control resembling a tooltip, such as a label with a yellow background, positioned as a tooltip would be.

If the mouse is not in that area, negate that objects visibility.

This is what Windows does anyway, it's just that you take over the control yourself.

Really makes you appreciate the workload that Windows relieves us of . . .
 
Old May 2nd, 2005, 10:42 PM
Registered User
 
Join Date: Jun 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian:

Thanks for your latest reply.

Your suggestion works like a charm. However, because the Label (resembling a ToolTip) is a control within the Form, I cannot position it as a ToolTip would be, which is often outside a Form's boundary.

Jim.
 
Old May 3rd, 2005, 02:10 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You could if you wanted to go to the trouble to get the desktop's drawing context, and use drawing APIs to do this.
But that is a [u]lot</u> of work...

It still remains true: Ain’t nothin’ like the real thing, baby . . .





Similar Threads
Thread Thread Starter Forum Replies Last Post
custom Property Enable & Disable in user control tiks C# 1 August 20th, 2008 09:31 AM
Enable Property kekec3778 Beginning VB 6 2 January 8th, 2008 06:32 AM
Persist Property Values In Controls. jahanzaib.attari ASP.NET 2.0 Basics 1 September 21st, 2007 09:19 AM
Non-displacement of controls when visible="false" rsearing ASP.NET 2.0 Professional 2 January 26th, 2007 06:27 PM
Button enable property - Late binding aruchamy .NET Framework 2.0 2 June 18th, 2006 09:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.