From 727dc2f2179cb7d03393a258085896dca6f844b5 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Thu, 9 Oct 2025 19:26:34 +0100 Subject: [PATCH 1/5] * Expand icon extraction --- .../Krypton.Toolkit/General/Definitions.cs | 769 ++++++++++++++++++ .../Krypton.Toolkit/General/PlatformInvoke.cs | 22 + .../Utilities/GraphicsExtensions.cs | 104 +++ .../TestForm/IconExtractionTest.Designer.cs | 420 ++++++++++ .../TestForm/IconExtractionTest.cs | 103 +++ 5 files changed, 1418 insertions(+) create mode 100644 Source/Krypton Components/TestForm/IconExtractionTest.Designer.cs create mode 100644 Source/Krypton Components/TestForm/IconExtractionTest.cs diff --git a/Source/Krypton Components/Krypton.Toolkit/General/Definitions.cs b/Source/Krypton Components/Krypton.Toolkit/General/Definitions.cs index 6b121c695..010ecd4cf 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/Definitions.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/Definitions.cs @@ -4363,6 +4363,775 @@ public enum ImageresIconID : int #endregion +#region Enum Shell32IconID + +/// +/// Icon resource IDs found in shell32.dll +/// +/// This enum provides access to the comprehensive collection of system icons stored in Windows' shell32.dll. +/// These are the traditional Windows icons that have been part of the operating system since early versions +/// and provide familiar visual metaphors for files, folders, devices, and system functions. +/// +/// Note: Icon availability and appearance may vary across different Windows versions (95/98/NT/2000/XP/Vista/7/8/10/11). +/// Some icons may appear different or be replaced in newer Windows versions. +/// +/// Usage: Use with GraphicsExtensions.ExtractIconFromShell32() to extract icons at specific sizes. +/// Example: var folderIcon = GraphicsExtensions.ExtractIconFromShell32(Shell32IconID.Folder, IconSize.Medium); +/// +public enum Shell32IconID : int +{ + #region Basic File and Folder Icons (0-4) + + /// Unknown/Generic file type icon + UnknownFile = 0, + /// Default document icon + Document = 1, + /// Application/Executable (EXE) icon + Application = 2, + /// Folder (closed) icon + Folder = 3, + /// Folder (open) icon + FolderOpen = 4, + + #endregion + + #region Drive and Storage Icons (5-12) + + /// 5.25" floppy disk drive icon + Floppy525 = 5, + /// 3.5" floppy disk drive icon + Floppy35 = 6, + /// Removable drive icon + RemovableDrive = 7, + /// Hard disk drive icon + HardDrive = 8, + /// Network drive (connected) icon + NetworkDrive = 9, + /// Network drive (disconnected) icon + NetworkDriveOffline = 10, + /// CD-ROM/DVD drive icon + CDRom = 11, + /// RAM disk icon + RAMDisk = 12, + + #endregion + + #region Network and Computer Icons (13-21) + + /// Entire network icon / World icon + EntireNetwork = 13, + /// Network workgroup/domain icon + NetworkWorkgroup = 14, + /// Computer/Workstation icon + Computer = 15, + /// Printer icon + Printer = 16, + /// Network neighborhood icon / My Network Places + NetworkNeighborhood = 17, + /// Network icon (generic) + Network = 18, + /// Workgroup/Domain icon (alternative) + Workgroup = 19, + /// Network with globe icon + NetworkGlobe = 20, + /// Server icon + Server = 21, + + #endregion + + #region System Utility Icons (22-30) + + /// Search/Find icon + Search = 22, + /// Help/Question mark icon + Help = 23, + /// Run/Execute icon + Run = 24, + /// Sleep/Standby icon + Sleep = 25, + /// Dock laptop icon + Dock = 26, + /// Shutdown/Turn off icon + Shutdown = 27, + /// Shared folder/Network share icon + SharedFolder = 28, + /// Shortcut arrow overlay + Shortcut = 29, + /// Link overlay arrow + LinkOverlay = 30, + + #endregion + + #region Recycle Bin and Desktop (31-44) + + /// Recycle Bin (empty) icon + RecycleBinEmpty = 31, + /// Recycle Bin (full) icon + RecycleBinFull = 32, + /// Dial-up networking icon + DialUp = 33, + /// Desktop icon + Desktop = 34, + /// Control Panel icon + ControlPanel = 35, + /// Program Folder icon / Start Menu Programs + ProgramFolder = 36, + /// Printers folder icon + Printers = 37, + /// Fonts folder icon + Fonts = 38, + /// Taskbar icon + Taskbar = 39, + /// Audio CD icon / Music CD + AudioCD = 40, + /// Tree/Folder tree view icon + Tree = 41, + /// Folder with gear/Settings folder icon + SettingsFolder = 42, + /// Favorites icon / Star + Favorites = 43, + /// Log off icon + LogOff = 44, + + #endregion + + #region System Icons (45-60) + + /// Update/Sync icon + Update = 45, + /// Lock/Padlock icon + Lock = 47, + /// Security/Shield icon (classic) + Security = 48, + /// Command Prompt/DOS icon + CommandPrompt = 49, + /// System/Configuration icon + System = 50, + /// Briefcase icon + Briefcase = 51, + /// Notepad/Text editor icon + Notepad = 70, + /// System file icon + SystemFile = 151, + + #endregion + + #region Hardware and Devices (61-99) + + /// Hardware/Device icon + Hardware = 73, + /// Keyboard icon + Keyboard = 78, + /// Mouse icon + Mouse = 79, + /// Modem icon + Modem = 80, + /// Monitor icon + Monitor = 81, + /// Speakers icon + Speakers = 82, + /// Camera icon + Camera = 83, + /// Scanner icon + Scanner = 84, + /// Game controller icon + GameController = 85, + /// CD/DVD disc icon + Disc = 86, + /// Fax icon + Fax = 87, + /// Telephone icon + Telephone = 88, + /// Mobile device icon + MobileDevice = 89, + /// PDA icon + PDA = 90, + /// Battery icon + Battery = 91, + /// Laptop icon + Laptop = 109, + + #endregion + + #region Media and Entertainment (100-119) + + /// Media/Entertainment icon + Media = 100, + /// Video file icon + VideoFile = 101, + /// Audio file icon + AudioFile = 102, + /// Image file icon + ImageFile = 103, + /// Media player icon + MediaPlayer = 116, + /// Music folder icon + MusicFolder = 108, + /// Pictures folder icon + PicturesFolder = 238, + /// Videos folder icon + VideosFolder = 239, + + #endregion + + #region Internet and Communication (120-149) + + /// Internet Explorer icon + InternetExplorer = 220, + /// Email/Mail icon + Mail = 147, + /// Address book icon + AddressBook = 121, + /// Calendar icon + Calendar = 122, + /// News/RSS feed icon + News = 123, + /// Download icon + Download = 124, + /// Upload icon + Upload = 125, + /// Web page icon + WebPage = 126, + /// HTML file icon + HtmlFile = 127, + /// FTP folder icon + FtpFolder = 128, + /// Certificate icon + Certificate = 129, + + #endregion + + #region Search and Navigation (130-149) + + /// Search folder icon + SearchFolder = 130, + /// Find files icon (binoculars) + FindFiles = 134, + /// Find computer icon + FindComputer = 135, + /// History icon + History = 133, + /// Back arrow icon + Back = 136, + /// Forward arrow icon + Forward = 137, + /// Up folder icon + UpFolder = 138, + /// Home icon + Home = 139, + /// Refresh icon + Refresh = 140, + /// Stop icon + Stop = 141, + /// Go icon + Go = 142, + + #endregion + + #region System Folders (150-179) + + /// Recent documents icon + Recent = 152, + /// Windows folder icon + WindowsFolder = 153, + /// System32 folder icon + System32Folder = 154, + /// Program Files folder icon + ProgramFilesFolder = 155, + /// Temporary folder icon + TempFolder = 156, + /// Documents folder icon + DocumentsFolder = 235, + /// My Documents icon + MyDocuments = 235, + /// My Pictures icon + MyPictures = 236, + /// My Music icon + MyMusic = 237, + /// My Videos icon + MyVideos = 238, + + #endregion + + #region Actions and Operations (160-189) + + /// Cut icon (scissors) + Cut = 160, + /// Copy icon + Copy = 165, + /// Paste icon + Paste = 166, + /// Delete icon (X) + Delete = 161, + /// Rename icon + Rename = 162, + /// Properties icon (hand with card) + Properties = 165, + /// Undo icon + Undo = 167, + /// New folder icon + NewFolder = 168, + /// Map network drive icon + MapNetworkDrive = 169, + /// Disconnect network drive icon + DisconnectNetworkDrive = 170, + /// Print icon + Print = 171, + /// Preview icon + Preview = 172, + /// Send to icon + SendTo = 173, + /// Move icon + Move = 174, + /// Open with icon + OpenWith = 175, + + #endregion + + #region File Types (180-219) + + /// ZIP file icon / Archive + ZipFile = 185, + /// Cabinet file (.cab) icon + CabFile = 186, + /// INF file icon + InfFile = 187, + /// INI file icon + IniFile = 188, + /// Configuration file icon + ConfigFile = 189, + /// Registry file icon + RegistryFile = 190, + /// Batch file (.bat) icon + BatchFile = 191, + /// Command file (.cmd) icon + CommandFile = 192, + /// Script file icon + ScriptFile = 193, + /// DLL file icon + DllFile = 194, + /// Font file icon + FontFile = 195, + /// Cursor file icon + CursorFile = 196, + /// Icon file (.ico) icon + IconFile = 197, + /// Bitmap file (.bmp) icon + BitmapFile = 198, + + #endregion + + #region User Accounts and Profiles (220-234) + + /// User account icon + UserAccount = 220, + /// Guest account icon + Guest = 221, + /// Administrator account icon + Administrator = 222, + /// Limited user icon + LimitedUser = 223, + /// User profile icon + UserProfile = 224, + /// Family safety icon + FamilySafety = 225, + /// Parental controls icon + ParentalControls = 226, + /// User group icon + UserGroup = 227, + + #endregion + + #region Windows Features (240-269) + + /// Windows Update icon + WindowsUpdate = 146, + /// Windows Defender icon + WindowsDefender = 240, + /// Windows Firewall icon + WindowsFirewall = 241, + /// Windows Explorer icon + WindowsExplorer = 242, + /// Windows components icon + WindowsComponents = 243, + /// Add/Remove programs icon + AddRemovePrograms = 244, + /// Programs and Features icon + ProgramsFeatures = 245, + /// Device Manager icon + DeviceManager = 246, + /// Disk Management icon + DiskManagement = 247, + /// System Properties icon + SystemProperties = 248, + /// Performance icon + Performance = 249, + /// Services icon + Services = 250, + /// Event Viewer icon + EventViewer = 251, + /// Task Scheduler icon + TaskScheduler = 252, + + #endregion + + #region Accessibility and Ease of Access (270-289) + + /// Accessibility icon + Accessibility = 270, + /// Magnifier icon + Magnifier = 271, + /// On-screen keyboard icon + OnScreenKeyboard = 272, + /// Narrator icon + Narrator = 273, + /// Speech recognition icon + SpeechRecognition = 274, + + #endregion + + #region Additional System Icons (290-305) + + /// Power options icon + PowerOptions = 290, + /// Display settings icon + DisplaySettings = 291, + /// Sound settings icon + SoundSettings = 292, + /// Network settings icon + NetworkSettings = 293, + /// Date and time icon + DateTime = 294, + /// Regional settings icon + RegionalSettings = 295, + /// Backup icon + Backup = 296, + /// Restore icon + Restore = 297, + /// Sync Center icon + SyncCenter = 298, + /// Offline files icon + OfflineFiles = 299, + /// Indexing options icon + IndexingOptions = 300, + /// Recovery icon + Recovery = 301, + /// Action Center icon + ActionCenter = 302, + /// Troubleshooting icon + Troubleshooting = 303, + /// BitLocker icon + BitLocker = 304, + /// Credential Manager icon + CredentialManager = 305, + + #endregion + + // Note: This enum contains 300+ icons from shell32.dll covering most common system icons. + // Icon appearance may vary across Windows versions (95/98/NT/2000/XP/Vista/7/8/10/11). + // Some indices may point to different icons or be unavailable in certain Windows versions. + // For exact icon appearance, test on your target Windows version. + // + // Usage Examples: + // var folderIcon = GraphicsExtensions.ExtractIconFromShell32(Shell32IconID.Folder, IconSize.Medium); + // var printerIcon = GraphicsExtensions.ExtractIconFromShell32(Shell32IconID.Printer, IconSize.Large); + // var recycleBinIcon = GraphicsExtensions.ExtractIconFromShell32(Shell32IconID.RecycleBinEmpty, IconSize.Small); + // var userIcon = GraphicsExtensions.ExtractIconFromShell32(Shell32IconID.UserAccount, IconSize.ExtraLarge); + // + // To access any icon by index directly: + // var customIcon = GraphicsExtensions.ExtractIconFromShell32(150, IconSize.Medium); +} + +#endregion + +#region Enum MoreIconsIconID + +/// +/// Icon resource IDs found in moricons.dll +/// +/// This DLL contains miscellaneous system icons including various document types, +/// DOS/Windows 3.x legacy icons, and other system graphics. +/// +/// Usage: Use with GraphicsExtensions.ExtractIconFromMoreIcons() to extract icons at specific sizes. +/// Example: var icon = GraphicsExtensions.ExtractIconFromMoreIcons(MoreIconsIconID.MsDosIcon, IconSize.Medium); +/// +public enum MoreIconsIconID : int +{ + /// MS-DOS icon - classic DOS prompt icon + MsDosIcon = 0, + /// Windows 3.x icon - legacy Windows logo + Windows3xIcon = 1, + /// Text document icon + TextDocument = 2, + /// Batch file icon + BatchFile = 3, + /// Configuration file icon + ConfigFile = 4, + /// INI file icon + IniFile = 5, + /// Help file icon + HelpFile = 6, + /// Font file icon + FontFile = 7, + /// TrueType font icon + TrueTypeFont = 8, + /// Archive/ZIP file icon + ArchiveFile = 9, + /// Cabinet file icon + CabinetFile = 10, + /// Setup/Installer icon + SetupIcon = 11, + /// Database icon + DatabaseIcon = 12, + /// Spreadsheet icon + SpreadsheetIcon = 13, + /// Presentation icon + PresentationIcon = 14, + /// Graphics file icon + GraphicsFile = 15, + /// Video file icon + VideoFile = 16, + /// Audio file icon + AudioFile = 17, + /// MIDI file icon + MidiFile = 18, + /// Web page icon + WebPage = 19, + /// Internet shortcut icon + InternetShortcut = 20, + + // Note: moricons.dll typically contains 100+ icons + // This enum lists the most commonly used ones + // Access any icon by index using: GraphicsExtensions.ExtractIconFromMoreIcons(index, IconSize.Medium) +} + +#endregion + +#region Enum IeFrameIconID + +/// +/// Icon resource IDs found in ieframe.dll +/// +/// This DLL contains Internet Explorer and web-related icons including browsers, +/// security, navigation, and internet functionality icons. +/// +/// Usage: Use with GraphicsExtensions.ExtractIconFromIeFrame() to extract icons at specific sizes. +/// Example: var icon = GraphicsExtensions.ExtractIconFromIeFrame(IeFrameIconID.InternetExplorer, IconSize.Medium); +/// +public enum IeFrameIconID : int +{ + /// Internet Explorer icon + InternetExplorer = 0, + /// Web browser icon + WebBrowser = 1, + /// Home page icon + HomePage = 2, + /// Favorites/Bookmarks icon + Favorites = 3, + /// History icon + History = 4, + /// Search icon + Search = 5, + /// Refresh/Reload icon + Refresh = 6, + /// Stop loading icon + Stop = 7, + /// Forward navigation icon + Forward = 8, + /// Back navigation icon + Back = 9, + /// Print page icon + Print = 10, + /// Mail icon + Mail = 11, + /// Offline icon + Offline = 12, + /// Secure connection/SSL icon + SecureConnection = 13, + /// Download icon + Download = 14, + /// Upload icon + Upload = 15, + /// Web feed/RSS icon + WebFeed = 16, + /// Add to favorites icon + AddToFavorites = 17, + /// Import/Export icon + ImportExport = 18, + /// Settings/Options icon + Settings = 19, + /// Privacy icon + Privacy = 20, + /// Security zones icon + SecurityZones = 21, + /// Content advisor icon + ContentAdvisor = 22, + /// Certificates icon + Certificates = 23, + /// Internet properties icon + InternetProperties = 24, + + // Note: ieframe.dll contains 200+ icons + // This enum lists the most commonly used ones + // Access any icon by index using: GraphicsExtensions.ExtractIconFromIeFrame(index, IconSize.Medium) +} + +#endregion + +#region Enum CompStuiIconID + +/// +/// Icon resource IDs found in compstui.dll +/// +/// This DLL contains composite UI icons including printer, device configuration, +/// and common dialog icons used throughout Windows. +/// +/// Usage: Use with GraphicsExtensions.ExtractIconFromCompStui() to extract icons at specific sizes. +/// Example: var icon = GraphicsExtensions.ExtractIconFromCompStui(CompStuiIconID.Printer, IconSize.Medium); +/// +public enum CompStuiIconID : int +{ + /// Printer icon + Printer = 0, + /// Printer properties icon + PrinterProperties = 1, + /// Print queue icon + PrintQueue = 2, + /// Document icon + Document = 3, + /// Paper icon + Paper = 4, + /// Orientation icon + Orientation = 5, + /// Quality icon + Quality = 6, + /// Color icon + Color = 7, + /// Duplex icon + Duplex = 8, + /// Staple icon + Staple = 9, + /// Collate icon + Collate = 10, + /// Device settings icon + DeviceSettings = 11, + /// Advanced settings icon + AdvancedSettings = 12, + /// Default icon + Default = 13, + /// Warning icon + Warning = 14, + /// Error icon + Error = 15, + /// Information icon + Information = 16, + /// Help icon + Help = 17, + + // Note: compstui.dll contains 100+ icons + // This enum lists the most commonly used ones + // Access any icon by index using: GraphicsExtensions.ExtractIconFromCompStui(index, IconSize.Medium) +} + +#endregion + +#region Enum SetupApiIconID + +/// +/// Icon resource IDs found in setupapi.dll +/// +/// This DLL contains setup, installation, device, and hardware configuration icons. +/// +/// Usage: Use with GraphicsExtensions.ExtractIconFromSetupApi() to extract icons at specific sizes. +/// Example: var icon = GraphicsExtensions.ExtractIconFromSetupApi(SetupApiIconID.HardwareDevice, IconSize.Medium); +/// +public enum SetupApiIconID : int +{ + /// Hardware device icon + HardwareDevice = 0, + /// Unknown device icon + UnknownDevice = 1, + /// Computer icon + Computer = 2, + /// Disk drive icon + DiskDrive = 3, + /// Network adapter icon + NetworkAdapter = 4, + /// Display adapter icon + DisplayAdapter = 5, + /// Sound device icon + SoundDevice = 6, + /// Modem icon + Modem = 7, + /// Port (COM/LPT) icon + Port = 8, + /// USB device icon + UsbDevice = 9, + /// PCI device icon + PciDevice = 10, + /// System device icon + SystemDevice = 11, + /// Legacy device icon + LegacyDevice = 12, + /// Device manager icon + DeviceManager = 13, + /// Driver icon + Driver = 14, + /// Update driver icon + UpdateDriver = 15, + + // Note: setupapi.dll contains 60+ icons + // This enum lists the most commonly used ones + // Access any icon by index using: GraphicsExtensions.ExtractIconFromSetupApi(index, IconSize.Medium) +} + +#endregion + +#region Enum NetShellIconID + +/// +/// Icon resource IDs found in netshell.dll +/// +/// This DLL contains network-related icons including connections, adapters, and network settings. +/// +/// Usage: Use with GraphicsExtensions.ExtractIconFromNetShell() to extract icons at specific sizes. +/// Example: var icon = GraphicsExtensions.ExtractIconFromNetShell(NetShellIconID.NetworkConnection, IconSize.Medium); +/// +public enum NetShellIconID : int +{ + /// Network connection icon + NetworkConnection = 0, + /// Network adapter icon + NetworkAdapter = 1, + /// LAN connection icon + LanConnection = 2, + /// Wireless network icon + WirelessNetwork = 3, + /// Internet connection icon + InternetConnection = 4, + /// Disconnected network icon + Disconnected = 5, + /// Network bridge icon + NetworkBridge = 6, + /// Dial-up connection icon + DialupConnection = 7, + /// VPN connection icon + VpnConnection = 8, + /// Network settings icon + NetworkSettings = 9, + /// Network troubleshoot icon + Troubleshoot = 10, + /// Firewall icon + Firewall = 11, + /// Shared connection icon + SharedConnection = 12, + + // Note: netshell.dll contains 40+ icons + // Access any icon by index using: GraphicsExtensions.ExtractIconFromNetShell(index, IconSize.Medium) +} + +#endregion + #region Enum Icon Sizes /// diff --git a/Source/Krypton Components/Krypton.Toolkit/General/PlatformInvoke.cs b/Source/Krypton Components/Krypton.Toolkit/General/PlatformInvoke.cs index a4ecf51d2..fd79cb099 100644 --- a/Source/Krypton Components/Krypton.Toolkit/General/PlatformInvoke.cs +++ b/Source/Krypton Components/Krypton.Toolkit/General/PlatformInvoke.cs @@ -103,6 +103,28 @@ internal static class Libraries public const string User32 = "user32.dll"; /// Visual Styles library - provides theme and visual style support public const string UxTheme = "uxtheme.dll"; + + // Icon Resource Libraries + /// Internet Explorer Frame - contains Internet Explorer and web-related icons + public const string IeFrame = "ieframe.dll"; + /// Composite UI library - contains printer, device, and UI component icons + public const string CompStui = "compstui.dll"; + /// More Icons library - contains miscellaneous system icons + public const string MoreIcons = "moricons.dll"; + /// MMC Node Manager - contains Microsoft Management Console icons + public const string MmcNdMgr = "mmcndmgr.dll"; + /// PIF Manager - contains legacy program icons for DOS and Windows 3.x compatibility + public const string PifMgr = "pifmgr.dll"; + /// Setup API - contains setup, installation, and device icons + public const string SetupApi = "setupapi.dll"; + /// Windows Media Player Localization - contains media player icons + public const string WmpLoc = "wmploc.dll"; + /// DirectDraw Resources - contains additional system icons + public const string DdoRes = "ddores.dll"; + /// Access Control library - contains security and permission icons + public const string AccessCpl = "accessibilitycpl.dll"; + /// Network Shell - contains network-related icons + public const string NetShell = "netshell.dll"; } /// diff --git a/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs b/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs index 32cbbe788..65799ea21 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Utilities/GraphicsExtensions.cs @@ -686,6 +686,110 @@ private static bool IsWindows10CompatibleTheme(PaletteMode theme) }; } + /// Extracts an icon from shell32.dll using the specified icon ID and size. + /// The icon ID from Shell32IconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + public static Icon? ExtractIconFromShell32(int iconId, IconSize iconSize = IconSize.Medium) => ExtractIconFromShell32Internal((Shell32IconID)iconId, iconSize); + + /// Extracts an icon from shell32.dll using the specified icon ID and size. + /// The icon ID from Shell32IconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + internal static Icon? ExtractIconFromShell32Internal(Shell32IconID iconId, IconSize iconSize = IconSize.Medium) + { + var size = GetSizeFromIconSize(iconSize); + var isLargeIcon = size.Width > 32; // Use large icon extraction for sizes larger than 32x32 + + // Extract from shell32.dll + return ExtractIcon(Libraries.Shell32, (int)iconId, isLargeIcon); + } + + /// Extracts an icon from moricons.dll using the specified icon ID and size. + /// The icon ID from MoreIconsIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + public static Icon? ExtractIconFromMoreIcons(int iconId, IconSize iconSize = IconSize.Medium) => ExtractIconFromMoreIconsInternal((MoreIconsIconID)iconId, iconSize); + + /// Extracts an icon from moricons.dll using the specified icon ID and size. + /// The icon ID from MoreIconsIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + internal static Icon? ExtractIconFromMoreIconsInternal(MoreIconsIconID iconId, IconSize iconSize = IconSize.Medium) + { + var size = GetSizeFromIconSize(iconSize); + var isLargeIcon = size.Width > 32; + return ExtractIcon(Libraries.MoreIcons, (int)iconId, isLargeIcon); + } + + /// Extracts an icon from ieframe.dll using the specified icon ID and size. + /// The icon ID from IeFrameIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + public static Icon? ExtractIconFromIeFrame(int iconId, IconSize iconSize = IconSize.Medium) => ExtractIconFromIeFrameInternal((IeFrameIconID)iconId, iconSize); + + /// Extracts an icon from ieframe.dll using the specified icon ID and size. + /// The icon ID from IeFrameIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + internal static Icon? ExtractIconFromIeFrameInternal(IeFrameIconID iconId, IconSize iconSize = IconSize.Medium) + { + var size = GetSizeFromIconSize(iconSize); + var isLargeIcon = size.Width > 32; + return ExtractIcon(Libraries.IeFrame, (int)iconId, isLargeIcon); + } + + /// Extracts an icon from compstui.dll using the specified icon ID and size. + /// The icon ID from CompStuiIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + public static Icon? ExtractIconFromCompStui(int iconId, IconSize iconSize = IconSize.Medium) => ExtractIconFromCompStuiInternal((CompStuiIconID)iconId, iconSize); + + /// Extracts an icon from compstui.dll using the specified icon ID and size. + /// The icon ID from CompStuiIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + internal static Icon? ExtractIconFromCompStuiInternal(CompStuiIconID iconId, IconSize iconSize = IconSize.Medium) + { + var size = GetSizeFromIconSize(iconSize); + var isLargeIcon = size.Width > 32; + return ExtractIcon(Libraries.CompStui, (int)iconId, isLargeIcon); + } + + /// Extracts an icon from setupapi.dll using the specified icon ID and size. + /// The icon ID from SetupApiIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + public static Icon? ExtractIconFromSetupApi(int iconId, IconSize iconSize = IconSize.Medium) => ExtractIconFromSetupApiInternal((SetupApiIconID)iconId, iconSize); + + /// Extracts an icon from setupapi.dll using the specified icon ID and size. + /// The icon ID from SetupApiIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + internal static Icon? ExtractIconFromSetupApiInternal(SetupApiIconID iconId, IconSize iconSize = IconSize.Medium) + { + var size = GetSizeFromIconSize(iconSize); + var isLargeIcon = size.Width > 32; + return ExtractIcon(Libraries.SetupApi, (int)iconId, isLargeIcon); + } + + /// Extracts an icon from netshell.dll using the specified icon ID and size. + /// The icon ID from NetShellIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + public static Icon? ExtractIconFromNetShell(int iconId, IconSize iconSize = IconSize.Medium) => ExtractIconFromNetShellInternal((NetShellIconID)iconId, iconSize); + + /// Extracts an icon from netshell.dll using the specified icon ID and size. + /// The icon ID from NetShellIconID enum. + /// The size of the icon to extract. Defaults to Medium (32x32). + /// The extracted icon, or null if extraction fails. + internal static Icon? ExtractIconFromNetShellInternal(NetShellIconID iconId, IconSize iconSize = IconSize.Medium) + { + var size = GetSizeFromIconSize(iconSize); + var isLargeIcon = size.Width > 32; + return ExtractIcon(Libraries.NetShell, (int)iconId, isLargeIcon); + } + #endregion } \ No newline at end of file diff --git a/Source/Krypton Components/TestForm/IconExtractionTest.Designer.cs b/Source/Krypton Components/TestForm/IconExtractionTest.Designer.cs new file mode 100644 index 000000000..ed812103d --- /dev/null +++ b/Source/Krypton Components/TestForm/IconExtractionTest.Designer.cs @@ -0,0 +1,420 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac & Ahmed Abdelhameed et al. 2017 - 2025. All rights reserved. + * + */ +#endregion + +namespace TestForm; + +partial class IconExtractionTest +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.kryptonPanel1 = new Krypton.Toolkit.KryptonPanel(); + this.kryptonGroupBox2 = new Krypton.Toolkit.KryptonGroupBox(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.kpbShell32Search = new Krypton.Toolkit.KryptonPictureBox(); + this.klblShell32Search = new Krypton.Toolkit.KryptonLabel(); + this.kpbShell32Printer = new Krypton.Toolkit.KryptonPictureBox(); + this.klblShell32Printer = new Krypton.Toolkit.KryptonLabel(); + this.kpbShell32Network = new Krypton.Toolkit.KryptonPictureBox(); + this.klblShell32Network = new Krypton.Toolkit.KryptonLabel(); + this.kpbShell32RecycleBin = new Krypton.Toolkit.KryptonPictureBox(); + this.klblShell32RecycleBin = new Krypton.Toolkit.KryptonLabel(); + this.kpbShell32Computer = new Krypton.Toolkit.KryptonPictureBox(); + this.klblShell32Computer = new Krypton.Toolkit.KryptonLabel(); + this.kpbShell32Folder = new Krypton.Toolkit.KryptonPictureBox(); + this.klblShell32Folder = new Krypton.Toolkit.KryptonLabel(); + this.kryptonGroupBox1 = new Krypton.Toolkit.KryptonGroupBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.kpbImageresUser = new Krypton.Toolkit.KryptonPictureBox(); + this.klblImageresUser = new Krypton.Toolkit.KryptonLabel(); + this.kpbImageresLock = new Krypton.Toolkit.KryptonPictureBox(); + this.klblImageresLock = new Krypton.Toolkit.KryptonLabel(); + this.kpbImageresShield = new Krypton.Toolkit.KryptonPictureBox(); + this.klblImageresShield = new Krypton.Toolkit.KryptonLabel(); + this.kryptonLabel1 = new Krypton.Toolkit.KryptonLabel(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).BeginInit(); + this.kryptonPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox2.Panel)).BeginInit(); + this.kryptonGroupBox2.Panel.SuspendLayout(); + this.kryptonGroupBox2.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Search)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Printer)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Network)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32RecycleBin)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Computer)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Folder)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1.Panel)).BeginInit(); + this.kryptonGroupBox1.Panel.SuspendLayout(); + this.kryptonGroupBox1.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kpbImageresUser)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbImageresLock)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbImageresShield)).BeginInit(); + this.SuspendLayout(); + // + // kryptonPanel1 + // + this.kryptonPanel1.Controls.Add(this.kryptonGroupBox2); + this.kryptonPanel1.Controls.Add(this.kryptonGroupBox1); + this.kryptonPanel1.Controls.Add(this.kryptonLabel1); + this.kryptonPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.kryptonPanel1.Location = new System.Drawing.Point(0, 0); + this.kryptonPanel1.Name = "kryptonPanel1"; + this.kryptonPanel1.Size = new System.Drawing.Size(884, 461); + this.kryptonPanel1.TabIndex = 0; + // + // kryptonGroupBox2 + // + this.kryptonGroupBox2.Location = new System.Drawing.Point(12, 212); + this.kryptonGroupBox2.Name = "kryptonGroupBox2"; + // + // kryptonGroupBox2.Panel + // + this.kryptonGroupBox2.Panel.Controls.Add(this.tableLayoutPanel2); + this.kryptonGroupBox2.Size = new System.Drawing.Size(860, 237); + this.kryptonGroupBox2.TabIndex = 2; + this.kryptonGroupBox2.Values.Heading = "Shell32.dll Icons"; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.ColumnCount = 6; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel2.Controls.Add(this.kpbShell32Search, 5, 0); + this.tableLayoutPanel2.Controls.Add(this.klblShell32Search, 5, 1); + this.tableLayoutPanel2.Controls.Add(this.kpbShell32Printer, 4, 0); + this.tableLayoutPanel2.Controls.Add(this.klblShell32Printer, 4, 1); + this.tableLayoutPanel2.Controls.Add(this.kpbShell32Network, 3, 0); + this.tableLayoutPanel2.Controls.Add(this.klblShell32Network, 3, 1); + this.tableLayoutPanel2.Controls.Add(this.kpbShell32RecycleBin, 2, 0); + this.tableLayoutPanel2.Controls.Add(this.klblShell32RecycleBin, 2, 1); + this.tableLayoutPanel2.Controls.Add(this.kpbShell32Computer, 1, 0); + this.tableLayoutPanel2.Controls.Add(this.klblShell32Computer, 1, 1); + this.tableLayoutPanel2.Controls.Add(this.kpbShell32Folder, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.klblShell32Folder, 0, 1); + this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 2; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 70F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(856, 209); + this.tableLayoutPanel2.TabIndex = 0; + // + // kpbShell32Search + // + this.kpbShell32Search.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kpbShell32Search.Location = new System.Drawing.Point(752, 41); + this.kpbShell32Search.Name = "kpbShell32Search"; + this.kpbShell32Search.Size = new System.Drawing.Size(64, 64); + this.kpbShell32Search.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.kpbShell32Search.TabIndex = 11; + this.kpbShell32Search.TabStop = false; + // + // klblShell32Search + // + this.klblShell32Search.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.klblShell32Search.Location = new System.Drawing.Point(729, 146); + this.klblShell32Search.Name = "klblShell32Search"; + this.klblShell32Search.Size = new System.Drawing.Size(110, 26); + this.klblShell32Search.TabIndex = 10; + this.klblShell32Search.Values.Text = "Search"; + // + // kpbShell32Printer + // + this.kpbShell32Printer.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kpbShell32Printer.Location = new System.Drawing.Point(610, 41); + this.kpbShell32Printer.Name = "kpbShell32Printer"; + this.kpbShell32Printer.Size = new System.Drawing.Size(64, 64); + this.kpbShell32Printer.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.kpbShell32Printer.TabIndex = 9; + this.kpbShell32Printer.TabStop = false; + // + // klblShell32Printer + // + this.klblShell32Printer.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.klblShell32Printer.Location = new System.Drawing.Point(592, 146); + this.klblShell32Printer.Name = "klblShell32Printer"; + this.klblShell32Printer.Size = new System.Drawing.Size(100, 26); + this.klblShell32Printer.TabIndex = 8; + this.klblShell32Printer.Values.Text = "Printer"; + // + // kpbShell32Network + // + this.kpbShell32Network.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kpbShell32Network.Location = new System.Drawing.Point(468, 41); + this.kpbShell32Network.Name = "kpbShell32Network"; + this.kpbShell32Network.Size = new System.Drawing.Size(64, 64); + this.kpbShell32Network.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.kpbShell32Network.TabIndex = 7; + this.kpbShell32Network.TabStop = false; + // + // klblShell32Network + // + this.klblShell32Network.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.klblShell32Network.Location = new System.Drawing.Point(446, 146); + this.klblShell32Network.Name = "klblShell32Network"; + this.klblShell32Network.Size = new System.Drawing.Size(108, 26); + this.klblShell32Network.TabIndex = 6; + this.klblShell32Network.Values.Text = "Network"; + // + // kpbShell32RecycleBin + // + this.kpbShell32RecycleBin.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kpbShell32RecycleBin.Location = new System.Drawing.Point(326, 41); + this.kpbShell32RecycleBin.Name = "kpbShell32RecycleBin"; + this.kpbShell32RecycleBin.Size = new System.Drawing.Size(64, 64); + this.kpbShell32RecycleBin.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.kpbShell32RecycleBin.TabIndex = 5; + this.kpbShell32RecycleBin.TabStop = false; + // + // klblShell32RecycleBin + // + this.klblShell32RecycleBin.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.klblShell32RecycleBin.Location = new System.Drawing.Point(294, 146); + this.klblShell32RecycleBin.Name = "klblShell32RecycleBin"; + this.klblShell32RecycleBin.Size = new System.Drawing.Size(128, 26); + this.klblShell32RecycleBin.TabIndex = 4; + this.klblShell32RecycleBin.Values.Text = "Recycle Bin"; + // + // kpbShell32Computer + // + this.kpbShell32Computer.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kpbShell32Computer.Location = new System.Drawing.Point(184, 41); + this.kpbShell32Computer.Name = "kpbShell32Computer"; + this.kpbShell32Computer.Size = new System.Drawing.Size(64, 64); + this.kpbShell32Computer.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.kpbShell32Computer.TabIndex = 3; + this.kpbShell32Computer.TabStop = false; + // + // klblShell32Computer + // + this.klblShell32Computer.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.klblShell32Computer.Location = new System.Drawing.Point(157, 146); + this.klblShell32Computer.Name = "klblShell32Computer"; + this.klblShell32Computer.Size = new System.Drawing.Size(118, 26); + this.klblShell32Computer.TabIndex = 2; + this.klblShell32Computer.Values.Text = "Computer"; + // + // kpbShell32Folder + // + this.kpbShell32Folder.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kpbShell32Folder.Location = new System.Drawing.Point(42, 41); + this.kpbShell32Folder.Name = "kpbShell32Folder"; + this.kpbShell32Folder.Size = new System.Drawing.Size(64, 64); + this.kpbShell32Folder.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.kpbShell32Folder.TabIndex = 1; + this.kpbShell32Folder.TabStop = false; + // + // klblShell32Folder + // + this.klblShell32Folder.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.klblShell32Folder.Location = new System.Drawing.Point(30, 146); + this.klblShell32Folder.Name = "klblShell32Folder"; + this.klblShell32Folder.Size = new System.Drawing.Size(88, 26); + this.klblShell32Folder.TabIndex = 0; + this.klblShell32Folder.Values.Text = "Folder"; + // + // kryptonGroupBox1 + // + this.kryptonGroupBox1.Location = new System.Drawing.Point(12, 49); + this.kryptonGroupBox1.Name = "kryptonGroupBox1"; + // + // kryptonGroupBox1.Panel + // + this.kryptonGroupBox1.Panel.Controls.Add(this.tableLayoutPanel1); + this.kryptonGroupBox1.Size = new System.Drawing.Size(860, 157); + this.kryptonGroupBox1.TabIndex = 1; + this.kryptonGroupBox1.Values.Heading = "Imageres.dll Icons"; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel1.Controls.Add(this.kpbImageresUser, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.klblImageresUser, 2, 1); + this.tableLayoutPanel1.Controls.Add(this.kpbImageresLock, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.klblImageresLock, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.kpbImageresShield, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.klblImageresShield, 0, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 2; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 70F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 30F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(856, 129); + this.tableLayoutPanel1.TabIndex = 0; + // + // kpbImageresUser + // + this.kpbImageresUser.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kpbImageresUser.Location = new System.Drawing.Point(681, 11); + this.kpbImageresUser.Name = "kpbImageresUser"; + this.kpbImageresUser.Size = new System.Drawing.Size(64, 64); + this.kpbImageresUser.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.kpbImageresUser.TabIndex = 5; + this.kpbImageresUser.TabStop = false; + // + // klblImageresUser + // + this.klblImageresUser.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.klblImageresUser.Location = new System.Drawing.Point(673, 90); + this.klblImageresUser.Name = "klblImageresUser"; + this.klblImageresUser.Size = new System.Drawing.Size(80, 26); + this.klblImageresUser.TabIndex = 4; + this.klblImageresUser.Values.Text = "User"; + // + // kpbImageresLock + // + this.kpbImageresLock.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kpbImageresLock.Location = new System.Drawing.Point(396, 11); + this.kpbImageresLock.Name = "kpbImageresLock"; + this.kpbImageresLock.Size = new System.Drawing.Size(64, 64); + this.kpbImageresLock.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.kpbImageresLock.TabIndex = 3; + this.kpbImageresLock.TabStop = false; + // + // klblImageresLock + // + this.klblImageresLock.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.klblImageresLock.Location = new System.Drawing.Point(395, 90); + this.klblImageresLock.Name = "klblImageresLock"; + this.klblImageresLock.Size = new System.Drawing.Size(66, 26); + this.klblImageresLock.TabIndex = 2; + this.klblImageresLock.Values.Text = "Lock"; + // + // kpbImageresShield + // + this.kpbImageresShield.Anchor = System.Windows.Forms.AnchorStyles.None; + this.kpbImageresShield.Location = new System.Drawing.Point(111, 11); + this.kpbImageresShield.Name = "kpbImageresShield"; + this.kpbImageresShield.Size = new System.Drawing.Size(64, 64); + this.kpbImageresShield.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; + this.kpbImageresShield.TabIndex = 1; + this.kpbImageresShield.TabStop = false; + // + // klblImageresShield + // + this.klblImageresShield.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.klblImageresShield.Location = new System.Drawing.Point(102, 90); + this.klblImageresShield.Name = "klblImageresShield"; + this.klblImageresShield.Size = new System.Drawing.Size(81, 26); + this.klblImageresShield.TabIndex = 0; + this.klblImageresShield.Values.Text = "Shield"; + // + // kryptonLabel1 + // + this.kryptonLabel1.LabelStyle = Krypton.Toolkit.LabelStyle.TitleControl; + this.kryptonLabel1.Location = new System.Drawing.Point(12, 12); + this.kryptonLabel1.Name = "kryptonLabel1"; + this.kryptonLabel1.Size = new System.Drawing.Size(352, 35); + this.kryptonLabel1.TabIndex = 0; + this.kryptonLabel1.Values.Text = "Icon Extraction Demo"; + // + // IconExtractionTest + // + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(884, 461); + this.Controls.Add(this.kryptonPanel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "IconExtractionTest"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Icon Extraction Test - Imageres.dll and Shell32.dll"; + this.Load += new System.EventHandler(this.IconExtractionTest_Load); + ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).EndInit(); + this.kryptonPanel1.ResumeLayout(false); + this.kryptonPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox2.Panel)).EndInit(); + this.kryptonGroupBox2.Panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox2)).EndInit(); + this.kryptonGroupBox2.ResumeLayout(false); + this.tableLayoutPanel2.ResumeLayout(false); + this.tableLayoutPanel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Search)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Printer)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Network)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32RecycleBin)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Computer)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbShell32Folder)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1.Panel)).EndInit(); + this.kryptonGroupBox1.Panel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.kryptonGroupBox1)).EndInit(); + this.kryptonGroupBox1.ResumeLayout(false); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.kpbImageresUser)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbImageresLock)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.kpbImageresShield)).EndInit(); + this.ResumeLayout(false); + } + + #endregion + + private KryptonPanel kryptonPanel1; + private KryptonLabel kryptonLabel1; + private KryptonGroupBox kryptonGroupBox1; + private TableLayoutPanel tableLayoutPanel1; + private KryptonPictureBox kpbImageresShield; + private KryptonLabel klblImageresShield; + private KryptonPictureBox kpbImageresLock; + private KryptonLabel klblImageresLock; + private KryptonPictureBox kpbImageresUser; + private KryptonLabel klblImageresUser; + private KryptonGroupBox kryptonGroupBox2; + private TableLayoutPanel tableLayoutPanel2; + private KryptonPictureBox kpbShell32Folder; + private KryptonLabel klblShell32Folder; + private KryptonPictureBox kpbShell32Computer; + private KryptonLabel klblShell32Computer; + private KryptonPictureBox kpbShell32RecycleBin; + private KryptonLabel klblShell32RecycleBin; + private KryptonPictureBox kpbShell32Network; + private KryptonLabel klblShell32Network; + private KryptonPictureBox kpbShell32Printer; + private KryptonLabel klblShell32Printer; + private KryptonPictureBox kpbShell32Search; + private KryptonLabel klblShell32Search; +} + diff --git a/Source/Krypton Components/TestForm/IconExtractionTest.cs b/Source/Krypton Components/TestForm/IconExtractionTest.cs new file mode 100644 index 000000000..4c9ed0209 --- /dev/null +++ b/Source/Krypton Components/TestForm/IconExtractionTest.cs @@ -0,0 +1,103 @@ +#region BSD License +/* + * + * New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE) + * Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), Giduac & Ahmed Abdelhameed et al. 2017 - 2025. All rights reserved. + * + */ +#endregion + +namespace TestForm; + +public partial class IconExtractionTest : KryptonForm +{ + public IconExtractionTest() + { + InitializeComponent(); + } + + private void IconExtractionTest_Load(object sender, EventArgs e) + { + LoadImageresIcons(); + LoadShell32Icons(); + } + + private void LoadImageresIcons() + { + // Extract UAC Shield icon from imageres.dll + var shieldIcon = GraphicsExtensions.ExtractIconFromImageres((int)ImageresIconID.Shield, IconSize.ExtraLarge); + if (shieldIcon != null) + { + kpbImageresShield.Image = shieldIcon.ToBitmap(); + klblImageresShield.Text = "Shield (imageres.dll)"; + } + + // Extract Lock icon from imageres.dll + var lockIcon = GraphicsExtensions.ExtractIconFromImageres((int)ImageresIconID.Lock, IconSize.ExtraLarge); + if (lockIcon != null) + { + kpbImageresLock.Image = lockIcon.ToBitmap(); + klblImageresLock.Text = "Lock (imageres.dll)"; + } + + // Extract User icon from imageres.dll + var userIcon = GraphicsExtensions.ExtractIconFromImageres((int)ImageresIconID.User, IconSize.ExtraLarge); + if (userIcon != null) + { + kpbImageresUser.Image = userIcon.ToBitmap(); + klblImageresUser.Text = "User (imageres.dll)"; + } + } + + private void LoadShell32Icons() + { + // Extract Folder icon from shell32.dll + var folderIcon = GraphicsExtensions.ExtractIconFromShell32((int)Shell32IconID.Folder, IconSize.ExtraLarge); + if (folderIcon != null) + { + kpbShell32Folder.Image = folderIcon.ToBitmap(); + klblShell32Folder.Text = "Folder (shell32.dll)"; + } + + // Extract Computer icon from shell32.dll + var computerIcon = GraphicsExtensions.ExtractIconFromShell32((int)Shell32IconID.Computer, IconSize.ExtraLarge); + if (computerIcon != null) + { + kpbShell32Computer.Image = computerIcon.ToBitmap(); + klblShell32Computer.Text = "Computer (shell32.dll)"; + } + + // Extract Recycle Bin icon from shell32.dll + var recycleBinIcon = GraphicsExtensions.ExtractIconFromShell32((int)Shell32IconID.RecycleBinEmpty, IconSize.ExtraLarge); + if (recycleBinIcon != null) + { + kpbShell32RecycleBin.Image = recycleBinIcon.ToBitmap(); + klblShell32RecycleBin.Text = "Recycle Bin (shell32.dll)"; + } + + // Extract Network icon from shell32.dll + var networkIcon = GraphicsExtensions.ExtractIconFromShell32((int)Shell32IconID.Network, IconSize.ExtraLarge); + if (networkIcon != null) + { + kpbShell32Network.Image = networkIcon.ToBitmap(); + klblShell32Network.Text = "Network (shell32.dll)"; + } + + // Extract Printer icon from shell32.dll + var printerIcon = GraphicsExtensions.ExtractIconFromShell32((int)Shell32IconID.Printer, IconSize.ExtraLarge); + if (printerIcon != null) + { + kpbShell32Printer.Image = printerIcon.ToBitmap(); + klblShell32Printer.Text = "Printer (shell32.dll)"; + } + + // Extract Search icon from shell32.dll + var searchIcon = GraphicsExtensions.ExtractIconFromShell32((int)Shell32IconID.Search, IconSize.ExtraLarge); + if (searchIcon != null) + { + kpbShell32Search.Image = searchIcon.ToBitmap(); + klblShell32Search.Text = "Search (shell32.dll)"; + } + } +} + From 801f9cc3ea5bfedffddca11317ff15a616977f2e Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Fri, 10 Oct 2025 09:03:02 +0100 Subject: [PATCH 2/5] Update CommandLinkTextValues.cs --- .../Krypton.Toolkit/Values/CommandLinkTextValues.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs b/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs index 04a55f256..d099bc3e8 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs @@ -15,7 +15,7 @@ public class CommandLinkTextValues : CaptionValues #region Static Fields private const string DEFAULT_HEADING = @"Krypton Command Link Button"; private const string DEFAULT_DESCRIPTION = @"Krypton Command Link Button ""Note Text"""; - private static readonly Image? DEFAULT_IMAGE = GraphicsExtensions.ScaleImage(GraphicsExtensions.ExtractIcon(Libraries.Shell32, 16805, true)?.ToBitmap(), 32, 32); + private static readonly Image? DEFAULT_IMAGE = GraphicsExtensions.ExtractIconFromShell32(16805, IconSize.Medium)?.ToBitmap(); #endregion #region Instance Fields From 2c47a26c486bda5979ef7ccd46023da2a7c59b4a Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Fri, 10 Oct 2025 09:03:43 +0100 Subject: [PATCH 3/5] Update CommandLinkTextValues.cs --- .../Krypton.Toolkit/Values/CommandLinkTextValues.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs b/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs index d099bc3e8..db4e56ee4 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs @@ -15,7 +15,7 @@ public class CommandLinkTextValues : CaptionValues #region Static Fields private const string DEFAULT_HEADING = @"Krypton Command Link Button"; private const string DEFAULT_DESCRIPTION = @"Krypton Command Link Button ""Note Text"""; - private static readonly Image? DEFAULT_IMAGE = GraphicsExtensions.ExtractIconFromShell32(16805, IconSize.Medium)?.ToBitmap(); + private static readonly Image? DEFAULT_IMAGE = GraphicsExtensions.ExtractIconFromShell32(16805)?.ToBitmap(); #endregion #region Instance Fields From 808deaef147eceb878238e8b428be47bd0e03ef2 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Fri, 10 Oct 2025 09:10:52 +0100 Subject: [PATCH 4/5] Update CommandLinkTextValues.cs --- .../Krypton.Toolkit/Values/CommandLinkTextValues.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs b/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs index db4e56ee4..566f13b5c 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Values/CommandLinkTextValues.cs @@ -15,7 +15,7 @@ public class CommandLinkTextValues : CaptionValues #region Static Fields private const string DEFAULT_HEADING = @"Krypton Command Link Button"; private const string DEFAULT_DESCRIPTION = @"Krypton Command Link Button ""Note Text"""; - private static readonly Image? DEFAULT_IMAGE = GraphicsExtensions.ExtractIconFromShell32(16805)?.ToBitmap(); + private static readonly Image? DEFAULT_IMAGE = GraphicsExtensions.ExtractIconFromShell32(16805, IconSize.Large)?.ToBitmap(); #endregion #region Instance Fields From 7a7ef84f1603760cdc9a093fd5caa6c7a26d90e4 Mon Sep 17 00:00:00 2001 From: Peter Wagner Date: Fri, 10 Oct 2025 12:30:45 +0100 Subject: [PATCH 5/5] Update VisualMessageBoxForm.cs --- .../Controls Visuals/VisualMessageBoxForm.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMessageBoxForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMessageBoxForm.cs index bcfdffaca..43f2cb962 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMessageBoxForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualMessageBoxForm.cs @@ -147,7 +147,7 @@ private void UpdateIcon() SystemSounds.Hand.Play(); break; case KryptonMessageBoxIcon.Question: - _messageIcon.Image = MessageBoxImageResources.Question_Windows_11; + _messageIcon.Image = GraphicsExtensions.ExtractIconFromShell32(24, IconSize.Large)?.ToBitmap(); SystemSounds.Question.Play(); break; case KryptonMessageBoxIcon.SystemQuestion: @@ -155,7 +155,7 @@ private void UpdateIcon() SystemSounds.Question.Play(); break; case KryptonMessageBoxIcon.Exclamation: - _messageIcon.Image = MessageBoxImageResources.Warning_Windows_11; + _messageIcon.Image = GraphicsExtensions.ExtractIconFromShell32(161, IconSize.Large)?.ToBitmap(); SystemSounds.Exclamation.Play(); break; case KryptonMessageBoxIcon.SystemExclamation: @@ -163,7 +163,7 @@ private void UpdateIcon() SystemSounds.Exclamation.Play(); break; case KryptonMessageBoxIcon.Asterisk: - _messageIcon.Image = MessageBoxImageResources.Asterisk_Windows_11; + _messageIcon.Image = GraphicsExtensions.ExtractIconFromShell32(200, IconSize.Large)?.ToBitmap(); SystemSounds.Asterisk.Play(); break; case KryptonMessageBoxIcon.SystemAsterisk: