Esempio n. 1
0
        public static Rectangle GetIconRect(NotifyIcon icon)
        {
            _RECT rect = new _RECT();
            NOTIFYICONIDENTIFIER notifyIcon = new NOTIFYICONIDENTIFIER();

            notifyIcon.cbSize = Marshal.SizeOf(notifyIcon);
            //use hWnd and id of NotifyIcon instead of guid is needed
            notifyIcon.hWnd = GetHandle(icon);
            notifyIcon.uID  = GetId(icon);

            int hresult = Core.Shell_NotifyIconGetRect(ref notifyIcon, out rect);

            //rect now has the position and size of icon

            return(new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取非客户区窗体信息
        /// </summary>
        /// <param name="hwnd"></param>
        /// <returns></returns>
        private NonClientSizeInfo GetNonClientInfo(IntPtr hwnd)
        {
            NonClientSizeInfo info = new NonClientSizeInfo();

            info.BorderSize    = BorderSize;
            info.CaptionHeight = CaptionHeight;

            _RECT areatRect = new _RECT();

            GetWindowRect(hwnd, ref areatRect);

            int width  = areatRect.right - areatRect.left;
            int height = areatRect.bottom - areatRect.top;

            info.Width  = width;
            info.Height = height;

            Point xy = new Point(areatRect.left, areatRect.top);

            xy.Offset(-areatRect.left, -areatRect.top);

            info.CaptionRect = new Rectangle(xy.X, xy.Y
                                             , width, info.CaptionHeight);
            info.Rect       = new Rectangle(xy.X, xy.Y, width, height);
            info.ClientRect = new Rectangle(xy.X + info.BorderSize.Width,
                                            xy.Y + info.CaptionHeight + info.BorderSize.Height,
                                            width - info.BorderSize.Width * 2,
                                            height - info.CaptionHeight - info.BorderSize.Height * 2);

            info.CloseBtnRect = new Rectangle(new Point(xy.X + width - 2 * BtnHeight, info.BorderSize.Height),
                                              new Size(BtnHeight, BtnHeight));
            info.MinimumBtnRect    = new Rectangle(info.CloseBtnRect.X - BtnHeight, info.CloseBtnRect.Y, BtnHeight, BtnHeight);
            info.UserNameImageRect = new Rectangle(info.MinimumBtnRect.X - 2 * BtnHeight, info.CloseBtnRect.Y, BtnHeight, BtnHeight);

            return(info);
        }
Esempio n. 3
0
 private static extern bool GetWindowRect(IntPtr hWnd, ref _RECT rect);
 static extern bool GetWindowRect(int hWnd, out _RECT lpRect);
Esempio n. 5
0
 public static extern bool GetWindowRect( IntPtr hWnd, out _RECT lpRect );
 static extern bool GetClientRect(int hWnd, out _RECT lpRect);
Esempio n. 7
0
    public void Read(TProtocol iprot)
    {
        iprot.IncrementRecursionDepth();
        try
        {
            TField field;
            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.Struct)
                    {
                        RcFace = new _RECT();
                        RcFace.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.Struct)
                    {
                        PtLeftEye = new _POINT();
                        PtLeftEye.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 3:
                    if (field.Type == TType.Struct)
                    {
                        PtRightEye = new _POINT();
                        PtRightEye.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 4:
                    if (field.Type == TType.Struct)
                    {
                        PtMouth = new _POINT();
                        PtMouth.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 5:
                    if (field.Type == TType.Struct)
                    {
                        PtNose = new _POINT();
                        PtNose.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 6:
                    if (field.Type == TType.I32)
                    {
                        NYaw = iprot.ReadI32();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 7:
                    if (field.Type == TType.I32)
                    {
                        NPitch = iprot.ReadI32();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 8:
                    if (field.Type == TType.I32)
                    {
                        NRoll = iprot.ReadI32();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 9:
                    if (field.Type == TType.I32)
                    {
                        NQuality = iprot.ReadI32();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 10:
                    if (field.Type == TType.I32)
                    {
                        NGender = iprot.ReadI32();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 11:
                    if (field.Type == TType.I32)
                    {
                        NAge = iprot.ReadI32();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 12:
                    if (field.Type == TType.I64)
                    {
                        DTm = iprot.ReadI64();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 13:
                    if (field.Type == TType.String)
                    {
                        TcSdkVer = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 14:
                    if (field.Type == TType.String)
                    {
                        Fea = iprot.ReadBinary();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 15:
                    if (field.Type == TType.String)
                    {
                        Img = iprot.ReadBinary();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 16:
                    if (field.Type == TType.String)
                    {
                        ChannelID = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
        finally
        {
            iprot.DecrementRecursionDepth();
        }
    }
 public static extern bool GetWindowRect(IntPtr hWnd, out _RECT lpRect);
Esempio n. 9
0
 static extern bool GetWindowRect(int hWnd, out _RECT lpRect);
Esempio n. 10
0
 static extern bool GetClientRect(int hWnd, out _RECT lpRect);