|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV SYS-CON.TV WEBCASTS |
POWERBUILDER LINKS YOU MUST CLICK ON Feature PBDJ Feature: Custom Common Dialogs Using SetWindowsHookEx
PowerBuilder contains a number of built-in common dialogs that can be used within your own applications
By: Bruce Armstrong
Mar. 2, 2008 10:00 AM
The dialogs PowerBuilder provides include:
Enter SetWindowsHookEx Fortunately, the introduction of the PowerBuilder Native Interface (PBNI) allows us to implement a callback in a fairly straightforward manner. In this particular example, the callback procedure within our PBNI extension will do all the necessary work. However, since PBNI extensions can invoke PowerBuilder object methods, it's certainly possible to move the processing back into PowerBuilder objects as well. Note that the SetWindowsHookEx method will hook all occurrences of the particular Windows message it's set for. This means we should follow a number of guidelines when using this method.
With the most recent versions of PowerBuilder, the DataWindow Control now supports saving the data out in 18 different file formats. In combination with the option to include column header information in the file for certain formats, the resulting dropdown list box of file formats in the SaveAs dialog contains 26 options. Unfortunately, the SaveAs method doesn't allow you to filter the list or to control which file format appears as the default format. There are a number of reasons that you might want to have those options. For example, two of the formats on that default list (XML and XSLFO) require you to deploy additional DLLs (e.g., PBXerces90.DLL and xerces-c_2_1_0.DLL). One of the other formats (PDF) requires the deployment of some printer driver files and Ghostscript, a third-party GPL-licensed utility. In most cases, the GPL license prohibits distribution of that utility outside of your own company, which could make it necessary for your end users to obtain and install it themselves to support that particular format. You may simply decide that you would rather remove those formats from the dropdown list rather than deal with the deployment issues. There are also a number of other formats (SYLK, WKS, WK1, DIF, dBASE2, dBASE3) that are largely irrelevant in most cases and that you may want to exclude. There are still other formats you may choose not to support for your application (e.g., older Excel formats, SQLInsert, PSReport, WMF, and HTMLTable). Finally, if you're fairly certain that your end users will be saving to a particular format the majority of the time (e.g., Excel8), you may want to make that the default format.
How It's Done Listing 1 is the header file for the extension. The template generates prototypes of sample methods in that header file with different names but the same argument list. We'll implement all of the methods within our class following that pattern. Any information that we need within our method, including the arguments that were passed to us from PowerBuilder in the extension call, will be available to us through the methods or properties of those arguments. So we rename one of the template-generated methods to Register, rename another to FilterFileTypes, and then copy one of those prototypes and rename that one SetDefaultFileType. There are four basic operations our extension will be involved in:
PBDJ LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING POWERBUILDER / SYBASE NEWS
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||