Consultor Eletrônico



Kbase 33846: How to Open a Web Browser Application such as the Microsoft Internet Explorer Web Browser from a Progress program using ActiveX programming techniques
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Solution ID: P3846

GOAL:

How to Open a Web Browser Application such as the Microsoft Internet Explorer Web Browser from a Progress program using ActiveX programming techniques.

FACT(s) (Environment):

Progress 8.x
Progress 9.x

FIX:

The code found below deals with the Microsoft Internet Explorer COM object (ActiveX Automation object or ActiveX Control).  To find additional references on this COM object's methods, attributes, and events, open the %SystemRoot%\System32\shdocvw.dll file with the Progress COM Object Viewer Tool.

DEFINE VARIABLE vchInternetExplorer AS COM-HANDLE NO-UNDO.

DEFINE VARIABLE FillInURL AS CHARACTER FORMAT "X(256)":U
    INITIAL "www.progress.com/support":U
    LABEL "URL":U
    VIEW-AS FILL-IN
    SIZE 40 BY 1.14 NO-UNDO.

DEFINE BUTTON BtnGo DEFAULT
    LABEL "&GO!":U
    SIZE 8 BY 1.14.

DEFINE BUTTON BtnDone
    LABEL "&Done":U
    SIZE 15 BY 1.14
    BGCOLOR 8.

DEFINE FRAME DEFAULT-FRAME
    FillInURL AT ROW 2 COL 2
    BtnGo     AT ROW 2 COL 48
    BtnDone   AT ROW 2 COL 56
   WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
        SIDE-LABELS NO-UNDERLINE THREE-D
        AT COL 1 ROW 1
        SIZE 80 BY 3
        DEFAULT-BUTTON BtnGo.

ON CHOOSE OF BtnGo
DO:
 IF NOT VALID-HANDLE(vchInternetExplorer) THEN
 DO:
   RUN initiateWebBrowser NO-ERROR.
   IF ERROR-STATUS:ERROR THEN
   DO:
     MESSAGE "Error initializing Internet Explorer Application.":U
        VIEW-AS ALERT-BOX ERROR.
     RETURN.
   END.
   RUN setWebBrowserStyle(FALSE,FALSE,FALSE).
   ASSIGN vchInternetExplorer:VISIBLE = TRUE.
   vchInternetExplorer:ENABLE-EVENTS('InternetExplorerEvents':U).
   MESSAGE "Internet Explorer was launched...":U.
 END.
 NO-RETURN-VALUE
vchInternetExplorer:Navigate(FillInURL:SCREEN-VALUE).
END.

ON CHOOSE OF BtnDone OR WINDOW-CLOSE OF CURRENT-WINDOW
DO:
 IF VALID-HANDLE(vchInternetExplorer) THEN
 DO:
   RUN closeWebBrowser.
   MESSAGE "Internet Explorer was closed out...":U.
 END.
 APPLY "CLOSE":U TO THIS-PROCEDURE.
 RETURN NO-APPLY.
END.

PROCEDURE initiateWebBrowser:
 CREATE "InternetExplorer.Application":U vchInternetExplorer
    NO-ERROR.
 IF ERROR-STATUS:ERROR THEN    
   RETURN ERROR.
END PROCEDURE.

PROCEDURE setWebBrowserStyle:
 DEFINE INPUT PARAMETER plStatusBar AS LOGICAL NO-UNDO.
 DEFINE INPUT PARAMETER plMenuBar   AS LOGICAL NO-UNDO.
 DEFINE INPUT PARAMETER plToolBar   AS LOGICAL NO-UNDO.

 ASSIGN vchInternetExplorer:StatusBar = plStatusBar
        vchInternetExplorer:MENUBAR   = plMenuBar
        vchInternetExplorer:ToolBar   = plToolBar
        vchInternetExplorer:WIDTH     = 800
        vchInternetExplorer:HEIGHT    = 600.         
END PROCEDURE.

PROCEDURE closeWebBrowser:
 NO-RETURN-VALUE vchInternetExplorer:QUIT().
END PROCEDURE.

PROCEDURE InternetExplorerEvents.OnQuit:
/******************************************************************/
/* This procedure gets fired whenever the user exits Internet     */
/* Explorer. Notice that the user can exit out of Internet        */
/* Explorer either through an actual option in Internet Explorer  */
/* (exit menu or close button) or through the selection of one of */
/* this program's options (Done button or close button on the     */
/* title bar). Therefore, as long as this program is executed,    */
/* this procedure will always be executed as well.                */
/******************************************************************/
 IF VALID-HANDLE(vchInternetExplorer) THEN
   RELEASE OBJECT vchInternetExplorer.
 ASSIGN vchInternetExplorer = ?.
END PROCEDURE.

ASSIGN
 CURRENT-WINDOW:HEIGHT = 3
 CURRENT-WINDOW:TITLE  = "Launch Internet Explorer Web Browser...":U.

DISPLAY FillInURL WITH FRAME DEFAULT-FRAME.
ENABLE ALL WITH FRAME DEFAULT-FRAME.
WAIT-FOR CLOSE OF THIS-PROCEDURE.

NOTE: In order to get the above code to work in Progress version 8,
you need to remove the ENABLE-EVENTS functionality, which is not
available for that version of the product.