Build a simple browser for icons

Winodws uses a special browser to show all icons contained in a file and offers the end user the possibility to choose an icon from it. You can add this functionallity to your applications through an undocumented API function, SHChangeIconDialog. Its Declare is:

Declare Function SHChangeIconDialog Lib "shell32" Alias "#62" (ByVal hOwner As _    Long, ByVal szFilename As String, ByVal Reserved As Long, _    lpIconIndex As Long) As Long

The first argument is the dialog owner: you can specify 0 for desktop, in order to make it a top-level window. The second argument is the file that is initially displayed and opened. I didn’t find a use for the third argument, so you should consider it as “reserved” and always pass zero to it. Finally, the last argument is the index of the icon that will be selected when the dialog is opened.

The function returns 0 if the dialog is cancelled and non-zero in all other cases. When the function returns it stores the index of the selected incon in the last argument: you can use this index to extract the icon by using ExtractIconEx or whatelse you want. Here’s a routine tha encapsulates this functionality:

' Display an icon browser and return the index of the selected icon,' or -1 if the user didn't select any iconPrivate Function DoIconDialog (ByVal sFile as String, Byval nIndex as Long) As _    Long    If SHChangeIconDialog(Me.hWnd, StrConv(sFile, vbUnicode), 0, nIndex) Then        DoIconDialog = nIndex    Else        DoIconDialog = -1    End IfEnd Function

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may