Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Using Path functions from Shell Lightweight Utility APIs (shlapi.dll)
WAV file player
Converting an HTTP time/date string to a SYSTEMTIME structure
GDI+: how to make VFP controls visually shake and shudder
How to copy the image of a form to the Clipboard using Bitmap API functions
How to create transparent areas inside a form -- punching holes in the form
How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Printing text on the main VFP window
Quering waveform-audio output devices
System Image List Viewer
Drawing Windows frame controls using the DrawFrameControl function
Enumerating ODBC drivers available on the local computer
GDI+: printing vertical text on VFP reports via generated images (VFP9)
Using the SetErrorMode for determining if a floppy drive is ready
GDI+: Creating thumbnails to preview images in a directory
Retrieving list of all active RAS connections
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)
Shortcut Menu Class
Using FillMemory
Using InternetGoOnline function
Another way to go online (it is not about choosing an ISP)
How to release and renew a lease on an IP address previously obtained through Dynamic Host Configuration Protocol (DHCP)
How to upload a local file to FTP server using FtpPutFile
How to display the Print property sheet

User rating: 9/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
Before you begin:
The Print property sheet is a standard user interface that enables the user to specify the properties of a particular print job.



The first page of a Print property sheet is the General page. The property sheet can also have additional application-specific and driver-specific property pages following the General page. The lower portion of the General page is a child dialog box template with controls similar to those of the Print Dialog Box.

See also:
  • Printing Image File, programmatically set print page orientation to landscape
  •  
    #DEFINE PRINTDLGEX_LEN 84
    #DEFINE PD_RETURNDC 0x100
    #DEFINE PD_RETURNDEFAULT 0x400
    #DEFINE PD_COLLATE 0x00000010
    #DEFINE START_PAGE_GENERAL 0xffffffff 
     
    DO declare
     
    *!*    typedef struct tagPRINTPAGERANGE {
    *!*        DWORD nFromPage;
    *!*        DWORD nToPage;
    *!*    } PRINTPAGERANGE, *LPPRINTPAGERANGE;
     
    LOCAL oPrintPageRange As PChar, nFlags, cPrintDlgEx
     
    * lpPageRanges must be non-NULL
    * allocating space for 10 PRINTPAGERANGE structures
    oPrintPageRange = CREATEOBJECT("PChar",;
        REPLICATE(CHR(0),80))
     
    nFlags = BITOR(PD_RETURNDC,PD_COLLATE)
     
    * populate PRINTDLGEX structure
    cPrintDlgEx = num2dword(PRINTDLGEX_LEN) +;
        num2dword(_screen.HWnd) +;
        num2dword(0) +;
        num2dword(0) +;
        num2dword(0) +;
        num2dword(m.nFlags) +;
        num2dword(0) +;
        num2dword(0) +;
        num2dword(0) +;
        num2dword(10) +;
        num2dword(oPrintPageRange.GetAddr()) +;
        num2dword(1) +;
        num2dword(10) +;
        num2dword(5) +;
        num2dword(0) +;
        num2dword(0) +;
        num2dword(0) +;
        num2dword(0) +;
        num2dword(0) +;
        num2dword(START_PAGE_GENERAL) +;
        num2dword(0)
     
    LOCAL nResult, nResultAction, hDC
    nResult = PrintDlgEx(@cPrintDlgEx)
     
    IF nResult = 0
        * the outcome of the dialog: PD_RESULT_APPLY,
        * PD_RESULT_CANCEL or PD_RESULT_PRINT
        nResultAction = buf2dword(SUBSTR(cPrintDlgEx, 81, 4))
     
        * handle to a device context for
        * the selected printer
        hDC = buf2dword(SUBSTR(cPrintDlgEx, 17, 4))
     
        ? nResultAction, hDC
    ELSE
        ? "Error:", TRANSFORM(m.nResult, "@0")
    ENDIF
    * end of main
     
    PROCEDURE declare
        DECLARE INTEGER PrintDlgEx IN comdlg32 STRING @lppd
     
    FUNCTION buf2dword(lcBuffer)
    RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
        BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
        BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
        BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
     
    FUNCTION num2dword(lnValue)
    #DEFINE m0 256
    #DEFINE m1 65536
    #DEFINE m2 16777216
        IF lnValue < 0
            lnValue = 0x100000000 + lnValue
        ENDIF
        LOCAL b0, b1, b2, b3
        b3 = Int(lnValue/m2)
        b2 = Int((lnValue - b3*m2)/m1)
        b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
        b0 = Mod(lnValue, m0)
    RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
     
    DEFINE CLASS PChar As Custom
        PROTECTED hMem
     
    PROCEDURE Init(lcString)
        THIS.hMem = 0
        THIS.setValue(lcString)
     
    PROCEDURE Destroy
        THIS.ReleaseString
     
    FUNCTION GetAddr  && returns a pointer to the string
    RETURN THIS.hMem
     
    FUNCTION GetValue && returns string value
        LOCAL lnSize, lcBuffer
        lnSize = THIS.getAllocSize()
        lcBuffer = SPACE(lnSize)
     
        IF THIS.hMem <> 0
            DECLARE RtlMoveMemory IN kernel32 As Heap2Str;
                STRING @, INTEGER, INTEGER
            = Heap2Str(@lcBuffer, THIS.hMem, lnSize)
        ENDIF
    RETURN lcBuffer
     
    FUNCTION GetAllocSize  && returns allocated memory size (string length)
        DECLARE INTEGER GlobalSize IN kernel32 INTEGER hMem
    RETURN Iif(THIS.hMem=0, 0, GlobalSize(THIS.hMem))
     
    PROCEDURE SetValue(lcString) && assigns new string value
    #DEFINE GMEM_FIXED 0 
        THIS.ReleaseString
     
        DECLARE INTEGER GlobalAlloc IN kernel32 INTEGER, INTEGER
        DECLARE RtlMoveMemory IN kernel32 As Str2Heap;
            INTEGER, STRING @, INTEGER
     
        LOCAL lnSize
        lcString = lcString + Chr(0)
        lnSize = Len(lcString)
        THIS.hMem = GlobalAlloc(GMEM_FIXED, lnSize)
        IF THIS.hMem <> 0
            = Str2Heap(THIS.hMem, @lcString, lnSize)
        ENDIF
     
    PROCEDURE ReleaseString  && releases allocated memory
        IF THIS.hMem <> 0
            DECLARE INTEGER GlobalFree IN kernel32 INTEGER
            = GlobalFree(THIS.hMem)
            THIS.hMem = 0
        ENDIF
    ENDDEFINE  && pchar
     

    User rating: 9/10 (1 votes)
    Rate this code sample:
    • ~
    3460 bytes  
    Created: 2007-10-04 15:33:13  
    Modified: 2009-09-24 10:38:40  
    Visits in 7 days: 92  
    Listed functions:
    GlobalAlloc
    GlobalFree
    GlobalSize
    PrintDlgEx
    Printer friendly API declarations
    My comment:
    When populating the PRINTDLGEX structure, note that the hwndOwner member cannot be NULL. It must refer to a valid window. As well the lpPageRanges must point at a valid memory block.
    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:
    Victor Espinoza | 2007-10-05 12:46:04
    This is great! Thank you for posting this example.
    Victor Espinoza | 2007-10-05 17:53:33
    Thank Anatoly for showing how to use this API function:

    For those how would like to find out the pages selected by the user:

    IF nResultAction = 1
     hPages = buf2dword(SUBSTR(cPrintDlgEx, 41,44))
     lnPtr = GlobalLock (hPages)
     lcBuffer = Repli(Chr(0), 8)
     = Heap2Str(@lcBuffer, lnPtr, 8)
     ? "FromPage = " + TRANS(buf2dword(SUBSTR(lcBuffer,1,4)))
     ? "ToPage = " + TRANS(buf2dword(SUBSTR(lcBuffer,5,4)))
     = GlobalUnlock(hPages)
    ENDIF

    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.22.252.150)
    6.8 min.Function: 'WNetEnumResource'
    2.34 hrs.Function: 'WNetGetProviderName'
    Function group: 'Windows Networking'
    9.5 hrs.Example: 'Disabling mouse and keyboard input for the main VFP window (with the app still running)'
     Example: 'Splash Screen for the VFP application'
    10.89 hrs.Function: 'AVIFileGetStream'
    14.18 hrs.Example: 'How to put a horizontal text scrolling on the form (a news line)'
     Example: 'Extensible Storage Engine class library'
    19.2 hrs.Example: 'Retrieving file information for the VFP executable running'
    23.83 hrs.Example: 'Using an Event Object. Part A: running an application that creates an Event object'
     Function: 'SQLDataSources'
    Google
    Advertise here!