Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Obtaining names and positions for shortcuts located on the Windows Desktop
GDI+: Implementing image scrolling with inertia
Browsing Windows Known Folders (Special Folders)
Displaying dimmed window behind VFP top-level form
Displaying icons in the system tray (VFP9)
Detecting changes in connections to removable drives (VFP9)
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Moving shortcut to a specified position on the Windows Desktop
Enumerating devices installed on the local machine
Printing Image File, programmatically set print page orientation to landscape
Compressing and decompressing files with Windows API Runtime Library routines
How to find which fonts Windows uses for drawing captions, menus and message boxes
Switching between keyboard layouts
Winsock: resolving an address to a host name
How to control Adobe Reader 9.0 (SDI mode) from VFP application
How to display Windows On-Screen Keyboard
Disconnecting USB Mass Storage Device programmatically
Monitoring clipboard content changes (VFP9)
Custom GDI+ class
Generating random cryptographic keys
How to load a user profile
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)
Reading and setting system access privileges for the current process
How to enable the SE_SHUTDOWN_NAME privilege for the application
Windows Shell Icons displayed and exported to ICO files (Vista)

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
This code sample employs SHGetStockIconInfo Shell API function for retrieving information about system-defined Shell icons.

Here is a VFP form hosting ListView control with Windows Shell icons.

ICO files are neither created or required to run this code sample. For icons, the ListView connects directly to the system image list using icon index obtained through SHGetStockIconInfo call.

A Shell icon (actually any ICO resource from EXE or DLL file) can be stored to ICO file perfectly usable in VFP. Like this one, for example:

The Comment part down this page has more on it.

See also:
  • How to view icons stored in executable files
  • Displaying the associated icons and descriptions for files and folders
  • Converting image file to .ICO file
  • Storing DLL icon resources in image files
  • Storing DLL icon resources in .ICO files
  • Displaying icons in the system tray
  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    9786 bytes  
    Created: 2011-01-17 15:43:32  
    Modified: 2011-01-27 08:12:08  
    Visits in 7 days: 193  
    Listed functions:
    DestroyIcon
    GetWindowLong
    GlobalAlloc
    GlobalFree
    GlobalSize
    SendMessage
    SetWindowLong
    SHGetFileInfo
    SHGetStockIconInfo
    Printer friendly API declarations
    My comment:
    When switched to Report mode (View=3), the ListView control displays the resource file and ICO resource index for each icon displayed (szPath and iIcon members of SHSTOCKICONINFO structure).

    That reveals that Windows 7 stores Shell icons in at least 4 files residing in System32 directory:
  • Shell32.dll
  • Imageres.dll
  • Imagesp1.dll
  • Mydocs.dll

    With known resource file and resource index, saving a Shell icon to ICO file is an easy task.

    Here is another code sample on this web site that explains how. It defines VFP classes IconGroupResource and IconResource. The former creates ICO files holding multiple versions of the same icon (size & color depth vary). The latter creates ICO files holding a single icon version, for example 48x48, 8 bit.


    Selected Windows iconsDownload a small selection of Windows icons from System32\Imageres.dll library.


    The code below stores Imageres.dll Icon resources to ICO files.
    oIconGroups = CREATEOBJECT("IconGroups",;
            GETENV("SystemRoot") + "\system32\imageres.dll")

    oIconGroups.EnumIconGroupResources
    ? "Icon groups:", oIconGroups.Count

    LOCAL cTargetPath, nGroupIndex, nIconIndex
    cTargetPath = GETDIR("", "Select ICO files destination folder.")

    IF NOT EMPTY(m.cTargetPath)
            SET SAFETY OFF
            nGroupIndex = 0

            FOR EACH oIconGroup IN oIconGroups
                    oIconGroup.SaveToFile(cTargetPath +;
                            "groupicon_" + TRANSFORM(nGroupIndex) + ".ico")

                    nIconIndex = 0
                    FOR EACH oIcon IN oIconGroup.icons
                            oIcon.SaveToFile(cTargetPath +;
                                    "icon_" +;
                                    TRANSFORM(nGroupIndex) + "_" +;
                                    TRANSFORM(nIconIndex) + "_" +;
                                    TRANSFORM(oIcon.resid) + ".ico")

                            nIconIndex = nIconIndex + 1
                    NEXT
                    nGroupIndex = nGroupIndex + 1
            NEXT
            SET SAFETY ON
    ENDIF

    Storing DLL icon resources in .ICO files

    * * *
    Another Icon Viewer code sample on this web site reads icons directly from .EXE or .DLL file calling ExtractIcon and GetIconInfo functions. If pointed at Shell32.dll, that viewer displays even larger number of icons then the one presented.

    But the former has a deficiency. The Shell icons are retrieved based on their respective resource index in Shell32.dll. This index may fluctuate through OS versions. In contrast, the SHGetStockIconInfo uses OS-approved SHSTOCKICONID enumeration.
  • Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright 2001-2016 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.33), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.227.96.5)
    17 sec.Function: 'NetShareEnum'
    1.03 min.Example: 'How to retrieve adapter information for the local computer (including MAC address)'
    3.42 min.Example: 'Displaying dimmed window behind VFP top-level form'
    18.81 hrs.Function: 'FindText'
    1 day(s)
    Function group: 'Shell Functions'
     Example: 'Placing an arbitrary rectangular area of main VFP window on the Clipboard'
     Function: 'AVIFileExit'
    Function group: 'Windows Multimedia'
     Function: 'GetWindowPlacement'
    Function group: 'Window'
    2 day(s)Function: 'NetServerGetInfo'
    Function group: 'Network Management'
     Function: 'GdipNewInstalledFontCollection'
    Google
    Advertise here!