Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Build a simple browser for icons

Total Hit ( 2957)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


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:

Click here to copy the following block
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:

Click here to copy the following block
' 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


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.