Page 1 of 2 1 2 LastLast
Showing results 1 to 10 of 11

Thread: Tooltips

  1. #1

    Default Tooltips

    Hello,

    Is it possible to have variable content displayed in a tooltip for a button/Combi element ? In our case we have a string variable which we would like to display in the tooltip of an element.

    Best regards,

    Stephan de Wit

  2. #2

    Default Re: Tooltips

    Unfortunately, this is currently not possible.

    However a requirement to implement this in a future version already exists.

  3. #3

    Default Re: Tooltips

    Will this feature be implemented in before-seven version of zenon?

    Or maybe somebody knows any walk-around way to use such dynamic-tooltip in 6.51-version of zenon?

  4. #4

    Default Re: Tooltips

    Hi,

    To avoid disappointment, I just want to clarify that "to be implemented in a future version", does not necessarily mean that this feature will be included in the next zenon version 7.

    The fact that a requirement exists means that we think this is a good idea and we intend do implement this in a future version, which not necessarily must be the next zenon version that is released.

  5. #5
    Join Date
    25.05.2010
    Location
    Dallas, TX
    Posts
    7

    Default Re: Tooltips

    We had the same need, and I found a workaround. See the attached project.

    How do the native tooltips work?
    In the zenon runtime, there always exists one (and only one) subclassed window (see attachment, spy.png) which is used to show tooltips over elements that have a tooltip assigned in the editor. Trust me, you do not want to try to force this tooltip to show your custom tooltips.

    How do the tooltips in the attached project work?
    In the VSTA ProjectAddin namespace, I have added a form (frmTooltip), with the "Opacity" property set to 1% (practically invisible.) One instance of the form is constructed at the "ProjectActive" event. At the "ElementMouseOver" event (provided by the DynPictures object at runtime), the form is moved to the location of the element, sized the same as the element and brought to the front. Finally the tooltip is set, if the value in the string variable has a length greater than zero. On the "MouseLeave" event of the form, the tooltip is set to an empty string and the form is hidden.

    I banged my head against the wall for a long time trying to use the existing hidden window in zenon. Finally, I realized the .NET solution was much simpler.

    Here's hoping someone finds this useful!
    Attached Thumbnails Attached Thumbnails tooltip.png  
    Attached Files Attached Files

  6. #6
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    882

    Default AW: Tooltips

    nice

  7. #7
    Join Date
    25.05.2010
    Location
    Dallas, TX
    Posts
    7

    Default Re: Tooltips

    Image (spy.png) is now attached.

    Quote Originally Posted by tsragland View Post
    We had the same need, and I found a workaround. See the attached project.

    How do the native tooltips work?
    In the zenon runtime, there always exists one (and only one) subclassed window (see attachment, spy.png) which is used to show tooltips over elements that have a tooltip assigned in the editor. Trust me, you do not want to try to force this tooltip to show your custom tooltips.

    How do the tooltips in the attached project work?
    In the VSTA ProjectAddin namespace, I have added a form (frmTooltip), with the "Opacity" property set to 1% (practically invisible.) One instance of the form is constructed at the "ProjectActive" event. At the "ElementMouseOver" event (provided by the DynPictures object at runtime), the form is moved to the location of the element, sized the same as the element and brought to the front. Finally the tooltip is set, if the value in the string variable has a length greater than zero. On the "MouseLeave" event of the form, the tooltip is set to an empty string and the form is hidden.

    I banged my head against the wall for a long time trying to use the existing hidden window in zenon. Finally, I realized the .NET solution was much simpler.

    Here's hoping someone finds this useful!
    Attached Thumbnails Attached Thumbnails spy.PNG  

  8. #8

    Daumen hoch Re: Tooltips

    Thanks tsragland!

    that is awesome

    And this way, the "tooltip" even supports more than 80 characters

    note, that you do need a later build of zenon 6.51, or zenon 7, that includes screen events in VSTA, in case you want to try out the sample project

    Cheers,
    Mark

  9. #9
    Join Date
    25.05.2010
    Location
    Dallas, TX
    Posts
    7

    Default Re: Tooltips

    I noticed the tooltip form was being activated and stealing focus from other windows, so I made a small change to the implementation:

    We need to show the tooltip form without activating it, so we can use the API method, 'ShowWindow' with the SW_SHOWNA parameter, which will show the form and bring it to the front without stealing focus from other windows.

    Add the following 'using' statement (this supports the DLLImport required to reference the Windows API function):

    using System.Runtime.InteropServices;

    Add the following method declaration (anywhere inside the 'frmTooltip' class):

    private const int SW_SHOWNA = 8;
            [DllImport("user32", CharSet = CharSet.Auto)]
            private extern static int ShowWindow(IntPtr hWnd, int nCmdShow);


    Replace the 'Set' method with the following code, which calls the API method, 'ShowWindow'

    public void Set(IElement obElement, string toolTipText)
            {
                bool allowTooltip = true;
    
                try
                {
                    IVariable v = obElement.ItemVariable(0);
                    if (v != null)
                    {
                        if (v.Name == "toolTipVariable")
                            allowTooltip = false;   //Don't show tooltip over an element linked to the string variable which contains the tooltip text!
                        v = null;
                    }
                }
                catch { }
    
                if (allowTooltip)
                {
                    try
                    {
                        if (toolTipText.Length > 0)
                        {
                            ShowWindow(this.Handle, SW_SHOWNA);
                            this.Left = obElement.Left;
                            this.Top = obElement.Top;
                            this.Width = obElement.Right - obElement.Left;
                            this.Height = obElement.Bottom - obElement.Top;
                            this.toolTip1.SetToolTip(this, toolTipText);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Print(ex.Message + ex.StackTrace);
                    }
                }
            }

    Now, the tooltip works without stealing focus from other zenon windows...

  10. #10
    Join Date
    29.11.2013
    Posts
    4

    Unglücklich Re: Tooltips

    Quote Originally Posted by markclemens View Post
    Hi,

    To avoid disappointment, I just want to clarify that "to be implemented in a future version", does not necessarily mean that this feature will be included in the next zenon version 7.

    The fact that a requirement exists means that we think this is a good idea and we intend do implement this in a future version, which not necessarily must be the next zenon version that is released.
    Hello!
    This functionality will be in this year? I want simply to add tooltips without programming. Maybe already it is time to add this functionality in Zenon? Passed three years...

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •