Microsoft Developer News and Blog Entries

Microsoft Developer

Subscribe to Microsoft Developer: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get Microsoft Developer: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Microsoft Developer Authors: Maureen O'Gara, Jeremy Geelan, RealWire News Distribution, Gram Smith, Pat Romanski

Related Topics: Microsoft Developer

PowerBuilder: Article

Customizing the PB IDE

New techniques and methods

Chapter 5 of PowerBuilder 9: Advanced Client/Server Development included a discussion on how to add items to the New dialog within the PowerBuilder IDE. This article will review that information and look at a couple of additional techniques for extending the PowerBuilder IDE

Adding Items to the New Dialog
All versions of PowerBuilder 7 and beyond allow you to add items to the New Dialog by adding entries to the registry. First navigate to:

HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\PowerBuilder\X.0

where X is the major version of PowerBuilder that you are creating the new item for (7, 8, or 9). Under that key create a new subkey called "CLSID" that all the new items will be located under (see Figure 1).

For each new item you want to add, create another new subkey under the CLSID key named with a globally unique identifier (GUID). A GUID is a 32-character value used within the Windows operating system to uniquely reference objects and has a format of {AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}. There are a number of different ways to generate GUIDs, including:

  • Using GUIDGEN.EXE, a GUI utility that's provided with Microsoft Visual Studio (see Figure 2).

  • Using UUIDGEN.EXE, a command-line utility that's provided with the Windows Platform Software Development Kit (SDK), which is available for free download from the Microsoft Developer's Network (msdn.microsoft.com) (see Figure 3).

  • Alternatively, PowerBuilder is capable of generating GUIDs. If you have a nonvisual object in a PowerBuilder project and a Jaguar profile defined (even if it's not operational), you can fire up the COM/MTS/COM+ Component Wizard. The fifth screen in that dialog generates a GUID for the Interface ID for the component (see Figure 4).

    Once you've generated the first GUID for the first dialog item, you might want to just use sequential values from that point on (refer to Figure 1 again).

    After the CSLID entry has been created, you need to modify the default string value and create three new ones:

  • (Default): The entry is automatically created when the CSLID entry is created. The value you provide for it will be the text that will appear in the New dialog under the new icon.
  • DefaultIcon: This entry points to which icon to use in the new dialog. In addition to .ICO files, this can also point to an .EXE or .DLL file, followed by a comma and then a number that indicates which index to the icon within the EXE or DLL file to use. A number of utilities will show the icons within an EXE or DLL you might select, including the Change Icon dialog within the Windows Create Shortcut utility (see Figure 5). Remember the index is zero-based (the first icon in a DLL or EXE has an index value of 0, the next has an index of 1, etc.).
  • URL: Create this entry to tell PowerBuilder what to run when the user selects the new icon. It can be one of the following:
    -Wizard (addressed below)
    -An Internet shortcut (http://, ftp://, or mailto:)
    -The name of one of the PowerBuilder painters or dialogs (Application://, Database://, DataWindow://, DBProfile://, DataPipeline://, Debug://, FileEdit://, Function://, Library://, Menu://, Project://, Query://, Report://, RunReport://, RunWindow://, Structure://, UserObject://, or Window://)

    The URL syntax follows the standard for Internet URLs in that the URL can be prefixed with username/password information and suffixed by a "?", followed by any arguments in a name/value combination. Arguments to painters can include "action" (where action can be "new," "inherit," "run," "runonly," and "open"), "path" (indicates the path to the PBL containing the object), and "entry" (indicates the name of the object).

  • Tabpage: This entry indicates the tabpage that you want the new icon to appear on. You don't need to provide a value for the string value, just the name.
    -WorkspaceTool for the Workspace tabpage
    -StartTool for the Target tabpage
    -ObjectTool for the Object tabpage
    -WebTool for the Web tabpage
    -DataWindowTool for the DataWindow tabpage
    -DataBaseTool for the DataBase tabpage
    -ProjectTool for the Project tabpage
    -Tool for the Tool tabpage

    Listing 1 is a portion of a PowerBuilder utility, available in the source code, that will create these registry entries for you.

    The results are shown in Figure 6. Note that there does not appear to be any way to control the position of the new icon. Interestingly enough, they're added to the front of the dialog, not at the end, as I would have expected.

    Also note that the URLs indicated here will work in the custom toolbar icon dialogs as well. The main advantage of adding items to the New Dialog over the toolbar is that the toolbar doesn't allow you to use icons other than those provided with PowerBuilder.

    Creating Custom Wizards
    You may not realize it, but a number of the PowerBuilder system DLLs in the Shared/PowerBuilder directory are not actually DLLs. They're PBDs (compiled PowerBuilder libraries) that have simply been renamed. If you rename the extension on a copy of them to PBL and add the PBDs to a target, you can examine the object listing and even open the objects in the PowerBuilder IDE, but you won't be able to view the source for any scripts. In particular, the PBADD90.DLL appears to contain the many items provided with PowerBuilder on the tools tab of the new dialog (migration assistant, DataWindow syntax, profiling tools, PFC extender, etc.). The PBGEN90.DLL file appears to be the PowerBuilder objects used during template target generation. Finally, the PBWIZ90.DLL and PBWZP90.DLL files appear to be the PowerBuilder objects that serve as a basis for many of the wizards that appear with the PowerBuilder IDE.

    This illustrates the next method of extending the PowerBuilder IDE. It's possible to create objects within PowerBuilder that can then be used as wizards within the IDE. Once you've created the objects and compiled the library that contains them to a PBD, let the PowerBuilder IDE know about them through a couple of registry entries. First, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Sybase\PowerBuilder\X.0 again, and this time create a subkey called "WizardLibraries." Under that new subkey create new string values for each PBD you want to be able to use the objects from. The name of the string values must be a sequential number, and the value will point to the PBD file.

    Now that the objects are available to the PowerBuilder IDE, create a new dialog icon or custom toolbar icon that runs them, using the "wizard" keyword mentioned above. The "wizard" keyword syntax is as follows:

    wizard:?entry=<name of window>

    where <name of window> is the window you want the PowerBuilder IDE to run when the option is selected (without the brackets).

    The source code for this article includes a small utility for creating the WizardLibraries entry for you. Listing 2 provides the most relevant section of that application.

    Figure 7 illustrates a custom wizard running from within the PowerBuilder IDE. The sample code for this wizard is also included in the sample code for the article.

  • More Stories By Bruce Armstrong

    Bruce Armstrong is a development lead with Integrated Data Services (www.get-integrated.com). A charter member of TeamSybase, he has been using PowerBuilder since version 1.0.B. He was a contributing author to SYS-CON's PowerBuilder 4.0 Secrets of the Masters and the editor of SAMs' PowerBuilder 9: Advanced Client/Server Development.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.