The following sample illustrates the class interface definition file (IDL):
//# Include the class definition file for the parent classes
#include <wpdataf.idl>
#include <somcls.idl>
interface M_Hello; // Forward reference to metaclass
//#******************************************************************************
//# Define the new class
//#******************************************************************************
interface Hello : WPDataFile
{
//
// CLASS: Hello
//
// CLASS HIERARCHY:
//
// SOMObject
// ÀÄÄÄWPObject
// ÀÄÄÄWPFileSystem
// ÀÄÄÄWPDataFile
// ÀÄÄÄHello
//
// DESCRIPTION:
//
// This is the sample class to demonstrate Workplace Shell menu
// customization.
//
#ifdef __SOMIDL__
implementation
{
//# Class modifiers
externalstem = hello;
local;
externalprefix = hlo_;
majorversion = 1;
minorversion = 2;
filestem = hello;
metaclass = M_Hello;
callstyle = idl;
dllname = "hello.dll";
passthru C_h = ""
"#define INCL_WIN"
"#include <os2.h>"
""
"/*"
" * The following user-defined pop-up menu items (ID_xxx) should"
" * be higher than WPMENUID_USER."
" *"
" * The ID_OPENHELLO will become a submenu of the system's pop-up"
" * open menu id, WPMENUID_OPEN."
" */"
""
"#define ID_OPENHELLO (WPMENUID_USER+1) /* Menus to be added */"
"#define ID_MSGBOX (WPMENUID_USER+2)"
"#define IDM_OPENHELLO (WPMENUID_USER+3) /* Submenus of added menus */"
"#define IDM_MSGBOX (WPMENUID_USER+4)"
"#define ID_FRAME 3000 /* Hello window frame ID */"
""
"// The ID of the Hello window view. This is returned by the override"
"// of wpclsQueryDefaultView to specify that the default view"
"// is to open the Hello window. This ID MUST be the same as the ID of"
"// the open menu item."
""
"#define OPEN_HELLO ID_OPENHELLO";
//#******************************************************************************
//# Define overridden methods
//#******************************************************************************
wpFilterPopupMenu: override;
// METHOD: wpFilterPopupMenu
//
// DESCRIPTION: Remove any menu items from the context
// menu that don't apply.
//
// HOW TO OVERRIDE: No restrictions.
//
// NOTES:
//
// This method is called when an objects' context menu has been requested
// (i.e. right click or S-F10 on an object) before displaying the menu. It
// is called before wpModifyPopupMenu.
wpModifyPopupMenu: override;
// METHOD: wpModifyPopupMenu
//
// DESCRIPTION: Add the menu items to the context menu.
//
// NOTES:
//
// This method is called when an objects' context menu has been requested
// (i.e. right click or S-F10 on an object) before displaying the menu. It
// is called after wpFilterPopupMenu.
wpMenuItemSelected: override;
// METHOD: wpMenuItemSelected
//
// DESCRIPTION: Processes input from the menu options that was added.
//
// NOTES:
//
// This method is called when an item in an objects' context menu has been
// selected.
wpOpen: override;
// METHOD: wpOpen
//
// DESCRIPTION: Opens the Hello Workplace Shell window.
//
// NOTES:
//
// This method is called when a new open view of an object is needed,
// i.e. when an item in an object's Open submenu has been selected or
// when an object is double clicked on. This is equivalent to selecting
// the default item in the object's Open submenu.
//
// wpOpen should always open a new view. The Workplace Shell actually calls
// wpViewObject first when an object is double clicked on or an open
// submenu item is selected. wpViewObject will then call wpOpen if there
// is currently no open view of the selected Open submenu item or if
// mutliple concurrent views of the object are enabled.
}; /* End implementation */
#Endif /* __SOMIDL__ */
};
//#******************************************************************************
//# Define the metaclass
//#******************************************************************************
interface M_Hello: M_WPDataFile
{
//#******************************************************************************
//# Define metaclass methods
//#******************************************************************************
HMODULE clsQueryModuleHandle();
// METHOD: clsQueryModuleHandle
//
// DESCRIPTION:
//
// Returns the module handle of this class. If this is the
// first invocation, DosQueryModuleHandle is called to save the handle
// for future invocations.
//
// RETURN:
//
// 0 Unsuccessful
// non-zero Module handle
//
// NOTES:
//
// This method is called when a new open view of an object is needed,
// i.e. when an item in an object's Open submenu has been selected or
// when an object is double clicked on. This is equivalent to selecting
// the default item in the object's Open submenu.
//
//#******************************************************************************
//# Define metaclass data
//#******************************************************************************
attribute HMODULE hmod;
#ifdef __SOMIDL__
implementation
{
releaseorder: clsQueryModuleHandle;
//# Class modifiers
externalstem = hello;
local;
externalprefix = hloM_;
majorversion = 1;
minorversion = 2;
filestem = hello;
callstyle = oidl;
dllname = "hello.dll";
//#******************************************************************************
//# Define overridden metaclass methods
//#******************************************************************************
wpclsQueryDefaultView: override;
// METHOD: wpclsQueryDefaultView
//
// DESCRIPTION: Returns the default view for a new instance
// of this object.
//
// REMARKS:
//
// Return the ID of the default view, OPEN_HELLO.
// This ID must be the same as the ID of the open
// submenu item, ID_OPENHELLO.
//
// NOTES:
//
// This method is called to determine which view to open when an
// object of class Hello is double clicked on.
wpclsQueryTitle: override;
// METHOD: wpclsQueryTitle
//
// DESCRIPTION: Return the string "Hello Workplace Shell".
//
// NOTES:
//
// This method is called by the Workplace Shell to determine the object
// title when an object of class Hello is created.
//
}; /* End implementation */
#endif /* __SOMIDL__ */
};