External/Aga.Controls/Tree/NativeMethods.cs
author moel.mich
Wed, 18 Jul 2012 19:45:59 +0000
changeset 366 667c75cad937
permissions -rw-r--r--
Changed the system tray icon font scaling to adapt to the size of the tray icon in pixels, because on Windows 7 the tray icon scales with the system font size, while on Windows XP the tray icons are always 16 pixels large.
moel@345
     1
using System;
moel@345
     2
using System.Drawing;
moel@345
     3
using System.Runtime.InteropServices;
moel@345
     4
moel@345
     5
moel@345
     6
namespace Aga.Controls.Tree
moel@345
     7
{
moel@345
     8
    internal static class NativeMethods
moel@345
     9
    {
moel@345
    10
        public const int DCX_WINDOW = 0x01;
moel@345
    11
        public const int DCX_CACHE = 0x02;
moel@345
    12
        public const int DCX_NORESETATTRS = 0x04;
moel@345
    13
        public const int DCX_CLIPCHILDREN = 0x08;
moel@345
    14
        public const int DCX_CLIPSIBLINGS = 0x10;
moel@345
    15
        public const int DCX_PARENTCLIP = 0x20;
moel@345
    16
        public const int DCX_EXCLUDERGN = 0x40;
moel@345
    17
        public const int DCX_INTERSECTRGN = 0x80;
moel@345
    18
        public const int DCX_EXCLUDEUPDATE = 0x100;
moel@345
    19
        public const int DCX_INTERSECTUPDATE = 0x200;
moel@345
    20
        public const int DCX_LOCKWINDOWUPDATE = 0x400;
moel@345
    21
        public const int DCX_VALIDATE = 0x200000;
moel@345
    22
moel@345
    23
        public const int WM_THEMECHANGED = 0x031A;
moel@345
    24
        public const int WM_NCPAINT = 0x85;
moel@345
    25
        public const int WM_NCCALCSIZE = 0x83;
moel@345
    26
moel@345
    27
        public const int WS_BORDER = 0x800000;
moel@345
    28
        public const int WS_EX_CLIENTEDGE = 0x200;
moel@345
    29
moel@345
    30
        public const int WVR_HREDRAW = 0x100;
moel@345
    31
        public const int WVR_VREDRAW = 0x200;
moel@345
    32
        public const int WVR_REDRAW = (WVR_HREDRAW | WVR_VREDRAW);
moel@345
    33
moel@345
    34
        [StructLayout(LayoutKind.Sequential)]
moel@345
    35
        public struct NCCALCSIZE_PARAMS
moel@345
    36
        {
moel@345
    37
            public RECT rgrc0, rgrc1, rgrc2;
moel@345
    38
            public IntPtr lppos;
moel@345
    39
        }
moel@345
    40
moel@345
    41
        [StructLayout(LayoutKind.Sequential)]
moel@345
    42
        public struct RECT
moel@345
    43
        {
moel@345
    44
            public int Left;
moel@345
    45
            public int Top;
moel@345
    46
            public int Right;
moel@345
    47
            public int Bottom;
moel@345
    48
moel@345
    49
            public static RECT FromRectangle(Rectangle rectangle)
moel@345
    50
            {
moel@345
    51
                RECT result = new RECT();
moel@345
    52
                result.Left = rectangle.Left;
moel@345
    53
                result.Top = rectangle.Top;
moel@345
    54
                result.Right = rectangle.Right;
moel@345
    55
                result.Bottom = rectangle.Bottom;
moel@345
    56
                return result;
moel@345
    57
            }
moel@345
    58
moel@345
    59
            public Rectangle ToRectangle()
moel@345
    60
            {
moel@345
    61
                return new Rectangle(Left, Top, Right - Left, Bottom - Top);
moel@345
    62
            }
moel@345
    63
        }
moel@345
    64
moel@345
    65
        [DllImport("user32.dll", SetLastError = true)]
moel@345
    66
        public static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags);
moel@345
    67
moel@345
    68
        [DllImport("user32.dll")]
moel@345
    69
        public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
moel@345
    70
moel@345
    71
        [DllImport("user32.dll")]
moel@345
    72
        public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
moel@345
    73
    }
moel@345
    74
}