Brought to you by Inside Microsoft FrontPage, a ZD Journals publication. Click here for a free issue .
If you've spent any time exploring the FrontPage 98 CD-ROM, you've probably discovered the FrontPage Software Developer's Kit, or SDK. The SDK combines special software with extensive documentation on how to customize FrontPage.
You may have gone into the SDK to install the Theme Designer. But chances are, you haven't done much more with it.
As a matter of fact, the SDK offers some other useful features. And you don't have to be a developer to take advantage of them. In this article, we'll show you how to customize FrontPage by adding commands to the program's menus. In doing so, we'll introduce you to some of the concepts you'll encounter in the SDK.
If you've installed the Theme Designer, you know that doing so adds a new command to FrontPage Explorer's Tools menu. By choosing that command, you launch the program.
Unlike other commands, however, this new command doesn't actually exist within FrontPage Explorer. Instead, it resides in a special database called the Registry. Each time you launch the Explorer, it checks the Registry to see if there are any new menus or menu items listed there.
To modify FrontPage's menus, then, you have to modify the Registry. And to do that, you use the Registry Editor, also called Regedit. In effect, you do manually what the Theme Designer installer did automatically.
Warning: The Registry Editor, which is in your Windows directory, is fairly easy to use. That simplicity masks the fact that you can completely corrupt your system by using it. Whenever you're modifying the Registry, be very careful to follow precisely the instructions you're given.
Now, let's take a quick tour of Regedit before we modify FrontPage. Choose Run . . . from the Start menu and type regedit at the prompt. Then, click Open to launch the application.
You should now see a window similar to Figure A. Down the left pane is a list of keys. Just as you do in Windows Explorer, you click the plus sign to expand the key and see its subkeys. When you select certain keys, you'll see those keys' values in the right pane of the window. To add a command to FrontPage Explorer, we'll add a value to a certain key. Let's see how that process works.
Click the plus sign next to HKEY_CURRENT_USER to expand it. Then, expand the following keys in order: Software, Microsoft, FrontPage, Explorer, Init Commands. (If you're having a hard time reading the key names, you can widen the left pane by dragging the divider to the right.)
At this point, your screen should resemble the one in Figure B, although it may not show the values for Microsoft GIF Animator and Theme Designer if you haven't installed those programs. Notice that each value (except Default) includes two parts: Name and Data. Name is a unique designator that the Registry uses to keep track of each value. Data is where the important information is kept.
More specifically, the Data field includes a list of arguments, separated by commas. In this case, there are 10 separate arguments, which we'll look at shortly. First, though, let's add a new value.
The most likely command to add to FrontPage Explorer would be one that would launch a companion program, such as an image editor or scanning program. For this article, however, we'll use a more trivial example: a command to launch Solitaire.
To add a new value (and thus a new menu command), choose String Value from the Edit menu's New submenu. Regedit will add a new item, temporarily called New Value #1. While this name would work, it's not very descriptive. So, type Solitaire to change it, then press [Enter].
Now we need to tell Regedit what that command will do. Right-click on Solitaire, then choose Modify from the context menu. When you do, the window shown in Figure C will appear. In the Value Data field, type the following:
2, , 1, Tools, Launch Solitaire, c:\windows\sol.exe,,0,Launches Solitaire.,
Then, click OK and close Regedit. Note that you aren't asked to confirm your changes.
Before we explore what all those arguments mean, let's see how our changes affected FrontPage Explorer. Launch the Explorer now, then open the Tools menu. You should see a command called Launch Solitaire at the end of the menu, as Figure D shows. Choosing that command should launch Solitaire. (You can celebrate your success by playing a game or two before we continue.)
Table A describes each of the 10 arguments you can use and indicates what potential values you can use. It's imperative that you list the arguments in the right order since FrontPage will interpret them by position. So, what's the meaning of the arguments we typed in?
Table A: Custom command arguments
Argument | Description |
first_version | The earliest version of FrontPage that should add the new command. Should be 2 or higher. |
last_version | The latest version of FrontPage that should add the new command. |
menu_bar_number | The menu bar that should include the new command. Should be 1 for FrontPage Explorer; can be 0 or 1 for FrontPage Editor. |
menu_name | The specific menu that should include the new command. You can specify menus by name (e.g., Tools) or by number. |
command_name | The text that should appear on the menu. To create a separator, type a single hyphen. To specify an accelerator key, put an ampersand before that character. |
command_line | The path name of the application to be launched. |
insert_flag | Tells FrontPage what to do with the command_line argument. Should always be 0 for the Explorer; can be 0, 1, or 2 for the Editor. |
status_text | The message that should appear on the status bar when the user selects the new command. |
help_reference | The file name and topic number for the new command's custom help topic, separated by an exclamation point. |
The first entry, 2, means that this new command should only be added to FrontPage if it's version 2 or later -- older versions don't accept custom commands. We omitted the second argument (thus the double commas), so we can add our new command to any version of FrontPage higher than 2.
The third argument, 1, tells the Explorer to add this command only to menu bar #1. You should always put a 1 in this argument because the Explorer has only one menu bar. Tools, the next argument, tells the program to add the command to the Tools menu.
The fifth argument, Launch Solitaire in our case, gives the text that should appear on the menu, while the sixth argument, c:\windows\sol.exe, gives the complete path to the target application. We've skipped the seventh argument, where we could have specified menu position. Since we skipped it, our new command will appear at the bottom of the menu.
Next comes the insert_flag argument, which tells the Explorer what to do with the text c:\windows\sol.exe. You should always put a 0 here to indicate that this command line should be executed. (We'll see how this flag can change when we get to the Editor.)
The ninth argument, Launches Solitaire in our example, indicates what text should appear on the status line at the bottom of the window. Figure D shows the result of this text. Finally, we skipped the tenth argument by adding a trailing comma.
That's all that's required to add a custom command. As long as you use the right arguments in the right order, adding a new command is relatively easy.
Now, let's look at how you can modify FrontPage Editor. We'll add a new command here as well, but first we'll create an entirely new menu.
Adding a menu works much like adding a command. The key you need to modify is
HKEY_CURRENT_USER\Software\Microsoft\FrontPage\Editor\Init Menus
Launch Regedit now and navigate to that key. As you'll see, there are no values set -- hence, no custom menus.
We're going to add a menu called Special, to which we'll later add a command. As you did before, choose String Value from the Edit menu's New submenu. Type Special for the new menu's name, then right-click it and choose Modify from the context menu. Now, type the following in the Value Data field:
2, , 1, &Special, Format
As you can see, menu values require only five arguments. Table B summarizes these arguments.
Table B: Custom menu arguments
Argument | Description |
first_version | The earliest version of FrontPage that should add the new command. Should be 2 or higher. (Same as for commands.) |
last_version | The latest version of FrontPage that should add the new command. (Same as for commands.) |
menu_bar_number | The menu bar that should include the new command. Should be 1 for FrontPage Explorer; can be 0 or 1 for FrontPage Editor. (Same as for commands.) |
menu_name | The name of the new menu. |
menu_position | Gives the menu location of the new menu. Can be either the numerical position from the left end of the menu or the name of the menu before which the new one should appear. |
The first three arguments are identical to those we used before. However, we do need to point out a difference between the Explorer and the Editor.
FrontPage Explorer has only one menu bar -- thus you always indicate a 1 for menu_bar_number. The Editor has two menu bars, however; one that appears when no document is open (0) and one that appears when a document is open (1). So, it's important to specify which menu bar you're modifying.
Given that information, you should easily be able to decipher the arguments you just typed. We want to add our new menu to the Editor if it's version 2 or later, and we want to add the menu to the "document-open" menu bar.
The new menu will be named Special. Note the underscore, which indicates that S is the accelerator key. Finally, the menu will appear just before (to the left of) the Format menu.
Now, let's see how our new menu looks. Close Regedit, then launch FrontPage Editor. Your menu bar should look like the one in Figure E. Of course, there's no command on the menu, but we'll add that next.
By now, working with Regedit should be routine for you, so we'll work through our last example a little more quickly. Close FrontPage Editor, then launch Regedit again. Now, look for the following key:
HKEY_CURRENT_USER\Software\Microsoft\FrontPage\Editor\Init Commands
Create a new string value as before, naming it Copyright. Then, type the following in the Value Data field:
2, , 1, Special, Insert Copyright, c:\windows\desktop\copyrite.txt,,1,Inserts standard copyright language.,
This value looks much like the one we created to launch Solitaire. There are two significant differences, however. First, the command_line is a text file, not an executable file. Second, the insert_flag is a 1, not a 0.
What these changes mean is that choosing the Insert Copyright command will actually insert the text in copyrite.txt directly into the current HTML document. This capability would be useful if you have standard text that you need to add to numerous pages.
You can also put a 2 in insert_flag. Doing that inserts the actual text from command_line into the document. Figure F shows the effect of these two options.
For now, though, leave a 1 as the argument and close Regedit. Launch Word or another text editor and create a simple text file called copyrite.text. Save this file to the Desktop, then launch FrontPage Editor. The Insert Copyright command should appear on the Special menu. Choose it, and the text from copyrite.txt will appear on your page.
In this article, we've shown you how to add custom commands and menus to both FrontPage Editor and Explorer. By using this technique, you can integrate other applications (image editors, scanning programs, etc.) into the FrontPage environment. In addition, you can simplify incorporating standard text into an HTML page.
Copyright © 1998 ZD Journals, a division of Ziff-Davis Inc. ZD Journals and the the ZD Journals logo are trademarks of Ziff-Davis Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis is prohibited.