Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
GDI+: sending image of FoxPro form to printer
Opening access to the Microsoft Internet functions for the application
Custom FTP Class for Visual FoxPro application
How to make application automatically close all documents it opened
How to print FoxPro form
Listing child windows for the Windows desktop
How to display the Properties dialog box for a file (ShellExecuteEx)
Uploading local file to FTP server with FtpPutFile
Adding a background image to VFP report (VFP9, ReportListener)
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
Displaying the associated icons and descriptions for files and folders
How to ping a remote site using ICMP API calls
How to print a bitmap file
Using InternetSetFilePointer when resuming interrupted download from the Internet
Enumerating Processes -- WinNT
How to change the name and the size of the font in the MessageBox dialog
How to copy the image of a form to the Clipboard using Bitmap API functions
How to display a dialog box with which the user can add a data source (DSN)
Creating a console window for Visual FoxPro application
Displaying Windows shell folders in TreeView control with Visual FoxPro FLL
Enumerating global and local group accounts on a server (WinNT/XP/2K)
Enumerating print jobs and retrieving information for default printer (JOB_INFO_1 structures)
How to enumerate, add and delete shares on the local computer (WinNT/XP)
Starting a dialog box for connecting to network resources (mapping network drive)
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: 52  
    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.234.74.85)
    15 sec.Function: 'send'
    Function group: 'Windows Sockets 2 (Winsock)'
    2 day(s)Example: 'Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera'
    Language: 'Visual FoxPro'
    3 day(s)Example: 'The original LoadPicture() function in VFP returns valid handles to bitmaps, icons, cursors, and metafiles'
     Function: 'MAPIFindNext'
    Function group: 'Simple MAPI'
     Example: 'Using WM_COPYDATA for interprocess communication (VFP9)'
    Google
    Advertise here!