Using Win32 functions in Visual FoxPro Image Gallery
Shell Functions
..msdn
AssocQueryString
DllGetVersion
DragAcceptFiles
DragFinish
DragQueryFile
DragQueryPoint
FileIconInit
FindExecutable
GetFileNameFromBrowse
GetMenuContextHelpId
GetWindowContextHelpId
InetIsOffline
IsUserAnAdmin
LoadUserProfile
PathMakeUniqueName
PathYetAnotherMakeUniqueName
RealDriveType
RestartDialog
SHAddToRecentDocs
SHBrowseForFolder
SHCreateDirectory
ShellAbout
ShellExecute
ShellExecuteEx
Shell_GetImageLists
Shell_NotifyIcon
SHEmptyRecycleBin
SHFileOperation
SHFormatDrive
SHGetFileInfo
SHGetFolderPath
SHGetPathFromIDList
SHGetSpecialFolderLocation
SHGetStockIconInfo
SHParseDisplayName
SHQueryRecycleBin
SHSimpleIDListFromPath
UnloadUserProfile
WinHelp
Code examples:
Accessing Adobe Reader 7.0 main menu from VFP application
Accessing examples contained in this reference from a VFP application
Accessing examples contained in this reference through Web Services
Accessing Windows Control Panel from VFP Application
GDI+: converting text strings to images and saving in a graphics file
GDI+: creating a gradient
GDI+: creating scaled copy of image file
GDI+: cropping images
GDI+: Drawing a Pie Chart
How to access a file using not its name but an alias (hard link)
How to control Adobe Reader 9.0 (SDI mode) from VFP application
How to display Windows On-Screen Keyboard
Mapping and disconnecting network drives
Reading the structure of VFP main menu
Saving local machine ODBC Registry Entries to XML file
Storing content of the Clipboard to a bitmap file
Using Shell for performing operations on files
GDI+: creating scaled copy of image file

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:
The code creates source image object from an image file. It also creates empty destination bitmap object. Note that the Bitmap class is subclassed from the Image class. GDI+ flat API calls allow to use bitmap handles as if they were image handles.

Then the code uses the graphics of the destination bitmap both as a tool and canvas to draw the scaled source image on it. Finally the destination bitmap saves itself to file.

The code is based on custom GDI+ class. Download the class module first and save it in gdiplus.prg file.

Make sure the source and destination file names are valid. The source file can be in any of graphics formats supported by the GDI+: BMP, GIF, JPG, TIF, EMF... The destination file type is limited to BMP, JPG, GIF, PNG and TIFF.

See also:
  • GDI+: cropping images
  • GDI+: rotating images

  • SET PROCEDURE TO gdiplus ADDITIVE
    
    LOCAL cSrcFile, cDstFile, nScale, gdip As gdiplusinit,;
        src As gdiplus_image, dst as gdiplus_bitmap
    
    * an instance of gdiplusinit should be created before 
    * and released after using any of gdi+ objects
    gdip = CREATEOBJECT("gdiplusinit")
    
    cSrcFile = "c:\windows\forest.bmp"
    cDstFile = "d:\temp\test.png"
    nScale=4
    
    * creating Image object from the source file
    src = CREATEOBJECT("gdiimage", cSrcFile)
    
    IF src.himage = 0
        ? "Could not load source image file:",;
            src.errorcode
        RETURN
    ENDIF
    
    * creating destination Bitmap object,
    * setting its dimensions scaled from the source image file
    dst = CREATEOBJECT("gdibitmap",;
        src.imgwidth/nScale, src.imgheight/nScale)
    
    * drawing the source file using the graphics object 
    * of the destination Bitmap
    dst.graphics.DrawImage(src, 0,0,;
        src.imgwidth/nScale, src.imgheight/nScale)
    
    IF NOT dst.SaveToFile(cDstFile)
        ? "Error code:", dst.errorcode
    ELSE
    * using default application to open the file
        DECLARE INTEGER ShellExecute IN shell32;
            INTEGER hwnd, STRING lpOperation,;
            STRING lpFile, STRING lpParameters,; 
            STRING lpDirectory, INTEGER nShowCmd
    
        = ShellExecute(0, "open", cDstFile, "", "", 3)
    ENDIF
    
    
    

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1246 bytes  
    Created: 2004-07-27 10:28:48  
    Modified: 2007-03-06 18:57:59  
    Visits in 7 days: 48  
    Listed functions:
    ShellExecute
    Printer friendly API declarations
    My comment:
    .Net code: GetThumbnailImage works well when the requested thumbnail image has a size of about 120 x 120.
    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.55.151)
    20 sec.
    Function group: 'Power Management'
    39 sec.
    Function group: 'Hook'
    58 sec.Example: 'Quering a waveform-audio input device'
    1.65 min.Articles
    1.98 min.Function: 'LoadString'
    Function group: 'Resource'
    2.27 min.
    2.67 min.Function: 'CeSetFilePointer'
    Function group: 'Remote Application Programming (RAPI)'
    3 min.
    Function group: 'Dynamic-Link Library'
    3.35 min.Function: 'getservbyport'
    Function group: 'Windows Sockets 2 (Winsock)'
    4 min.Function: 'EndDoc'
    Function group: 'Printing and Print Spooler'
    Google
    Advertise here!