Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to register custom Event Log source
Moving shortcut to a specified position on the Windows Desktop
Creating a clipping region from the path selected into the device context of a form
How to change the name and the size of the font in the MessageBox dialog
Semi-transparent Form
Setting the date and time that a file was created
Adding a background image to VFP report (VFP9, ReportListener)
Enumerating global and local group accounts on a server (WinNT/XP/2K)
GDI+: Storing content of the Clipboard to a bitmap file
How to disable the Windows Clipboard (VFP9)
Obtaining names and positions for shortcuts located on the Windows Desktop
How to create non-blocking Winsock server
How to put a vertical text scrolling on the form (a movie cast)
How to find the application associated with a file name
How to remove a directory that is not empty
Obtaining current Internet Explorer browser version and UserAgent
Peer-to-peer LAN messenger built with Mailslot API functions
Retrieving list of available disk drives
Using FlashWindowEx to flash the taskbar button of the VFP application
How to view icons stored in executable files (Icon Viewer) - II
Testing serial ports
Monitoring changes in a directory
Compressing and decompressing files with Windows API Runtime Library routines
Current keyboard type
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)
                RETURN
        ENDIF
        IF NOT oReader.OpenAcrobatDocument(cDocument)
                = MESSAGEBOX("Could not open " +;
                        "Acrobat Reader document. ",;
                        48, "Error!")
                RETURN
        ENDIF
ENDIF

FOR EACH oDoc IN oReader.documents
        ? oDoc.filename
        IF oDoc.filename = "mydoc.pdf"
                oReader.CloseDocument(m.oDoc)
        ENDIF
NEXT

IF MESSAGEBOX("Exit Acrobat?",32+4)=6
        oReader.ExitAcrobat
ENDIF

See also:
  • How to control Adobe Reader 9.0 from VFP application
  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      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: 43  
    Listed functions:
    FindWindow
    GetMenu
    GetMenuItemCount
    GetMenuItemID
    GetSubMenu
    GetWindowText
    IsMenu
    IsWindow
    SendMessage
    ShellExecute
    SwitchToThisWindow
    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  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    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.91.159.232)
    2.37 min.Example: 'How to make application automatically close all documents it opened'
    11.45 min.Function: 'LockWorkStation'
    4 day(s)Example: 'How to retrieve information about a cache entry (Internet Explorer)'
     Function: 'MAPIFindNext'
    Function group: 'Simple MAPI'
     Example: 'Using WM_COPYDATA for interprocess communication (VFP9)'
     Example: 'How to change display settings: screen resolution, screen refresh rate'
     Example: 'How to create non-blocking Winsock server'
    Language: 'C++'
     Example: 'Enumerating MIDI output devices'
     Function: 'NetGetDCName'
    Function group: 'Network Management'
     Example: 'How to detect if additional monitor is connected and active'
    Language: 'C#'
    Google
    Advertise here!