Exemplo n.º 1
0
        static private bool ComCtlDllSupportsArrows()
        {
            IntPtr hModule = IntPtr.Zero;

            try
            {
                hModule = LoadLibrary("comctl32.dll");
                if (hModule != IntPtr.Zero)
                {
                    UIntPtr proc = GetProcAddress(hModule, "DllGetVersion");
                    if (proc == UIntPtr.Zero)    // Old versions don't support this method
                    {
                        return(false);
                    }
                }

                DLLVERSIONINFO vi = new DLLVERSIONINFO();
                vi.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO));

                DllGetVersion(ref vi);

                return(vi.dwMajorVersion >= 6);
            }
            finally
            {
                if (hModule != IntPtr.Zero)
                {
                    FreeLibrary(hModule);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a Version object that contains information about the verion
        /// of the CommonControls that the application is using
        /// </summary>
        /// <returns>A Version object that contains information about the verion
        /// of the CommonControls that the application is using</returns>
        private static Version GetComctlVersion()
        {
            DLLVERSIONINFO comctlVersion = new DLLVERSIONINFO();

            comctlVersion.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO));

            if (NativeMethods.DllGetVersion(ref comctlVersion) == 0)
            {
                return(new Version(comctlVersion.dwMajorVersion, comctlVersion.dwMinorVersion, comctlVersion.dwBuildNumber));
            }

            return(new Version());
        }
Exemplo n.º 3
0
 private bool IsCommonCtrl6()
 {
     // Cache this value for efficenty
     if (bGotIsCommonCtrl6 == false)
     {
         DLLVERSIONINFO dllVersion = new DLLVERSIONINFO();
         // We are assummng here that anything greater or equal than 6
         // will have the new XP theme drawing enable
         dllVersion.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO));
         WindowsAPI.GetCommonControlDLLVersion(ref dllVersion);
         bGotIsCommonCtrl6 = true;
         isCommonCtrl6     = (dllVersion.dwMajorVersion >= 6);
     }
     return(isCommonCtrl6);
 }
Exemplo n.º 4
0
        //---------------------------------------------------------------------------
        public void SetImage
        (
            Bitmap[] images,
            Alignment align,
            int leftMargin, int topMargin, int rightMargin, int bottomMargin
        )
        {
            if (ComCtlMajorVersion < 0)
            {
                DLLVERSIONINFO dllVersion = new DLLVERSIONINFO();
                dllVersion.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO));
                GetCommonControlDLLVersion(ref dllVersion);
                ComCtlMajorVersion = dllVersion.dwMajorVersion;
            }

            if (ComCtlMajorVersion >= 6 && FlatStyle == FlatStyle.System)
            {
                RECT rect = new RECT();
                rect.left   = leftMargin;
                rect.top    = topMargin;
                rect.right  = rightMargin;
                rect.bottom = bottomMargin;

                BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST();
                buttonImageList.margin = rect;
                buttonImageList.uAlign = (int)align;

                ImageList            = GenerateImageList(images);
                buttonImageList.himl = ImageList.Handle;

                SendMessage(this.Handle, BCM_SETIMAGELIST, 0, ref buttonImageList);
            }
            else
            {
                FlatStyle = FlatStyle.Standard;

                if (images.Length > 0)
                {
                    Image = images[0];
                }
            }
        }
        public static bool IsThemed()
        {
            bool retval = false;

            if ((Environment.OSVersion.Version.Major == 5 &&
                 Environment.OSVersion.Version.Minor >= 1) ||
                Environment.OSVersion.Version.Major > 5)
            {
                bool appThemed   = NativeMethods.IsAppThemed();
                bool themeActive = NativeMethods.IsThemeActive();

                if (appThemed && themeActive)
                {
                    DLLVERSIONINFO dvi = new DLLVERSIONINFO();
                    dvi.cbSize = (uint)Marshal.SizeOf(dvi);

                    NativeMethods.DllGetVersion(ref dvi);

                    retval = (dvi.dwMajorVersion >= 6);
                }
            }

            return(retval);
        }
 public static extern uint DllGetVersion( ref DLLVERSIONINFO pdvi );
Exemplo n.º 7
0
 internal static extern int DllGetVersion(ref DLLVERSIONINFO pdvi);
Exemplo n.º 8
0
 [DllImport(comctl32)]  public static extern int DllGetVersion(ref DLLVERSIONINFO pdvi);
Exemplo n.º 9
0
 static extern int DllGetVersion(ref DLLVERSIONINFO pdvi);
Exemplo n.º 10
0
 private static extern int GetCommonControlDLLVersion(ref DLLVERSIONINFO dvi);
Exemplo n.º 11
0
 public static extern Int32 DllGetVersion(
     ref DLLVERSIONINFO pdvi);
Exemplo n.º 12
0
 public static extern int CommonControlsGetVersion(ref DLLVERSIONINFO pdvi);
Exemplo n.º 13
0
			public extern static int DllGetVersion(ref DLLVERSIONINFO dvi);
        public static bool IsThemed()
        {
            bool retval = false;

             if ( ( Environment.OSVersion.Version.Major == 5 &&
                Environment.OSVersion.Version.Minor >= 1 ) ||
               Environment.OSVersion.Version.Major > 5 )
             {
            bool appThemed   = NativeMethods.IsAppThemed();
            bool themeActive = NativeMethods.IsThemeActive();

            if ( appThemed && themeActive )
            {
               DLLVERSIONINFO dvi = new DLLVERSIONINFO();
               dvi.cbSize = (uint)Marshal.SizeOf(dvi);

               NativeMethods.DllGetVersion( ref dvi );

               retval = ( dvi.dwMajorVersion >= 6 );
            }
             }

             return retval;
        }
Exemplo n.º 15
0
 public static extern int CommonControlsGetVersion(ref DLLVERSIONINFO pdvi);
Exemplo n.º 16
0
 static extern int DllGetVersion(ref DLLVERSIONINFO dwVersion);
Exemplo n.º 17
0
        /// <summary>
        /// Sets the images of the button to the specified value with the specified alignment and margins.
        /// </summary>
        /// <param name="images">The images for the button.</param>
        /// <param name="align">The alignment of the image</param>
        /// <param name="leftMargin">The left margin of the image in pixels</param>
        /// <param name="topMargin">The top margin of the image in pixels</param>
        /// <param name="rightMargin">The right margin of the image in pixels</param>
        /// <param name="bottomMargin">The bottom margin of the image in pixels</param>
        public void SetImage(Bitmap[] images,
                             Alignment align, int leftMargin, int topMargin, int rightMargin,
                             int bottomMargin)
        {
            if (GenerateDisabledImage)
            {
                if (images.Length == 1)
                {
                    Bitmap image = images[0];
                    images = new Bitmap[] { image, image, image, image, image };
                }

                images[3] = DrawImageDisabled(images[3]);
            }

            if (ComCtlMajorVersion < 0)
            {
                DLLVERSIONINFO dllVersion = new DLLVERSIONINFO();
                dllVersion.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO));
                GetCommonControlDLLVersion(ref dllVersion);
                ComCtlMajorVersion = dllVersion.dwMajorVersion;
            }

            if (ComCtlMajorVersion >= 6 && FlatStyle == FlatStyle.System)
            {
                RECT rect = new RECT();
                rect.left   = leftMargin;
                rect.top    = topMargin;
                rect.right  = rightMargin;
                rect.bottom = bottomMargin;

                BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST();
                buttonImageList.margin = rect;
                buttonImageList.uAlign = (int)align;

                ImageList            = GenerateImageList(images);
                buttonImageList.himl = ImageList.Handle;

                SendMessage(this.Handle, BCM_SETIMAGELIST, 0, ref buttonImageList);
            }
            else
            {
                FlatStyle = FlatStyle.Standard;

                if (images.Length > 0)
                {
                    Image = images[0];
                }

                switch (align)
                {
                case Alignment.Bottom:
                    ImageAlign = ContentAlignment.BottomCenter;
                    break;

                case Alignment.Left:
                    ImageAlign = ContentAlignment.MiddleLeft;
                    break;

                case Alignment.Right:
                    ImageAlign = ContentAlignment.MiddleRight;
                    break;

                case Alignment.Top:
                    ImageAlign = ContentAlignment.TopCenter;
                    break;

                case Alignment.Center:
                    ImageAlign = ContentAlignment.MiddleCenter;
                    break;
                }
            }
        }
Exemplo n.º 18
0
 public static extern int DllGetVersion(ref DLLVERSIONINFO s);
Exemplo n.º 19
0
        private static bool ComCtlDllSupportsArrows()
        {
            IntPtr hModule = IntPtr.Zero;

            try
            {
                hModule = LoadLibrary("comctl32.dll");
                if (hModule != IntPtr.Zero)
                {
                    UIntPtr proc = GetProcAddress(hModule, "DllGetVersion");
                    if (proc == UIntPtr.Zero)    // Old versions don't support this method
                        return false;
                }

                DLLVERSIONINFO vi = new DLLVERSIONINFO();
                vi.cbSize = Marshal.SizeOf(typeof(DLLVERSIONINFO));

                DllGetVersion(ref vi);

                return vi.dwMajorVersion >= 6;
            }
            finally
            {
                if (hModule != IntPtr.Zero)
                    FreeLibrary(hModule);
            }
        }
Exemplo n.º 20
0
 public extern static int DllGetVersion(ref DLLVERSIONINFO dvi);
Exemplo n.º 21
0
        public static extern Int32 DllGetVersion(
			ref DLLVERSIONINFO pdvi);