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); } } }
/// <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()); }
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); }
//--------------------------------------------------------------------------- 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 );
internal static extern int DllGetVersion(ref DLLVERSIONINFO pdvi);
[DllImport(comctl32)] public static extern int DllGetVersion(ref DLLVERSIONINFO pdvi);
static extern int DllGetVersion(ref DLLVERSIONINFO pdvi);
private static extern int GetCommonControlDLLVersion(ref DLLVERSIONINFO dvi);
public static extern Int32 DllGetVersion( ref DLLVERSIONINFO pdvi);
public static extern int CommonControlsGetVersion(ref DLLVERSIONINFO pdvi);
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; }
static extern int DllGetVersion(ref DLLVERSIONINFO dwVersion);
/// <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; } } }
public static extern int DllGetVersion(ref DLLVERSIONINFO s);
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); } }