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
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Winsock: sending email messages (SMTP, port 25)
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)
Custom GDI+ class
Converting Unicode data from the Clipboard to a character string using a given code page
Disk in drive A:
How to display the Properties dialog box for a file (ShellExecuteEx)
Enumerating network resources
Detecting changes in connections to removable drives (VFP9)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to download a file from the FTP server using FtpGetFile
Using EnumPrinters function to enumerate locally installed printers
How to play AVI file on the _screen
Retrieving the name of the network resource associated with a local device
Creating a console window for Visual FoxPro application
Custom HttpRequest class (WinHTTP)
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Custom FTP Class for Visual FoxPro application
How to put a horizontal text scrolling on the form (a news line)
Deleting files into the Recycle Bin
GDI+: printing image 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
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 source file name is valid. The source file can be in any of graphics formats supported by the GDI+: BMP, GIF, JPG, TIF, EMF...

See also:
  • Printing Image File, programmatically set print page orientation to landscape
  • How to display the Print property sheet
  •  
    SET PROCEDURE TO gdiplus ADDITIVE
    DO decl
     
    * an instance of gdiplusinit should be created before
    * and released after using any of gdi+ objects
    PRIVATE gdiplus
    gdiplus = CREATEOBJECT("gdiplusinit")
     
    LOCAL img, hPrnDC, gdip, docinfo
    hPrnDC = GetPrnDC()
    img = CREATEOBJECT("gdiimage", "c:\windows\forest.bmp")
    gdip = CREATEOBJECT("graphics", hPrnDC)
     
    docinfo = PADR(CHR(20), 20, CHR(0))
    = StartDoc(m.hPrnDC, m.docinfo)
    = StartPage(m.hPrnDC)
    WITH gdip
        .DrawImage(img, 20,20)
        .DrawImage(img, 25+img.imgwidth,20,;
            img.imgwidth/4, img.imgheight/4)
    ENDWITH
    = EndPage(m.hPrnDC)
    = EndDoc(m.hPrnDC)
    = DeleteDC(hPrnDC)
    * end of main
     
    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 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
     
     
     

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1361 bytes  
    Created: 2004-07-08 09:30:41  
    Modified: 2011-12-10 09:20:22  
    Visits in 7 days: 73  
    Listed functions:
    DeleteDC
    EndDoc
    EndPage
    PrintDlg
    StartDoc
    StartPage
    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 (23.20.196.179)
    4 sec.Example: 'Enumerating data formats currently available on the clipboard'
    6.32 hrs.Function: 'CeRapiInitEx'
    Function group: 'Remote Application Programming (RAPI)'
     Function: 'GetRgnBox'
    13.25 hrs.Example: 'Simple MAPI: how to pick an email recipient from Outlook Express address book'
     Example: 'How to assemble an array of strings and pass it to external function'
    14.4 hrs.Example: 'Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)'
    Language: 'Visual FoxPro'
     Function: 'SetSystemPowerState'
    Function group: 'Power Management'
    19.05 hrs.Example: 'Shortcut Menu Class'
     Function: 'DrawFrameControl'
    Function group: 'Painting and Drawing'
    19.75 hrs.Example: 'How to change display settings: screen resolution, screen refresh rate'
    Google
    Advertise here!