Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Custom GDI+ class
Winsock: sending email messages (SMTP, port 25)
Using EnumPrinters function to enumerate locally installed printers
Semi-transparent Form
Custom HttpRequest class (WinHTTP)
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
How to convert a bitmap file to monochrome format (1 bpp)
Custom HttpRequest class (WinINet)
Custom FTP Class for Visual FoxPro application
Compressing and decompressing files with Windows API Runtime Library routines
Printing Image File, programmatically set print page orientation to landscape
How to create MD-5 and SHA-1 hash values from a string
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
GDI+: Creating thumbnails to preview images in a directory
Adding icon to the systray (requires VFP9)
Extended MessageBox Class
How to ping a remote site using ICMP API calls
How to detect if additional monitor is connected and active
GDI+: Storing content of the Clipboard to a bitmap file
Transparent Menu Class (requires VFP9)
Using Month Calendar Control (VFP9, Comctl32.dll)
How to activate Windows Calculator
How to print FoxPro form
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)

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.

Make sure the target file name is valid. The target file can be created in several graphics format supported by the GDI+: BMP, GIF, JPG, TIF.

Call this code from a method or event of a FoxPro form when that form is active, i.e. posesses the keyboard focus.

See also:
  • GDI: Storing screen shot of a form to bitmap file
  • Printing the image of a FoxPro form
  • Storing clipboard contents to a BMP file
  • Using the LoadImage() to display a BMP file on the main VFP window
  • How to print a bitmap file

  •  
    SET PROCEDURE TO gdiplus ADDITIVE
    #DEFINE SRCCOPY  0x00CC0020
    DO decl
     
    * an instance of gdiplusinit should be created before
    * and released after using any of gdi+ objects
    PRIVATE gdiplus
    gdiplus = CREATEOBJECT("gdiplusinit")
     
    LOCAL hwindow, hdc, bmp, nWidth, nHeight
    hwindow = GetFocus()
    hdc = GetWindowDC(hwindow)
    STORE 0 TO nWidth, nHeight
    = GetWinRect(hwindow, @nWidth, @nHeight)
     
    bmp = CREATEOBJECT("gdibitmap", m.nWidth, m.nHeight)
    WITH bmp
        .graphics.GetDC
        = BitBlt(.graphics.hdc, 0,0, .imgwidth, .imgheight,;
            m.hdc, 0,0, SRCCOPY)
        .graphics.ReleaseDC
        .SaveToFile("d:\temp\vfp.tif")    
    ENDWITH
     
    = ReleaseDC(m.hwindow, m.hdc)
    * end of main
     
    PROCEDURE GetWinRect(hwindow, nWidth, nHeight)
    #DEFINE maxDword  0xffffffff
        LOCAL lpRect, nLeft, nTop, nRight, nBottom
        lpRect = REPLI (Chr(0), 16)
        = GetWindowRect (hwindow, @lpRect)
        nRight  = buf2dword(SUBSTR(lpRect, 9,4))
        nBottom = buf2dword(SUBSTR(lpRect, 13,4))
     
        nLeft = buf2dword(SUBSTR(lpRect, 1,4))
        IF nLeft > nRight
            nLeft = nLeft - maxDword
        ENDIF
        nTop = buf2dword(SUBSTR(lpRect, 5,4))
        IF nTop > nBottom
            nTop = nTop - maxDword
        ENDIF
        nWidth = nRight - nLeft
        nHeight = nBottom - nTop
    RETURN
     
    PROCEDURE decl
        DECLARE INTEGER GetFocus IN user32
        DECLARE INTEGER GetWindowDC IN user32 INTEGER hwindow
        DECLARE INTEGER ReleaseDC IN user32 INTEGER hwindow, INTEGER hdc
        DECLARE INTEGER GetWindowRect IN user32 INTEGER hwnd, STRING @lpRect 
     
        DECLARE INTEGER BitBlt IN gdi32;
            INTEGER hDestDC, INTEGER x, INTEGER y,;
            INTEGER nWidth, INTEGER nHeight, INTEGER hSrcDC,;
            INTEGER xSrc, INTEGER ySrc, INTEGER dwRop
     
     
     

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1637 bytes  
    Created: 2004-07-08 21:35:49  
    Modified: 2006-06-19 08:56:30  
    Visits in 7 days: 69  
    Listed functions:
    BitBlt
    GetFocus
    GetWindowDC
    GetWindowRect
    ReleaseDC
    Printer friendly API declarations
    My comment:


    #kwd: sln_gdiplus.
    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-2010 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.0.85), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (38.107.191.109)
    31.12 min.Example: 'Reading entries from Event logs'
    32.87 min.Function: 'DeleteDC'
    51.18 min.Function: 'GetEnvironmentStrings'
    Function group: 'Process and Thread'
    54.58 min.
    2 day(s)Function: 'waveInReset'
    Function group: 'Windows Multimedia'
     Function: 'WindowFromDC'
    Function group: 'Painting and Drawing'
     
    Function group: 'Clipboard'
     Function: 'midiOutShortMsg'
    Function group: 'Windows Multimedia'
     Function: 'midiOutReset'
    Function group: 'Windows Multimedia'
     Example: 'Get the power status of your laptop computer'
    Google
    Advertise here!