Using Win32 functions in Visual FoxPro Image Gallery
Device Context
..msdn
ChangeDisplaySettings
CreateCompatibleDC
CreateDC
DeleteDC
DeleteObject
EnumDisplayDevices
EnumDisplaySettings
GetDC
GetDeviceCaps
GetObject
GetObjectType
ReleaseDC
SelectObject
Code examples:
Bitmap Class for Visual FoxPro application
Converting twips to pixels and vice versa
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
Creating a clipping region from the path selected into the device context of a form
Creating a window using CreateWindowEx function
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
Displaying bitmap using the AlphaBlend function
Displaying the associated icons and descriptions for files and folders
Drawing a rectangle using Windows regular edges and borders
Drawing a window caption using the DrawCaption routine
Drawing cursors for the classes defined by the system (preregistered): BUTTON, EDIT, LISTBOX etc.
Drawing icons associated with the VFP main window
Drawing standard Windows icons
Drawing Windows frame controls using the DrawFrameControl function
Drawing Windows predefined bitmaps using the LoadBitmap functions
Form Magnifier
GDI+ fun: roach-infested desktop
GDI+: Color Transparency
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
GDI+: Creating thumbnails to preview images in a directory
GDI+: custom control, base class
GDI+: how to make VFP controls visually shake and shudder
GDI+: Implementing image scrolling with inertia
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
GDI+: Scrolling through large image using the mouse
GDI+: sending image of FoxPro form to printer
How to change the name and the size of the font in the MessageBox dialog
How to copy the image of a form to the Clipboard using Bitmap API functions
How to display picture stored in enhanced-format metafile (*.emf)
How to find which fonts Windows uses for drawing captions, menus and message boxes
How to make a VFP form fading out when released (GDI version)
How to make a VFP form fading out when released (GDI+ version)
How to play AVI file on the _screen
How to print a bitmap file
How to print FoxPro form
How to print FoxPro form -- II
How to print picture stored in enhanced-format metafile (*.emf)
How to put a horizontal text scrolling on the form (a news line, marquee)
How to put a vertical text scrolling on the form (a movie cast)
How to view icons stored in executable files (Icon Viewer)
How to view icons stored in executable files (Icon Viewer) - II
Obtaining the bounding rectangle for the specified device context
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Placing On-screen Alert on top of all windows
Printing text on the client area of the main VFP window
Printing text on the main VFP window
Printing text with the Escape function
Reading metrics for the currently selected font
Retrieving graphic capabilities of your display
Splash Screen for the VFP application
Storing content of the Clipboard to a bitmap file
Storing screen shot of a form to bitmap file
Storing screen shot of a form to enhanced metafile (*.emf)
Subclassing CommandButton control to create BackColor property
Using Font and Text functions
Using FrameRgn for displaying system colors
Using GetNearestColor
Using the DrawText function
Using the GradientFill function
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Vertical Label control
GDI+: sending image of FoxPro form to printer

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.

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:

Download ScreenCapture Library

  • How to print FoxPro form
  • How to print FoxPro form -- II (using metafile)
  • Storing screen shot of a form to a BMP file
  • Storing clipboard contents to a BMP 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
    ENDWITH
    
    LOCAL hPrnDC, gdip, docinfo
    hPrnDC = GetPrnDC()
    gdip = CREATEOBJECT("graphics", hPrnDC)
    
    docinfo = PADR(CHR(20), 20, CHR(0))
    = StartDoc(m.hPrnDC, m.docinfo)
    = StartPage(m.hPrnDC)
    WITH gdip
        * note that the actual printing is scaled
        .DrawImage(bmp, 20,20,;
            bmp.imgwidth/2, bmp.imgheight/2)
    
    *    .DrawImage(bmp, 20,20)
    ENDWITH
    = EndPage(m.hPrnDC)
    = EndDoc(m.hPrnDC)
    = DeleteDC(m.hPrnDC)
    = 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
    
    FUNCTION GetPrnDC
    * returns device context of default printer
    #DEFINE PD_RETURNDC      0x100
    #DEFINE PD_RETURNDEFAULT 0x400
        LOCAL lcStruct, lnFlags
        lnFlags = PD_RETURNDEFAULT + PD_RETURNDC
    
        lcStruct = num2dword(66) + Repli(Chr(0), 16) +;
            num2dword(lnFlags) + Repli(Chr(0), 42)
        IF PrintDlg(@lcStruct) <> 0
            RETURN buf2dword (SUBSTR(lcStruct, 17,4))
        ENDIF
    RETURN 0
    
    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 DeleteDC IN gdi32 INTEGER hdc
        DECLARE INTEGER PrintDlg IN comdlg32 STRING @ lppd
        DECLARE INTEGER StartPage IN gdi32 INTEGER hdc
        DECLARE INTEGER EndPage IN gdi32 INTEGER hdc
        DECLARE INTEGER EndDoc IN gdi32 INTEGER hdc
        DECLARE INTEGER StartDoc IN gdi32 INTEGER hdc, STRING lpdi
    
        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:
    • ~
    2696 bytes  
    Created: 2004-07-13 10:11:10  
    Modified: 2011-03-28 09:41:52  
    Visits in 7 days: 76  
    Listed functions:
    BitBlt
    DeleteDC
    EndDoc
    EndPage
    GetFocus
    GetWindowDC
    GetWindowRect
    PrintDlg
    ReleaseDC
    StartDoc
    StartPage
    Printer friendly API declarations
    My comment:

    #kwd: sln_gdiplus, sln_printform
    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:
    65.13.0.61 | 2006-08-19 11:49:49
    Anatoliy,

    I am creating a thematic map of the United States. It consists of a container object on a form. The container object contains shape objects in the form of each state in the U.S.

    I would like to save the image of the map to a .BMP, .JPG or .PNG without making the form visible. How do I do this?

    Dan
    danrhymes@bellsouth.net | 2006-08-19 11:50:11
    Anatoliy,

    I am creating a thematic map of the United States. It consists of a container object on a form. The container object contains shape objects in the form of each state in the U.S.

    I would like to save the image of the map to a .BMP, .JPG or .PNG without making the form visible. How do I do this?

    Dan
    Hugh Winters | 2006-08-30 12:55:10
    I am having trouble finding the gdiplus.prg you refer to in your code setup. Please tell me exactly where I might find this program. I have looked everywhere.

    Perhaps this program was outmoded by the new GDIPlusX.vcx class library and is no longer available. If so, please adjust your code to work with it.

    Thanks!

    Hugh Winters
    A.M. | 2006-08-30 19:34:07
    Hugh,

    There's a link to this code in Before You Begin section on this page

    http://www.news2news.com/vfp/?example=450

    This GDI+ library is not freeware though. It is also not compatible with GDI+ FFC code, since I have decided to create this library from scratch.

    Copyright 2001-2014 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.68), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.82.217.75)
    4 sec.Example: 'Monitoring changes occurring within a directory'
    Language: 'C#'
    23 sec.Example: 'Subclassing CommandButton control to create BackColor property'
    7 day(s)Example: 'Custom GDI+ class'
    Google
    Advertise here!