Jump to content

Tips and Techniques - April 1995: Difference between revisions

From EDM2
Created page with "By IBM '''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 ab..."
 
Ak120 (talk | contribs)
No edit summary
Line 1: Line 1:
By [[IBM]]
''by [[IBM]]''


'''Tip:'''


'''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 <tt>SET SHELLEXCEPTIONHANDLER=OFF</tt> 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.


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:'''
 
'''Tip'''


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


'''Technique'''
'''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
The cleanest implementation results from overriding <tt>wpInitData</tt>. Call the parent before adding your code to create the new thread. Kill the thread by overriding <tt>wpUnInitData</tt>.


'''Tip'''
'''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 appliccation
Whenever creating Presentation Manager threads in a program (those that call <tt>WinInitialize</tt> and <tt>WinCreateMsgQueue</tt>) that do not receive user input or are not top-level windows, be sure to call <tt>WinCancelShutdown</tt> right after creating the message queue. Not doing so will cause the system to send the thread a <tt>WM_QUIT</tt> message when the user is shutting down the system. By calling <tt>WinCancelShutdown</tt>, your main thread can control the termination of all other threads in the application.


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


'''Tip'''
'''Tip:'''


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
For <tt>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'''
'''Technique:'''


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


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


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
'''Tip:'''


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


Now with <tt>WinMessageBox2</tt> you can:
* Specify a customized icon (such as a program s icon or a company logo)
* Specify a customized icon (such as a program s icon or a company logo)
* Create a non-modal message box
* Create a non-modal message box
* Specify your own text for the buttons within the 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
* 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
* Include a whole row of buttons The dialog created by <tt>WinMessageBox2</tt> resizes to display all of them.


'''Tip'''
'''Tip:'''


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 <tt>WinSetPresParam</tt> to set a new presentation parameter (PP), remember that if the new PP is in string form its size is <tt>strlen("PP_string")+1</tt>.


'''Tip'''
'''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
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'''
'''Technique:'''


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
A <tt>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'''
'''Tip:'''


DSOM naming conventions in SOM V2 0
DSOM naming conventions in SOM V2.0:
 
SOM kernel classes SOMXxxxxx (where Xxxxxx is the class name) For example


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


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


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


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


'''Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation'''
'''Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation'''


 
[[Category:Developer Connection News]][[Category:Miscellaneous Articles]]
[[Category:Miscellaneous Articles]]

Revision as of 19:39, 21 April 2016

by IBM

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

Tip:

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.

Technique:

Specify the following as the button's text string:

"#nnnn\tMy Button"

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.

Tip:

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.

Tip:

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.

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 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.

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

Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation