Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Enumerating data formats currently available on the clipboard
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Mapping and disconnecting network drives
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Winsock: sending email messages (SMTP, port 25)
How to display the Properties dialog box for a file (ShellExecuteEx)
Disk in drive A:
Detecting changes in connections to removable drives (VFP9)
Using Font and Text functions
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to download a file from the FTP server using FtpGetFile
How to play AVI file on the _screen
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Using EnumPrinters function to enumerate locally installed printers
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Creating irregularly shaped FoxPro form using transparency color key
Splash Screen for the VFP application
Subclassing CommandButton control to create BackColor property
Vertical Label control
Converting Unicode data from the Clipboard to a character string using a given code page
Enumerating network resources
Creating a console window for Visual FoxPro application
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: 2012-10-13 14:27:58  
    Visits in 7 days: 83  
    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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.234.231.49)
    1.51 hrs.Function: 'CeGetFileSize'
    Function group: 'Remote Application Programming (RAPI)'
     Example: 'Setting the mouse capture to the specified window'
    2.54 hrs.Solution: 'Extended MessageBox library (FLL) for Visual FoxPro'
     Function: 'SQLNativeSql'
    Function group: 'ODBC API'
     Example: 'Capturing keyboard activity of another application with the Raw Input API (VFP9)'
    3.47 hrs.Example: 'Opening access to the Microsoft Internet functions for the application'
    3.48 hrs.Example: 'Using Common Controls: the Header Control'
    4.17 hrs.Example: 'Running a regular FoxPro form while main VFP window is minimized'
     Function: 'CeWriteRecordProps'
    Function group: 'Remote Application Programming (RAPI)'
    6.19 hrs.Example: 'Storing screen shot of a form to enhanced metafile (*.emf)'
    Google
    Advertise here!