Example: Creating a Client-side DLL

Here is an example to show you how to create a simple client-side DLL that displays a simple dialog box. This example uses Microsoft Visual C++ and MFC. Please note that this method is for illustrative purposes and backward compatibility only. The preferred method of developing client-side components is to develop them as Design Time Controls.

  1. Start Microsoft Visual C++. From the File menu, choose the New option, and select Project Workspace. From the New Project Workspace dialog, choose the MFC AppWizard (dll) option. Name the project “simple”.

  2. Click the “Create” button. Choose either an MFC shared DLL or an extension DLL.

  3. Create a new dialog box resource for the component. Add controls to the resource as desired. For instance, OK and Cancel buttons and an edit field.

  4. Derive a class from the dialog resource using ClassWizard. Name the class “CSimpleDialog”. Attach a value member variable called “m_edit” to the edit field using the classwizard.

  5. Copy the file webbot.h from the SDK into the project directory

  6. Add the following lines to the top of simple.cpp:
#include "simpledialog.h"
#include "webbot.h"

Add the following function to simple.cpp:

BeginWebBotEdit(simple, botAttribs)
{
   CSimpleDialog dlg;
   dlg.m_edit = botAttribs.GetValue("PREVIEW");
   int nResponse = dlg.DoModal();
   botAttribs.SetValue("ExpandTo", dlg.m_edit);
   botAttribs.SetValue("PREVIEW", dlg.m_edit);
   return (nResponse == IDOK);
}
EndWebBotEdit
  1. Add the following function to make the DLL also be a server-side custom FrontPage component DLL. If you don’t add this function, you will need to make a BTL file, which expands the “ExpandTo” key to be the resulting HTML text for the component, and set the serverbinding in the .inf file to be BTL.
BeginWebBotExpand(simple,ret,botAttribs,cgi,form)
{
   ret.Append(botAttribs.GetValue("ExpandTo"));
}
EndWebBotExpand
  1. Select the Win32 Release target from the drop-down menu on the toolbar and compile the DLL.

  2. To do local testing, create c:\Program Files\Microsoft FrontPage\bots\simple (that is, create a bots\simple directory in the FrontPage root directory on the local machine) and copy the newly created DLL into that directory. Later, when the component is ready for release, it should be made platform independent and placed on the server in the root web/_vti_bot/botname directory

  3. Create a simple.inf file in the same directory, using the examples as a guide. Be sure to set the clientbinding and serverbinding keys to DLL. Set the “type” to “insert”.

  4. Run FrontPage. From the FrontPage Tools menu, choose Recalculate Links. Your component should now show up in the Insert|FrontPage Components listbox.

  5. Select the Simple Bot. It will prompt you to download the component into the botcache directory. After downloading, the simple component will display its dialog. Enter some text into the edit box and click okay. The preview string contains the text that was entered.

This sample component (including a simple.inf file) can be found in the SDK’s WebBot\simple folder.

Important: If your component requires any DLLs, be sure to include them with the component setup so that they can be installed on the system. FrontPage ships with MFC 4.2 DLLs, but in general, you need to make sure that you provide any necessary DLLs that might not be included with FrontPage itself. For this reason, you should make sure that you only install Win32 Release builds of your component, particularly if you use the Microsoft Foundation Classes (MFC). If you use the same module on both the client and server, and you require additional libraries, you are responsible for installing them on both the client and server machines.