Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Using Common Controls: the Header Control
Displaying the associated icons and descriptions for files and folders
How to activate Windows Calculator
How to disable the Windows Clipboard (VFP9)
Retrieving Printer Device Context using PrintDlg function
Converting image file to .ICO file
Creating irregularly shaped FoxPro form using transparency color key
Disabling mouse and keyboard input for the main VFP window (with the app still running)
How to download a file from the FTP server using FtpGetFile
Semi-transparent Form
Testing serial ports
Using the NetMessageBufferSend to send messages on the network
Converting Unicode data from the Clipboard to a character string using a given code page
How to set Creation Date/Time for a folder (WinNT)
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Playing WAV sounds simultaneously
Reading data from INI files
Retrieving information specific to the current Time Zone
Using shared memory to exchange data between applications (processes)
GDI+: saving image of FoxPro form to graphics file (BMP, GIF, JPG, PNG, TIF)
Sending a standard message with one or more attached files using default email client
Storing screen shot of a form to bitmap file
Animating a transition of the VFP form (a wire-frame rectangle)
How to draw custom Window Caption on FoxPro form
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: 76  
    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.
    Google
    Advertise here!