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
Mapping and disconnecting network drives
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Winsock: sending email messages (SMTP, port 25)
How to display the Properties dialog box for a file (ShellExecuteEx)
Disk in drive A:
Using Font and Text functions
Detecting changes in connections to removable drives (VFP9)
How to download a file from the FTP server using FtpGetFile
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to play AVI file on the _screen
Using EnumPrinters function to enumerate locally installed printers
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Splash Screen for the VFP application
Subclassing CommandButton control to create BackColor property
Creating irregularly shaped FoxPro form using transparency color key
Vertical Label control
Converting Unicode data from the Clipboard to a character string using a given code page
Creating a console window for Visual FoxPro application
Enumerating network resources
GDI+: Storing content of the Clipboard to a bitmap 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 is based on custom GDI+ class. Download the class module first and save it in gdiplus.prg file.

Related code samples:
  • Storing content of the Clipboard to a bitmap file using GDI API
  • GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
  • Copying picture of the active form to the Clipboard using Bitmap API functions
  • Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
  • Storing screen shot of a form to a bitmap file

  •  
    SET PROCEDURE TO gdiplus ADDITIVE
    #DEFINE CF_BITMAP 2
    #DEFINE CF_DIB    8
    DO decl
     
    IF IsClipboardFormatAvailable(CF_DIB)=0
        = MESSAGEBOX("No image data found stored " +;
            "on the clipboard.   ")
        RETURN
    ENDIF
     
    * an instance of gdiplusinit should be created before
    * and released after using any of gdi+ objects
    PRIVATE gdiplus As gdiplusinit, img As gdibitmap
    gdiplus = CREATEOBJECT("gdiplusinit")
     
    = OpenClipboard(0)
     
    LOCAL bmp As gdibitmap, hBitmap, hDib, lResult
    hBitmap = GetClipboardData(CF_BITMAP)
    hDib = GetClipboardData(CF_DIB)
    bmp = CREATEOBJECT("gdibitmap")
     
    * use either of two ways to create an instance
    * of the gdibitmap object
    *lResult = bmp.CreateFromHBITMAP(hBitmap)
    lResult = bmp.CreateFromBITMAPINFO(hDib)
     
    IF lResult
    * make sure the target folder is valid 
    * uncomment one or more lines with savetofile 
    *!*        bmp.savetofile("c:\temp\tmp.jpg")
    *!*        bmp.savetofile("c:\temp\tmp.gif")
    *!*        bmp.savetofile("c:\temp\tmp.bmp")
    *!*        bmp.savetofile("c:\temp\tmp.tif")
    *!*        bmp.savetofile("c:\temp\tmp.png")
    ENDIF
     
    = CloseClipboard()
    * end of main
     
    PROCEDURE decl
        DECLARE INTEGER CloseClipboard IN user32 
        DECLARE INTEGER OpenClipboard IN user32 INTEGER hwnd 
        DECLARE INTEGER GetClipboardData IN user32 INTEGER uFormat
     
        DECLARE INTEGER IsClipboardFormatAvailable IN user32;
            INTEGER wFormat
     
     
     

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1358 bytes  
    Created: 2004-12-05 15:02:35  
    Modified: 2004-12-05 16:06:00  
    Visits in 7 days: 191  
    Listed functions:
    CloseClipboard
    GetClipboardData
    IsClipboardFormatAvailable
    OpenClipboard
    Printer friendly API declarations
    My comment:
    When an image is copied, most likely it creates on the clipboard at least three different blocks of data:
    - Bitmap handle (CF_BITMAP)
    - BITMAPINFO structure (CF_DIB)
    - BITMAPV5HEADER structure (CF_DIBV5)

    This code above retrieves data in CF_DIB format from the clipboard and passes it to the GdipCreateBitmapFromGdiDib function to create an instance of GDI+ bitmap object. This newly created object can be saved to a file, printed or painted on a window.

    The GetClipboardData returns a pointer to a memory object containing a BITMAPINFO structure followed by the bitmap bits.

    There is a simplification in the way the code treats the BITMAPINFO data. For some display resolutions, like 1, 4, 8 and rarely 16 bits per pixel, the BITMAPINFO structure may contain a color table. If you are able to use GDI+ and Visual FoxPro, most likely your display resolution does not require a presence of such color table in the BITMAPINFO structure. That is how this structure is believed to contain only 40 bytes occupied by BITMAPINFOHEADER data.

    * * *
    Same way the GetClipboardData call with CF_BITMAP as input parameter can retrieve a bitmap handle. This handle then can be passed to the GdipCreateBitmapFromHBITMAP function to create an instance of GDI+ bitmap object. This newly created object can be saved to a file, printed or painted on a window.
    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 (107.22.127.92)
    3.24 hrs.Function: 'OpenSCManager'
    Function group: 'Service'
     Example: 'Enumerating files opened on the network'
    12.07 hrs.Function: 'GetUserName'
    Function group: 'System Information'
     Function: 'HeapValidate'
    Function group: 'Memory Management'
    12.88 hrs.Function: 'GetTextFace'
     Example: 'Starting an external application in VFP using WinExec'
    16.84 hrs.Example: 'Connecting a local device to a network resource'
    16.85 hrs.Example: 'Using Font and Text functions'
     Example: 'Setting properties of the window: caption and user-defined value'
    19.64 hrs.Example: 'How to ping a remote site using ICMP API calls'
    Google
    Advertise here!