Using Win32 functions in Visual FoxPro Image Gallery
Message and Message Queue
..msdn
BroadcastSystemMessage
GetQueueStatus
MQCloseQueue
MQDeleteQueue
MQHandleToFormatName
MQOpenQueue
MQPathNameToFormatName
MQPurgeQueue
PeekMessage
PostMessage
PostQuitMessage
SendMessage
Code examples:
Accessing Adobe Reader 7.0 main menu from VFP application
Browsing Windows Known Folders (Special Folders)
Controlling master audio volume by sending WM_APPCOMMAND messages
Creating irregularly shaped FoxPro form using transparency color key
Detecting changes in connections to removable drives (VFP9)
Displaying hypertext links with the SysLink control (VFP9, Comctl32.dll)
Displaying the associated icons and descriptions for files and folders
Enumerating devices installed on the local machine
Extended MessageBox Class
How to change the name and the size of the font in the MessageBox dialog
How to control Adobe Reader 9.0 (SDI mode) from VFP application
How to disable the Windows Clipboard (VFP9)
How to drag a Form not using its Titlebar or Caption
How to draw custom Window Caption on FoxPro form
How to start the screen saver and how to find whether the screen saver is active
How to view icons stored in executable files (Icon Viewer) - II
How to view system icons for the classes installed on the local machine
Moving shortcut to a specified position on the Windows Desktop
Obtaining names and positions for shortcuts located on the Windows Desktop
Round FoxPro form
System Image List Viewer
Using Common Controls: the Header Control
Using Month Calendar Control (VFP9, Comctl32.dll)
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Using WM_COPYDATA for interprocess communication (VFP9)
Windows Shell Icons displayed and exported to ICO files (Vista)
Displaying the associated icons and descriptions for files and folders

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
Versions:
click to open
Before you begin:
When the list of files and folders is to be displayed inside a VFP form, the ListBox VFP control and the ListView ActiveX control are probably the first two candidates for the job.

The ListBox`s presentation style can only be described as the minimalistic :) , while the ListView shows items in much fancier manner, and can even accompany each file and folder with an icon.


And then one start thinking, where are those icons stored and how to put them to work?



See also:
  • System Image List Viewer
  • System Image List Viewer II
  • How to view system icons for the classes installed on the local machine
  • How to find an application associated with the file name
  • How to obtain Content-Type value for a file type from the System Registry
  • Finding the application, icon and friendly names associated with a file name
  •  
      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:
    • ~
    8677 bytes  
    Created: 2007-05-16 17:13:14  
    Modified: 2016-02-25 09:23:01  
    Visits in 7 days: 179  
    Listed functions:
    DestroyIcon
    GetDeviceCaps
    GetWindowDC
    GetWindowLong
    ReleaseDC
    SendMessage
    SetWindowLong
    SHGetFileInfo
    SystemParametersInfo
    Printer friendly API declarations
    My comment:
    Ouput produced by C# version of this code:



    * * *
    The associated icon and the description for each file type are stored in the Registry.

    To get these associates for DBF files, for example, the first step is to locate "HKEY_CLASSES_ROOT\.dbf" registry key. The default value for this key is "Visual.FoxPro.Table". Which means "HKEY_CLASSES_ROOT\Visual.FoxPro.Table" key must be located next.

    The latter has the default value "Microsoft Visual FoxPro Table", which is the actual description that the OS sticks to DBF file type.

    The "DefaultIcon" subkey for this key has value "C:\Program Files\Microsoft Visual FoxPro 9\vfp9.exe,-103". That means that Group Icon #103 resource exists in VFP9 executable.



    This resource contains several icons that the OS uses for representing Visual FoxPro DBF files whenever required; for example, when displaying list of files in Explorer window.

    A Resource Viewer shows this and other resources stored in VFP9 executable.



    In a similar way any other file type (read "file extension") can be traced to an icon+description pair.

    There is no single rule, and the ways of finding associations are tricky if not messy. Going this way would require rather extensive coding. Luckily, MS had bothered to hide the complexity of the process inside the SHGetFileInfo API call.

    nBufsize=1024
    cBuffer = REPLICATE(CHR(0), nBufsize)

    nFlags = BITOR(SHGFI_SYSICONINDEX, SHGFI_SMALLICON,;
                    SHGFI_ICON, SHGFI_TYPENAME,
                    SHGFI_USEFILEATTRIBUTES)

            nResult = SHGetFileInfo(m.cFilename,;
                    FILE_ATTRIBUTE_NORMAL,;
                    @cBuffer, nBufsize, nFlags)

    For the specified cFilename, the call above populates the SHFILEINFO structure with valuable information. That includes the description for the file type as well as the associated icon presented as the index in the System Image List.

    The OS creates the System Image List for each running process, with the process mainly responsible for populating the list with ListImage items via SHGetFileInfo calls and may be by some other means.

    This is how the handle to the System Image List (HIMAGELIST) can be obtained.

    cBuffer = REPLICATE(CHR(0), 1024)
    hSysImageList = SHGetFileInfo("", FILE_ATTRIBUTE_NORMAL,;
            @cBuffer, LEN(cBuffer),;
            BITOR(SHGFI_SYSICONINDEX, SHGFI_SMALLICON,;
                    SHGFI_ICON, SHGFI_TYPENAME,;
                    SHGFI_USEFILEATTRIBUTES))

    Such System Image List is very similar if not identical to the ImageList ActiveX control. That is why the list can be linked to Icons or SmallIcons property of a MS Common Control (ListView or TreeView) placed on VFP form, which hence allows this control to display images found in the System Image List.

    * * *
    As stated in MSDN, the SHGetFileInfo may not be the best way, even if the simplest, for retrieving associated icons.

    The IExtractIcon Interface performs this task better. The Shell uses nothing else bu the the IExtractIcon for retrieving icons when displaying the contents of a folder.

    * * *
    Calling AssocQueryString API provides yet another way of obtaining the path to the associated icon as well as so called friendly names for the application and the file.

    Finding the application, icon and friendly names associated with a file name
    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-2018 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.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.226.41.91)
    31 sec.Examples
    1.12 min.Function: 'WNetGetProviderName'
    Function group: 'Windows Networking'
    1.72 min.Solutions
    2.3 min.Function: 'GetCharABCWidths'
    Function group: 'Font and Text'
    2.9 min.Function: 'CeGlobalMemoryStatus'
    Function group: 'Remote Application Programming (RAPI)'
    3.53 min.
    6.73 min.Function: 'CreateEvent'
    Function group: 'Synchronization'
    18.99 hrs.Function: 'CreateCompatibleDC'
     Function: 'QueryPerformanceCounter'
     Function: 'StartDoc'
    Google
    Advertise here!