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+: cropping images

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:
The code is based on custom GDI+ class. Download the class module first and save it in gdiplus.prg file.


See also:
  • GDI+: creating scaled copy of image file
  • GDI+: rotating images

  • SET PROCEDURE TO gdiplus ADDITIVE
    
    * an instance of gdiplusinit should be created before 
    * and released after using any of gdi+ objects
    LOCAL gdip
    gdip = CREATEOBJECT("gdiplusinit")
    
    * source and target files
    LOCAL cSrcFile, cDstFile
    cSrcFile = "c:\windows\forest.bmp"
    cDstFile = SYS(2023) + "\test.jpg"
    
    *create Image object from the source file
    LOCAL src As gdiimage
    src = CREATEOBJECT("gdiimage", cSrcFile)
    IF src.himage = 0
        ? "Could not load source image file."
        RETURN
    ENDIF
    
    * set crop coordinates and dimensions
    LOCAL cropLeft, cropTop, cropWidth, cropHeight
    cropLeft = 10
    cropTop = 80
    cropWidth = src.imgwidth - m.cropLeft
    cropHeight = 60
    
    * create destination Bitmap object using crop dimensions
    LOCAL dst As gdibitmap
    dst = CREATEOBJECT("gdibitmap", m.cropWidth, m.cropHeight)
    
    * draw source image on the target bitmap;
    * note how coordinates and dimensions are set 
    dst.graphics.DrawImage(src, -m.cropLeft, -m.cropTop,;
        src.imgwidth, src.imgheight)
    
    IF NOT dst.SaveToFile(cDstFile)
        ? "Could not save file", cDstFile
    ELSE
    * open the file using default application
        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:
    • ~
    1352 bytes  
    Created: 2006-05-17 17:47:28  
    Modified: 2007-03-06 18:57:02  
    Visits in 7 days: 44  
    Listed functions:
    ShellExecute
    Printer friendly API declarations
    My comment:
    Initially I used the GdipDrawImageI to draw a part of the source image on target bitmap. A difference in resolutions (DPI) between them often caused dimension issues. So finally I decided to use the GdipDrawImageRectI for cropping.
    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.227.17.101)
    21 sec.
    Function group: 'GDI+ Font'
    44 sec.Function: 'MAPIFindNext'
    Function group: 'Simple MAPI'
    1.07 min.Function: 'WSARecv'
    Function group: 'Windows Sockets 2 (Winsock)'
    1.43 min.Function: 'LoadUserProfile'
    Function group: 'Shell Functions'
    2.15 min.Function: 'SQLGetPrivateProfileString'
    Function group: 'ODBC API'
    2.5 min.Function: 'GetThreadLocale'
    2.88 min.Function: 'PathYetAnotherMakeUniqueName'
    Function group: 'Shell Functions'
    3.18 min.Example: 'Monitoring clipboard content changes (VFP9)'
    3.65 min.Function: 'MAPIAddress'
    Function group: 'Simple MAPI'
    4 min.Function: 'WSAStartup'
    Function group: 'Windows Sockets 2 (Winsock)'
    Google
    Advertise here!