Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Playing WAV files on InteractiveChange
Simple Window Viewer
WAV file player
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
How to enable the SE_SHUTDOWN_NAME privilege for the application
How to play AVI file on the _screen
Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)
Using the GetTempFileName
Using the LoadImage function to have a bitmap file loaded and displayed on VFP main window
Creating a mailslot
Finding out if the current user is the Guest account
GDI+: sending image of FoxPro form to printer
How to make application automatically close all documents it opened
How to ping a remote site using ICMP API calls
Wininet last error description
OS version and revision
Windows Shell Icons displayed and exported to ICO files (Vista)
Adding supplementary data to AVI files
Attaching menu to a top-level form
How to display Windows On-Screen Keyboard
System and Local Time values
How to create transparent areas inside a form -- punching holes in the form
Scanning a hierarchy of child windows down from the Windows Desktop
Using FlashWindowEx to flash the taskbar button of the VFP application
Accessing Adobe Reader 7.0 main menu from VFP application

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:
I was looking for a simple way of closing Adobe Reader document (PDF) and leaving intact other open documents and the Reader itself.

Presented on this page, the AdobeAcrobat7 class enumerates opened pdf documents. It also can close any Acrobat document window or all document windows and more.

Use the following code to test the class:

LOCAL oReader As AdobeAcrobat7, oDoc As AdobeDocument
oReader = CREATEOBJECT("AdobeAcrobat7")

IF NOT oReader.AcrobatIsRunning()
        cDocument = GETFILE("PDF", "Acrobat document",;
                "Open",0,"Open Acrobat Reader document")
        IF EMPTY(cDocument)
        IF NOT oReader.OpenAcrobatDocument(cDocument)
                = MESSAGEBOX("Could not open " +;
                        "Acrobat Reader document. ",;
                        48, "Error!")

FOR EACH oDoc IN oReader.documents
        ? oDoc.filename
        IF oDoc.filename = "mydoc.pdf"

IF MESSAGEBOX("Exit Acrobat?",32+4)=6

See also:
  • How to control Adobe Reader 9.0 from VFP application
      Members area. Log in to view this example.
      User name:
      Forgot your password?
      Sign up for
    the Membership

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    4845 bytes  
    Created: 2005-10-04 00:00:17  
    Modified: 2009-01-27 08:52:49  
    Visits in 7 days: 95  
    Listed functions:
    Printer friendly API declarations
    My comment:
    When started, the AcrobatReader creates a window with the class name AdobeAcrobat. All pdf documents opened are its child windows with the class name AcrobatMDIChildWnd. Use Microsoft Spy++ or a similar tool to find out more.

    Once the window class name is known, it is easy to find the process linked to this window and terminate it. This will also terminate all open pdf documents. So it does not help when only one document window is to be closed.

    * * *
    It is possible to enumerate all AcrobatMDIChildWndwindows currently existing. Yet no such window can be closed by calling the DestroyWindow: a thread cannot use DestroyWindow to destroy a window created by a different thread.

    Acrobat document window closes upon receiving a special window message:
    PostMessage(hDocument, WM_SYSCOMMAND, SC_CLOSE, 0)
    where hDocument is the handle for a document window parented by the main Acrobat window.

    * * *
    Finally, I decided to go through using the Acrobat`s menu. First I obtained identifiers for several submenu popups and menu items, like Close All, Exit, File, Window etc. For that I used program code similar to Reading structure of a menu attached to the main VFP window code sample.

    Once the identifier for a menu item is known, it is simple to create a virtual click on this item without even moving the mouse:
    = SendMessage(hWindow, WM_COMMAND, nMenuItemID, 0)
    where hWindow is the main Acrobat window handle, and nMenuItemID is a menu item`s identifier. For example, identifier 6026 is assigned to File - Exit menu item.

    * * *
    An article called A simple wrapper to control Acrobat Reader from your application written by seasidetech explains how to use selected DDE messages to control the reader from outside.

    * * *
    If AdobeAcrobat settings are configured to display each PDF document in a separate window, then all document windows are created with window class AcrobatSDIWindow. Which means the code sample will not work, since it searches windows with AdobeAcrobat class name.

    Still this approach will work after reshaping the code, because each SDI window has a menu that can be reached through SendMessage calls.

    Menu IDs in the Adobe Reader 8.1 seem to be different from those used in previous versions, which prevents the code sample from working properly with the newer Adobe Reader version.

    * * *
    In Acrobat Reader 9 the class of the main window is "AcrobatSDIWindow", not "AdobeAcrobat" anymore. The number of open windows of this class corresponds to the the number of PDF documents currently open. Each AcrobatSDIWindow has a separate menu. All main Acrobat windows are aware of other open Acrobat documents.

    * * *
    Jan.26, 2009: Starting with version 9 of the Adobe Reader for Windows, may be even with an earlier 8+ version, the preference "Show each document in its own window (requires restart)" is no longer available. There is a TechNote from Adobe (kb405108) explaining why such questionable decision was ever taken -- no more MDI.

    * * *
    Read on Adobe Solutions Network Acrobat Interapplication Communication Overview.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.

    Copyright 2001-2015 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.5.44), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (
    29 sec.
    Function group: 'Keyboard Input'
    Advertise here!