Feedback Search Top Backward Forward
EDM/2

The Codesmith's Library

Written by Carsten Whimster

 

Introduction

The Codesmith's Library is a monthly column which focuses on development oriented books and materials. This will mostly consist of programming books, such as this month's Learning to Program OS/2 2.0 Presentation Manager by Example, but could also cover books like The Design of OS/2. The column is from a beginning PM programmer's eyes (because that's what I am), and hopefully that is most useful to the community in general. As I get on with the column, however, I expect to get better, and so within a year or so, I will presumably :) qualify as an intermediate programmer, or perhaps even somewhat of an expert. Hopefully you, the readers, will move with me in that respect. When reading this column, try to pick up whichever book strikes your fancy, and join the growing group of people following our introductory PM programming columns. I will try to review books aimed at beginners to start with, and then move on from there.

The column will largely be demand-oriented (after I get my own books out of the way early on), so if you have a book you would like reviewed, send me e-mail and tell me about it, or even better, send me the book. Finally, please send me your comments and thoughts so that I can make this column as effective as possible. After all, this is our magazine, and it will be most effective with lots of reader feedback.

This month's selection was chosen because I own a copy :), and because it has a number of good chapters in it. It was purchased through IBM. It is obviously for the previous version of OS/2, and so does not have any 2.1 features in it. However, most of the API is unchanged so there is still lots of useful material in it.

Errata

After the March review I was contacted by someone who told me that the Watcom makefile wasn't on the disk that came with Real World Programming for OS/2 2.1. I took a quick look, and at first glance he appeared to be right. I looked a little closer, however, and found the file in a:\brief\backup\watcom.mak. Fairly well hidden, but there nonetheless. Why it was two levels deep remains a mystery, as the other makefiles were in the root directory. It does look like it is a Watcom C386 makefile, though. I don't know enough about their product to say whether it will work with Watcom C/C++, but I imagine it probably will.

Some people have commented on Borland problems as well, so here is how to make RWPOS2 work with Borland:

  1. edit BORLAND.MAK to say OS2 instead of OS2386 in both TLINK lines.

    OR

    if you have the Toolkit, make sure that BC can find OS2386.LIB . This lets you recompile the programs (link, to be accurate).

  2. set an environment variable called LIB to point to your BCOS2\LIB directory. This fixes the command-line MAKE command.

  3. if you don't have the Toolkit (see above), then you will have to edit the definition file from chapter 3 to include these lines to be able to recompile that particular program:
       IMPORTS
          Win32StretchPointer = PMWIN.968
    

Learning to Program OS/2 2.0 Presentation Manager by Example

This book has been an eye-opener for me. When I first bought it, I was a little disappointed with the fairly dry presentation, and the only 230 pages. As I started reviewing it in earnest, however, I realized that its small size is misleading. Before I go any further, let me list the chapter headings:

 1.  Overview
 2.  Working With Messages
 3.  Drawing in the Client Area
 4.  Working With Resources
 5.  Message and Dialog Boxes
 6.  Animation
 7.  Implementing a Help Interface
 8.  Working With Time
 9.  Notable OS/2 2.0 Enhancements
This doesn't look like much on the face of it, but several of these chapters are very well written, and give a very good introduction to their material. Unfortunately, the installation "program" for the sample code (on a 3.5" disk) consists of a series of copy statements, so there is no great learning material in that area.

First, I should note that I didn't really get a chance to read very much in chapters 3, 6, and 8, so, sorry Q, I don't know if the animation you are looking for is in chapter 6 :). It looks like it is only the imaginative application of GpiBitBlt and DosSleep, however, with GpiSetPattern thrown in for the fade effect demonstrated. No sprites. Chapter 3 looks like a fairly good introduction to GPI functions, working with fonts, kerning and so on. Chapter 8 contains a brief introduction to using WM_TIMER messages, DosSleep(), and threads.

The chapters I did read in depth (chapters 1, 2, 4, 5, and 7) are very good, though. "Overview" is perhaps a bit brief, but I think that most programmers prefer getting their feet wet quickly, so no great loss there.

"Working With Messages" introduces the first snippets of code. By the way, this book has only one sample program! It is a puzzle-type application, in which you cut the screen up into a grid, scramble the rectangles, and try to put it back together again. This program eventually grows to be fairly large, and serves to introduce a number of important basic areas, but if you are looking for a series of diverse applications and lots of sample code, look elsewhere. Having said that, let me explain why this is a good beginner's book after all. The introduction to why PM programs are as strangely laid out as they are is quite good, and the code is well documented and explained. This chapter lays out the obligatory skeleton program, on which the rest of the features are hung along the way.

Each chapter adds its own components to the basic program, until at the end of the book, the full source code listing is presented in an appendix. In this manner, "Working With Resources" explains how the various pointers, bitmaps, the application icon, the menus, and the accelerator keys are added to the application. This chapter is probably the best written in the book, and goes a long way towards explaining why I appreciate this book. This doesn't mean that it goes into incredible depth, merely that each of the relevant resource statements is well explained, and the proper usage demonstrated.

"Message and Dialog Boxes" explains how these types of windows are created and manipulated, and how they can be used most effectively, but again, there isn't great depth here, just very careful explanations.

And so it goes: "Implementing a Help Interface" explains briefly how to use the tagging language to make HLP and INF files, and how to interface your application to them. It skips some of the more advanced features of IPFC, but covers the basics pretty well.

Finally, "Notable OS/2 2.0 Enhancements" discusses the theoretical value of the file dialog, the font dialog, the value set control, the slider control, the container control, and the notebook control, but gives no code. This, for me, was disappointing, since I am trying to add a notebook to my application.

In summary, for the rank novice, this book has some very good explanations, including good discussions of the various data structures, but it does not go into great depth anywhere. You will not become an expert in any one field by reading this book, but you will have a solid foundation on which to build. There aren't very many explanations of calls other than the ones used by the author, though. The language is a little dry, with less humour than I prefer, but it is also very competent. I feel that the description on the back of the book is a little ambitious given its size and content. If this book was rewritten with maybe another application or two to explain other techniques, more pages, more professional animation techniques, some 2.1 additions, and more depth (lotsa code!), especially in chapter 9, I would buy it (again). Especially if some chuckles were added.

Summary

This book is a bit of a mixed bag. It completely skips such areas as profile management, compatibility with 16 bit code, device drivers, WPS, SOM, and numerous others. It also brushes very lightly over DLLs, common dialogs, notebooks, etc. But, and it is a big "but", it has very good introductory chapters on messages, resources (including bitmaps, icons, pointers, menus, and accelerator keys), message boxes, dialog boxes, and implementing a help interface. If you are just getting into PM C programming (which I am), these chapters explain their material very well, and I went from knowing next to zip about resources to writing very nice dialogs, menus, and so on. It is slim, and expensive for its size, but in my case, it is what the doctor prescribed. In my humble opinion it needs rewriting for OS/2 2.1, and should have more depth in most areas, but it is still a good book for beginners. Intermediate and expert programmer's won't find much in here, though.

Learning to Program OS/2 2.0 Presentation Manager by Example, Stephen A. Knight

  • Van Nostrand Reinhold, ISBN 0-442-01292-6, US $40, CAN$50.
  • Intended audience: Beginning C Programmers
  • Mark: B-

Reviewed Books

Our Bookstore has reviews and links to Amazon for all books we have reviewed in the past, as well as several books waiting to be reviewed, and others which we recommend.