Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Drawing / March 2008

Tip: Looking for answers? Try searching our database.

How to tooltip and hyperlink a shape?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gnewsgroup - 14 Mar 2008 15:22 GMT
Quite many charting tools (such as dundas) create charts whose
components can display a tooltip when the cursor them.  And the
components can also be hyperlinked.

If I am not make it clear, the following picture shows what I am
talking about.

http://farm3.static.flickr.com/2326/2333252986_1a6ba6d548_o.png

Now, how do we achieve such effects through .net graphics
programming?  I searched around, but could not find anything helpful.

Thank you.
Mad-Hollander - 14 Mar 2008 17:37 GMT
Look at this code
All objects in my application are derived from PictureBase class.

interface IPicture
{
    IShape Bounds {get;set;} // for clipping and mouse operations
    Point Location {get;set;}

    void Draw(Graphics gr);
    void DrawDragged(Graphics gr);

    IStyle Style{get; set;}
    IState State{get; set;}

    string Tip {get;set;}
    CursorObject Cursor {get;set;}

    void Think();
}

class PictureBase  : IPicture // base class for all objects and
primitives
{
    // to do
}

class View
{
// to do
    void TrackMouseMove()
    {
        PictureBase   htObj = CheckHitTest(m_lastMouseMovePos);
                               if(htObj == null)
        {
            SetMousePointer(CurrentMode.Cursor);
            return;
        }
        if (m_lastHoveredObj != htObj) // another object under the mouse
        {
            m_tooltip.Active = false;
            m_tooltip.SetToolTip(m_canvas, (htObj != null) ? htObj.Tip : null);
                       m_tooltip.Active = (htObj != null);
              SetMousePointer(htObject.Cursor);
            m_lastHoveredObj = htObj;
        }
    }
}

> Quite many charting tools (such as dundas) create charts whose
> components can display a tooltip when the cursor them.  And the
[quoted text clipped - 9 lines]
>
> Thank you.
gnewsgroup - 14 Mar 2008 19:21 GMT
> Look at this code
> All objects in my application are derived from PictureBase class.
[quoted text clipped - 59 lines]
>
> > Thank you.

Hi,

Thank you very much.  But, I have little graphics programming
experience.  So would you mind explaining what each class and major
method does?
Mad-Hollander - 17 Mar 2008 16:14 GMT
> Thank you very much.  But, I have little graphics programming
> experience.  So would you mind explaining what each class and major

There is pseudocode of simplier version

abstract class PictureBase // base class for all objects
{
      public Rectangle Bounds {get;set;}    // contains the topleft
corner (position) of object and its width and height
      // when your object has not a rectangle shape, you should
implement you own class for boundaries

      public abstract void Draw(Graphics gr); // draws the content
and setup property Bounds
      // example - if method draws a rectangle  with size (10,10) at
point of topleft corner (100,100), you should use these values for
Bounds property.

      public string Tip {get;set;}  // the string for showing when
mouse is moving over the objec
      public System.Windows.Forms.Cursor Cursor {get;set;}  // the
cursor for using when mouse is moving over the object
}

class View  // this is usercontrol or panel which contains a canvas
control or it is the class of canvas :-)
{
// to do

       // this method shoul be called on each move move event
       void TrackMouseMove()
       {
               // CheckHitTest - the method which uses
PictureBase.Bounds property and determines the object under the mouse
pointer.
               //Usually it iterates through all objects and return
an object which Bounds contains  mouse position.
               PictureBase   htObj =
CheckHitTest(m_lastMouseMovePos);
                               if(htObj == null)
               {
                       m_canvas.Cursor = m_defaultCursor; // set
default cursor
                       return;
               }
               if (m_lastHoveredObj != htObj) // another object under
the mouse
               {
                       m_tooltip.Active = false;
                       m_tooltip.SetToolTip(m_canvas, (htObj !=
null) ? htObj.Tip : null);
                               m_tooltip.Active = (htObj != null);
                       m_canvas.Cursor = htObject.Cursor;
                       m_lastHoveredObj = htObj;
               }
       }
Jeff Johnson - 17 Mar 2008 15:00 GMT
> Quite many charting tools (such as dundas) create charts whose
> components can display a tooltip when the cursor them.  And the
[quoted text clipped - 7 lines]
> Now, how do we achieve such effects through .net graphics
> programming?  I searched around, but could not find anything helpful.

Tooltips are actually windows. As such, they have built-in functionality for
processing mouse messages, etc. I think you'd be better served trying to
implement your tips as a window rather than drawing directly on your control
and having to worry about mouse coordinates and stuff.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.