Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Generating random cryptographic keys
How to Start a Process as Another User (NT/XP/2K)
How to view icons stored in executable files (Icon Viewer) - II
Storing content of the Clipboard to a bitmap file
Creating a console window for Visual FoxPro application
Creating a window using CreateWindowEx function
Disconnecting USB Mass Storage Device programmatically
Exporting DLL icon resources as .ICO files
GDI+: creating a gradient
How to ping a remote site using ICMP API calls
Verifying a file using the Authenticode policy provider
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Displaying the associated icons and descriptions for files and folders
How to display Windows On-Screen Keyboard
How to make a VFP form fading out when released (GDI version)
Reading security permissions for NTFS files and folders
Retrieving long values associated with the class of the VFP window
Storing the environment strings in cursor
Using Extended MessageBox() Class
Class library providing access to the System Registry
How to block the PrintScreen key
Storing screen shot of a form to bitmap file
Adding user-defined items to the Control Menu of VFP form (requires VFP9)
Creating irregularly shaped FoxPro form using transparency color key
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: 107  
    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.46), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (
    2.6 min.Example: 'Using WM_COPYDATA for interprocess communication (VFP9)'
    Language: 'C#'
    Advertise here!