Windows 95/NT Shell Programming Service |
Ver. 1.08 Contributed by Roy Kiesler |
Many PowerBuilder developers spend too much time trying to create visual user objects
that resemble the Windows standard user interface and common controls, only to end up with
something that sort of looks like the real thing, but not quite. PowerBuilder 5.0 brought along tab objects and tab pages, tree and list views. PFC 6.0 has provided some additional visual objects (notably the dropdown calendar and calculator objects, and the progress bar object.) However, PowerBuilder applications are still lacking functionality in certain UI aspects. The Windows® 95/NT shell provides a plethora of goodies that can be used from a PowerBuilder. Using the shell functionality helps reduce the size of your applications, and gives them a consistent look and feel. This PFC extension service encapsulates a number of important Win32 shell API functions. |
n_cst_winsrv_shell32 inherited from n_cst_winsrv. |
Function | Description |
of_AddToRecentDocs | Adds a document to the shells list of recently used documents. |
of_ClearRecentDocs | Removes all links from the shells list of recently used documents. |
of_AddToSysTray | Adds an status indicator icon to the system tray area. |
of_ModifySysTray | Changes the icon and/or tooltip text of a status indicator object. |
of_RemoveFromSysTray | Removes a status indicator icon from the system tray. |
of_BrowseForComputer | Displays the shell's namespace browse dialog. Allows the user to select a single computer name. |
of_BrowseForFolder | Displays the shell's namespace browse dialog. Allows the user to select a single directory name. |
of_BrowseForPrinter | Displays the shell's namespace browse dialog. Allows the user to select a single printer name. |
of_BrowseURL | Opens a URL in the default web browser. |
of_FileCopy | Copy file system objects with an animated progress dialog. |
of_FileMove | Move file system objects with an animated progress dialog. |
of_FileDelete | Delete file system objects with an animated progress dialog. |
of_FormatDrive | Displays the standard shell format dialog box. |
of_GetSpecialFolderPath | Returns the full qualified path of a system special folder. |
Curtesy of . | |
of_ExploreSpecialFolder | Opens an Explorer window for a special system folder. |
of_GetFileVersionInfo | Returns a structure with version
information for executables and DLLs. Curtesy of . |
of_FilePrint | Prints a file using its associated application (e.g., *.TXT using Notepad, *.XLS using Excel, etc.) |
of_FileProperties | Displays the standard Windows Explorer file properties dialog. |
of_CreateShortcut | Creates a shortcut (.LNK file) for a specified file in a specified target directory. |
of_ResolveShortcut | Resolves the attributes of a shortcut file (target executable, startup directory, icon, window state, etc.) |
The n_cst_winsrv_shell32 is an auto-instantiated NVO. In order to use it, you need to declare it as a variable and register a window object with it, as shown in listing 1 below. |
Listing 1: Open() event for a window |
n_cst_winsrv_shell32 lnv_shell lnv_shell.of_SetRequestor( This ) |
The file shellsrv.pbl contains a small PFC application that demonstrates the use of all functions in this service. |
The of_AddToSysTray() and of_ModifySysTray() functions demonstrate a way to handle a
limited set of Windows callback functions in PowerBuilder (everyone told you it isn't
possible, right?) When calling the underlying Win32 API function, Shell_NotifyIcon(), one can supply a Windows message to be sent back to the owner window when the user interacts with the tray icon. It turns out that if one chooses the WM_MOUSEMOVE message as the callback message, then the X position of the mouse cursor corresponds to the value of the message generated, as shown in the following table. |
|
Mouse xpos | Windows Message |
512 | WM_MOUSEMOVE |
513 | WM_LBUTTONDOWN |
514 | WM_LBUTTONUP |
515 | WM_LBUTTONDBLCLK |
516 | WM_RBUTTONDOWN |
517 | WM_RBUTTONUP |
518 | WM_RBUTTONDBLCLK |
Note: | the PowerScript function UnitsToPixelsX() does not always return the correct pixel
value corresponding to the PBU value passed to it (unlike the TwipsPerPixelsX property in
Visual Basic, from which this method is adapted.) On some systems, if the mouse is moved in a consistently erratic way across the screen, the calculation of UnitsToPixelsX( xpos, XUnitsToPixels! ) might yield a value in the range of 512-518, which will cause your application to process it as if you clicked on the tray icon. Until a more reliable way to calculate exact positioning in pixels is provided by Powersoft, try to limit the functionality of the tray icon to non-destructive actions (e.g., displaying an about box, restoring a minimized/hidden window, etc.) |
Revision History | ||
05/11/1999 | of_ControlPanel function to invoke control panel applets.
3 new C++ functions added: A new function, of_SetTrayCallback(), allows the user to pass a user-event id (pbm_custom01-75 mapped to 1024-1098) to handle mouse messages from the system tray. The default is 1024 (pbm_custom01). Added overloaded versions of file operation functions to accept multiple filenames (in unbounded arrays). Thanks to for the code. The demo application and the shell service objects were split into two separate libraries, so that users could more easily determine which objects are which. Thanks to for this productivity enhancement. |
Ver. 1.08 |
11/22/1998 | Added a C++ companion userobject and DLL that extend the current capabilities of this service. New features include the ability to manipulate shell object links (shortcut files), browse the shell namespace from any given folder and display the standard Explorer file properties dialog. 4 new public functions were added: of_FilePrint() of_FileProperties() of_CreateShortcut() of_resolveShortcut() | Ver. 1.07 |
10/02/1998 | Bug fixes for of_FileCopy and of_FileDelete functions that gets rid of the system error #1026 when using wildcard parameters. | Ver. 1.06 |
07/08/1998 | A new public function of_GetFileVersionInfo was added. The function returns a structure with version information for executables and DLLs. | Ver. 1.05 |
06/22/1998 | Updated the shell service to overload the of_AddToSysTray() and of_ModifySysTray() functions to load an icon from the machine code executable withoput having to specify an icon file name. | Ver. 1.04 |
05/22/1998 | Added a version of the service. | Ver. 1.03 |
04/15/1998 | Overloaded the
functions below to provide caching of the last browsed item, so the next time you browse,
the last item will be at the root of the dialog instead of the default 'My Computer'. of_BrowseForComputer() of_BrowseForFolder() of_BrowseForPrinter() |
Ver. 1.02 |
03/10/1998 | Added two functions: of_GetSpecialFolderPath() and of_ExploreSpecialFolder() |
Ver. 1.01 |
03/06/1998 | Initial Revision | Ver. 1.00 |
Interested in contributing material to this web site? Send an email to submit@pfcguide.com, but don't forget to check the contribution guidelines first.
For information or suggestions about this web site please contact webmaster@pfcguide.com
PFCGuide is
sponsored by Dynamic Technology Group.
The information on this site is provided for advice only and not to be considered a
contract or a liability against Dynamic
Technology Group.