Exemple #1
0
        public int GetInfoTip(QITIPF dwFlags, out string ppwszTip)
        {
            string sValues = string.Empty;

            foreach (Column column in _folderObj.Columns)
            {
                sValues += string.Format("{0}: {1}\r\n", column.Name, _folderObj.GetColumnValue(column));
            }
            sValues  = sValues.TrimEnd('\n');
            sValues  = sValues.TrimEnd('\r');
            ppwszTip = sValues;
            return(WinError.S_OK);
        }
Exemple #2
0
        /// <summary>
        /// Gets the info tip text for an item.
        /// </summary>
        /// <param name="dwFlags">Flags that direct the handling of the item from which you're retrieving the info tip text. This value is commonly zero.</param>
        /// <param name="ppwszTip">The address of a Unicode string pointer that, when this method returns successfully, receives the tip string pointer. Applications that implement this method must allocate memory for ppwszTip by calling CoTaskMemAlloc.
        /// Calling applications must call CoTaskMemFree to free the memory when it is no longer needed.</param>
        /// <returns>
        /// Returns S_OK if the function succeeds. If no info tip text is available, ppwszTip is set to NULL. Otherwise, returns a COM-defined error value.
        /// </returns>
        int IQueryInfo.GetInfoTip(QITIPF dwFlags, out string ppwszTip)
        {
            //  Do we need to get the tip on a single line?
            var singleLine = dwFlags.HasFlag(QITIPF.QITIPF_SINGLELINE);

            //  Now work out what type of info to get.
            RequestedInfoType infoType;

            if (dwFlags.HasFlag(QITIPF.QITIPF_USENAME))
            {
                infoType = RequestedInfoType.Name;
            }
            else if (dwFlags.HasFlag(QITIPF.QITIPF_LINKUSETARGET))
            {
                infoType = RequestedInfoType.InfoOfShortcutTarget;
            }
            else if (dwFlags.HasFlag(QITIPF.QITIPF_LINKNOTARGET))
            {
                infoType = RequestedInfoType.InfoOfShortcut;
            }
            else
            {
                infoType = RequestedInfoType.InfoTip;
            }

            try
            {
                //  Get the requested info.
                var infoTip = GetInfo(infoType, singleLine);

                //  Set the tip. The runtime marshals out strings with CoTaskMemAlloc for us.
                ppwszTip = infoTip;
            }
            catch (Exception exception)
            {
                //  DebugLog the exception.
                LogError("An exception occured getting the info tip.", exception);

                //  If an exception is thrown, we cannot return any info.
                ppwszTip = string.Empty;
            }

            //  Return success.
            return(WinError.S_OK);
        }
        /// <summary>
        /// Gets the info tip text for an item.
        /// </summary>
        /// <param name="dwFlags">Flags that direct the handling of the item from which you're retrieving the info tip text. This value is commonly zero.</param>
        /// <param name="ppwszTip">The address of a Unicode string pointer that, when this method returns successfully, receives the tip string pointer. Applications that implement this method must allocate memory for ppwszTip by calling CoTaskMemAlloc.
        /// Calling applications must call CoTaskMemFree to free the memory when it is no longer needed.</param>
        /// <returns>
        /// Returns S_OK if the function succeeds. If no info tip text is available, ppwszTip is set to NULL. Otherwise, returns a COM-defined error value.
        /// </returns>
        int IQueryInfo.GetInfoTip(QITIPF dwFlags, out string ppwszTip)
        {
            //  Do we need to get the tip on a single line?
            var singleLine = dwFlags.HasFlag(QITIPF.QITIPF_SINGLELINE);

            //  Now work out what type of info to get.
            RequestedInfoType infoType;
            if(dwFlags.HasFlag(QITIPF.QITIPF_USENAME))
                infoType = RequestedInfoType.Name;
            else if(dwFlags.HasFlag(QITIPF.QITIPF_LINKUSETARGET))
                infoType = RequestedInfoType.InfoOfShortcutTarget;
            else if(dwFlags.HasFlag(QITIPF.QITIPF_LINKNOTARGET))
                infoType = RequestedInfoType.InfoOfShortcut;
            else
                infoType = RequestedInfoType.InfoTip;
            
            try
            {
                //  Get the requested info.
                var infoTip = GetInfo(infoType, singleLine);

                //  Set the tip. The runtime marshals out strings with CoTaskMemAlloc for us.
                ppwszTip = infoTip;
            }
            catch (Exception exception)
            {
                //  Log the exception.
                LogError("An exception occured getting the info tip.", exception);

                //  If an exception is thrown, we cannot return any info.
                ppwszTip = string.Empty;
            }

            //  Return success.
            return WinError.S_OK;
        }