11.07.2015 Views

in PowerBuilder - sys-con.com's archive of magazines - SYS-CON ...

in PowerBuilder - sys-con.com's archive of magazines - SYS-CON ...

in PowerBuilder - sys-con.com's archive of magazines - SYS-CON ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

FIGURE 6 |FIGURE 8 |FIGURE 7 | FIGURE 9 |SELECT "pbcatcol"."pbc_cnam","pbcatcol"."pbc_cmnt"FROM "pbcatcol"WHERE "pbcatcol"."pbc_cmnt" is not NULL;The above query should return the column name and the column’scomment textual value as located <strong>in</strong> the PBCatCol table. For this test Iadded a comment to the Employee’s Sex column and the query aboveresulted <strong>in</strong> the ISQL result set shown <strong>in</strong> Figure 5.Help CompilationOnce you have taken the time to populate appropriate commentson the data elements with<strong>in</strong> your data model (schema), the extendedproperties will also be loaded <strong>in</strong>to your database’s <strong>sys</strong>tem tables. Youcan use the technique I just described earlier to extract the columnname and the column’s comment text us<strong>in</strong>g the previous SQL example.To test this, I commented the “Contact” table’s columns and ran theSQL, which resulted <strong>in</strong> a two-column output <strong>in</strong> the ISQL pane <strong>of</strong> thedatabase pa<strong>in</strong>ter. To export this <strong>in</strong>formation, I used the “alternate”mouse button (RHMB) and chose the “Save Rows As” option <strong>in</strong> theresult<strong>in</strong>g pop-up menu. I then proceeded to save the result set as a tabdelimited text file. Us<strong>in</strong>g this format allows the developer to easily<strong>in</strong>clude this key <strong>in</strong>formation <strong>in</strong>to any help compiler.The favorite product that I use to generate help files is called “Docto-Help”from ComponentOne. I can utilize this tool to generate varioushelp file flavors for all my Web, PocketBuilder, and <strong>PowerBuilder</strong>projects. I will briefly show you the highlights <strong>of</strong> this process. The firststep is to create a new project and import the tabbed delimited textoutput from the database pa<strong>in</strong>ter as described above. The new projectwill generate an MS-Word document where you can import the text filewith the column name and description. At this po<strong>in</strong>t you must markthe column names as a procedural head<strong>in</strong>g. In Doc-to-Help, you cando this by select<strong>in</strong>g each column name and sett<strong>in</strong>g each property to“Head<strong>in</strong>g 4.” The type “Head<strong>in</strong>g 4” sets the font, po<strong>in</strong>t size, and marksthe column name as “procedural” help (see Figure 6).Doc2Help will automatically generate Context IDs for any project.In the project pa<strong>in</strong>ter <strong>of</strong> Doc-to-Help, select “topic types,” then thesub-type “procedural.” At this po<strong>in</strong>t you can select a property called“AutoContextID” and set this value to “True” (see Figure 7). This forcesthe Doc-to-Help Compiler <strong>in</strong> <strong>con</strong>cert with the MS-Help compiler togenerate and <strong>in</strong>corporate “Context ID” numbers <strong>in</strong>to your .HLP or.CHM file. From this po<strong>in</strong>t onward, the easy part can be enjoyed by the<strong>PowerBuilder</strong> developer who only has to use the ShowPopupHelp ( )command to activate this great MS-W<strong>in</strong>dows feedback mechanism.Doc2Help has also generated a reference file for the <strong>PowerBuilder</strong>,VisualBasic, C#, Delphi, etc., programmer as to the topic names andtheir Context IDs, so now we have the direct mapp<strong>in</strong>g to the <strong>in</strong>formationthat we need for the help or bubble help feature we want to use.In the test case above, I used the “Contact” table <strong>in</strong> the sample ASA9.0 database and the columns such as City, Fax, and First Name showup as well as their Context ID numbers (see Figure 8). When cod<strong>in</strong>g aS<strong>in</strong>gleL<strong>in</strong>eEdit, Multil<strong>in</strong>eEdit, DataW<strong>in</strong>dow, or other type <strong>of</strong> <strong>con</strong>trol <strong>in</strong><strong>PowerBuilder</strong>, you are provided with a “Help” event (present s<strong>in</strong>ce<strong>PowerBuilder</strong> version 8.0). The Help event is automatically triggeredwhen the application user has focus on the <strong>con</strong>trol and presses the“shift+F1” key. Also, <strong>in</strong> a response dialog, you use the “ContextHelp”property (set to True) to have the O/S generate a “?” on the w<strong>in</strong>dow’stitle bar. Dragg<strong>in</strong>g the w<strong>in</strong>dow “?” on to any <strong>con</strong>trol also fires the Helpevent dur<strong>in</strong>g the drop operation.For the Help event, use the ShowPopupHelp ( ) command. If I wantedto provide Context help to the command button, for example, called“City,” my Help event would use the code: ShowPopupHelp ("<strong>CON</strong>-TEXT.HLP", THIS, 63) – which would result <strong>in</strong> Figure 9.To make this more reusable, I typically use the “Tag” property orcreate an ancestor class that adds a protected <strong>in</strong>stance variable (suchas il_<strong>con</strong>text_id”) where I can store the Context ID mapp<strong>in</strong>g that I getfrom the help compiler. You would never want to hard-code this valueas it can change as new <strong>in</strong>formation is added to the help file. I wouldeven take this further for pure object-oriented reusability and create aservice that would dynamically read the “mapp<strong>in</strong>g file” and return theContext ID based on a component name.DataW<strong>in</strong>dow ColumnsFor DataW<strong>in</strong>dow columns, the process has to be slightly different aswe have to <strong>con</strong>sider two objects – the DataW<strong>in</strong>dow <strong>con</strong>trol and theDataW<strong>in</strong>dow object – that when comb<strong>in</strong>ed create the “dynamic duo”that all <strong>PowerBuilder</strong> developers have come to know and love (evenVisual Studio developers now with DataW<strong>in</strong>dow.NET). When the Helpevent is fired, the operat<strong>in</strong>g <strong>sys</strong>tem message is actually sent to theDataW<strong>in</strong>dow <strong>con</strong>trol but it only <strong>con</strong>ta<strong>in</strong>s the X and Y position <strong>of</strong> theContext Help request. What the developer needs to do at this po<strong>in</strong>t isdeterm<strong>in</strong>e the column name. Luckily, we can use the “GetColumn-Name” method to return the column, which has focus <strong>in</strong> the DataW<strong>in</strong>dowobject. Once we have that <strong>in</strong>formation, you could use the technique<strong>of</strong> stor<strong>in</strong>g the Context ID <strong>in</strong> the “tag” property.Once you have the column name and its Context ID, the ShowPopupHelp( ) method should do nicely here. However, the DataW<strong>in</strong>dow<strong>con</strong>trol does not activate the “Help” event and we need to acquire the<strong>in</strong>formation about the column that has focus (which is an object <strong>in</strong>sidethe DataW<strong>in</strong>dow object, which is <strong>in</strong>side the DataW<strong>in</strong>dow Control, i.e.,nested scenario). Remember, the GUI standard for request<strong>in</strong>g Help isShift+F1, but if you try this on the DataW<strong>in</strong>dow Control, the Help eventwill not fire. This seems to have been an oversight <strong>in</strong> <strong>PowerBuilder</strong>s<strong>in</strong>ce release 8.0.We can easily simulate the Help request though by add<strong>in</strong>g a userevent to the DataW<strong>in</strong>dow <strong>con</strong>trol. In this case, we need to map a newuser event to the “pbm_dwkey” Event ID. This will allow you to receivenotifications from the keyboard. Once this event is mapped, we can18PBDJ volume12 issue11www.<strong>SYS</strong>-<strong>CON</strong>.COM/pbdj/

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!