Example #1
0
        public short GetObject(HGDIOBJ hgdiobj, short cbBuffer, uint ptr)
        {
            unsafe
            {
                var objectType = GetObjectType(hgdiobj);
                switch (objectType)
                {
                case Win32.OBJ_PEN:
                {
                    if (ptr == 0)
                    {
                        return((short)Marshal.SizeOf <Win16.LOGPEN>());
                    }

                    // Check if buffer big enough
                    if (cbBuffer < Marshal.SizeOf <Win16.LOGPEN>())
                    {
                        return(0);
                    }

                    // Get it
                    var lp32  = new Win32.LOGPEN();
                    var plp32 = &lp32;
                    var size  = GetObject(hgdiobj, Marshal.SizeOf <Win32.LOGPEN>(), (IntPtr)plp32);

                    // Convert and write it back
                    _machine.WriteStruct(ptr, Win32.LOGPEN.To16(lp32));

                    return((short)Marshal.SizeOf <Win16.LOGPEN>());
                }

                case Win32.OBJ_BRUSH:
                {
                    if (ptr == 0)
                    {
                        return((short)Marshal.SizeOf <Win16.LOGBRUSH>());
                    }

                    if (cbBuffer < Marshal.SizeOf <Win16.LOGBRUSH>())
                    {
                        return(0);
                    }

                    var lb32  = new Win32.LOGBRUSH();
                    var plb32 = &lb32;
                    var size  = GetObject(hgdiobj, Marshal.SizeOf <Win32.LOGBRUSH>(), (IntPtr)plb32);

                    _machine.WriteStruct(ptr, Win32.LOGBRUSH.To16(lb32));
                    return((short)Marshal.SizeOf <Win16.LOGBRUSH>());
                }

                case Win32.OBJ_BITMAP:
                {
                    // Just asking for size?
                    if (ptr == 0)
                    {
                        return((short)Marshal.SizeOf <Win16.BITMAP>());
                    }

                    // Check if buffer big enough
                    if (cbBuffer < Marshal.SizeOf <Win16.BITMAP>())
                    {
                        return(0);
                    }

                    // Get it
                    var bmp32  = new Win32.BITMAP();
                    var pbmp32 = &bmp32;
                    var size   = GetObject(hgdiobj, Marshal.SizeOf <Win32.BITMAP>(), (IntPtr)pbmp32);

                    // Convert and write it back
                    _machine.WriteStruct(ptr, Win32.BITMAP.To16(bmp32));

                    // Return size
                    return((short)Marshal.SizeOf <Win16.BITMAP>());
                }

                case Win32.OBJ_FONT:
                {
                    // Just asking for size?
                    if (ptr == 0)
                    {
                        return((short)Marshal.SizeOf <Win16.LOGFONT>());
                    }

                    // Check if buffer big enough
                    if (cbBuffer < Marshal.SizeOf <Win16.LOGFONT>())
                    {
                        return(0);
                    }

                    // Get it
                    var lf32 = new Win32.LOGFONT();
                    var size = GetObject(hgdiobj, Marshal.SizeOf <Win32.LOGFONT>(), out lf32);

                    // Convert and write it back
                    _machine.WriteStruct(ptr, Win32.LOGFONT.To16(lf32));

                    // Return size
                    return((short)Marshal.SizeOf <Win16.LOGFONT>());
                }

                default:
                    throw new NotImplementedException("Unsupported object type passed to GetObject");
                }
            }
        }
Example #2
0
 static extern int GetObject(HGDIOBJ hgdiobj, int cbBuffer, IntPtr lpvObject);
Example #3
0
 static extern int GetObject(HGDIOBJ hgdiobj, int cbBuffer, out Win32.LOGFONT lpvObject);
Example #4
0
 public static extern bool DeleteObject([Destroyed] HGDIOBJ hGdiObj);
Example #5
0
 static extern uint GetObjectType(HGDIOBJ h);
Example #6
0
 // does not exist anymore in gdi32.dll
 public void SetObjectOwner(HGDIOBJ hObject, uint hTask)
 {
     // nothing to do
     return;
 }
Example #7
0
 public static extern HGDIOBJ CreatePatternBrush(HGDIOBJ hBrush);
Example #8
0
 public static extern nint SelectClipRgn(HDC hDC, HGDIOBJ hRgn);
Example #9
0
 public static extern HGDIOBJ SelectObject(HDC hdc, HGDIOBJ hgdiobj);
Example #10
0
 public static extern bool InvertRgn(HDC hDC, HGDIOBJ hRgn);
Example #11
0
 public static extern bool PaintRgn(HDC hDC, HGDIOBJ hRgn);
Example #12
0
 public static extern bool FrameRgn(HDC hDC, HGDIOBJ hRgn, nint w, nint h);
Example #13
0
 public static extern bool FillRgn(HDC hDC, HGDIOBJ hRgn, HGDIOBJ hBrush);
Example #14
0
 // does not exist anymore in gdi32.dll
 public bool IsGdiObject(HGDIOBJ hObject)
 {
     return(hObject.value != IntPtr.Zero);
 }
Example #15
0
 public static extern bool UnrealizeObject(HGDIOBJ hObj);
Example #16
0
 public static extern nint CombineRgn(HGDIOBJ hrgnDest, HGDIOBJ hrgnSrc1, HGDIOBJ hrgnSrc2, nint combineMode);
Example #17
0
 public static extern void SetRectRgn(HGDIOBJ hRgn, nint l, nint t, nint r, nint b);
Example #18
0
 public static ushort To16(HGDIOBJ hObj)
 {
     return(Map.To16(hObj.value));
 }