dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Sep 11, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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 icon

Private 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 If
End Function
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date