Esempio n. 1
0
        private unsafe void GetToolTip(Message *ptrMessage, int messageNumber)
        {
            //must be first message
            if (messageNumber != 1)
            {
                throw new Exception("GetToolTip must be first message");
            }

            // p1  = handle
            IntPtr handle = GetParameterIntPtr(ptrMessage, 0);

            CleanUpMessage(ptrMessage);

            NM.EnumWindowsProc windowsToGetToolTipsCallback = new NM.EnumWindowsProc(EnumWindowsToGetToolTips);

            m_ToolTipWindows = new List <IntPtr>();
            NM.EnumWindows(windowsToGetToolTipsCallback, IntPtr.Zero);

            IntPtr    toolTipHandle    = IntPtr.Zero;
            string    toolTipTitle     = null;
            Rectangle toolTipRectangle = new Rectangle(0, 0, 0, 0);

            foreach (IntPtr hWnd in m_ToolTipWindows)
            {
                NM.ToolInfo info = NM.GetToolInfo(hWnd, TimeOut);

                if (info.hWnd == handle)
                {
                    //we have the tooltip so return infomation about it
                    toolTipHandle = hWnd;
                    toolTipTitle  = GetWindowTextViaWindowMessage(toolTipHandle);

                    NM.tagRect windowPosition;
                    NM.tagRect windowSize;
                    NM.GetWindowRect(toolTipHandle, out windowPosition);
                    windowSize = NM.GetClipBox(toolTipHandle);

                    toolTipRectangle = new Rectangle(windowPosition.left, windowPosition.top, windowSize.right, windowSize.bottom);
                    break;
                }
            }

            AddReturnValue(new Parameter(this, toolTipHandle));
            AddReturnValue(new Parameter(this, toolTipTitle));
            AddReturnValue(new Parameter(this, toolTipRectangle.X));
            AddReturnValue(new Parameter(this, toolTipRectangle.Y));
            AddReturnValue(new Parameter(this, toolTipRectangle.Width));
            AddReturnValue(new Parameter(this, toolTipRectangle.Height));
        }