Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
How to print a bitmap file
How to display Windows On-Screen Keyboard
Winsock: sending email messages (SMTP, port 25)
System Image List Viewer
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Printing Image File, programmatically set print page orientation to landscape
Using EnumPrinters function to enumerate locally installed printers
Creating the Save dialog box to specify the drive, directory, and name of a file to save
Custom HttpRequest class (WinHTTP)
How to convert a bitmap file to monochrome format (1 bpp)
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Mapping and disconnecting network drives
How to download a file from the FTP server using FtpGetFile
The window and its ancestors
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Custom FTP Class for Visual FoxPro application
Drawing Windows predefined bitmaps using the LoadBitmap functions
Displaying the associated icons and descriptions for files and folders
Displaying icons in the system tray (VFP9)
How to activate Windows Calculator
Sending email messages with Simple MAPI
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)

User rating: 10/10 (1 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: 10/10 (1 votes)
    Rate this code sample:
    • ~
    1637 bytes  
    Created: 2004-07-08 21:35:49  
    Modified: 2011-12-10 09:20:22  
    Visits in 7 days: 145  
    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-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.21.156.140)
    2.58 hrs.Example: 'Using the GetLogicalDriveStrings'
     
    Function group: 'Memory Management'
    2.8 hrs.Example: 'How to get Special Folders paths'
    3.92 hrs.
    Function group: 'Terminal Services'
     Example: 'Obtaining addresses for the adapters on the local computer (Win XP/2003/Vista)'
    Google
    Advertise here!