Using Win32 functions in Visual FoxPro Image Gallery
Device Context
..msdn
ChangeDisplaySettings
CreateCompatibleDC
CreateDC
DeleteDC
DeleteObject
EnumDisplayDevices
EnumDisplaySettings
GetDC
GetDeviceCaps
GetObject
GetObjectType
ReleaseDC
SelectObject
Code examples:
Bitmap Class for Visual FoxPro application
Converting twips to pixels and vice versa
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
Creating a clipping region from the path selected into the device context of a form
Creating a window using CreateWindowEx function
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Displaying bitmap using the AlphaBlend function
Displaying the associated icons and descriptions for files and folders
Drawing a rectangle using Windows regular edges and borders
Drawing a window caption using the DrawCaption routine
Drawing cursors for the classes defined by the system (preregistered): BUTTON, EDIT, LISTBOX etc.
Drawing icons associated with the VFP main window
Drawing standard Windows icons
Drawing Windows frame controls using the DrawFrameControl function
Drawing Windows predefined bitmaps using the LoadBitmap functions
Form Magnifier
GDI+ fun: roach-infested desktop
GDI+: Color Transparency
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
GDI+: Creating thumbnails to preview images in a directory
GDI+: how to make VFP controls visually shake and shudder
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
GDI+: Scrolling through large image using the mouse
GDI+: sending image of FoxPro form to printer
How to change the name and the size of the font in the MessageBox dialog
How to copy the image of a form to the Clipboard using Bitmap API functions
How to display picture stored in enhanced-format metafile (*.emf)
How to find which fonts Windows uses for drawing captions, menus and message boxes
How to make a VFP form fading out when released (GDI version)
How to make a VFP form fading out when released (GDI+ version)
How to play AVI file on the _screen
How to print a bitmap file
How to print FoxPro form
How to print FoxPro form -- II
How to print picture stored in enhanced-format metafile (*.emf)
How to put a horizontal text scrolling on the form (a news line)
How to put a vertical text scrolling on the form (a movie cast)
How to view icons stored in executable files (Icon Viewer)
How to view icons stored in executable files (Icon Viewer) - II
Obtaining the bounding rectangle for the specified device context
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Placing On-screen Alert on top of all windows
Printing text on the client area of the main VFP window
Printing text on the main VFP window
Printing text with the Escape function
Reading metrics for the currently selected font
Retrieving graphic capabilities of your display
Splash Screen for the VFP application
Storing content of the Clipboard to a bitmap file
Storing screen shot of a form to bitmap file
Storing screen shot of a form to enhanced metafile (*.emf)
Subclassing CommandButton control to create BackColor property
Using Font and Text functions
Using FrameRgn for displaying system colors
Using GetNearestColor
Using the DrawText function
Using the GradientFill function
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Vertical Label control
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: 119  
    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 (50.19.155.235)
    3 sec.Example: 'Using Beep and Sleep functions to make the old tin buzz sing (WinNT only?)'
    6 sec.Example: 'How to create MD-5 and SHA-1 hash values from a string'
    1.3 hrs.Example: 'Using an Event Object. Part A: running an application that creates an Event object'
     Function: 'AlphaBlend'
    4.68 hrs.Example: 'How to view system icons for the classes installed on the local machine'
     Example: 'How to print FoxPro form -- II'
    5.84 hrs.Example: 'Winsock: how to retrieve a service information corresponding to a port'
    6.65 hrs.Function: 'DeletePort'
     Example: 'Converting command-line string to a set of Unicode argument strings (WinNT only)'
     Function: 'EndUpdateResource'
    Google
    Advertise here!