Ejemplo n.º 1
0
        /// <summary>
        /// マウスカーソルの座標を返します。
        /// </summary>
        /// <param name="x">[out]マウスカーソルのX座標</param>
        /// <param name="y">[out]マウスカーソルのY座標</param>
        /// <returns>GetCursorPosの戻り値</returns>
        public static bool GetCursorPosition(out int x, out int y)
        {
            POINTFX point = new POINTFX();
            bool    blRtn = GetCursorPos(out point);

            x = point.x.fract;
            y = point.y.fract;
            return(blRtn);
        }
Ejemplo n.º 2
0
        public static ushort GetOutline(UnmanagedPointer ipHeader, int size, out float2[] pnts, out sbyte[] onCurve)
        {
            ushort cTotal = 0;
            UnmanagedPointer endPtr = ipHeader + size;
            UnmanagedPointer ipCurve;

            int MaxPts = size / Marshal.SizeOf(typeof(POINTFX));

            TTPOLYGONHEADER Header;
            TTPOLYCURVE Curve;
            POINTFX pntfx = new POINTFX();

            pnts = new float2[MaxPts];
            onCurve = new sbyte[MaxPts];

            while (ipHeader < endPtr && pnts != null)
            {
                Header = (TTPOLYGONHEADER)Marshal.PtrToStructure(ipHeader, typeof(TTPOLYGONHEADER));

                if (Header.dwType == GDI32.TT_POLYGON_TYPE)
                {
                    pnts[cTotal].x = Header.pfxStart.x.ToSingle();
                    pnts[cTotal].y = Header.pfxStart.y.ToSingle();
                    onCurve[cTotal++] = -1; // new contour

                    ipCurve = ipHeader + Marshal.SizeOf(typeof(TTPOLYGONHEADER));

                    while (ipCurve < ipHeader + Header.cb)
                    {
                        Curve = (TTPOLYCURVE)Marshal.PtrToStructure(ipCurve, typeof(TTPOLYCURVE));
                        ipCurve = ipCurve + Marshal.SizeOf(typeof(TTPOLYCURVE));

                        for (int i = 0; i < Curve.cpfx; i++)
                        {
                            pntfx = (POINTFX)Marshal.PtrToStructure(ipCurve, typeof(POINTFX));

                            pnts[cTotal].x = pntfx.x.ToSingle();
                            pnts[cTotal].y = pntfx.y.ToSingle();

                            onCurve[cTotal++] = (sbyte)((i == Curve.cpfx - 1) ? 1 : (Curve.wType == GDI32.TT_PRIM_LINE) ? 1 : 0);

                            ipCurve = ipCurve + Marshal.SizeOf(typeof(POINTFX));
                        }
                    }
                    // check to see if first contour point is repeated and remove it
                    if (Header.pfxStart == pntfx)
                        cTotal--;
                }

                ipHeader = ipHeader + Header.cb;
            }

            return cTotal;
        }
Ejemplo n.º 3
0
 public static extern bool GetCursorPos(out POINTFX lpPoint);