Tips and Techniques - April 1995

Tip:

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.

Tip:

Need to start another thread while overriding a Workplace Shell method?

Technique:

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.

Tip:

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.

Tip:

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</tt>) or the circular slider (WC_CIRCULARSLIDER</tt>) to present a more powerful set of controls.

Tip:

For BS_PUSHBUTTON</tt> style button controls in OS/2 Warp, you can display text and an icon (or mini-icon or bitmap) within a push button.

Technique:

Specify the following as the button's text string: "#nnnn\tMy Button"

where nnnn</tt> indicates the ID (for example, 3000) for a given icon (*.ICO file), and \t</tt> indicates the beginning of the text field. Don't forget to specify the BS_TEXT</tt> and BS_ICON</tt> (or BS_MINIICON</tt> or BS_BITMAP</tt>) styles.

Tip:

WinMessageBox2</tt> 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</tt> buttons, there was no way to change the text.

Now with WinMessageBox2</tt> 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</tt> resizes to display all of them.

Tip:

When using WinSetPresParam</tt> to set a new presentation parameter (PP), remember that if the new PP is in string form its size is strlen("PP_string")+1</tt>.

Tip:

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.

Technique:

A va_list</tt> 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 <tt>va_list</tt> is not a CORBA type - a sequence is a CORBA type). Keep in mind, however, that for code portability this use of <tt>va_list</tt> should be a straightforward ANSI C implementation.

Tip:

DSOM naming conventions in SOM V2.0:

SOM kernel classes: SOMXxxxxx (where Xxxxxx is the class name). For example: SOMObject

SOM frameworks: SOMFXxxxxx (where F represents the framework type). For example, a DSOM framework: SOMDServer

Method names: somfXxxxxx (where f is the framework type, if any). For example, a method in DSOM framework: somdNewObject

Macros: SOMF_xxxxxx (where F is the framework type, if any). For example: SOM_InitEnvironment