Home Page Software Inc. Demo Download Order a Webster Pro Support Area Frequently Asked Questions About Us Subscriber Area
 
Home Page Software Inc. Webster Pro DLL: Usage
DLL Topics:

- Overview
- Installation
- Usage


Download a fully functional 30-day demo.


Purchase a licensed release.                

The following sections describe how to create and manipulate Webster Pro DLL web browser windows:
  Introduction
A Webster Pro window immediately provides full web browser functionality, including a toolbar, status bar and standard user interface, with no additional code. You can also configure the appearance and control the behavior of the Webster Pro by getting and setting properties, invoking methods and handling events. Your application can display one or more browser windows and control each one independently.

The C++ include file WebsterDllWrap.h defines a wrapper class named CWebsterProWrapper that is used to create the browser window, set and get properties, and call methods. The file also contains function templates for event handlers that you can optionally implement in your application, and it defines all of the constants and enumerations used by the Webster Pro. Include this file in your project.

#include "WebsterDllWrap.h"
Most of the code fragments in this article are taken from the Dill sample application. This is plain vanilla MDI application, generated by the VC++ App-Wizard and modified slightly to display a Webster Pro browser window in each view.
  Loading the DLL
The Webster Pro DLL must be loaded by your application at runtime. This needs to be done only once, typically in your application InitInstance() function. The CWebsterProWrapper static function LoadLibrary() loads the Webster Pro DLL:
CWebsterProWrapper::LoadLibrary(stringDllName);
Correspondingly, unload the DLL at the end of of your run by calling the static function FreeLibrary() This is typically done in the application ExitInstance() function:
CWebsterProWrapper::FreeLibrary();
You can use the static isLoaded() function to check if the library is currently loaded.
  Creating a Browser Window
To create a Webster Pro Browser window, first create an instance of CWebsterProWrapper. Typically this would be a data member of some window object:
CWebsterProWrapper m_WebsterPro1;
Call the Create() member function for that instance of CWebsterProWrapper. The browser window can be embedded in any other window as a child (control) window.
m_WebsterPro1.Create(WS_CHILD | WS_VISIBLE, 
                     left, top, right, bottom, 
                     GetSafeHwnd(), 
                     (DWORD) ((LPCTSTR) "0000000000"));
When using a licensed release product, specify your product serial number in place of the "0000000000":

To destroy the browser object you can either call the Destroy() member function of CWebsterProWrapper or, if the CWebsterProWrapper was created with new then you can just delete it.

The browser object is built around a regular Windows window and you can get the HWND of that window with the GetHwnd() member function. Use this HWND in standard Windows API calls to set generic window characteristics, as in this WM_SIZE handler:

void CDillView::OnSize(UINT nType, int cx, int cy) 
{
   // Make sure that the Webster Pro window has been created:
   if (m_WebsterPro1.isCreated())
   {
      // Size the control to fill the view
      ::MoveWindow(m_WebsterPro1.GetHwnd(), 0, 0, cx, cy, TRUE);
   }

   // Chain to the base class:
   CView::OnSize(nType, cx, cy);
}
  Getting and Setting Properties
Every property has associated Get and Set functions in the CWebsterProWrapper class. For example, the BevelWidth property is accessed through the GetBevelWidth() and SetBevelWidth() member functions.

The argument to string property Set functions is a pointer to a string (char*) which can be temporary. For example, to set the PageURL property:

WebsterPro1.SetPageURL("http://www.someplace.com")
The pointer (char*) returned by string property Get functions points to allocated memory that must be freed with FreeObject() or FreeAllObjects() when you are done with it, for example:
char* lpszPageUrl = WebsterPro1.GetPageURL();
//
// Do something with lpszPageUrl...
// ...
// Done with the string object, free it:
WebsterPro1.FreeObject(lpszPageUrl);
Collection properties are accessed by member functions of the form GetXxxCount(), GetXxxItem() etc. For example, the ProxyExclusionsHTTP collection property is exposed through these functions:
long GetProxyExclusionsHTTPCount();
char* GetProxyExclusionsHTTPItem(long index);
void SetProxyExclusionsHTTPItem(long index, LPCTSTR lpszItem);
void AddProxyExclusionsHTTPItem(LPCTSTR lpszItem);
long FindProxyExclusionsHTTPItem(LPCTSTR lpszItem);
void RemoveProxyExclusionsHTTPItem(long index);
void RemoveAllProxyExclusionsHTTPItems();
This code fragment cycles through all of the servers in the proxy exclusion collection:
for (int index = 0; 
         index < WebsterPro1.GetProxyExclusionsHTTPCount(); 
         index++)
{
   // Get the next proxy server name in the collection:
   char* lpszProxy = GetProxyExclusionsHTTPItem(long index);

   // Do something with lpszProxy...
   //...

   // Done with the string object, free it:
   WebsterPro1.FreeObject(lpszProxy);
}
Font properties are accesses through a shared set of functions that take a font ordinal (dispidFontHeading1 through dispidFontAddress, defined in WebsterDllWrap.h) as an argument. For example, to set the Normal font to Arial 10 pt:
WebsterPro1.SetFontName(dispidFontNormal, "Arial");
WebsterPro1.SetFontSize(dispidFontNormal, 10);
There are Get and Set functions for the font name, size, weight, charset, italic, underline and strikethrough attributes.
  Invoking Methods
Method invocation is a straightforward function call. The only caveat is that as with string properties, any returned strings must be freed with FreeObject() or FreeAllObjects(). This applies to string return values as well as to string output arguments (i.e. method arguments of the form char** ppWhatever). For Example:
char* pObjectURL;
char* pHyperlinkURL;
long* lPureTextOffset;
// Get the object at the x,y coordinates of interest:
long maskOfObject = WebsterPro1.GetObjectAtXY(x, y, 
                                              &pObjectURL, 
                                              &pHyperlinkURL, 
                                              &lPureTextOffset);

// Do something with pObjectURL and pHyperlinkURL...
//...

// Done with the string objects pObjectURL and pHyperlinkURL:
WebsterPro1.FreeAllObjects();
  Handling Events
An event is fired as an outgoing function call from the Webster Pro to your application. There are fourteen event types to signal various navigation actions, mouse, keyboard and other user actions, load state changes, text selection progress and other significant occurrences. Some events are merely informative while others have input/outputs arguments that you can modify to affect subsequent behavior.

To handle an event, you implement an event handler function in your application and then specify the address of that function to the Webster Pro DLL at runtime. It is perfectly safe to completely ignore any event that you don't need to handle.

Steps for handling an event are:

  1. Write an event handling function based on the event prototype in WebsterDllWrap.h. When a Webster Pro fires the corresponding event, it calls this function.

    The event handler prototypes specify extern "C" functions, so event handlers cannot be class member functions. You can use the hControl argument to identify the specific Webster Pro instance in the handler. This can be useful if you create multiple browser windows simultaneously, as in the following BeforeNavigate handler from an MDI application:

    DWORD  gfEventBeforeNavigate(HANDLE  hControl,
                                 LPSTR*  plpszHyperlinkUrl,
                                 DWORD   dwNavFlags,
                                 DWORD   dwContextHandle,
                                 LPSTR*  plpszTargetName,
                                 LPSTR*  plpszTextToPost,
                                 LPSTR*  plpszExtraHeaders,
                                 DWORD*  pdwContainerCancel)
    {
       // A BeforeNavigate event was fired by the Webster Pro.
       // The specific window that fired the event is identified by
       // the hControl argument.
    
       // In this particular implementation, we assume that the 
       // Webster Pro is embedded in a CDillView object (derived from 
       // CView) and so is a child window of  the CDillView window.  
       // We call a BeforeNavigate handler in the parent CDillView 
       // of the object that fired the event.
       //
       CWnd* pDillView = CWnd::FromHandle(::GetParent((HWND) hControl));
    
       ASSERT(pDillView && pDillView->IsKindOf(RUNTIME_CLASS(CDillView)));
    
       // If we have obtained the parent DillView...
       if (pDillView && pDillView->IsKindOf(RUNTIME_CLASS(CDillView)))
       {
         // Convey the event to a handler in the specific DillView 
         // that hosts this Webster Pro window:
         ((CDillView*) pDillView)->eventBeforeNavigate(hControl,
                                                       plpszHyperlinkUrl,
                                                       dwNavFlags,
                                                       dwContextHandle,
                                                       plpszTargetName,
                                                       plpszTextToPost,
                                                       plpszExtraHeaders,
                                                       pdwContainerCancel);
       }
       return 0;
    }
  2. Specify the address of your event handling function:
    m_WebsterPro1.SetEventHandlerAddress(eventidBeforeNavigate, 
                                         ::gfEventBeforeNavigate);
    To stop handling an event specify an address of NULL:
    m_WebsterPro1.SetEventHandlerAddress(eventidBeforeNavigate, NULL);
Some events have string parameters that can be modified. Use the ReplaceObject() function to replace a string paramter, as in this fragment from CDillView::eventBeforeNavigate().
m_WebsterPro1.ReplaceObject(plpszHyperlinkUrl, 
                            stringNewUrl, stringNewUrl.GetLength());


Copyright © Home Page Software Inc. query@homepagesw.com