Tips and Techniques - April 1995
If you are writing a Workplace Shell class and have gotten to the debugging phase, be sure to set the shell s exception handler off so that you will be able to see any traps in your code. Add the line SET SHELLEXCEPTIONHANDLER=OFF to your CONFIG.SYS file and reboot your system to make the change effective. If you don't do this, the shell s exception handler will intercept the traps and restart the shell before you get a chance to see and debug the situation.
Need to start another thread while overriding a Workplace Shell method?
The cleanest implementation results from overriding wpInitData. Call the parent before adding your code to create the new thread. Kill the thread by overriding wpUnInitData.
Whenever creating Presentation Manager threads in a program (those that call WinInitialize and WinCreateMsgQueue) that do not receive user input or are not top-level windows, be sure to call WinCancelShutdown right after creating the message queue. Not doing so will cause the system to send the thread a WM_QUIT message when the user is shutting down the system. By calling WinCancelShutdown, your main thread can control the termination of all other threads in the application.
Notice that the Circular Slider class code has been moved from the OS/2 Multimedia Toolkit to the Developer's Toolkit for OS/2 Warp Version 3.0. Now that it's part of the base system, you can choose to use the linear slider (WC_SLIDER) or the circular slider (WC_CIRCULARSLIDER) to present a more powerful set of controls.
For BS_PUSHBUTTON style button controls in OS/2 Warp, you can display text and an icon (or mini-icon or bitmap) within a push button.
Specify the following as the button's text string:
where nnnn indicates the ID (for example, 3000) for a given icon (*.ICO file), and \t indicates the begining of the text field. Don't forget to specify the BS_TEXT and BS_ICON (or BS_MINIICON or BS_BITMAP) styles.
WinMessageBox2 was added to OS/2 Warp to give you an easy way to customize the contents of message boxes. Before OS/2 Warp, if a developer in Spain did not like IBM's Spanish equivalent of Cancel for one of the WinMessageBox2 buttons, there was no way to change the text.
Now with WinMessageBox2 you can:
- Specify a customized icon (such as a program s icon or a company logo)
- Create a non-modal message box
- Specify your own text for the buttons within the message box
- Show a title bar with a title of your choice, and a field to display information in text form
- Include a whole row of buttons The dialog created by WinMessageBox2 resizes to display all of them.
When using WinSetPresParam to set a new presentation parameter (PP), remember that if the new PP is in string form its size is strlen("PP_string")+1.
When using SOM V2.0, you cannot use Interface Definition Language (IDL) to define a function twice with different sets of parameters (overloading) However, if you must, try the following.
A va_list type, used for a variable list of arguments, will enable you to define a function that handles different groups of parameters. However, once the types of arguments have been defined, you cannot vary them when you override the function. Also, the variable cannot be used with classes that have proxies (that is, the variable can t be used with DSOM because va_list is not a CORBA type - a sequence is a CORBA type). Keep in mind, however, that for code portability this use of va_list should be a straightforward ANSI C implementation.
DSOM naming conventions in SOM V2.0:
SOM kernel classes: SOMXxxxxx (where Xxxxxx is the class name). For example:
SOM frameworks: SOMFXxxxxx (where F represents the framework type). For example, a DSOM framework:
Method names: somfXxxxxx (where f is the framework type, if any). For example, a method in DSOM framework:
Macros: SOMF_xxxxxx (where F is the framework type, if any). For example:
Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation