home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / vrac_os2 / pfaq32.zip / PROGFAQ.INF (.txt) < prev    next >
OS/2 Help File  |  1994-11-24  |  206KB  |  6,902 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Introduction and Credits ΓòÉΓòÉΓòÉ
  3.  
  4.             OS/2 2.x Frequently Asked Questions, Programmer's Edition
  5.  
  6.                          Version 3.2, November 24, 1994
  7.                            Compiled by Andreas Almroth
  8.  
  9.                        Pre-3.x versions by Jeff M. Garzik
  10.                         Pre-2.x versions by Barry Jaspan
  11.  
  12.                       Copyright (c) 1994 by Andreas Almroth
  13.                               All Rights Reserved.
  14.  
  15. For changes, suggestions, or additions please mail andreas@traci.almroth.pp.se 
  16. or write to: 
  17.  
  18. Andreas Almroth
  19. Fanrik Stals Gata 153
  20. S-754 39 UPPSALA
  21. SWEDEN
  22.  
  23. Mention of a product does not constitute an endorsement.  Customers outside the 
  24. United States should not necessarily rely on 800 telephone numbers, page 
  25. numbers, part numbers, or upgrade policies contained in this List.  Electronic 
  26. mail addresses are in Internet form; use addressing appropriate to your mail 
  27. system. 
  28.  
  29. This FAQ is freely distributable for noncommercial purposes.  (For commercial 
  30. purposes, please contact the author.)  If you redistribute the FAQ, please 
  31. include all the original files. 
  32.  
  33. This FAQ is updated quarterly and is distributed through various computer 
  34. networks and online services, including the Internet and many BBSes. 
  35.  
  36. Both ASCII text and OS/2 Information Presentation Facility (INF) versions of 
  37. the FAQ are provided.  To view the INF version of the List, go to any OS/2 
  38. command line prompt (e.g. double click on "OS/2 Window") and type: 
  39.  
  40. VIEW PROGFAQ.INF
  41.  
  42. The ASCII text version may be viewed using any text editor, word processor, or 
  43. file listing utility.  The text version is intended to answer any questions you 
  44. may have before actually obtaining and using OS/2.  You will find that the INF 
  45. version provides a much more attractive interface, with hypertext links, fast 
  46. indexing, and, increasingly, illustrations. 
  47.  
  48. If you have not received all three files (README.CMD, PROGFAQ.INF, and 
  49. PROGFAQ.TXT), please ask your system operator to make sure he/she is receiving 
  50. the correct and complete package. 
  51.  
  52. Many of the answers in this FAQ refer to anonymous ftp site FTP-OS2.CDROM.COM 
  53. (192.153.46.2). The name 'cdrom.com' is used as a shorthand to refer to this 
  54. site.  It has become, by default, the Internet storehouse for OS/2 files.  If 
  55. you cannot get files from this site (for whatever reason), then check OS/2 
  56. Software Sources for a source near you. You may find a more convenient method 
  57. of getting files than from cdrom.com.  (Non-US readers will note ftp.luth.se, 
  58. is the main overseas FTP site.) 
  59.  
  60.  
  61. Related Information:
  62.  
  63. Release Notes
  64. OS/2 Software Sources
  65. Obtaining this FAQ / Contacting the Author
  66.  
  67.  
  68. ΓòÉΓòÉΓòÉ 2. Release Notes ΓòÉΓòÉΓòÉ
  69.  
  70. Text which has been revised or updated since the last release will appear in 
  71. the same color as this paragraph. 
  72.  
  73. Version 3.2: 
  74. Updated some answers and added some answers. 
  75. Added a lot of books 
  76.  
  77. Version 3.1: 
  78. Added index search facility (but only to some extent, sorry) 
  79. As usual, questions and answers have been added or changed. 
  80.  
  81. Version 3.0: A new maintainer of the OS/2 Programming FAQ: Andreas Almroth 
  82. Some answers changed or added. 
  83.  
  84. Version 2.3:  This release does not include very many new sections, but the 
  85. information has been reorganized for greater readability and easier maintenence 
  86. (for me).  Major changes include title re-wording for brevity, revision 
  87. coloring, and updated information. 
  88.  
  89.  
  90. Related Information:
  91.  
  92. Introduction and Credits
  93. OS/2 Software Sources
  94. Obtaining this FAQ / Contacting the Author
  95.  
  96.  
  97. ΓòÉΓòÉΓòÉ 3. Questions Covered in this Release ΓòÉΓòÉΓòÉ
  98.  
  99. Languages, Compilers, Debuggers
  100.   What programming languages come with OS/2?
  101.   Programming language availability
  102.   Which of these compilers can be used to generate PM apps?
  103.   Which assemblers can produce OS/2 32-bit code?
  104.   The two GNU C/C++/ObjC packages
  105.   What is REXX?  How do I write and run a REXX program?
  106.   What debuggers are available for OS/2?
  107.    CSD levels for IBM C Set++?
  108. Tools, Toolkits, Accessories
  109.   How do I use PATCH, maybe with my own programs?
  110.   What programming editors are available for OS/2?
  111.   What programming tools/toolkits/accessories are available for OS/2?
  112.   What GNU tools are available and where can I find them?
  113.   Is a socket library available?  How can I use it?
  114. Compiling
  115.   Can I distribute the C-Set++ runtime DLL?
  116.   How big should my stacksize be?
  117.   How do I determine what C/C++ compilator is compiling my code?
  118.   How do I perform parallel compilation?
  119.   What is an RC of 87 (invalid param) from the API?
  120.   GCC/2 crashes with a trap when I try to compile a program.  Why?
  121.   How do I recompile EPM (easily)?
  122.   How to I get BC++ for DOS/Windows to run?
  123. Documentation, Help
  124.   Where can I get information on OS/2 APIs and programming?
  125.   Where can I get sample code?
  126.   Are there any OS/2 programming classes or seminars?
  127.   What are good ref. books for programming in OS/2 and PM?
  128.   What are good OS/2 programming magazines?
  129.   What are the OS/2 redbooks, and how do I get them?
  130.   How can I view the GNU C documentation?
  131.   Where can I get documentation on the OBJ/LIB/EXE format used by OS/2 2.x?
  132.   Where can I find information on HPFS?
  133. PM Programming
  134.   Printing
  135.     Are there any SIMPLE examples of printing?
  136.     Is there an easy way to get printer output (another opinion)?
  137.     How do I print a bitmap?
  138.     How do I do my own Print Screen?
  139.   Menus
  140.     How do I add a menu to a dialog box?
  141.     How do I make a dynamically changing menu?
  142.     How do I create a conditional cascade menu?
  143.     How do I remove a separator from a menu?
  144.   Container Controls
  145.     How do I stop a container from flashing every time I add a record?
  146.     How do I get my containers to use Mini-icons?
  147.     How do I sort a container control?
  148.     How do I query all records in a container - tree view?
  149.   I can't get different colors in text control windows
  150.   How can I toggle my titlebar on and off?
  151.   How can I get transparent regions in bitmaps?
  152.   How do I create a status bar at the bottom of my window?
  153.   How to have a frame/client and still have a std window?
  154.   How do I use printf() in a PM program?
  155.   I have a SOM DLL. How do I register it?
  156.   How do I save and restore my window size and position?
  157.   How do you make a window float above all other?
  158.   How to ensure the sizing's correct so the dlg "fits" in the notebook...?
  159.   How do I prevent Shutdown from stopping my app?
  160.   When I pass a structure to WinCreateWindow, sometimes it doesn't work!
  161.   How do I use type filtering in 2.0's open dlg?
  162.   When minimizing, my dialog box is overwriting my icon!
  163.   How do I make a multi-column listbox?
  164.   How do I create my own Master Help Index?
  165.   How do I change the font in an MLE?
  166.   Why can't I import files larger than 64KB into my MLE?
  167.   How do I get PM screen size?
  168.   How do I attach Instance data to window created with WinCreateStdWindow?
  169.   How do I get a list of fonts?
  170.   How do I create a folder in C and put my pgm in it?
  171.   How do I do it in REXX?
  172.   How do I use the Font dialog (WinFontDlg)?
  173.   How do I take control of frame sizing?
  174.   How do I use the 16-bit EPM toolkit?
  175.   How do I get error info after using WinGetLastError()?
  176.   Do you have code to save/restore the clipboard?
  177.   How do I know what item was selected in a Combo box?
  178.   How do I get a bitmap into a dialog in a DLL?
  179.   How does programming PM compare to programming X?
  180.   How do I put bitmaps on buttons?
  181.   Can a PM program tell if there's a previous instance of itself running?
  182.   How to avoid crash when using Drag and Drop?
  183. Miscellaneous Programming
  184.   Explain the SYS_DLL keywords.
  185.   How do I start another session?
  186.   How do I check if a filename is valid?
  187.   Why should I use _beginthread instead of DosCreateThread?
  188.   How do I open a file that is already in use?
  189.   Can we use Vio in v2.0? Where are the docs for it?
  190.   Can I redirect stdin and stdout in a child process?
  191.   How do I use DosMon*() to stuff the kbd buf?
  192.   How do I determine what file system a drive uses?
  193.   How do I get the error message from a DOS API call?
  194.   How do I set an exception handler?
  195.   How can I determine a diskette format and if a disk is in a drive?
  196.   What do all those keywords mean when making a DLL?
  197.   Where can I find serial port sample code?
  198.   How do I disable <Ctrl><Alt><Del>?
  199.   Why doesn't printf() produce output when I expect it to?
  200.   How do I write an OS/2 device driver?
  201.   How do I change the master environment?
  202.   What is the best way to communicate between processes?
  203.   What is the best way to communicate between threads?
  204.   How to I write an IFS?
  205.   How do I interface with OS/2's SCSI support?
  206.   How do I program full-screen graphics?
  207.   How do I program MMPM/2 programs?
  208.   How do I peripheral memory or an I/O port?
  209. Porting
  210.   How do I port my DOS keyboard TSR to OS/2?
  211.   How can I simulate (Unix feature) under OS/2?
  212.   How can I recompile public domain/shareware source code for OS/2?
  213.   How can I port my DOS program to OS/2?
  214.   How can I port my Windows program to OS/2?
  215. Miscellaneous
  216.   Is OS/2 suitable for real time programs?
  217.   What is available for multimedia programming under OS/2?
  218.   What is available for AI/neural net programming under OS/2?
  219.   Special software offers
  220.   Technical Support
  221.   Developer's Assistance Program (DAP)
  222.  
  223.  
  224. ΓòÉΓòÉΓòÉ 4. Languages, Compilers, Debuggers ΓòÉΓòÉΓòÉ
  225.  
  226. This section covers the programming tools currently available for OS/2.  The 
  227. following topics are available: 
  228.  
  229. What programming languages come with OS/2?
  230. Programming language availability
  231. Which of these compilers can be used to generate PM apps?
  232. Which assemblers can produce OS/2 32-bit code?
  233. The two GNU C/C++/ObjC packages
  234. What is REXX?  How do I write and run a REXX program?
  235. What debuggers are available for OS/2?
  236. CSD levels for C Set++2?
  237.  
  238.  
  239. ΓòÉΓòÉΓòÉ 4.1. What programming languages come with OS/2? ΓòÉΓòÉΓòÉ
  240.  
  241. The original BASIC and BASICA (for systems with BASIC in ROM, mainly IBM 
  242. systems), DOS's QBASIC, and OS/2's REXX comes with OS/2 2.x. 
  243.  
  244. REXX is basically the official command language of OS/2. 
  245.  
  246.  
  247. Related Information:
  248.  
  249. What is REXX?  How do I write and run a REXX program?
  250.  
  251.  
  252. ΓòÉΓòÉΓòÉ 4.2. Programming language availability ΓòÉΓòÉΓòÉ
  253.  
  254. Virtually all of them: Assembler, C, C++, COBOL, Pascal, Fortran, Smalltalk, 
  255. Modula-2, LISP, Forth, Perl, and more.  The OS/2 Tools Guide on cdrom.com 
  256. (os2/all/info/tinf34.zip) contains information on these and more.  Also check 
  257. the User's Edition for information on IBM's Development Tools Guide.  It's a 
  258. free catalog from IBM. 
  259.  
  260. All prices listed are "list price," as listed in Fall/Winter Programmer's 
  261. Paradise catalog.  All entries marked "Freely Available" can be obtained from 
  262. cdrom.com unless otherwise noted. 
  263.  
  264.  1. Ada 
  265.  
  266.    o GNU Ada 1.67 for OS/2; freely available; under development; cs.nyu.edu in 
  267.      the pub/gnat directory. Needs GCC/2 to compile applications written in 
  268.      Ada. 
  269.    o Alsys AdaWorld OS/2 i2 refid=proglang.Assembler 
  270.  
  271.  2. Assembly Language 
  272.  
  273.    o IBM Macro Assembler, $288 
  274.    o GNU assembler v1.38, included in emx/gcc 0.8h package 
  275.    o GNU assembler v1.38, included in GCC/2 v2.5.4 package 
  276.    o Turbo Assembler v3.21, included in Borland C++ for OS/2 package 
  277.  
  278.  3. BASIC 
  279.  
  280.    o CA-REALIZER, $100 
  281.    o ObjectView PM Basic, $899 
  282.  
  283.  4. C/C++ 
  284.  
  285.    o Borland C++ for OS/2 v1.00, $495 
  286.    o CA-C++ for OS/2, $449 
  287.    o emx/gcc 0.8h (v2.5.8), freely available 
  288.    o GCC/2 v2.4.5, freely available 
  289.    o IBM C-Set++ FirstStep (without optimization) $85 (CD-ROM) 
  290.    o IBM C-Set++, $595 
  291.    o Objective C, $249 (not to be confused with the Objective-C language 
  292.      included free with emx/gcc and GCC/2) 
  293.    o TopSpeed C Pro, $297 
  294.    o TopSpeed C Standard, $198 
  295.    o WATCOM C/C++ 16 9.5, $495 
  296.    o WATCOM C/C++ 32 9.5, $599 
  297.    o Metaware High C/C++ 
  298.  
  299.  5. CSP 
  300.  
  301.    o IBM CSP/2, $??? 
  302.  
  303.  6. COBOL 
  304.  
  305.    o MicroFocus Workbench with COBOL, tools and editor, $1,250. Call 1 
  306.      800-872-6265 for more information 
  307.  
  308.  7. FORTRAN 
  309.  
  310.    o f2c [Fortran to C translator], freely available 
  311.    o IBM Fortran/2 OS/2, $761 
  312.    o WATCOM FORTRAN 77 16 9.5, $495 
  313.    o WATCOM FORTRAN 77 32 9.5, $599 
  314.  
  315.  8. LISP 
  316.  
  317.    o CLISP, freely available (ma2s2.mathematik.uni-karlsruhe.de) 
  318.    o XLisp, freely available 
  319.  
  320.  9. Pascal 
  321.  
  322.    o Borland Pascal v7.0, $495 (requires patch) 
  323.    o MicroWay, $??? 
  324.    o Power Pascal/2, freely available, req. MASM 6.00 
  325.    o p2c [Pascal to C translator], freely available 
  326.    o pasos2, freely available, supports EMX/GCC (ftp.eb.ele.tue.nl) 
  327.    o Speed-Pascal/2, available at hobbes.nmsu.edu as speed2.zip 
  328.    o TopSpeed, $??? 
  329.  
  330. 10. PERL 
  331.  
  332.    o GNU PERL v4.0pl36, freely available 
  333.  
  334. 11. PL/I 
  335.  
  336.    o IBM PL/I for OS/2 
  337.  
  338. 12. Prolog 
  339.  
  340.    o SWI Prolog for OS/2, available at fpt.cdrom.com:os2/2_x/unix/plbin.zip 
  341.  
  342. 13. Modula-2 
  343.  
  344.    o TopSpeed, $??? 
  345.    o Stonybrook, $??? 
  346.  
  347. 14. Scheme 
  348.  
  349.    o XScheme for OS/2, freely available 
  350.  
  351. 15. SmallTalk 
  352.  
  353.    o SmallTalk/V PM, $995 
  354.    o Parc Place Smalltalk, $??? 
  355.  
  356.  
  357. RelatedInformation :
  358.  
  359. The two GNU C/C++/ObjC packages
  360.  
  361.  
  362. ΓòÉΓòÉΓòÉ 4.3. The two GNU C/C++/ObjC packages ΓòÉΓòÉΓòÉ
  363.  
  364. The two versions of GNU C that are available were ported to OS/2 with different 
  365. goals and philosophies in mind and therefore have different characteristics. 
  366. However, both systems include a fairly complete C library and can be used to 
  367. compile useful programs, although their support of Unix-specific semantics 
  368. differs.  Furthermore, both systems are being actively developed and are 
  369. constantly improving. 
  370.  
  371. The goal of GCC/2 is to create a pure, freely redistributable OS/2 2.x 
  372. development environment.  It is based on GNU C 2.5.4, supports C, C++, and 
  373. Objective C, and can create PM programs.  It produces "native" 32 bit .OBJ 
  374. files that are linked with OS/2's LINK386.EXE, and can be linked together with 
  375. .OBJ files produced by IBM C-Set++ and other compatible compilers.  The mailing 
  376. list os2gcc@netcom.com exists for discussion of this port; send mail to 
  377. os2gcc-request@netcom.com for subscription information. 
  378.  
  379. emx/gcc 0.8h, based on GNU C 2.5.7, supports C, C++, and Objective C and can 
  380. create PM programs.  emx's goal is to make porting Unix programs easier by 
  381. emulating Unix semantics as closely as possible. It produces programs that can 
  382. run under OS/2 using EMX.DLL, it produces programs that can run under OS/2 
  383. without any DLL requirements (linked with OS/2's LINK386), and it can produce 
  384. MS-DOS 32-bit executables (emx.exe DOS extender required for MS-DOS 
  385. executables).  emx/gcc uses standard Unix development tools like ld and nm, and 
  386. fully supports Unix-isms like select() and fork().  A version of gdb exists 
  387. that can debug emx/gcc programs. An emx-related mailing list exists; send mail 
  388. to LISTSERV@eb.ele.tue.nl with a message body of "help" for subscription 
  389. information. 
  390.  
  391.  
  392. ΓòÉΓòÉΓòÉ 4.4. Which of these compilers can be used to generate PM apps? ΓòÉΓòÉΓòÉ
  393.  
  394. Basically, all the compilers except the following can generate PM applications: 
  395.  
  396. o CLISP 
  397. o XLisp 
  398. o PERL 
  399. o XScheme 
  400.  
  401.  
  402. ΓòÉΓòÉΓòÉ 4.5. What is REXX?  How do I write and run a REXX program? ΓòÉΓòÉΓòÉ
  403.  
  404. REXX is the IBM SAA (Systems Application Architecture) standard, user-friendly 
  405. programming language.  It is available for IBM mainframes, Unix, the Amiga, DOS 
  406. (Quercus's Personal REXX), Windows, and other platforms.  It has been a part of 
  407. standard OS/2 since Version 1.3.  Programs written in REXX that do not use 
  408. system-specific libraries are fully portable. 
  409.  
  410. OS/2 2.x comes with an online REXX reference, and printed REXX documentation is 
  411. available (Mike Cowlishaw's REXX book, IBM's twin guides).  The Usenet group 
  412. comp.lang.rexx discusses REXX programming. 
  413.  
  414. It should be stressed, however, that OS/2's online REXX reference is a 
  415. reference, not really a tutor.    Paul Prescod 
  416. (papresco@undergrad.math.uwaterloo.ca) is working on a free REXX tutor, which 
  417. will be available on cdrom.com. 
  418.  
  419. Watcom also makes VX REXX and Hockware makes VisPro/REXX.  Both of these 
  420. products allow quick and easy development of REXX PM programs. 
  421.  
  422.  
  423. ΓòÉΓòÉΓòÉ 4.6. What debuggers are available for OS/2? ΓòÉΓòÉΓòÉ
  424.  
  425. IPMD, a PM-based debugger, ships with C-Set++.  It is capable of source- and 
  426. assembly-level debugging multithreaded 16 bit and 32 bit OS/2 applications 
  427.  
  428. emx/gcc comes with gdb 4.11, the GNU debugger. 
  429.  
  430. Borland C++/2 comes with a PM-based debugger called Turbo Debugger GX which has 
  431. the same basic functionality as IPMD. 
  432.  
  433. There are also several commercial debuggers on the market.  WATCOM C and 
  434. FORTRAN come with WVIDEO, a full-screen source or assembly level debugger that 
  435. handles multithreaded 16 and 32 bit OS/2 programs. Multiscope (no longer 
  436. available for 32-bit OS/2) and Periscope are others.  CodeView is still 
  437. applicable for 16-bit OS/2 apps, but it is not recommended for 32-bit apps. 
  438.  
  439.  
  440. ΓòÉΓòÉΓòÉ 4.7. Which assemblers can produce OS/2 32-bit code? ΓòÉΓòÉΓòÉ
  441.  
  442. o Masm 5.2 and 6.0B can produce 32 bit, 2.x compatible code. 
  443. o Masm 6.1 no longer supports OS/2. 
  444. o Tasm 1.0 (OS/2) generates 2.x code, when proper options are given. 
  445. o Tasm 3.2.1 (DOS) can produce OS/2 compatible .OBJ files with the /oi option. 
  446. o GAS (GNU Assembler) 1.38.1 
  447. o IBM has an assembler for 2.x, but they won't release it to the public. 
  448.  
  449.  
  450. ΓòÉΓòÉΓòÉ 4.8. CSD levels for IBM C Set++? ΓòÉΓòÉΓòÉ
  451.  
  452. Following CSD's are current 
  453.  
  454. o CTC0010 - IBM C/C++ Tools (Compiler) 2.0 and 2.01 
  455. o CTU0003 - IBM C/C++ Tools (Utilities) 2.0 and 2.01 
  456. o CTL0008 - IBM C/C++ Tools (Class Libraries) 2.0 
  457. o CTM0008 - IBM C/C++ Tools (Class Libraries) 2.01 
  458.  
  459. Be careful with CTL0008 and CTM0008. Do NOT install wrong CSD. Check with the 
  460. OS/2 command SYSLEVEL the version level of the class libraries. IBM C/C++ 
  461. packages bought later than November 1993 should be 2.01 or higher. 
  462.  
  463.  
  464. ΓòÉΓòÉΓòÉ 5. Tools, Toolkits, Accessories ΓòÉΓòÉΓòÉ
  465.  
  466. This section covers tools, toolkits, and accessories available to OS/2 
  467. programmers. 
  468.  
  469.  
  470. ΓòÉΓòÉΓòÉ 5.1. How do I use PATCH, maybe with my own programs? ΓòÉΓòÉΓòÉ
  471.  
  472. The file format is actually quite simple - you just need a text file which 
  473. consists of lines each starting with one of the following commands: 
  474.  
  475.   FILE <filename>     e.g. FILE test.exe 
  476.  
  477. specifies the file to which the following instructions are to be applied. A 
  478. patch file may contain multiple FILE directives. 
  479.  
  480.   VER <offset> <data>   e.g. VER 00001234 abcdef 
  481.  
  482. checks if the specified data is present at the given file offset [all values in 
  483. hex, data can be just a string of digits with no blanks in between; up to 16 
  484. bytes are allowed in one statement]. If the check fails, the patch process is 
  485. aborted resp. the program skips to the next FILE statement. 
  486.  
  487.   CHA <offset> <data>   e.g. CHA 00001234 012345 
  488.  
  489. changes the data at the given offset - syntax is same as in VER. It is a good 
  490. idea to do all VERification before starting the first CHA. 
  491.  
  492. Blank lines and data lines starting with a ";" are ignored. 
  493.  
  494. As you can see from this, there seems to be no way to _insert_ or _delete_ 
  495. bytes in the file. To make patches applicable to multiple versions of the same 
  496. file, you can specifiy more than one FILE directive for the same filename - 
  497. only a patch with all VER commands matching is executed. 
  498.  
  499. Credit:  Marcus Groeber 
  500.  
  501.  
  502. ΓòÉΓòÉΓòÉ 5.2. What programming editors are available for OS/2? ΓòÉΓòÉΓòÉ
  503.  
  504. OS/2 2.x comes with the Enhanced Editor (EPM). 
  505.  
  506. GNU Emacs 19.22 is available.  It supports PM and text mode programming. Emacs 
  507. is available on cdrom.com in os2/2_x/unix/gnu/emacs.  (If you want to recompile 
  508. emacs, you will need the full emx distribution; see question 1.2.) Also, you 
  509. must have HPFS installed to use GNU emacs. You can read, write, and edit files 
  510. that exist on a DOS partition, but you must have GNU emacs installed on an HPFS 
  511. partition. 
  512.  
  513. Several public-domain vi clones are available, including elvis, Stevie and 
  514. levee.  The MKS Toolkit also includes vi. 
  515.  
  516. Many other text editors are available. 
  517.  
  518. Epsilon, by Luguru, (412) 421-5678.  DOS upgrade to OS/2 is $90.  Character 
  519. based editor. 
  520.  
  521. QEdit 3.0, by SemWare, (404) 641-9002.  Character based editor. Supports long 
  522. filenames and extended attributes. Semware can be reached by EMail: 
  523. tech.support@semware.atl.ga.us or sales@semware.atl.ga.us. 
  524.  
  525. Brief, KEDIT, others? [Vendors, phone numbers, prices?] 
  526.  
  527. EHP, a text mode editor, was recently ported by Axel Uhl to PM, and is 
  528. available on cdrom.com. 
  529.  
  530. THE (The Hessling Editor), is a free text-mode editor, based on IBM's VM/CMS 
  531. XEDIT and Mansfield Software's KEDIT.  THE has full REXX macro capabilities. 
  532. Versions also exist for DOS and most Unices. 
  533.  
  534. BOXER 6.0 for OS/2. Shareware and commercial versions available. Some features; 
  535. multi-level undo, multiple windows, syntax highlighting. Commercial version 
  536. priced at $89. Boxer Software can be contacted at; phone: 800-982-6937, 
  537. Internet: 70242.2126@compuserve.com 
  538.  
  539.  
  540. ΓòÉΓòÉΓòÉ 5.3. What programming tools/toolkits/accessories are available for OS/2? ΓòÉΓòÉΓòÉ
  541.  
  542. C-Set++ includes the following tools (excluding the compiler & debugger 
  543. themselves): 
  544.  
  545. o EXTRA - Execution trace analyzer 
  546. o A Class browser 
  547.  
  548. The IBM Programmer's Toolkit, included in Workset/2 and also in C-Set++, 
  549. includes many tools: 
  550.  
  551. o A dialog editor 
  552. o A SOM compiler 
  553. o A font editor 
  554. o An icon editor 
  555. o An IPF compiler 
  556. o Message compile & bind tools 
  557. o Resource compile & bind tools 
  558. o KwikInf 
  559. o ...and a couple others 
  560.  
  561. Borland C++ for OS/2 also includes a number of utilities, such as the Resource 
  562. Workshop. 
  563.  
  564. The MKS Toolkit, available from MKS ($299 USD, 800-265-2797 or 
  565. inquiry@mks.com), has over 160 Unix tools, including Korn shell, tar, vi, awk, 
  566. grep, tail, cpio, and so forth.  It also contains a Lex and Yacc capable of 
  567. generating C, C++, and Turbo Pascal code. 
  568.  
  569. There is a product called ARGO/UX which provides a BSD environment for OS/2. 
  570. [details?] 
  571.  
  572. SOFTPRO GmbH has announced its 32bit C++ class library TOUCH-GUI 2.0 for OS/2 
  573. 2.x. 
  574.  
  575.  
  576. ΓòÉΓòÉΓòÉ <hidden> TOUCH-GUI 2.0 for OS/2 2.x ΓòÉΓòÉΓòÉ
  577.  
  578. SOFTPRO GmbH has announced its 32bit C++ class library TOUCH-GUI 2.0 for OS/2 
  579. 2.x. The product contains more than 130 classes which support windows, menu 
  580. bars, multi-threading, controls, dialog boxes, graphics, printer control, MDI, 
  581. DDE, Drag and Drop, loadable resources from DLL's, and management of profiles 
  582. (.INI files). Other features include auxiliary classes for data manipulation 
  583. and storage management. Additionally, TOUCH-GUI 2.0 contains high-level classes 
  584. like toolbars, formatted entry fields, tables, and complete NLS. 
  585.  
  586. Supported C++ compilers are: Borland, GNU (emx), IBM, and WATCOM 
  587.  
  588. The product includes online (.INF) and printed documentation, a demo program, 
  589. and samples. 
  590.  
  591. TOUCH-GUI 2.0 costs DM 1.720,00 excl. VAT (ca. $1075), the runtime DLL's may be 
  592. distributed royalty free. Special project licenses are available, contact the 
  593. supplier. 
  594.  
  595. Contact:
  596. SOFTPRO GmbH, Stadtgrabenstr. 21, 71032 Boeblingen, Germany
  597. Tel.: +49 7031 6606-0
  598. Fax: +49 7031 6606-66
  599. Mr. Frank Fuchs (extension -50)
  600. Internet email: ffu@softpro.de
  601. IBMMAIL (IEA): DEJP9SK9
  602.  
  603.  
  604. ΓòÉΓòÉΓòÉ 5.4. What GNU tools are available and where can I find them? ΓòÉΓòÉΓòÉ
  605.  
  606. Nearly all the GNU utilities have been ported to OS/2 2.x - and nearly all of 
  607. those ports are located on cdrom.com in os2/2_x/unix/gnu. Other, more involved 
  608. (or independent) ports of GNU software is scattered about cdrom.com, including 
  609. a PM version of GhostView and GhostScript. 
  610.  
  611.  
  612. ΓòÉΓòÉΓòÉ 5.5. Is a socket library available?  How can I use it? ΓòÉΓòÉΓòÉ
  613.  
  614. IBM's TCP/IP 2.0 ($200) includes an optional Programmer's Toolkit ($500, part 
  615. #02G6973).  It includes a socket library, and support for Sun RPC, NCS RPC, and 
  616. a limited Kerberos capability.  It requires IBM C-Set++ or another compiler 
  617. that understands 16-bit code.  The 32-bit version is in beta right now. 
  618. (contact IBM for details) 
  619.  
  620. For REXX programs there is a socket library called REXXSOCK available from 
  621. cdrom.com as os2/ibm/ews/rxsock.zip.  It can be used to write TCP/IP 
  622. applications such as Gopher, IRC, etc. 
  623.  
  624. FTP Software, Inc., has an OS/2 version of its TCP/IP product.  They can be 
  625. reached at (617) 246-0900 or info@ftp.com. 
  626.  
  627. If you have the IBM TCP/IP 2.0 base package and IBM C-Set++, you can use the 
  628. TCPIPDLL.DLL directly. 
  629.  
  630.  
  631. ΓòÉΓòÉΓòÉ 6. Compiling ΓòÉΓòÉΓòÉ
  632.  
  633. This section covers compiling OS/2 programs and accessories.  The following 
  634. topics are available: 
  635.  
  636. Can I distribute the C-Set++ runtime DLL?
  637. How big should my stacksize be?
  638. How do I perform parallel compilation?
  639. What is an RC of 87 (invalid param) from the API?
  640. GCC/2 crashes with trap when I try to compile a program. Why?
  641. How do I recompile EPM (easily)?
  642. How to I get BC++ for DOS/Windows to run?
  643.  
  644.  
  645. ΓòÉΓòÉΓòÉ 6.1. Can I distribute the C-Set++ runtime DLL? ΓòÉΓòÉΓòÉ
  646.  
  647. Yes, you can! (But it is not as simple as that really...) 
  648.  
  649. You can not distribute the runtime DLL that comes with C-Set++ in its native 
  650. form, you must rebuild the DLLs you want to distribute and delete functions in 
  651. the .DEF files, so that your DLL files only contains functions your program 
  652. need. Read more about this topic in C/C++ Tools - Programming Guide pages 
  653. 195-222, that comes with C-Set++ (2.x). 
  654.  
  655.  
  656. ΓòÉΓòÉΓòÉ 6.2. How do I determine what C/C++ compilator is compiling my code? ΓòÉΓòÉΓòÉ
  657.  
  658. If your source code is written for several compilers, one need to know what 
  659. uniqe defines these compilers use. 
  660.  
  661.  
  662.  IBM C/C++            __IBMCPP__
  663.  
  664.  Borland C++ for OS/2 __BORLANDC__
  665.  
  666.  EMX/GCC              __EMX__
  667.  
  668.  
  669. ΓòÉΓòÉΓòÉ 6.3. How big should my stacksize be? ΓòÉΓòÉΓòÉ
  670.  
  671. o For non-PM programs: At least 8k for every thread. 
  672. o It is critical to avoid stack sizes where byte 2 has a value of 2 or 4, e.g.: 
  673.  
  674.    0x00020000 (128k) 
  675.    0x00040000 (256k) 
  676.    0x33023678 
  677.    0x11041111 
  678.  
  679. Otherwise, when executing under OS/2 2.0GA there may be various and always 
  680. differing runtime error behaviors.  (This is documented in OMF.INF, an online 
  681. reference from IBM concerning OBJ/EXE file formats for 16 and 32 bits.) 
  682.  
  683.  
  684. ΓòÉΓòÉΓòÉ 6.4. How do I perform parallel compilation? ΓòÉΓòÉΓòÉ
  685.  
  686. You can accomplish parallel compilation in one of two ways. The first involves 
  687. GNU Make, the second involves DMAKE. 
  688.  
  689. GNU Make: 
  690.  
  691. To perform parallel compilation with GNU Make simply do two things: 
  692.  
  693. o Make sure your make file does not execute the make utility (again) from 
  694.   inside the make file. 
  695. o On the GNU Make command line, specify '--jobs x', where 'x' is the maximum 
  696.   number of concurrent jobs you will allow GNU Make to execute. If you do not 
  697.   wish to have a maximum, then you may specify simply '--jobs' and GNU Make 
  698.   will execute as many jobs as possible at one time. 
  699.  
  700. DMAKE: 
  701.  
  702. The ini file comes in the dmake archive in a few different flavours.  Take the 
  703. file with the extension .msc and rename it to dmake.ini.  Set an environment 
  704. variable in config.sys 
  705.  
  706. SET MAKESTARTUP=d:\COMPILER\DMAKE.INI 
  707.  
  708. ====== Makefile 
  709.  
  710. CC=icc
  711. COPTS=/Sm /Gt+ /Ti+ /O- /Gs+
  712. CONLY=-c
  713.  
  714. LIBS=os2
  715.  
  716. INCS=psfax2.h
  717.  
  718. MAXPROCESS=2
  719.  
  720. all: psfax2.exe sendfax.exe
  721.  
  722. modem.obj:  modem.c $(INCS)
  723.    $(CC) $(CONLY) $(COPTS) modem.c
  724.  
  725. psfax2.obj: psfax2.c $(INCS)
  726.    $(CC) $(CONLY) $(COPTS) psfax2.c
  727.  
  728. psfax2.exe: psfax2.obj modem.obj
  729.    link386 /ST:32768 /CO psfax2+modem;
  730.  
  731. sendfax.obj: sendfax.c $(INCS)
  732.    $(CC) $(CONLY) $(COPTS) sendfax.c
  733.  
  734. sendfax.exe: sendfax.obj modem.obj
  735.    link386 /ST:32768 /CO sendfax+modem;
  736.  
  737. ====== End of makefile 
  738.  
  739. Couple of gotchas.  There is a bug in the MAXPROCESS handling of the copy I 
  740. use.  Set it to 1, and you get a typical make, ie one at a time. Set it to 2, 
  741. and the thing launches 3 processes. Ie with more than 1, you actually get n+1 
  742. processes running. 
  743.  
  744. Another caveat 
  745.  
  746. xxx.yy: aaa.bbb
  747.     command1
  748.     command2
  749.     command3
  750.  
  751. The above structure does not work.  The reason is that all 3 commands will be 
  752. spawned together in parallel sessions.  To serialize them you must make up 
  753. dependancies in the makefile.  I ran into this becuase I have one makefile that 
  754. completes every link stage by copying the result onto a network drive.  I had 
  755. to take all the links that previously had 2 commands, and break them into 2 
  756. blocks with the second being a dependancy of the remote file on the local file, 
  757. and the copy command. 
  758.  
  759. One more word of warning, dmake is not to pleased with those convoluted things 
  760. that workframe spits out in the name of makefiles.  You may have to do a 
  761. significant amount of makefile editing, depending on how you makefile look now. 
  762.  
  763. Provided that 3 simultaneous copies of your compiler doesn't push your machine 
  764. into excessive swapping, the improvements in build speed are amazing.  Before 
  765. dmake I'd never seen a build actually top the cpu meter here, the process was 
  766. always waiting for disk as it loaded compilers/headers etc.    Now the compiler 
  767. sits in ram and just gets re-used, and the headers are coming directly from 
  768. cache all the time. Build time cut in half, and my cpu guage is pegged at 100% 
  769. when a build is running. 
  770.  
  771.  
  772. ΓòÉΓòÉΓòÉ 6.5. What is an RC of 87 (invalid param) from the API? ΓòÉΓòÉΓòÉ
  773.  
  774. You are (most likely) not including the prototype.  Use the following flags to 
  775. get a good balance of warning messages: 
  776.  
  777.     /Kbperc 
  778.  
  779. For C Set++, I use these flags as the approximate equivalent 
  780.  
  781.     /Wall /Wext- /Wgnr- /Wgot- /Wpor- /Wppt- /Wtrd /Wuni- /Wvft- 
  782.  
  783. I have these set as part of my ICC string in CONFIG.SYS, so I don't have to add 
  784. them to each compile.  I have found that these settings give me a good 
  785. combination of thorough warning messages without too many warnings. 
  786.  
  787.  
  788. ΓòÉΓòÉΓòÉ 6.6. GCC/2 crashes with a trap when I try to compile a program.  Why? ΓòÉΓòÉΓòÉ
  789.  
  790. Because you didn't read the README or INSTALL files, probably.  There are three 
  791. general reasons GCC/2 will crash: 
  792.  
  793.  1. You did not set up the environment variables in CONFIG.SYS properly.  Read 
  794.     doc/INSTALL for instructions. 
  795.  
  796.  2. Some program that gcc expects to be in the PATH is not; unfortunately, gcc 
  797.     crashes instead of just printing an error message.  You may have forgotten 
  798.     to install something, or your PATH may be wrong; see above.  Giving gcc the 
  799.     -v option will cause it to print each command line as it executes it; this 
  800.     will tell you which program is missing. 
  801.  
  802.  3. You are trying to get gcc to link your program for you. It cannot because 
  803.     ld does not exist, and so it crashes (see item 2).  You must specify -c, 
  804.     -E, or -S on every invokation of gcc, and then use LINK386.EXE to create an 
  805.     executable.  See the sample makefiles for an example of how to do this. 
  806.  
  807. [Colin Jensen, the current maintainer of GCC/2, also adds the following...] 
  808.  
  809. Not true as of gcc/2 2.3.3.  Gcc will invoke a small stub program called ld.exe 
  810. that in turn will invoke link386 for you.  If the command line is too long for 
  811. the ever-pathetic link386 to handle, ld will properly create a response file. 
  812.  
  813. It is easier to use gcc/2 to call link386 than to do it yourself since gcc/2 
  814. will also arrange to call a subprogram called "collect" that is required before 
  815. linking a C++ program. 
  816.  
  817. Also, gcc/2 is just plain easier to use than link386, for example: 
  818.  
  819.          gcc -o foobar.exe mydef.def foobar.cpp mylib.lib
  820.  
  821. will compile foobar.cpp, link with mylib.lib, and pass the linker definition 
  822. file mydef.def to link386 in the correct order.  Link386 demands that you know 
  823. which types of files can be put between which sets of commas on the command 
  824. line. 
  825.  
  826.  
  827. ΓòÉΓòÉΓòÉ 6.7. How do I recompile EPM (easily)? ΓòÉΓòÉΓòÉ
  828.  
  829. I have a small CMD file to automatically compile all needed macros.  It is from 
  830. Larry Margolis (IBM), one of the authros of EPM. 
  831.  
  832. You need to have at aleast minimum knowledge of EPM.  The online manual 
  833. describes most things.    Concerning the E macros (.E) the best thing to do is, to 
  834. look in the online documentation for general questions (like: What does 
  835. 'getpminfo' do?) and then look into the supplied standard E macros for detailed 
  836. reference on hwo to use the EPM functions exactly. 
  837.  
  838. Online documentation files are: EPMTECH.INF and EPMUSERS.INF 
  839.  
  840. Here is MAKEEPM.CMD: 
  841.  
  842. @echo off
  843. set EPMPATH=h:\e;h:\e\emacros;h:\e\ebookie;h:\e\lamacros;h:\e\mye;
  844. rem Command file to call ETPM and beep in case of error.  Can be given
  845. rem a list of macro files to compile; the default is to compiler all of
  846. rem the distributed .ex files.            by Larry Margolis
  847. setlocal
  848. @if .%1 == . goto all
  849. :loop
  850. etpm %1 /v || echo 'Error in %1!'
  851. @shift
  852. @if .%1 == . goto end
  853. @goto loop
  854. :all
  855. etpm EPM /v      || echo 'Error in EPM!'
  856. etpm EPMLIST /v  || echo 'Error in EPMLIST!'
  857. etpm LAMEXTRA /v || echo 'Error in LAMEXTRA!'
  858. etpm MAILLIST /v || echo 'Error in MAILLIST!'
  859. etpm EXTRA /v    || echo 'Error in EXTRA!'
  860. etpm BKEYS /v    || echo 'Error in BKEYS!'
  861. etpm E3EMUL /v   || echo 'Error in E3EMUL!'
  862. etpm BOX /v      || echo 'Error in BOX!'
  863. etpm DRAW /v     || echo 'Error in DRAW!'
  864. etpm GET /v      || echo 'Error in GET!'
  865. etpm MATHLIB /v  || echo 'Error in MATHLIB!'
  866. etpm PUT /v      || echo 'Error in PUT!'
  867. etpm HELP /v     || echo 'Error in HELP!'
  868. etpm EPMLEX /v   || echo 'Error in EPMLEX!'
  869. etpm MAKETAGS /v || echo 'Error in MAKETAGS!'
  870. :end
  871. endlocal
  872.  
  873.  
  874. ΓòÉΓòÉΓòÉ 6.8. How to I get BC++ for DOS/Windows to run? ΓòÉΓòÉΓòÉ
  875.  
  876. Open up the Settings folder for the executable, and under "DOS Settings" set 
  877. DPMI_DOS_API to ENABLED. 
  878.  
  879.  
  880. ΓòÉΓòÉΓòÉ 7. Documentation, Help ΓòÉΓòÉΓòÉ
  881.  
  882. This section covers documentation and help available for OS/2 programming. 
  883.  
  884.  
  885. ΓòÉΓòÉΓòÉ 7.1. Where can I get information on OS/2 APIs and programming? ΓòÉΓòÉΓòÉ
  886.  
  887. The IBM Programmer's Toolkit, included in Workset/2, includes a complete 
  888. on-line syscall reference. 
  889.  
  890. You can FTP the documentation for the 16-bit calls (IBM does not supply them), 
  891. such as Vio*(), Kbd*(), Mou*(), from cdrom.com as os2/2_x/program/inf16bit.zip. 
  892.  
  893. You can order the seventeen volume IBM OS/2 Technical Library (possibly at a 
  894. discount, see question 1.2) and/or order various volumes individually. 
  895.  
  896. Most of these volumes are now published by Que books also, and can be found in 
  897. many bookstores. 
  898.  
  899. All this information is also on the OS/2 Online Library Omnibus Edition: OS/2 
  900. Collection CD-ROM (SK2T-2176), and the Professional Developer's Kit CD-ROMs 
  901. have this information as well. 
  902.  
  903.  
  904. Related Information:
  905.  
  906. What are good reference books for programming in OS/2 and PM?
  907.  
  908.  
  909. ΓòÉΓòÉΓòÉ 7.2. Where can I get sample code? ΓòÉΓòÉΓòÉ
  910.  
  911. There is a lot of sample code included in the IBM Toolkit, and four sample 
  912. programs (with source) included with C-Set++.  GNU C/C++, from cdrom.com, 
  913. includes a sample C, C++, and C++ PM program.  The OS/2 Redbooks also have some 
  914. sample code.  cdrom.com also has little bits of OS/2 and PM source code lying 
  915. around in the os2/2_x/program directory. 
  916.  
  917.  
  918. Related Information:
  919.  
  920. What are the OS/2 redbooks, and how do I get them?
  921.  
  922.  
  923. ΓòÉΓòÉΓòÉ 7.3. Are there any OS/2 programming classes or seminars? ΓòÉΓòÉΓòÉ
  924.  
  925. Yes.  Call IBM at either 1-800-3-IBM-OS2 in U.S. (or the PS/2 Help Center). 
  926. Local IBM branches frequently hold OS/2 classes and seminars. 
  927.  
  928. See os2/2_x/info/ivleague.txt on cdrom.com or the User's Edition for a list of 
  929. third-party support organizations. 
  930.  
  931. Make sure to check your local software companies.  Many of them offer OS/2 
  932. specific classes also. 
  933.  
  934.  
  935. ΓòÉΓòÉΓòÉ 7.4. What are good ref. books for programming in OS/2 and PM? ΓòÉΓòÉΓòÉ
  936.  
  937. Van Nostrand Reinhold publishes a number of books on OS/2 2.x.  Those that 
  938. relate to programming are: 
  939.  
  940. INTEGRATING APPLICATIONS WITH OS/2 2.0
  941. By William H. Zack
  942. 0-422-01234-9
  943.  
  944. CLIENT/SERVER PROGRAMMING WITH OS/2 2.0, 2nd Edition
  945. By Robert Orfali and Daniel Harkey, IBM Corporation
  946. 0-422-01219-5
  947.  
  948. WRITING OS/2 2.0 DEVICE DRIVERS IN C
  949. By Steven J. Mastrianni; Foreword by John Soyring, IBM Corporation
  950. 0-442-01141-5
  951.  
  952. OS/2 2.0 PRESENTATION MANAGER GPI: A Programming Guide to Text, Graphics, And Printing
  953. By Graham C.E. Winn, IBM Corporation
  954. 0-442-00739-6
  955.  
  956. THE COBOL PRESENTATION MANAGER PROGRAMMING GUIDE
  957. By David M. Dill, Consultant
  958. 0-442-01293-4
  959.  
  960. LEARNING TO PROGRAM OS/2 2.0 PRESENTATION MANAGER BY EXAMPLE: Putting the Pieces Together
  961. By Stephen Knight, IBM Corportaion
  962. 0-442-01292-6
  963.  
  964. THE ART OF OS/2 2.1 C PROGRAMMING
  965. By Panov, Salomon, and Panov
  966. 620p, $39.95 US (suggested) includes disk with samples
  967. ISBN 0-89435-446-9
  968.  
  969. OS/2 PRESENTATION MANAGER PROGRAMMING
  970. By Charles Petzold
  971. Ziff-Davis Press
  972. ISBN 1-56276-123-4
  973.  
  974. DESIGN OF OS/2, SECOND EDITION
  975. By Kogan & Deitel
  976. Addison-Wesley
  977. 0-201-52886-X
  978.  
  979. ULTIMATE OS/2 PROGRAMMER's MANUAL
  980. Mueller
  981. McGraw-Hill Professional Computing
  982. 0-07-043972-9
  983.  
  984. EFFECTIVE MULTITHREADING IN OS/2
  985. By Dorfman & Neuberger, McGraw-Hill Professional Computing
  986. 0-07-017841-0,
  987.  
  988. OS/2 REMOTE COMMUNICATIONS: Async to sync
  989. By Stonecipher
  990. Van Nostrand Reinhold
  991. 0-0442-01814-2,
  992.  
  993. OS/2 V2 C++ CLASS LIBRARY: Power GUI Programming using C Set++
  994. By Kevin Leong, William Law, Robert Love, Hiroshi Tsuji and Bruce Olson
  995. Van Nostrand Reinhold
  996. $36.95
  997. 0-442-01795-2
  998.  
  999. OBJECTS FOR OS/2 2.1
  1000. By S. Danforth, P Koenen and Tate et al
  1001. Van Nostrand Reinhold
  1002. ISBN 0-442-01738-3
  1003.  
  1004. OS/2 AND NETWARE PROGRAMMING: Netware Client API
  1005. By Gauthier
  1006. Van Nostrand Reinhold
  1007. ISBN 0-442-01815-0
  1008.  
  1009. OS/2 PROGRAMMING: Your Fast-Track Guide to OS/2
  1010. By Herbert Schildt & Robert Goosey
  1011. 306p, $29.95
  1012. ISBN 0-07-881910-5
  1013.  
  1014. ADVANCED ASSEMBLY LANGUAGE
  1015. Steven Holzner and Peter Norton Computing Inc.
  1016. Brady Books, A division of Simon & Schuster, New York, NY, USA
  1017. 1991  ISBN 0-13-633014-6
  1018.  
  1019. OBJECT-ORIENTED PROGRAMMING WITH SOM AND DSOM
  1020. Christina Lau
  1021. Van Nostrand Reinhold
  1022. ISBN 0-442-01948-3
  1023.  
  1024. REAL WORLD PROGRAMMING FOR OS/2 2.1
  1025. By Blain, Delimon and English
  1026. SAMS
  1027. ISBN 0-673-30300-0
  1028.  
  1029. RUNNING WINDOWS APPLICATIONS IN OS/2:  A Power User's Guide
  1030. Ayo Anise, Teresa Beck and Jean Shortley
  1031.  
  1032. DYNAMIC DATA EXCHANGE FOR OS/2 PROGGRAMMERS
  1033. By Glenn T. Puchtel
  1034. Disk included.
  1035.  
  1036. LOTUS NOTES RELEASE 3 IN THE OS/2 ENVIROMENT
  1037. By Tony Walsh
  1038.  
  1039. Books announced to be released Dec '94 and early '95. 
  1040.  
  1041. THE OS/2 SURVIVAL KIT
  1042. By Proffit
  1043. Addison-Wesley
  1044.  
  1045. STEPPING UP TO OS/2 WARP
  1046. Abacus
  1047.  
  1048. THE OS/2 WARP BIBLE
  1049. Abacus
  1050.  
  1051. THE PHOTO CD BOOK (with OS/2 Warp applications disk)
  1052. Abacus
  1053.  
  1054. OS/2 FOR DUMMIES (2nd Edition)
  1055. By Rathbone
  1056. IDG Books
  1057. ISBN 1-56884-205-8
  1058.  
  1059. YOUR OS/2 CONSULTANT (Warp Edition)
  1060. By Tyson
  1061. Sams
  1062.  
  1063. OS/2 Unleashed (Warp Edition)
  1064. Moskowitz & Kerr
  1065. Sams
  1066.  
  1067. MASTERING OS/2 WARP
  1068. By Dyson
  1069. Sybex
  1070.  
  1071. USING OS/2 WARP
  1072. By Clifford et al
  1073. QUE
  1074.  
  1075. TEACH YOURSELF OS/2 PROGRAMMING
  1076. Sams
  1077.  
  1078. Quick Reference Library for OS/2 Functions: Vol 3 - Workplace Shell
  1079. By Scholin
  1080. VNR
  1081. ISBN 0-442-01899-1
  1082.  
  1083. Developing Multimedia Applications Under OS/2
  1084. By Lopez
  1085. VNR
  1086. ISBN 0-442-01929-7
  1087.  
  1088. OS/2 Warp Advanced Graphics GPI
  1089. By Knight and Ryan
  1090. John Wiley & Sons
  1091.  
  1092. OS/2 Remote Communications: Asynchronous to Synchronous T&T
  1093. Stonecipher
  1094. VNR
  1095. ISBN 0-442-01814-2
  1096.  
  1097. Quick Reference Library for OS/2 Functions: Vol 4 - GPI Functions
  1098. By Scholin
  1099. VNR
  1100. ISBN 0-442-01900-9
  1101.  
  1102. Quick Reference Library for OS/2 Functions: Vol 5 - DOS Functions
  1103. By Scholin
  1104. VNR
  1105. ISBN 0-442-01901-7
  1106.  
  1107. OS/2 Warp Presentation Manager Programming for Power Programmers
  1108. By Stern and Morrow
  1109. Wiley-QED
  1110. ISBN 0-471-05839-4
  1111.  
  1112. OS/2 Warp Control Program API
  1113. By Stock
  1114. Wiley-QED
  1115. ISBN 0-471-03887-3
  1116.  
  1117. Secrets of the OS/2 Masters
  1118. By Sullivan
  1119. VNR
  1120. ISBN 0-442-01991-2
  1121.  
  1122. OS/2 Presentation Manager
  1123. By Drapkin
  1124. VNR
  1125. ISBN 0-442-01989-0
  1126.  
  1127. IBM has a .INF file where all IBM OS/2 related books are listed. 
  1128.  
  1129.  
  1130. Related Information:
  1131.  
  1132. What are the OS/2 redbooks, and how do I get them?
  1133.  
  1134.  
  1135. ΓòÉΓòÉΓòÉ 7.5. What are good OS/2 programming magazines? ΓòÉΓòÉΓòÉ
  1136.  
  1137. OS/2 Developer 
  1138.  
  1139. (subscription info?) 
  1140.  
  1141. Electronic Developers' Magazine/2 
  1142.  
  1143. Excellent electronic magazine for OS/2 developers.  Available somewhat monthly 
  1144. from ftp-os2.cdrom.com in 2_x/program/newsltr/edmi*.zip. 
  1145.  
  1146. PC Magazine 
  1147.  
  1148. While this is not by any means a dedicated OS/2 programming magazine, it 
  1149. includes several gems from Charles Petzold, most notably a nice series on font 
  1150. handling. 
  1151.  
  1152.  
  1153. ΓòÉΓòÉΓòÉ 7.6. What are the OS/2 redbooks, and how do I get them? ΓòÉΓòÉΓòÉ
  1154.  
  1155. (see end note for FTP information) 
  1156.  
  1157. IBM publishes so-called "redbooks" on many products, including OS/2 2.x.  They 
  1158. seem to be a combination of power-user's guides and design information that may 
  1159. be of use to both users and programmers [I haven't received my copies yet, so I 
  1160. cannot say for sure.]  These are usually intended only for special IBM 
  1161. customers and contain documentation that is generally unavailable anywhere 
  1162. else.  You can order these books directly from IBM (see below).  All of the 
  1163. following names are implicitly preceeded by "OS/2 Version 2.0." 
  1164.  
  1165. Volume 1: Control Program: GG24-3730, $4.15 
  1166.      Technical information on Memory Management, Task Mangement, Support, 
  1167.      Installation Considerations, Hardware Considerations, Boot Manager, 
  1168.      National Language Considerations, Intel 386 architecture, Channel 
  1169.      Architecture and SCSI.    Documents config.sys. 
  1170.  
  1171. Volume 2: DOS and Windows Environment, GG24-3731, $6.20 
  1172.      MVDM,8086 Emulation,MVDM DOS emulation, Device Drivers, Memory Extender 
  1173.      Support, Installing and Migrating Applications, Windows Applications, 
  1174.      DPMI, Running DOS apps,DOS settings, VMB. 
  1175.  
  1176. Volume 3:  PM and Workplace Shell GG24-3732, $3.65 
  1177.      Available now, but I don't know precisely what's in it. 
  1178.  
  1179. Volume 4: Application Development GG24-3774, $5.25 
  1180.      Technical programming info (includes list in C) Overview, Object-Oriented 
  1181.      Apps, PM application model, flat memory model, building PM app, Workplace 
  1182.      AOAShell and System Object Model, Direct Manipulation (Drag/drop), PM 
  1183.      resources, Multitasking Considerations, SAA CUA considerations, App 
  1184.      Migration, Mixing 16 and 32 bit application modules, compiling and link 
  1185.      editing (SOM), Adding Online Help, Problem Determination, Managing 
  1186.      Development, Naming conventions. 
  1187.  
  1188. Volume 5: Print Subsystem, GG24-3775, $5.20 
  1189.      Information on programming the print subsystem. 
  1190.  
  1191. The special part number GBOF-2254 is for all currently available volumes 
  1192. (presently 1-5). 
  1193.  
  1194. ORDERING INFORMATION: 
  1195.  
  1196. The OS/2 2.x Redbooks are available from IBM's TeleServices customer support 
  1197. number.  The number is 1-800-7654-IBM (1-800-765-4426).  You can pay by credit 
  1198. card or mail in a check after calling.  The order will take about 2 weeks but 
  1199. can be sped up by paying for faster shipping. 
  1200.  
  1201. You can also order the redbooks from your local IBM Branch Office library. 
  1202. Some possibly useful phone numbers are included here. 
  1203.  
  1204.     IBM Central Library, Los Angeles CA: (213) 621-6710
  1205.         P.O. Box 60737
  1206.         Los Angeles, CA 90060
  1207.     Canada: (800) 465-1234, ext 4205 ($33.52)
  1208.     UK: (0256) 478166, (#36.51, credit cards accepted)
  1209.     Australia (Victoria): 698-1234 ($46.80 A)
  1210.         IBM Australia
  1211.         The Library
  1212.         211 Sturt Street
  1213.         South Melbourne, 3205
  1214.         Att: Kate Seeley
  1215.     Denmark: 33 32 40 55 (dkk 310)
  1216.  
  1217. The redbooks are also FTP'able from cdrom.com as the os2/ibm/misc/redbk*.zip. 
  1218. The source code that accompanies the first three redbooks can FTP'able from 
  1219. cdrom.com as os2/2_x/program/rb37*.zip. 
  1220.  
  1221. Various OS/2 technical programming books can be found on the Developers 
  1222. Connection CDROM.  The entire OS/2 Library can be found on the "OS/2 Online 
  1223. Book Collection CDROM", Order Number S53G-2166-00. 
  1224.  
  1225.  
  1226. ΓòÉΓòÉΓòÉ 7.7. How can I view the GNU C documentation? ΓòÉΓòÉΓòÉ
  1227.  
  1228. GNU C/C++ comes with documentation from the Free Software Foundation in texinfo 
  1229. (.texi) format.  This documentation is about gcc in general, and has no 
  1230. OS/2-specific information. 
  1231.  
  1232. All utilities needed to compile/view/tex the texinfo files are readily 
  1233. available for OS/2.  The GNU texinfo package, available on cdrom.com in 
  1234. os2/all/unix/gnu/gnuinfo.zip, includes makeinfo.exe for compiling texinfo, 
  1235. info.exe for viewing them, and texinfo.tex and texindex.exe for TeXing them. 
  1236.  
  1237. An ASCII text version of the gcc documentation is also available on cdrom.com, 
  1238. in the file os2/2_x/unix/gnu/gcc2_233/gcc_inf.zip. 
  1239.  
  1240. An INF hypertext version of the gcc (and related programs) documentation was 
  1241. uploaded recently to cdrom.com. 
  1242.  
  1243. emx/gcc includes its own hypertext style reader and texinfo files for all the 
  1244. GNU tools that come with it. 
  1245.  
  1246. GCC/2 includes the hypertext manuals for gcc, gas, and gnumake as well as a PM 
  1247. reader for the manuals. 
  1248.  
  1249. GNU Emacs for OS/2 reads GNU info files in their native format, with no 
  1250. conversion necessary on the user's part. 
  1251.  
  1252.  
  1253. ΓòÉΓòÉΓòÉ 7.8. Where can I get documentation on the OBJ/LIB/EXE format used by OS/2 2.x? ΓòÉΓòÉΓòÉ
  1254.  
  1255. o The .EXE format was described briefly in PC Magazine, Vol 11 No. 12 (June 30, 
  1256.   1992?); it was also described in a 1988 issue. 
  1257. o The glib source code contains a full description of the 32 bit OBJ and LIB 
  1258.   formats.  It is found at cdrom.com:/os2/2_x/unix/gnu/gcc2_233/glibs115.zip. 
  1259. o It is available in text form from cdrom.com as os2/2_x/program/lxexe.doc. 
  1260. o OMF.INF from IBM (the IBM BBS) comes highly recommended. 
  1261.  
  1262.  
  1263. ΓòÉΓòÉΓòÉ 7.9. Where can I find information on HPFS? ΓòÉΓòÉΓòÉ
  1264.  
  1265. There is a Microsoft Systems Journal article about it (64k ZIPped, so it has a 
  1266. lot of information) in ftp-os2.cdrom.com in all/info.hpfs.zip. 
  1267.  
  1268.  
  1269. ΓòÉΓòÉΓòÉ 8. PM Programming ΓòÉΓòÉΓòÉ
  1270.  
  1271. This section covers Presentation Manager programming. 
  1272.  
  1273.  
  1274. ΓòÉΓòÉΓòÉ 8.1. Printing ΓòÉΓòÉΓòÉ
  1275.  
  1276. This section covers Presentation Manager printing. 
  1277.  
  1278.  
  1279. ΓòÉΓòÉΓòÉ 8.1.1. Are there any SIMPLE examples of printing? ΓòÉΓòÉΓòÉ
  1280.  
  1281. Here is some sample code, but also check out PRINTQ12.ZIP on cdrom.com in 
  1282. 2_x/program. PRINTQ12.ZIP contains a DLL that encapselates alot of the messy 
  1283. details. 
  1284.  
  1285. Here is the working code for allowing the user to change the printer setup. 
  1286. I've also included the code that I use to start and end printing, so you can 
  1287. see how it all works. 
  1288.  
  1289. If you have any questions or comments, feel free to write. 
  1290.  
  1291. PrinterSetup() is the routine that gets the printer setup information from the 
  1292. user. 
  1293.  
  1294. GetPrinterHPS() is the routine that gets the DC and PS for the printer, and 
  1295. starts the document. 
  1296.  
  1297. EndPrint() is the routine that ends the document, and closes the DC. 
  1298.  
  1299. First, here's a little sample of how to use PrinterSetup(), GetPrinterHPS(), 
  1300. and EndPrint(): 
  1301.  
  1302. {
  1303.    HPS          hPrinterPS;
  1304.    HDC          hPrinterDC;
  1305.    DEVOPENSTRUC dops;
  1306.  
  1307.    ...
  1308.  
  1309.    dops->pszLogAddress = NULL;  // in case PrinterSetup fails, this will tell
  1310.                                 // GetPrinterHPS() to use default printer info
  1311.  
  1312.    PrinterSetup(&dops);
  1313.  
  1314.    hPrinterPS = GetPrinterHPS(&dops, &hPrinterDC,
  1315.                               "Document Name", 0L, 0L);
  1316.    if (hPrinterPS != GPI_ERROR) {
  1317.       // do your printing here
  1318.  
  1319.       EndPrint(hPrinterPS, hPrinterDC, "Document Name");
  1320.    }
  1321.  
  1322.    ...
  1323. }
  1324.  
  1325.  
  1326. /*
  1327. ******************************************************************************
  1328. **  FUNCTION: PrinterSetup
  1329. **  PURPOSE :   This function allows the user to change printer settings.
  1330. **
  1331. **  PARAMS  :   lpdos - the printer info
  1332. **  RETURN  :   BOOL   (TRUE = success)
  1333. **
  1334. **  DATE    :   11-Dec-1992
  1335. **  AUTHOR  :   Carl Samos
  1336. ******************************************************************************
  1337. **  Modified: Date:     Description of changes
  1338. **  CNS     :   11-Dec-1992 Initial version
  1339. ******************************************************************************
  1340. */
  1341. BOOL PrinterSetup(DEVOPENSTRUC FAR *lpdos)
  1342. {
  1343.    PDRIVDATA     pDriveData;      /*  The drive data  */
  1344.    unsigned long ulSize;          /*  The buffer size required  */
  1345.    char          szPrinter[32];   /*  The printer name  */
  1346.    PSZ           pszDriver;       /*  The driver name  */
  1347.    PSZ           pszLogicalPort;  /*  The logical port  */
  1348.    char          szDeviceName[32];/*  The printer's name */
  1349.  
  1350.  
  1351.    // get the printer driver, name and logical port
  1352.    // GetPrinterInformation allocates space for pszDriver and pszLogicalPort
  1353.    if (!GetPrinterInformation(szPrinter, &pszDriver,
  1354.                               szDeviceName,&pszLogicalPort))
  1355.       return(FALSE);
  1356.  
  1357.  
  1358.    // get the size needed for the DRIVDATA struct
  1359.    ulSize = DevPostDeviceModes(habMain, NULL, pszDriver, NULL, szPrinter, 0L);
  1360.  
  1361.  
  1362.    if (ulSize != DPDM_NONE && ulSize != DPDM_ERROR) {
  1363.       pDriveData = (PDRIVDATA) _fmalloc(ulSize);
  1364.       pDriveData->cb = ulSize;
  1365.  
  1366.       // bring up the dialog boxes, and fill the DRIVDATA struct
  1367.       ulSize = DevPostDeviceModes(habMain, pDriveData, pszDriver, NULL,
  1368.                                   szPrinter, 0L);
  1369.  
  1370.       if (ulSize == DEV_OK) {
  1371.           // if there is a printer name, copy it into the DRIVDATA
  1372.           if (szDeviceName[0] != '\0')
  1373.              strcpy(pDriveData->szDeviceName, szDeviceName);
  1374.  
  1375.           // remove the old information
  1376.           if (lpdos->pszLogAddress != NULL) {
  1377.              _ffree(lpdos->pszLogAddress);
  1378.           }
  1379.           if (lpdos->pszDriverName != NULL) {
  1380.              _ffree(lpdos->pszDriverName);
  1381.           }
  1382.           if (lpdos->pdriv != NULL)
  1383.              _ffree(lpdos->pdriv);
  1384.  
  1385.           /*  Setup the DEVOPENSTRUC  */
  1386.           lpdos->pszLogAddress = pszLogicalPort;
  1387.           lpdos->pszDriverName = pszDriver;
  1388.           lpdos->pszDataType   = NULL;
  1389.           lpdos->pdriv         = pDriveData;
  1390.       }
  1391.       else {
  1392.           _ffree(pszDriver);
  1393.           _ffree(pszLogicalPort);
  1394.           _ffree(pDriveData);
  1395.       }
  1396.    }
  1397.    else {
  1398.       _ffree(pszDriver);
  1399.       _ffree(pszLogicalPort);
  1400.    }
  1401.  
  1402.    return(TRUE);
  1403. }
  1404.  
  1405.  
  1406. /*
  1407. ******************************************************************************
  1408. **  FUNCTION:   GetPrinterInformation
  1409. **  PURPOSE :   This function gets the current printer information from the
  1410. **                    os2.ini file.
  1411. **
  1412. **  PARAMS  :   PSZ pszPrinter
  1413. **              PSZ pszDriver
  1414. **              PSZ pszDeviceName
  1415. **              PSZ pszLogicalPort
  1416. **
  1417. **  RETURN  :   void
  1418. **
  1419. **  DATE    :   11-Dec-1992
  1420. **  AUTHOR  :   Carl Samos
  1421. ******************************************************************************
  1422. **  Modified: Date:     Description of changes
  1423. **  CNS     :   11-Dec-1992 Initial version
  1424. ******************************************************************************
  1425. */
  1426. BOOL GetPrinterInformation(PSZ pszPrinter, PSZ FAR *lpszDriver,
  1427.                            PSZ pszDeviceName, PSZ FAR *lpszLogicalPort)
  1428. {
  1429.    int  cb;
  1430.    char szDetails[256];
  1431.    PSZ  pszBegin;
  1432.    PSZ  pszTemp;
  1433.    char szPort[64];
  1434.    char szDriver[64];
  1435.    char szLogPort[64];
  1436.  
  1437.    /*  Get the printer name  */
  1438.    cb = WinQueryProfileString(habMain, "PM_SPOOLER",
  1439.                               "PRINTER", "", pszPrinter,32);
  1440.    pszPrinter[cb-2] = 0;
  1441.  
  1442.  
  1443.    /*  Get the other details  */
  1444.    WinQueryProfileString(habMain, "PM_SPOOLER_PRINTER", pszPrinter, "",
  1445.                          szDetails, 256);
  1446.  
  1447.    // the profile string has the following format:
  1448.    // PORT;DRIVER;LOGICAL PORT;NETWORK INFO;
  1449.    // fields can have more than one entry, separated by a comma
  1450.    // the printer's name will follow the driver, separated by a period.
  1451.  
  1452.    pszBegin = szDetails;
  1453.  
  1454.    // get the printer port
  1455.    pszTemp = strchr(pszBegin, ';');
  1456.    if (pszTemp != NULL) {
  1457.       *pszTemp = '\0';
  1458.       strcpy(szPort, pszBegin);
  1459.       *pszTemp = ';';
  1460.       pszBegin = pszTemp + 1;
  1461.  
  1462.       // check for a comma in the string
  1463.       pszTemp = strchr(szPort, ',');
  1464.       if (pszTemp != NULL) *pszTemp = '\0';
  1465.    }
  1466.    else {
  1467.       return(FALSE);
  1468.    }
  1469.  
  1470.    // now get the driver and printer name
  1471.    pszTemp = strchr(pszBegin, ';');
  1472.    if (pszTemp != NULL) {
  1473.       *pszTemp = '\0';
  1474.       strcpy(szDriver, pszBegin);
  1475.       *pszTemp = ';';
  1476.       pszBegin = pszTemp + 1;
  1477.  
  1478.       // check for a period (printer name follows it)
  1479.       pszTemp = strchr(szDriver, '.');
  1480.       if (pszTemp != NULL) {
  1481.          strcpy(pszDeviceName, pszTemp+1);
  1482.          *pszTemp = '\0';
  1483.       }
  1484.       else {
  1485.          pszDeviceName[0] = '\0';
  1486.       }
  1487.  
  1488.       // check for a comma in the string
  1489.       pszTemp = strchr(szDriver, ',');
  1490.       if (pszTemp != NULL)
  1491.         *pszTemp = '\0';
  1492.    }
  1493.    else {
  1494.       return(FALSE);
  1495.    }
  1496.  
  1497.  
  1498.    // now get the logical port
  1499.    pszTemp = strchr(pszBegin, ';');
  1500.    if (pszTemp != NULL) {
  1501.       *pszTemp = '\0';
  1502.       strcpy(szLogPort, pszBegin);
  1503.       *pszTemp = ';';
  1504.       pszBegin = pszTemp + 1;
  1505.  
  1506.       // check for a comma in the string
  1507.       pszTemp = strchr(szLogPort, ',');
  1508.       if (pszTemp != NULL)
  1509.         *pszTemp = '\0';
  1510.    }
  1511.    else {
  1512.       return(FALSE);
  1513.    }
  1514.  
  1515.    *lpszDriver = _fmalloc(sizeof(char) * (strlen(szDriver)+1));
  1516.    strcpy(*lpszDriver, szDriver);
  1517.  
  1518.    *lpszLogicalPort = _fmalloc(sizeof(char) * (strlen(szLogPort)+1));
  1519.    strcpy(*lpszLogicalPort, szLogPort);
  1520.  
  1521.    return(TRUE);
  1522. }
  1523.  
  1524.  
  1525. /*
  1526. ******************************************************************************
  1527. **  FUNCTION: GetPrinterHPS
  1528. **  PURPOSE :   Gets the presentation space for a printer, and starts the doc
  1529. **  PARAMS  :   lpdos
  1530. **          :   lphDC           - the printer's hdc
  1531. **          :   pszDocName      - the name of the document
  1532. **          :   lWidth          - the width of the document
  1533. **          :   lHeight         - the height of the document
  1534. **  RETURN  : hPS
  1535. **  DATE    :   11-Dec-1992
  1536. **  AUTHOR  :   Carl Samos
  1537. ******************************************************************************
  1538. **  Modified: Date:     Description of changes
  1539. **  CNS     :   11-Dec-1992 Initial version
  1540. ******************************************************************************
  1541. */
  1542. HPS GetPrinterHPS(DEVOPENSTRUC FAR *lpdos, HDC FAR* lphDC, PSZ pszDocName,
  1543.           LONG lWidth, LONG lHeight)
  1544. {
  1545.    LONG  lReturn;
  1546.    SIZEL sizl;
  1547.    HPS   hPS;
  1548.  
  1549.    if (lpdops->pszLogAddress == NULL) {  // get the default settings
  1550.       char szPrinter[32];   /*  The printer name    */
  1551.       PSZ  pszDriver;       /*  The driver name  */
  1552.       PSZ  pszLogicalPort;  /*  The logical port    */
  1553.       char szDeviceName[32];/*  The printer's name */
  1554.  
  1555.       // GetPrinterInformation allocates space for pszDriver and pszLogicalPort
  1556.       if (!GetPrinterInformation(szPrinter, &pszDriver, szDeviceName,
  1557.                                  &pszLogicalPort))
  1558.       return(GPI_ERROR);
  1559.  
  1560.       lpdops->pszLogAddress = pszLogicalPort;
  1561.       lpdops->pszDriverName = pszDriver;
  1562.       lpdops->pszDataType   = NULL;
  1563.       lpdops->pdriv         = NULL;
  1564.    }
  1565.  
  1566.    // open the printer DC
  1567.    *lphDC = DevOpenDC (habMain, OD_QUEUED, "*", 4L, lpdops, (HDC) NULL);
  1568.    if (*lphDC == DEV_ERROR) {
  1569.       return(GPI_ERROR);
  1570.    }
  1571.  
  1572.    // start the document
  1573.    lReturn = DevEscape(*lphDC, DEVESC_STARTDOC, strlen(pszDocName),
  1574.                        pszDocName,NULL, NULL);
  1575.  
  1576.    // get the PS for the printer
  1577.    if (lReturn == DEV_OK) {
  1578.        sizl.cx = lWidth;
  1579.        sizl.cy = lHeight;
  1580.  
  1581.        if (lWidth == 0) {
  1582.           hPS =  GpiCreatePS (habMain, *lphDC, &sizl,
  1583.                               PU_LOENGLISH | GPIF_DEFAULT |
  1584.                               GPIT_NORMAL | GPIA_ASSOC);
  1585.           return(hPS);
  1586.        }
  1587.        else {
  1588.           hPS = GpiCreatePS (habMain, *lphDC, &sizl,
  1589.                               PU_ARBITRARY | PU_LOENGLISH |
  1590.                               GPIF_DEFAULT | GPIT_NORMAL |
  1591.                               GPIA_ASSOC);
  1592.           return(hPS);
  1593.       }
  1594.    }
  1595.  
  1596.    return(GPI_ERROR);
  1597. }
  1598.  
  1599.  
  1600. /*
  1601. ******************************************************************************
  1602. **  FUNCTION: EndPrint
  1603. **  PURPOSE : To close the hdc and end the document
  1604. **  PARAMS  : hpsPrinter - the printer's presentation space
  1605. **     : hdcPrinter - the printer's device context
  1606. **     : pszDocName - the name of the document
  1607. **  RETURN  : nothing
  1608. **  DATE    :   11-Dec-1992
  1609. **  AUTHOR  :   Carl Samos
  1610. ******************************************************************************
  1611. **  Modified: Date:     Description of changes
  1612. **  CNS     :   11-Dec-1992 Initial version
  1613. ******************************************************************************
  1614. */
  1615. void EndPrint(HPS hpsPrinter, HDC hdcPrinter, PSZ pszDocName)
  1616. {
  1617. DevEscape(hdcPrinter, DEVESC_ENDDOC, strlen(pszDocName),
  1618. pszDocName, NULL,NULL);
  1619. GpiAssociate(hpsPrinter, (HDC) NULL);
  1620. DevCloseDC(hdcPrinter);
  1621. GpiDestroyPS(hpsPrinter);
  1622. }
  1623.  
  1624. Credit:  Carl Samos 
  1625.  
  1626.  
  1627. ΓòÉΓòÉΓòÉ 8.1.2. Is there an easy way to get printer output (another opinion)? ΓòÉΓòÉΓòÉ
  1628.  
  1629. A reader who desires to remain anonymous writes: 
  1630.  
  1631. Generally:  My understanding was that OS/2 would handle printing for me.  That 
  1632. is to say that I wouldn't have to create separate printer drivers for every 
  1633. printer under the sun (or any for that matter).  Since I am creating an image 
  1634. on the screen that is device independent (well, mostly anyway), is there an 
  1635. easy way to get printer output? 
  1636.  
  1637. PM achieves a level of device independence by defining a logical output space. 
  1638. This logical output space is then bound to a physical output space, which 
  1639. creates a mapping of logical characteristics to their physical counterparts. 
  1640. The logical and physical output spaces are referred to as the presentation 
  1641. space and the device context (HPS and HDC) and are bound to one another by 
  1642. using either the GpiAssociate function or by specifying GPIA_ASSOC to the 
  1643. GpiCreatePS function. 
  1644.  
  1645. The easiest way to accomplish what you desire is to organize your drawing code 
  1646. into one or more functions with a single entrypoint that accepts an HPS as a 
  1647. parameter.  Then, when you want to draw to the screen, you can call 
  1648. WinGetPS/WinBeginPaint to get an HPS and call the function. When you want 
  1649. hardcopy, you call DevOpenDC to get an HDC and GpiCreatePS to get an HPS and 
  1650. call the function. 
  1651.  
  1652. Note that to get hardcopy, you need to perform some additional setup to get 
  1653. things to work properly.  The two most important things are that you initialize 
  1654. the DEVOPENSTRUC structure properly before calling DevOpenDC and that you send 
  1655. the following escape codes (via DevEscape) at the following times: 
  1656.  
  1657.   hdcPrn=DevOpenDC(...);
  1658.   hpsPrn=GpiCreatePS(...);
  1659.  
  1660.   DevEscape(...,DEVESC_STARTDOC,...);
  1661.  
  1662.   if (!doDraw(hpsPrn)) {
  1663.      DevEscape(...,DEVESC_ABORTDOC,...);
  1664.   } /* endif */
  1665.  
  1666.   DevEscape(...,DEVESC_ENDDOC,...);
  1667.  
  1668.   GpiDestroyPS(hpsPrn);
  1669.   DevCloseDC(hdcPrn);
  1670.  
  1671. I'm not sure because I can't seem to find my copy anywhere, but I belive that 
  1672. the book by Graham Winn (entitled something to the effect of "Building 
  1673. applications using the OS/2 Presentation Manager") dedicates a chapter to the 
  1674. nuances of printing. 
  1675.  
  1676. (Quoted almost directly from EDMI/2 Edition 1) 
  1677.  
  1678.  
  1679. Related Information:
  1680.  
  1681. What are good reference books for programming in OS/2 and PM?
  1682.  
  1683.  
  1684. ΓòÉΓòÉΓòÉ 8.1.3. How do I print a bitmap? ΓòÉΓòÉΓòÉ
  1685.  
  1686. Here's my code for sending a bitmap to the printer I'm leaving out the part 
  1687. where I maintain an aspect ratio between the screen and the printer page. 
  1688.  
  1689.     SIZEL sizl = {0,0};
  1690.     // Get DC/PS for printer
  1691.     hdcPrinter = GetPrinterDC( hab, PM_Q_STD );
  1692.     hpsPrinter = GpiCreatePS( hab, hdcPrinter, &sizl,
  1693.                               PU_PELS | GPIF_DEFAULT |
  1694.                               GPIT_NORMAL | GPIA_ASSOC);
  1695.  
  1696.     // Get DC/PS for memory DC compatible with printer
  1697.     hdcPrtMem = DevOpenDC( hab, OD_MEMORY, "*", 0, NULL, hdcPrinter );
  1698.     hpsPrtMem = GpiCreatePS( hab, hdcPrtMem, &sizl,
  1699.                              PU_PELS | GPIF_DEFAULT |
  1700.                              GPIT_MICRO | GPIA_ASSOC );
  1701.  
  1702.     // Get DC/PS for memory DC compatible with display
  1703.     hdcMemory = DevOpenDC( hab, OD_MEMORY, "*", 0, NULL, NULLHANDLE );
  1704.     hpsMemory = GpiCreatePS( hab, hdcMemory, &sizl,
  1705.                              PU_PELS | GPIF_DEFAULT |
  1706.                              GPIT_MICRO | GPIA_ASSOC );
  1707.  
  1708.     // Get PS for a window to be printed
  1709.     hpsToPrint = WinGetPS( hwndToPrint );
  1710.  
  1711.     // Set up memory BitBlt
  1712.     BITMAPINFOHEADER2 bmih;
  1713.     LONG alBitmapStuff[ 2 ];
  1714.     WinQueryWindowPos( hwndToPrint, &swp );
  1715.     bmih.cbFix = sizeof( BITMAPINFOHEADER2 );
  1716.     bmih.cx = swp.cx;
  1717.     bmih.cy = swp.cy;
  1718.     GpiQueryDeviceBitmapFormats( hpsToPrint, 2L, alBitmapStuff );
  1719.     bmih.cPlanes = (USHORT) alBitmapStuff[ 0 ];
  1720.     bmih.cBitCount = (USHORT) alBitmapStuff[ 1 ];
  1721.  
  1722.     // ....Set up aptl[0],[1],[2],[3] for the memory BitBlt
  1723.  
  1724.     // Do BitBlt from Display memory PS to Printer memory PS
  1725.     hbmToPrint = GpiCreateBitmap( hpsMemory, &bmih, 0, NULL, NULL );
  1726.     GpiSetBitmap( hpsMemory, hbmToPrint );
  1727.     GpiBitBlt( hpsMemory, hpsToPrint, 3L, aptl, ROP_SRCCOPY, BBO_IGNORE );
  1728.     GpiSetBitmap( hpsMemory, NULLHANDLE );
  1729.  
  1730.     GpiSetBitmap( hpsPrtMem, hbmToPrint );
  1731.  
  1732.     // ....Set up aptl[0],[1],[2],[3] for the printer BitBlt
  1733.  
  1734.     // BitBlt to printer PS from Printer memory PS
  1735.     DevEscape( hdcPrinter, DEVESC_STARTDOC,strlen( szDocName ), szDocName,
  1736.                &lBytes, NULL );
  1737.     GpiBitBlt( hpsPrinter, hpsPrtMem, 4L, aptl, ROP_SRCCOPY,BBO_IGNORE );
  1738.     DevEscape( hdcPrinter, DEVESC_ENDDOC, 0, NULL, &lBytes, NULL );
  1739.     GpiSetBitmap( hpsPrtMem, NULLHANDLE );
  1740.     GpiDeleteBitmap( hbmToPrint );
  1741.  
  1742.     // Release all hdc's and hps's
  1743.  
  1744. Credit:  Rick Fishman 
  1745.  
  1746.  
  1747. ΓòÉΓòÉΓòÉ 8.1.4. How do I do my own Print Screen? ΓòÉΓòÉΓòÉ
  1748.  
  1749. The following code segments are drawn from a much larger system that I manage 
  1750. at work.  The intent is to show how to provide a graphical print screen 
  1751. capability in a PM program.  We install a hook to watch for the print screen 
  1752. key and then take a bit map snapshot of the screen.  This bit map is then sent 
  1753. to the printer. Forgive me if I don't go into all the details about the 
  1754. non-related data structures -- it's late and my mind is a bit foggy. 
  1755.  
  1756. Feel free to use anything here.  Please add some kind of acknowledgement, if 
  1757. you use them as is, like: 
  1758.  
  1759.   "Print routines (c) 1990, 1991 Applied Signal Technology, Inc." 
  1760.  
  1761. Comment, questions, ridicule should be directed to:
  1762.  
  1763.   Jeff Hitchcock
  1764.   CompuServe 71601,260
  1765.  
  1766.   or U.S. Mail to
  1767.  
  1768.   Applied Signal Technology, Inc.
  1769.   470 Spring Park Place, Suite 700
  1770.   Herndon, VA 22070
  1771.  
  1772.   or phone to
  1773.  
  1774.   703/478-5619
  1775.  
  1776. /*****************************************************************************/ 
  1777.  
  1778. 1.  During the WM_CREATE message processing, add the following: 
  1779.  
  1780.    // Set the print screen hook
  1781.  
  1782.    WinSetHook (hab, HMQ_CURRENT, HK_INPUT, (PFN) PrintScreenHook,
  1783.                (HMODULE) NULL);
  1784.  
  1785. /*****************************************************************************/ 
  1786.  
  1787. 2.  Somewhere, have this function: 
  1788.  
  1789. BOOL CALLBACK PrintScreenHook (HAB hab, PQMSG pQmsg, USHORT fs)
  1790. {
  1791.    if ( pQmsg->msg == WM_CHAR )
  1792.       if ( ( SHORT1FROMMP(pQmsg->mp1) & KC_KEYUP) &&
  1793.            ( SHORT1FROMMP(pQmsg->mp1) & KC_VIRTUALKEY ) &&
  1794.            ( SHORT2FROMMP(pQmsg->mp2) == VK_PRINTSCRN) )
  1795.              PrintScreen (hab);
  1796.    return FALSE;
  1797. }
  1798.  
  1799. /*****************************************************************************/ 
  1800.  
  1801. 3.  Here's the "driver:" 
  1802.  
  1803. VOID EXPENTRY PrintScreen (HAB hab)
  1804. {
  1805.     HBITMAP     hbm;
  1806.  
  1807.     hbm = ScreenToBitmap (hab);
  1808.     PrintBitMap(hbm);
  1809. }
  1810.  
  1811. /*****************************************************************************/ 
  1812.  
  1813. 4.  Here's a general print-related structure we use.  We often have many print 
  1814. threads running concurrently, but we only allow one to "run" at a time.  We use 
  1815. a semaphore to show availability of the printer (so to speak), and only one 
  1816. thread at a time gets it.    If we didn't do this, and more than a few print 
  1817. threads are running (especially graphical prints), even a 486/33 with 16 MB of 
  1818. RAM begins to C-R-A-W-L.  So, for what it's worth, these are the structures 
  1819. that we use: 
  1820.  
  1821. /**************************************************************
  1822. *                                                             *
  1823. *   PRINTTHREADPARAMS structure                               *
  1824. *                                                             *
  1825. *   Parameters that are used to manage separate print threads *
  1826. *                                                             *
  1827. *   Item             Contents/Use                             *
  1828. *   --------------   ---------------------------------------- *
  1829. *                                                             *
  1830. *   sJobNumber       Print job number, used for cancelling    *
  1831. *   aiThreadStack    Thread's stack                           *
  1832. *   hwndNotify       Window to which notif. msgs are sent     *
  1833. *   tidPrint         System task id                           *
  1834. *   hssmPrinter...   Semaphore for printer available          *
  1835. *   fSemSet          TRUE if semaphore was made and cleared   *
  1836. *   szSummary        Print summary (e.g., fax printout)       *
  1837. *   fStart           Can't start until TRUE (default FALSE)   *
  1838. *   fContinue        Quit if FALSE (default is TRUE)          *
  1839. *   fHold            Hold if TRUE (default is FALSE)          *
  1840. *   sStartingPage    For multipage, start here                *
  1841. *   sEndingPage      For multipage, end here                  *
  1842. *   usParam          Module-dependent USHORT                  *
  1843. *   ulParam          Module-dependent ULONG                   *
  1844. *   pPrintData       PVOID to the print data                  *
  1845. *                                                             *
  1846. *   PAGESETUP structure                                       *
  1847. *                                                             *
  1848. *   Parameters used to describe the appearance                *
  1849. *                                                             *
  1850. *   Item             Contents/Use                             *
  1851. *   --------------   ---------------------------------------- *
  1852. *                                                             *
  1853. *   szFont           The name of the font to use              *
  1854. *   sLinesPerPage    Used to scale font                       *
  1855. *   sCharsPerLine    Used to scale font                       *
  1856. *   sLeft            Used to position on page, in chars       *
  1857. *   sRight           Used to position on page, in char        *
  1858. *   sTop             Used to position on page, in lines       *
  1859. *   sBottom          Used to position on page, in lines       *
  1860. *   szHeader         Text to place on top of each page        *
  1861. *   fIncludeSummary  If TRUE, include SRI summary on page 1   *
  1862. *   fHeaderEveryPage TRUE for every page, false for pg 1      *
  1863. *   fHeaderUnderline TRUE for underline                       *
  1864. *   szFooter         Text to place at bottom of each page     *
  1865. *   fFooterEveryPage TRUE for every page, false for pg 1      *
  1866. *   fOverlineFooter  TRUE for overline                        *
  1867. *                                                             *
  1868. *   HEADER AND FOOTER OPTIONS:                                *
  1869. *                                                             *
  1870. *   Special Flags that should be supported in each module:    *
  1871. *                                                             *
  1872. *           &l  Left justify                                  *
  1873. *           &c  Center                                        *
  1874. *           &r  Right justify                                 *
  1875. *           &d  Date                                          *
  1876. *           &t  Time                                          *
  1877. *           &p  Page number                                   *
  1878. *                                                            *
  1879. **************************************************************/
  1880.  
  1881. typedef struct
  1882.     {
  1883.     CHAR       szFont[FACESIZE] ;
  1884.     SHORT      sLinesPerPage ;
  1885.     SHORT      sCharsPerLine ;
  1886.     SHORT      sLeft ;
  1887.     SHORT      sRight ;
  1888.     SHORT      sTop ;
  1889.     SHORT      sBottom ;
  1890.     BOOL       fIncludeSummary ;
  1891.     CHAR       szHeader[HEADERFOOTERLENGTH] ;
  1892.     BOOL       fHeaderEveryPage ;
  1893.     BOOL       fUnderlineHeader ;
  1894.     CHAR       szFooter[HEADERFOOTERLENGTH] ;
  1895.     BOOL       fFooterEveryPage ;
  1896.     BOOL       fOverlineFooter ;
  1897.     }
  1898.     PAGESETUP ;
  1899.  
  1900. typedef PAGESETUP FAR *PPAGESETUP ;
  1901.  
  1902. typedef struct
  1903.     {
  1904.     SHORT        sJobNumber ;
  1905.     int          aiThreadStack[STACKSIZE / sizeof (int)] ;
  1906.     HWND         hwndNotify ;
  1907.     HSYSSEM      hssmPrinterAvailable ;
  1908.     BOOL         fSemSet ;
  1909.     CHAR         szSummary[HEADERFOOTERLENGTH] ;
  1910.     BOOL         fStart ;
  1911.     BOOL         fRunning ;
  1912.     BOOL         fContinue ;
  1913.     BOOL         fHold ;
  1914.     SHORT        sStartingPage ;
  1915.     SHORT        sEndingPage ;
  1916.     PAGESETUP    page ;
  1917.     USHORT       usParam ;
  1918.     ULONG        ulParam ;
  1919.     VOID huge    *pPrintData ;
  1920.     }
  1921.     PRINTTHREADPARAMS ;
  1922.  
  1923. typedef PRINTTHREADPARAMS FAR *PPRINTTHREADPARAMS ;
  1924.  
  1925. /*****************************************************************************/ 
  1926.  
  1927. 5.  This function saves the screen display to a bitmap. 
  1928.  
  1929. HBITMAP ScreenToBitmap (HAB hab)
  1930. {
  1931.      BITMAPINFOHEADER bmp ;
  1932.      HBITMAP          hbm ;
  1933.      HDC              hdcMemory ;
  1934.      HPS              hpsScreen, hpsMemory ;
  1935.      LONG             alBitmapFormats [2] ;
  1936.      POINTL           aptl[3] ;
  1937.      SIZEL            sizl ;
  1938.      SHORT            cxScreen;
  1939.      SHORT            cyScreen;
  1940.      BOOL             fMonochrome = FALSE;
  1941.                       // Create memory DC and PS
  1942.  
  1943.      cxScreen = (SHORT) WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
  1944.      cyScreen = (SHORT) WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
  1945.  
  1946.      hdcMemory = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULL) ;
  1947.  
  1948.      sizl.cx = sizl.cy = 0 ;
  1949.      hpsMemory = GpiCreatePS (hab, hdcMemory, &sizl,
  1950.                               PU_PELS | GPIF_DEFAULT |
  1951.                               GPIT_MICRO | GPIA_ASSOC) ;
  1952.  
  1953.                               // Create bitmap for destination
  1954.  
  1955.      bmp.cbFix = sizeof bmp ;
  1956.  
  1957.      if (fMonochrome)
  1958.      {
  1959.         bmp.cPlanes = 1 ;
  1960.         bmp.cBitCount = 1 ;
  1961.      }
  1962.      else
  1963.      {
  1964.         GpiQueryDeviceBitmapFormats (hpsMemory, 2L, alBitmapFormats) ;
  1965.  
  1966.         bmp.cPlanes = (USHORT) alBitmapFormats[0] ;
  1967.         bmp.cBitCount = (USHORT) alBitmapFormats[1] ;
  1968.      }
  1969.  
  1970.      bmp.cx = cxScreen ;
  1971.      bmp.cy = cyScreen ;
  1972.  
  1973.      hbm = GpiCreateBitmap (hpsMemory, &bmp, 0L, NULL, NULL) ;
  1974.  
  1975.                               // Copy from screen to bitmap
  1976.  
  1977.      if (hbm != NULL)
  1978.      {
  1979.         GpiSetBitmap (hpsMemory, hbm) ;
  1980.         hpsScreen = WinGetScreenPS (HWND_DESKTOP) ;
  1981.  
  1982.         aptl[0].x = 0 ;
  1983.         aptl[0].y = 0 ;
  1984.         aptl[1].x = cxScreen ;
  1985.         aptl[1].y = cyScreen ;
  1986.         aptl[2].x = 0 ;
  1987.         aptl[2].y = 0 ;
  1988.  
  1989.         WinLockVisRegions (HWND_DESKTOP, TRUE) ;
  1990.  
  1991.         GpiBitBlt (hpsMemory, hpsScreen, 3L, aptl,
  1992.                    fMonochrome ? ROP_NOTSRCCOPY : ROP_SRCCOPY, BBO_IGNORE) ;
  1993.  
  1994.         WinLockVisRegions (HWND_DESKTOP, FALSE) ;
  1995.  
  1996.         WinReleasePS (hpsScreen) ;
  1997.         GpiDestroyPS (hpsMemory) ;
  1998.         DevCloseDC (hdcMemory) ;
  1999.      }
  2000.  
  2001.      return hbm ;
  2002. }
  2003.  
  2004. /***************************************************************************** 
  2005.  
  2006. 6.  The "core" function: 
  2007.  
  2008. This function prints a bitmap to the printer.  The bitmap is scaled according 
  2009. to the size of the printer.  No distortion is allowed of the bitmap image. 
  2010.  
  2011. Returns False : if an error occurrs 
  2012. Returns True : no Error occurred 
  2013.  
  2014. Known bug(s): 
  2015.  
  2016. Areas on the screen that have a black foreground and a gray background are 
  2017. completely black when printed.  For example, when a window does not have the 
  2018. focus, it's title bar becomes black lettering on a gray background.  When this 
  2019. window is printed, the entire title bar is black and no title can be read. 
  2020. This is using the Hewlett Packard LaserJet Series II printer. 
  2021.  
  2022. According to MicroSoft online help this is a known bug with the printer device 
  2023. driver.    To fix the bug you must go to the control panel and change the colors 
  2024. of the inactive window. 
  2025.  
  2026. ************************************************************************/
  2027. SHORT  sBitmapToPrinter(PPRINTTHREADPARAMS pptp,
  2028. HPS   hpsPrinter,
  2029. HDC   hdcPrinter,
  2030. HAB   habPrinter,
  2031. SIZEL *psizlPage,
  2032. SIZEL *psizlChar)
  2033. {
  2034.     HDC    hdcPrinterMemory;
  2035.     HPS    hpsPrinterMemory;
  2036.     POINTL ptl;
  2037.     SHORT  sPage = 1;
  2038.     RECTL  rcl;     // Coordinates of region
  2039.  
  2040.     long  lCapsHRes;
  2041.     long  lCapsVRes;
  2042.     float fYAspectRatio;
  2043.     float fXAspectRatio;
  2044.     SIZEL sizl;
  2045.  
  2046.     HBITMAP hbm;
  2047.     POINTL  aptl [4] ;
  2048.     SHORT   cxScreen;
  2049.     SHORT   cyScreen;
  2050.     float   fltScale;
  2051.  
  2052.     // Skip down top margin, ...
  2053.  
  2054.     ptl.x = pptp->page.sLeft * psizlChar->cx ;
  2055.     ptl.y = psizlPage->cy - (pptp->page.sTop * psizlChar->cy) ;
  2056.  
  2057.     // Print header, if requested
  2058.  
  2059.     if (pptp->page.szHeader[0] != '\0')
  2060.     {
  2061.        PrintHeaderFooter (hpsPrinter, &ptl, pptp,
  2062.                           psizlPage, psizlChar,
  2063.                           pptp->page.szHeader,
  2064.                           sPage, PRINT_HEADER) ;
  2065.     }
  2066.  
  2067.     hbm = pptp->pPrintData;
  2068.  
  2069.     // Find the aspect ratio of the printer
  2070.  
  2071.     DevQueryCaps(hdcPrinter,CAPS_HORIZONTAL_RESOLUTION,1L,&lCapsHRes);
  2072.     DevQueryCaps(hdcPrinter,CAPS_VERTICAL_RESOLUTION,1L,&lCapsVRes);
  2073.  
  2074.     if ( (lCapsVRes == 0) || (lCapsHRes == 0) ) {
  2075.        fXAspectRatio = (float) 1;
  2076.        fYAspectRatio = (float) 1;
  2077.     }
  2078.     else {
  2079.        fXAspectRatio = (float) ((float) lCapsVRes / (float) lCapsHRes);
  2080.        fYAspectRatio = (float) ((float) lCapsHRes / (float) lCapsVRes);
  2081.     }
  2082.  
  2083.     // determine coordinates to print on printer
  2084.  
  2085.     rcl.xLeft =  pptp->page.sLeft * psizlChar->cx; // Printer left
  2086.  
  2087.     rcl.xRight = psizlPage->cx -
  2088.                  (pptp->page.sRight * psizlChar->cx); // Printer right
  2089.  
  2090.     rcl.yBottom = (pptp->page.sBottom + 1) * psizlChar->cy; // Printer bottom
  2091.  
  2092.     rcl.yTop = psizlPage->cy -
  2093.               ( (pptp->page.sTop + 1) * psizlChar->cy);     // Printer top
  2094.  
  2095.     cxScreen = (SHORT) WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
  2096.     cyScreen = (SHORT) WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
  2097.  
  2098.     ScaleToWindowSize ((SHORT) (rcl.xRight - rcl.xLeft),   // sXtarget
  2099.                        (SHORT) (rcl.yTop - rcl.yBottom),   // sYTarget
  2100.                        cxScreen,                           // sXSource
  2101.                        cyScreen,                           // sYSource
  2102.                        &fltScale) ;
  2103.  
  2104.     // Create a memory device context
  2105.     // Memory device contexts are used to contain bitmaps
  2106.  
  2107.     hdcPrinterMemory = DevOpenDC (habPrinter, OD_MEMORY, "*", 0L,
  2108.                                   NULL, hdcPrinter);
  2109.  
  2110.     if ( hdcPrinterMemory == DEV_ERROR ) return FALSE;
  2111.  
  2112.     sizl.cx = 0;
  2113.     sizl.cy = 0;
  2114.  
  2115.     // Create a presentation space and associate it the memory device context
  2116.  
  2117.     hpsPrinterMemory = GpiCreatePS (habPrinter, hdcPrinterMemory, &sizl,
  2118.                                     PU_PELS | GPIF_DEFAULT |
  2119.                                     GPIT_NORMAL | GPIA_ASSOC);
  2120.  
  2121.     if( ! hpsPrinterMemory) {
  2122.        DevCloseDC (hdcPrinterMemory);
  2123.        return FALSE;
  2124.     }
  2125.  
  2126.     GpiSetBitmap(hpsPrinterMemory,hbm);
  2127.  
  2128.     aptl [0].x = rcl.xRight - (long) ((float) cxScreen * fltScale);
  2129.     aptl [0].y = rcl.yTop - (long) ((float) cyScreen * fltScale *
  2130.                  fYAspectRatio);
  2131.     aptl [1].x = rcl.xRight;
  2132.     aptl [1].y = rcl.yTop;
  2133.     aptl [2].x = 0;
  2134.     aptl [2].y = 0;
  2135.     aptl [3].x = cxScreen;
  2136.     aptl [3].y = cyScreen;
  2137.  
  2138.     GpiBitBlt(hpsPrinter,hpsPrinterMemory,4L,aptl,ROP_SRCCOPY,BBO_IGNORE);
  2139.  
  2140.     GpiAssociate   (hpsPrinterMemory, NULL) ;
  2141.     GpiDestroyPS   (hpsPrinterMemory);
  2142.     DevCloseDC     (hdcPrinterMemory);
  2143.  
  2144.     // If a footer is defined, ...
  2145.  
  2146.     if (pptp->page.szFooter[0] != '\0')
  2147.     {
  2148.        // ... compute its position ...
  2149.  
  2150.        ptl.x = pptp->page.sLeft * psizlChar->cx ;
  2151.        ptl.y = pptp->page.sBottom * psizlChar->cy ;
  2152.  
  2153.        // ... and print it.
  2154.  
  2155.        PrintHeaderFooter (hpsPrinter, &ptl, pptp,
  2156.                           psizlPage, psizlChar,
  2157.                           pptp->page.szFooter,
  2158.                          sPage, PRINT_FOOTER) ;
  2159.    }
  2160.    return( TRUE);
  2161. }
  2162.  
  2163.  
  2164. ΓòÉΓòÉΓòÉ 8.2. Menus ΓòÉΓòÉΓòÉ
  2165.  
  2166. This section covers Presentation Manager menus. 
  2167.  
  2168.  
  2169. ΓòÉΓòÉΓòÉ 8.2.1. How do I add a menu to a dialog box? ΓòÉΓòÉΓòÉ
  2170.  
  2171. Do a WinLoadMenu and then WM_UPDATEFRAME. 
  2172.  
  2173.  
  2174. ΓòÉΓòÉΓòÉ 8.2.2. How do I make a dynamically changing menu? ΓòÉΓòÉΓòÉ
  2175.  
  2176. Create the menu with all the items that it will ever contain, then dynamically 
  2177. remove and insert the items as required. After loading menu, Query and maintain 
  2178. a copy of the menuitem(s) that will be removed. 
  2179.  
  2180.  // Obtain and keep a copy of the convert submenuitem
  2181.   if (!WinSendMsg (pwd->hwndAB, MM_QUERYITEM,
  2182.       MPFROM2SHORT (IDM_KanCnvMnu, TRUE), MPFROMP (&pwd->miCnvMnu))) {
  2183.  
  2184.   // And the convert submenu text
  2185.   if (!WinSendMsg (pwd->hwndAB, MM_QUERYITEMTEXT,
  2186.     MPFROM2SHORT (IDM_KanCnvMnu, sizeof (pwd->szCnvMnuTxt)),
  2187.                   MPFROMP (&pwd->szCnvMnuTxt)) ){
  2188.  
  2189. When menu is to updated, insert/remove as necessary 
  2190.  
  2191.     // This is layout, is the submenu already in place?
  2192.     if (!pwd->fCnvMenu) {
  2193.  
  2194.       // The submenu is not installed, so insert the submenu
  2195.       WinSendMsg (pwd->hwndAction, MM_INSERTITEM,
  2196.                   MPFROMP (&pwd->miCnvMnu), MPFROMP (pwd->szCnvMnuTxt));
  2197.  
  2198.       // And remove the convert menuitem
  2199.       WinSendMsg (pwd->hwndAB, MM_REMOVEITEM,
  2200.                   MPFROM2SHORT (IDM_KanCnv, TRUE), 0L);
  2201.  
  2202.       // Set the submenu flag
  2203.       pwd->fCnvMenu = TRUE;
  2204.     }
  2205.  
  2206. Credit:  Matthew S. Osborn 
  2207.  
  2208.  
  2209. ΓòÉΓòÉΓòÉ 8.2.3. How do I create a conditional cascade menu? ΓòÉΓòÉΓòÉ
  2210.  
  2211. The following works for me to set a submenu as a conditional-cascade menu, then 
  2212. set it's default id (hwndMenu is the hwnd of the top-level menu): 
  2213.  
  2214.    MENUITEM mi;
  2215.  
  2216.    WinSendMsg( hwndMenu, MM_QUERYITEM,
  2217.                MPFROM2SHORT( idSubMenu, TRUE ), &mi );
  2218.  
  2219.    // Set the MS_CONDITIONALCASCADE bit for the submenu.
  2220.  
  2221.    WinSetWindowBits( mi.hwndSubMenu, QWL_STYLE, MS_CONDITIONALCASCADE,
  2222.                      MS_CONDITIONALCASCADE );
  2223.  
  2224.    // Set cascade menu default
  2225.  
  2226.    WinSendMsg( mi.hwndSubMenu, MM_SETDEFAULTITEMID,
  2227.                MPFROMSHORT( idDefaultItem ), NULL );
  2228.  
  2229. Then I do this to query the default item: 
  2230.  
  2231.  MENUITEM mi;
  2232.  
  2233.  WinSendMsg( hwndMenu, MM_QUERYITEM, MPFROM2SHORT( idSubMenu, TRUE ),
  2234.              &mi );
  2235.  
  2236.  id = (USHORT) WinSendMsg( mi.hwndSubMenu,
  2237.                            MM_QUERYDEFAULTITEMID, NULL, NULL );
  2238.  
  2239. Credit:  Rick Fishman 
  2240.  
  2241.  
  2242. ΓòÉΓòÉΓòÉ 8.2.4. How do I remove a separator from a menu? ΓòÉΓòÉΓòÉ
  2243.  
  2244. Here are two methods of doing that.  The first is from the PMHINTS file, and 
  2245. the second is from Gpf.  PMHINTS takes the approach of removing SC_CLOSE and 
  2246. the nearby separator.  The Gpf solution takes the approach of deleting 
  2247. everything that it doesn't explicitly want.  I've extended it to, among other 
  2248. things, conditionally delete the "Window List" menu item as well. 
  2249.  
  2250. The deletion problems get messier in application menus when there are multiple 
  2251. separaters in different pull-downs.  That is when assigning the separators an 
  2252. id really pays off. 
  2253.  
  2254. Both examples are 16-bit OS/2 1.x code. 
  2255.  
  2256. PMHINTS: 
  2257.  
  2258.  VOID  DelClose(HWND hwnd)
  2259.  {
  2260.    HWND        hSysMenu,
  2261.                hSysSubMenu;
  2262.    MENUITEM    SysMenu;
  2263.    SHORT       idItem,
  2264.                idSep,
  2265.                idSysMenu;
  2266.  
  2267.    hSysMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT, FALSE),
  2268.                               FID_SYSMENU);
  2269.  
  2270.    idSysMenu = SHORT1FROMMR(WinSendMsg(hSysMenu, MM_ITEMIDFROMPOSITION,
  2271.                             NULL, NULL));
  2272.  
  2273.    WinSendMsg(hSysMenu, MM_QUERYITEM, MPFROM2SHORT(idSysMenu, FALSE),
  2274.               MPFROMP(&SysMenu));
  2275.  
  2276.    hSysSubMenu = SysMenu.hwndSubMenu;
  2277.  
  2278.    idItem = SHORT1FROMMR(WinSendMsg(hSysSubMenu, MM_ITEMPOSITIONFROMID,
  2279.                          MPFROM2SHORT(SC_CLOSE, FALSE), NULL));
  2280.    if (idItem != MIT_ERROR)
  2281.    {
  2282.      idSep = idItem + 1;  // Get separator ID
  2283.  
  2284.      idSep  = SHORT1FROMMR(WinSendMsg(hSysSubMenu, MM_ITEMIDFROMPOSITION,
  2285.                            MPFROMSHORT(idSep), NULL));
  2286.  
  2287.      WinSendMsg(hSysMenu, MM_DELETEITEM, MPFROM2SHORT(SC_CLOSE, TRUE),
  2288.                 MPFROMSHORT(NULL));
  2289.  
  2290.      WinSendMsg(hSysSubMenu, MM_DELETEITEM, MPFROM2SHORT(idSep, FALSE), NULL);
  2291.    }
  2292.  }
  2293.  
  2294. Derived from Gpf, adapted for a client, with some of my changes expurgated (so 
  2295. it won't compile as is): 
  2296.  
  2297.  /*****
  2298.   *
  2299.   *  UtilDlgSysMenu
  2300.   *
  2301.   *      Remove unavailable items from system menu of dialog box.
  2302.   *
  2303.   *  History:
  2304.   *      8/31/92  gts  Adapted from Gpf's GpfSetDialogBoxSysMenu
  2305.   *               with slight modifications.
  2306.   *
  2307.   *****/
  2308.  
  2309.  void _export UtilDlgSysMenu (          /* Remove unwanted system menu items */
  2310.  HWND hwndFrame)                      /* I - Handle to dialog window */
  2311.  {
  2312.     HWND     hwndSubMenu;             /* sys menu pull-down handle  */
  2313.     MENUITEM miTemp;                  /* menu item template         */
  2314.     SHORT    sItemId;                 /* system menu item ID        */
  2315.     SHORT    sItemIndex;              /* system menu item index     */
  2316.     MRESULT  mresult;
  2317.  
  2318.     /********************************************************************/
  2319.     /* Get the handle of the system menu pull-down.            */
  2320.     /********************************************************************/
  2321.     hwndSubMenu = WinWindowFromID( hwndFrame, FID_SYSMENU );
  2322.     WinSendMsg( hwndSubMenu,
  2323.                 MM_QUERYITEM,
  2324.                 MPFROM2SHORT( SC_SYSMENU, FALSE ),
  2325.                 MPFROMP( (PSZ)&miTemp ) );
  2326.     hwndSubMenu = miTemp.hwndSubMenu;
  2327.  
  2328.     /********************************************************************/
  2329.     /* Remove all items from the system menu pull-down that are no    */
  2330.     /* longer wanted.                            */
  2331.     /********************************************************************/
  2332.     mresult = WinSendMsg( hwndSubMenu,
  2333.                          MM_QUERYITEMCOUNT,
  2334.                          MPFROMSHORT(0),
  2335.                          MPFROMSHORT(0) );
  2336.     sItemIndex = SHORT1FROMMR(mresult);
  2337.     for (sItemId = 0; sItemIndex != -1; sItemIndex--)
  2338.     {
  2339.        mresult = WinSendMsg( hwndSubMenu,
  2340.                              MM_ITEMIDFROMPOSITION,
  2341.                              MPFROMSHORT(sItemIndex),
  2342.                              MPFROMSHORT(0) );
  2343.        sItemId = SHORT1FROMMR(mresult);
  2344.        if ( sItemId != MIT_ERROR
  2345.              &&sItemId != SC_MOVE
  2346.              &&sItemId != SC_CLOSE
  2347.              &&(sItemId != SC_TASKMANAGER
  2348.              || (flFlags & MAXONLY)) )   // <- application controls
  2349.        {
  2350.           WinSendMsg( hwndSubMenu,
  2351.                       MM_DELETEITEM,
  2352.                       MPFROM2SHORT(sItemId,FALSE),
  2353.                       MPFROMSHORT(0) );
  2354.        }
  2355.     }
  2356.  }
  2357.  
  2358. Credit:  Guy Scharf 
  2359.  
  2360.  
  2361. ΓòÉΓòÉΓòÉ 8.3. Container Controls ΓòÉΓòÉΓòÉ
  2362.  
  2363. This section covers Presentation Manager container controls. 
  2364.  
  2365.  
  2366. ΓòÉΓòÉΓòÉ 8.3.1. How do I stop a container from flashing every time I add a record? ΓòÉΓòÉΓòÉ
  2367.  
  2368. Disable/Enable the container window before and after the insertion/deletion. 
  2369.  
  2370.  
  2371. ΓòÉΓòÉΓòÉ 8.3.2. How do I get my containers to use Mini-icons? ΓòÉΓòÉΓòÉ
  2372.  
  2373. Here is some sample code that displays mini icons.  First, supply a missing 
  2374. #define: 
  2375.  
  2376.  #ifndef CCS_MINIICONS
  2377.      #define CCS_MINIICONS 0x0800
  2378.  #endif // not CCS_MINIICONS
  2379.  
  2380. Use CCS_MINIICONS as part of your container style (when you create the 
  2381. container).  Now, fill in the RECORDCORE structure pointed to by 'pRecordCore'; 
  2382. 'pUserRecord' also points to 'pRecordCore', which is part of a "user data" 
  2383. structure: 
  2384.  
  2385.  // Fill in fields of container record.
  2386.  #ifdef USE_MINIRECORDCORE
  2387.      pRecordCore->cb = sizeof (MINIRECORDCORE) ;
  2388.  #else
  2389.      pRecordCore->cb = sizeof (RECORDCORE) ;
  2390.  #endif // USE_MINIRECORDCORE
  2391.      pRecordCore->flRecordAttr = 0 ; // CRA_DROPONABLE ;
  2392.      // pRecordCore->ptlIcon is left to zeros.
  2393.      pRecordCore->pszIcon = pUserRecord->szName ;
  2394.      if (*DDirRecord.szIconName)
  2395.         LoadIcon (pUserRecord) ;
  2396.      // pRecordCore->hptrMiniIcon is left to zeros.
  2397.      // pRecordCore->hbmBitmap is left to zeros.
  2398.      // pRecordCore->hbmMiniBitmap is left to zeros.
  2399.      // pRecordCore->pTreeItemDesc is left to zeros.
  2400.  
  2401.  #ifndef USE_MINIRECORDCORE
  2402.      pRecordCore->pszText = pUserRecord->szName ;
  2403.      pRecordCore->pszName = pUserRecord->szName ;
  2404.      pRecordCore->pszTree = pUserRecord->szName ;
  2405.  #endif // not USE_MINIRECORDCORE
  2406.  
  2407. Now, if your user asks for mini-icons (via a popup menu, presumably), you send 
  2408. a CM_SETCNRINFO message to your container, after ORing in the CV_MINI style to 
  2409. CnrInfo.flWindowAttr, or removing it to restore full-size icons.  Hope this 
  2410. helps. 
  2411.  
  2412. Credit:  Wayne Kovsky 
  2413.  
  2414.  
  2415. ΓòÉΓòÉΓòÉ 8.3.3. How do I sort a container control? ΓòÉΓòÉΓòÉ
  2416.  
  2417. /*
  2418.  * Note that PSESSION is my own instance data structure.
  2419.  * I use it here to retrieve the type of field comparison I should do.
  2420.  */
  2421.  
  2422.  static SHORT APIENTRY Compare (PMINIRECORDCORE pmrc1,
  2423.                                 PMINIRECORDCORE pmrc2,
  2424.                                 PVOID pvStorage)
  2425.  {
  2426.     PSESSION pSession = (PSESSION) pvStorage ;
  2427.     PFIELDINFO pFieldInfo = pSession->pFieldInfoSort ;
  2428.     PPVOID pField1 = (PPVOID) ((PBYTE) pmrc1 +
  2429.        pFieldInfo->offStruct) ;
  2430.     PPVOID pField2 = (PPVOID) ((PBYTE) pmrc2 +
  2431.        pFieldInfo->offStruct) ;
  2432.     SHORT sResult = 0 ;
  2433.  
  2434.     if (pFieldInfo->flData & CFA_STRING) {
  2435.        sResult = strcmp ((PCHAR) *pField1, (PCHAR) *pField2) ;
  2436.     }
  2437.     else if (pFieldInfo->flData & CFA_ULONG) {
  2438.        if ((ULONG) *pField1 < (ULONG) *pField2)
  2439.           sResult = -1 ;
  2440.        else if ((ULONG) *pField1 > (ULONG) *pField2)
  2441.           sResult = 1 ;
  2442.        else
  2443.           sResult = 0 ;
  2444.     }
  2445.     else if (pFieldInfo->flData & CFA_DATE) {
  2446.        sResult = CompareDate ((PCDATE) (PVOID) pField1,
  2447.                               (PCDATE) (PVOID) pField2) ;
  2448.     }
  2449.     else if (pFieldInfo->flData & CFA_TIME) {
  2450.        sResult = CompareTime ((PCTIME) (PVOID) pField1,
  2451.                               (PCTIME) (PVOID) pField2) ;
  2452.     }
  2453.  
  2454.     // Any other data type gets treated as equal;
  2455.     // no sorting can be done. Now handle reverse sequence.
  2456.     if (pSession->fSortReverse && sResult)
  2457.        sResult = -sResult ;
  2458.     return sResult ;
  2459.  }
  2460.  
  2461. Here is how I invoke the sort: 
  2462.  
  2463.  // Send container a sort message.
  2464.  ulRC = LONGFROMMR (WinSendMsg (
  2465.                     pSession->hwndContainer,
  2466.                     CM_SORTRECORD,
  2467.                     MPFROMP (Compare), MPFROMP (pSession))) ;
  2468.  if (!ulRC) {
  2469.     // Report error.
  2470.  }
  2471.  
  2472. Credit:  Wayne Kovsky 
  2473.  
  2474.  
  2475. ΓòÉΓòÉΓòÉ 8.3.4. How do I query all records in a container - tree view? ΓòÉΓòÉΓòÉ
  2476.  
  2477. The following code works for querying all records in a tree structure but 
  2478.  
  2479.  USHORT usParentCmd = CMA_FIRST, usChildCmd;
  2480.  PUSERREC purParent = NULL, purChild;
  2481.  
  2482.  for( ; ; )
  2483.  {
  2484.     purParent = (PUSERREC) WinSendMsg( hwndCnr, CM_QUERYRECORD,
  2485.                                        MPFROMP( purParent ),
  2486.                                        MPFROM2SHORT( usParentCmd, CMA_ITEMORDER ) );
  2487.     if( !purParent )
  2488.        break;
  2489.  
  2490.     DoWhatever( purParent );
  2491.  
  2492.     usChildCmd = CMA_FIRSTCHILD;
  2493.     purChild = NULL;
  2494.     for( ; ; )
  2495.     {
  2496.        purChild = (PUSERREC) WinSendMsg( hwndCnr, CM_QUERYRECORD,
  2497.                                          MPFROMP( purChild ),
  2498.                                          MPFROM2SHORT( usChildCmd, CMA_ITEMORDER ));
  2499.        if( !purChild )
  2500.           break;
  2501.  
  2502.        DoWhatever( purChild );
  2503.        usChildCmd = CMA_NEXT;
  2504.     }
  2505.  
  2506.     usCmdParent = CMA_NEXT;
  2507.  }
  2508.  
  2509. Credit:  Rick Fishman 
  2510.  
  2511.  
  2512. ΓòÉΓòÉΓòÉ 8.4. I can't get different colors in text control windows ΓòÉΓòÉΓòÉ
  2513.  
  2514. I've finally got static text control windows (WS_STATIC, SS_TEXT) working with 
  2515. a different color pres. parameter set ! Thanks, Rick, Dan and Wayne. Code as 
  2516. follows: 
  2517.  
  2518.  RGB2 rgb2 ;   // RGB2 structure
  2519.  HWND hwnd ;   // window handle
  2520.  
  2521.  // Set RGB values for a SYSCLR_BACKGROUND (light gray) color
  2522.  rgb2.bred = 204 ;     // Found these in 'WinSetSysColors' API
  2523.  rgb2.bgreen = 204 ;
  2524.  rgb2.bblue = 204 ;
  2525.  rgb2.fcOptions = 0 ;
  2526.  // Set background color
  2527.  WinSetPresParam (hwnd, PP_BACKGROUNDCOLOR, (ULONG) sizeof (RGB2),
  2528.                   &rgb2) ;
  2529.  // Set RGB values for black
  2530.  rgb2.bred = 0 ;
  2531.  rgb2.bgreen = 0 ;
  2532.  rgb2.bblue = 0 ;
  2533.  rgb2.fcOptions = 0 ;
  2534.  // Set text foreground color
  2535.  WinSetPresParam (hwnd, PP_FOREGROUNDCOLOR, (ULONG) sizeof (RGB2),
  2536.                   &rgb2) ;
  2537.  // Set text border color (important for outline fonts)
  2538.  WinSetPresParam (hwnd, PP_BORDERCOLOR, (ULONG) sizeof (RGB2), &rgb2) ;
  2539.  
  2540. Three big caveats here: 
  2541.  
  2542.  1. The OS/2 internal code for static text control windows is *definitely* 
  2543.     using RGB colors, not index colors when it draws the text string. Thus, the 
  2544.     PP_*INDEX presentation parameter values will *not* work. 
  2545.  2. You *must* use a set of colors that are already loaded in the color table. 
  2546.     If the RGB color is not found, the background will be dithered affecting 
  2547.     the text appearance (washed out). If you are not sure the RGB color is 
  2548.     loaded do a GpiQueryNearestColor to get the nearest color. 
  2549.  3. You *must* use the RGB2 structure and *not* the RGB structure. This is 
  2550.     *NOT* documented, but it appears in general that all OS/2 2.0 APIs should 
  2551.     use RGB2 *instead* of RGB. 
  2552.  
  2553. Credit:  Bill Kenning 
  2554.  
  2555.  
  2556. ΓòÉΓòÉΓòÉ 8.5. How can I toggle my titlebar on and off? ΓòÉΓòÉΓòÉ
  2557.  
  2558. Basically, move frame window controls from being children of the frame to being 
  2559. children of the background HWND_OBJECT.  You can then reverse the process to 
  2560. bring them back into view.  Following function implements this code. 
  2561.  
  2562. /* --------------------------------------------------------------
  2563. -- Function:  ToggleFrame
  2564. --
  2565. -- Description:  Toggles frame control visible/invisible
  2566. --
  2567. -- Notes: Code stolen from someone who stole it from an MS sample
  2568. ----------------------------------------------------------------- */
  2569. void ToggleFrame(HWND hwndFrame) {
  2570.  
  2571.  if (! Hidden) {     /* hide contorls */
  2572.     hwndTitle = WinWindowFromID( hwndFrame, FID_TITLEBAR );
  2573.     hwndSys   = WinWindowFromID( hwndFrame, FID_SYSMENU );
  2574.         ... repeat for FID_MINMAX, etc ...
  2575.     WinSetParent(hwndTitle, HWND_OBJECT, FALSE );
  2576.     WinSetParent(hwndSys,   HWND_OBJECT, FALSE );
  2577.         ... repeat for FID_MINMAX, etc ...
  2578.  }
  2579.  else { /* restore controls */
  2580.     WinSetParent( hwndTitle, hwndFrame, FALSE );
  2581.     WinSetParent( hwndSys, hwndFrame, FALSE );
  2582.         ... basically reverse of above ...
  2583.  }
  2584.  WinSendMsg( hwndFrame, WM_UPDATEFRAME,
  2585.       (MPARAM)(FCF_TITLEBAR | FCF_SYSMENU | ...), NULL);
  2586.  SizeTheWindow( hwndFrame );
  2587.  Hidden = ! Hidden;
  2588.  return;
  2589. }
  2590.  
  2591. Credit:  Mike Thompson 
  2592.  
  2593.  
  2594. ΓòÉΓòÉΓòÉ 8.6. How can I get transparent regions in bitmaps? ΓòÉΓòÉΓòÉ
  2595.  
  2596. Currently, you can get the same effect with PM if you use the method used with 
  2597. icons: 
  2598.  
  2599.  1. Use a monochrome mask to prep the destination area. The mask would define 
  2600.     which areas would be transparent and which would show the bitmap. The bits 
  2601.     would be defined as 1=transparent,0=bitmap. You would blit the mask to the 
  2602.     destination using ROP_SRCAND. This would blacken out the area that would 
  2603.     display the non-transparent bits of the bitmap. 
  2604.  2. Now blit the bitmap to the destination using ROP_SRCPAINT. Note that the 
  2605.     "transparent" areas of the bitmap must have the color black (i.e. bits=0). 
  2606.     This ORs the bitmap onto the prep area. Viola - "transparent" bitmap. 
  2607.  
  2608. Credit:  John Webb 
  2609.  
  2610.  
  2611. ΓòÉΓòÉΓòÉ 8.7. How do I create a status bar at the bottom of my window? ΓòÉΓòÉΓòÉ
  2612.  
  2613. You need to intercept several frame messages: 
  2614.  
  2615. WM_CALCFRAMERECT to calculate the new location of the client.  You should send 
  2616. it to the frame superclass then modify the result.  This message is invoked 
  2617. during frame formatting and whenever WinCalcFrameRect is called against your 
  2618. frame window handle. 
  2619.  
  2620. WM_FRAMECTLCOUNT to tell the frame superclass the number of frame controls you 
  2621. expect to format.  If you're adding a status line as a child of the frame 
  2622. (below the client, I suspect), you would add 1 to the result returned by your 
  2623. frame superclass. 
  2624.  
  2625. WM_FORMATFRAME is where you actually position/size the frame controls. The 
  2626. message gives you an array of SWP's.  Call your frame superclass and modify the 
  2627. result (in your case, I would expect only FID_CLIENT and your status line). 
  2628.  
  2629. Sample follows... 
  2630.  
  2631.     /*
  2632.      * FYI, WinDefFrameProc is just a macro I defined to
  2633.      * call my superclass frame window procedure, ie,
  2634.      *    (*vpfnFrameWndProc) (h,m,p1,p2).
  2635.      *
  2636.      * This example splits the client area space 1/3
  2637.      * and 2/3 horizontally with the old client area
  2638.      * and a new sibling.
  2639.      */
  2640.  
  2641.     case WM_CALCFRAMERECT:
  2642.       mr = WinDefFrameProc(hwnd, msg, mp1, mp2);
  2643.  
  2644.       /*
  2645.        * Calculate the position of the client rectangle
  2646.        * Otherwise,  we'll see a lot of redraw when we move the
  2647.        * client during WM_FORMATFRAME.
  2648.        */
  2649.  
  2650.       if (mr && mp2)
  2651.       {
  2652.          prectl = (PRECTL) mp1;
  2653.          prectl->xLeft += ((prectl->xRight - prectl->xLeft) / 3);
  2654.       }
  2655.       break;
  2656.  
  2657.     case WM_FORMATFRAME:
  2658.       sCount = (SHORT) WinDefFrameProc(hwnd, msg, mp1, mp2);
  2659.  
  2660.       /*
  2661.        * Reformat the frame to move the client
  2662.        * over and make room for the his/her sibling.
  2663.        */
  2664.  
  2665.       pswp = (PSWP) mp1;
  2666.       pswpClient = pswp + sCount - 1;
  2667.       pswpNew = pswpClient + 1;
  2668.  
  2669.       *pswpNew = *pswpClient;
  2670.       swpClient = *pswpClient;
  2671.  
  2672.       pswpNew->hwnd = WinWindowFromID(hwnd, ID_SIBLING);
  2673.       pswpNew->cx = pswpClient->cx / 3;
  2674.  
  2675.       pswpClient->x = pswpNew->x + pswpNew->cx - 1;
  2676.       pswpClient->cx = swpClient.cx - pswpNew->cx + 1;
  2677.  
  2678.       sCount++;
  2679.       mr = MRFROMSHORT(sCount);
  2680.       break;
  2681.  
  2682.     case WM_QUERYFRAMECTLCOUNT:
  2683.       sCount = (SHORT) WinDefFrameProc(hwnd, msg, mp1, mp2);
  2684.       sCount++;
  2685.       mr = MRFROMSHORT(sCount);
  2686.       break;
  2687.  
  2688. Credit:  Dan Kehn 
  2689.  
  2690.  
  2691. ΓòÉΓòÉΓòÉ 8.8. How to have a frame/client and still have a std window? ΓòÉΓòÉΓòÉ
  2692.  
  2693.  FRAMECDATA fcdata;
  2694.  
  2695.  fcdata.cb          = sizeof( FRAMECDATA );
  2696.  fcdata.flCreateFlags = FCF_TASKLIST | FCF_MENU, etc.;
  2697.  fcdata.hmodResources = 0; // or the hmod of the DLL containing the resources
  2698.  fcdata.idResources   = ID_RESOURCES;  // ID of the resources, as usual
  2699.  
  2700.  hwndFrame = WinCreateWindow( HWND_DESKTOP, WC_FRAME, NULL, 0, 0, 0, 0, 0,
  2701.                               NULLHANDLE, HWND_TOP, ID_RESOURCES,
  2702.                               &fcdata, NULL);
  2703.  
  2704.  hwndClient = WinCreateWindow( hwndFrame, szClientClass, NULL, 0, 0, 0, 0, 0,
  2705.                                NULLHANDLE, HWND_TOP, FID_CLIENT, NULL, NULL );
  2706.  
  2707.  WinSetWindowPos( hwndFrame, HWND_TOP, x, y, cx, cy,
  2708.                   SWP_ZORDER | SWP_SIZE | SWP_MOVE |
  2709.                   SWP_SHOW | SWP_ACTIVATE );
  2710.  
  2711. If you want to then add new controls, like the system menu, you would do this: 
  2712.  
  2713.  fcdata.flCreateFlags = FCF_SYSMENU;
  2714.  WinCreateFrameControls( hwndFrame, &fcdata, NULL );
  2715.  WinSendMsg( hwndFrame, WM_UPDATEFRAME,
  2716.              MPFROMLONG( FCF_SYSMENU ), NULL );
  2717.  
  2718. The same thing applies to all the other controls like FCF_SIZEBORDER, 
  2719. FCF_TITLEBAR, FCF_HORZSCROLL, FCF_MINMAX, etc. You could also OR more than one 
  2720. together if you wanted to add more than one frame control in the same shot. On 
  2721. the titlebar, you need to also send this message: 
  2722.  
  2723.  WinSendMsg( WinWindowFromID( hwndFrame, FID_TITLEBAR ),
  2724.              TBM_SETHILITE, MPFROMSHORT( TRUE ), NULL );
  2725.  
  2726. If you want to delete frame controls, you would do this (assuming system menu): 
  2727.  
  2728.  WinDestroyWindow( WinWindowFromID( hwndFrame, FID_SYSMENU ) );
  2729.  WinSendMsg( hwndFrame, WM_UPDATEFRAME,
  2730.              MPFROMLONG( FCF_SYSMENU ), NULL );
  2731.  
  2732. Unfortunately this doesn't fit completely well with OOP, since the controls 
  2733. really are not themselves objects independent of the frame window. One of the 
  2734. problems here is that in order to make them independent objects, you need to 
  2735. know the internals of the frame window proc. For instance, you would think that 
  2736. the MIN and MAX are two WC_BUTTON controls, but they are really one menu with 
  2737. two bitmap menuitems (at least in 1.x they were). So if you were to do a 
  2738. WinCreateWindow for either, you'd have to know where to get the bitmaps, and 
  2739. hope that doesn't change. 
  2740.  
  2741. Similarly you'd have to be able to construct the system menu after creating a 
  2742. WC_MENU window. This isn't a tough feat, but if a later version of OS/2 adds a 
  2743. new menu item to the system menu, you'd have to become aware of it. 
  2744.  
  2745. The titlebar and the scrollbars aren't a problem since they have their own 
  2746. public window classes - WC_TITLEBAR and WC_SCROLLBAR respectively. You can, for 
  2747. instance, do a WinCreateWindow( ..., WC_SCROLLBAR,..., FID_HORZSCROLL, ..), 
  2748. then send the frame a WM_UPDATEFRAME message for FCF_HORZSCROLL and this would 
  2749. work. But there is no WC_SIZEBORDER so you couldn't use this method to add the 
  2750. sizing border later. So for the sizing border you need to use the method I 
  2751. first posted above. 
  2752.  
  2753. I spoke too soon about the sizing border. If you want to add or remove it from 
  2754. a frame window, you need to add or remove the FS_SIZEBORDER style from the 
  2755. frame, then send the frame an UPDATEFRAME message for FCF_SIZEBORDER. 
  2756.  
  2757. To change the style, here is a technique that John Webb just turned me on to. 
  2758. To add the style: 
  2759.  
  2760.  WinSetWindowBits( hwndFrame, QWL_STYLE, FS_SIZEBORDER, FS_SIZEBORDER );
  2761.  
  2762. To remove it: 
  2763.  
  2764.  WinSetWindowBits( hwndFrame QWL_STYLE, 0, FS_SIZEBORDER );
  2765.  
  2766. Also, if you want to add or remove just one of the MIN or the MAX, you 
  2767. basically need to get the window handle of the MINMAX menu, then do a 
  2768. MM_REMOVEITEM for the one you want to remove. I did this in 1.x but haven't yet 
  2769. in 2.0. 
  2770.  
  2771. Credit:  Rick Fishman 
  2772.  
  2773.  
  2774. ΓòÉΓòÉΓòÉ 8.9. How do I use printf() in a PM program? ΓòÉΓòÉΓòÉ
  2775.  
  2776. Use PMPRINTF, check your local BBS's, CIS, BIX or cdrom.com or redirect stdout 
  2777. and stderr to files. 
  2778.  
  2779.     // Redirect 'stderr'.
  2780.     (void) freopen ("stderr.txt", "w", stderr) ;
  2781.  
  2782.     // Redirect 'stdout'.
  2783.     (void) freopen ("stdout.txt", "w", stdout) ;
  2784.  
  2785.  
  2786. ΓòÉΓòÉΓòÉ 8.10. I have a SOM DLL. How do I register it? ΓòÉΓòÉΓòÉ
  2787.  
  2788. Here's an example I use for registering.  It checks if the DLL is valid before 
  2789. continuing: 
  2790.  
  2791. #define INCL_WPCLASS
  2792. #define INCL_WIN
  2793. #define INCL_DOS
  2794. #include <os2.h>
  2795. #include <string.h>
  2796. #include <stdio.h>
  2797.  
  2798. int main(int argc, char *argv[]) {
  2799.    HMQ hmq;
  2800.    HAB hab;
  2801.    CHAR szText[256];
  2802.    USHORT usResponse;
  2803.    CHAR szLoadError[128];
  2804.    HMODULE hmod;
  2805.    APIRET rc;
  2806.  
  2807.    if (argc != 3)
  2808.      return 0;
  2809.  
  2810.    hab = WinInitialize(0);
  2811.    hmq = WinCreateMsgQueue(hab, 0);
  2812.  
  2813.    WinDeregisterObjectClass(argv[1]);
  2814.  
  2815.    sprintf(szText, "Register %s DLL '%s'?", argv[1], argv[2]);
  2816.    usResponse = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szText,
  2817.       "Register WPS Class", 0, MB_YESNO | MB_MOVEABLE | MB_ICONQUESTION);
  2818.  
  2819.    if (usResponse != MBID_YES)
  2820.      return 0;
  2821.  
  2822.    rc = DosLoadModule(szLoadError, sizeof(szLoadError), argv[2], &hmod);
  2823.  
  2824.    if (rc != 0)
  2825.    {
  2826.      sprintf(szText, "Return code = %u, error module = '%s'.",
  2827.              rc, szLoadError);
  2828.      WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szText,
  2829.                    "DosLoadModule Failed", 0,
  2830.                    MB_ENTER | MB_MOVEABLE | MB_ERROR);
  2831.  
  2832.      return 0;
  2833.   }
  2834.  
  2835.  
  2836.   if (WinRegisterObjectClass(argv[1], argv[2]))
  2837.   {
  2838.     if (WinCreateObject(argv[1], argv[1], " ",
  2839.         "<WP_DESKTOP>", CO_REPLACEIFEXISTS))
  2840.       WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Created.",argv[1],
  2841.                     0, MB_ENTER | MB_MOVEABLE | MB_INFORMATION);
  2842.     else
  2843.     {
  2844.       DosFreeModule(hmod);
  2845.       WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Failed.",argv[1],
  2846.                     0,MB_ENTER | MB_MOVEABLE | MB_ERROR);
  2847.     }
  2848.   }
  2849.   else
  2850.   {
  2851.     DosFreeModule(hmod);
  2852.     WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Registration failed.",
  2853.                   argv[1], 0,MB_ENTER | MB_MOVEABLE | MB_ERROR);
  2854.   }
  2855.  
  2856.   return 0; }
  2857.  
  2858. FYI, when WPS registers your DLL with SOM, SOM checks if your DLL has a module 
  2859. entry point called SOMInitModule.  If it does, it is called (most use 
  2860. SOMInitModule for registering DLLs that have more than one class). Otherwise, 
  2861. it checks for YourClassNewClass, and tries to call it (where 'YourClass' is the 
  2862. parameter you specified on the WinRegisterObjectClass). SOM generates 
  2863. 'YourClassNewClass' in the .IH file; if you're still stuck, verify it is being 
  2864. called and that it doesn't fail (eg, because of version number check). 
  2865.  
  2866. I suggest registering with a full DLL filespec, eg, C:\MYSTUFF\MYCAR.DLL. Saves 
  2867. on the length of the LIBPATH. 
  2868.  
  2869. Credit:  Dan Kehn 
  2870.  
  2871.  
  2872. ΓòÉΓòÉΓòÉ 8.11. How do I save and restore my window size and position? ΓòÉΓòÉΓòÉ
  2873.  
  2874. Here is code I use to restore a saved window position, which includes checks to 
  2875. make sure the user hasn't saved a window position at one screen resolution and 
  2876. then restored it at a different screen resolution (which might cause the 
  2877. window's frame controls to be completely off the display -- we've all seen 
  2878. that, right???): 
  2879.  
  2880.  BOOL SetWindowPosition (const HAB hab, const HWND hwndFrame,
  2881.                          const SWP swpConfig)
  2882.  {
  2883.      SWP swp ;
  2884.      APIRET ulRC ;
  2885.  
  2886.      // Initialize the window positioning flags.
  2887.      swp.fl = SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW ;
  2888.  
  2889.      /* Check for saved user preferences for screen width/height in
  2890.       * config file.  Did user want to start maximized?
  2891.       */
  2892.      if (swpConfig.fl & SWP_MAXIMIZE)
  2893.      {
  2894.          // Get maximized frame window position and size.
  2895.          ulRC = WinGetMaxPosition (hwndFrame, &swp) ;
  2896.          if (!ulRC)
  2897.          {
  2898.              // Report error, and then ...
  2899.              return TRUE ;
  2900.          }
  2901.          swp.fl |= SWP_MAXIMIZE ;
  2902.      }
  2903.  
  2904.      // Did user want to start minimized?
  2905.      else if (swpConfig.fl & SWP_MINIMIZE)
  2906.      {
  2907.          // Get minimized frame window position and size.
  2908.          ulRC = WinGetMinPosition (hwndFrame, &swp, (PPOINTL) NULL) ;
  2909.          if (!ulRC)
  2910.          {
  2911.              // Report error, and then ...
  2912.              return TRUE ;
  2913.          }
  2914.          swp.fl |= SWP_MINIMIZE ;
  2915.      }
  2916.  
  2917.      // Did user have a saved starting position and size?
  2918.      else if (swpConfig.cy || swpConfig.cx || swpConfig.x || swpConfig.y)
  2919.      {
  2920.          LONG cxClientMax ;
  2921.          LONG cyClientMax ;
  2922.          LONG cyTitleBar ;
  2923.          LONG cxSizeBorder ;
  2924.          LONG cySizeBorder ;
  2925.  
  2926.          // Get maximum client window size.
  2927.          cxClientMax = WinQuerySysValue (HWND_DESKTOP, SV_CXFULLSCREEN) ;
  2928.          cyClientMax = WinQuerySysValue (HWND_DESKTOP, SV_CYFULLSCREEN) ;
  2929.          cyTitleBar = WinQuerySysValue (HWND_DESKTOP, SV_CYTITLEBAR) ;
  2930.          cxSizeBorder = WinQuerySysValue (HWND_DESKTOP, SV_CXSIZEBORDER) ;
  2931.          cySizeBorder = WinQuerySysValue (HWND_DESKTOP, SV_CYSIZEBORDER) ;
  2932.  
  2933.          // Maximum client window size excludes title bar.
  2934.          cyClientMax += cyTitleBar ;
  2935.  
  2936.          // Make sure x origin is within display boundaries.
  2937.          swp.x = swpConfig.x ;
  2938.          if (swp.x < -cxSizeBorder)
  2939.              swp.x = 0 ;
  2940.  
  2941.          // Make sure window isn't too wide, or negative value.
  2942.          swp.cx = swpConfig.cx ;
  2943.          if (swp.cx >= cxClientMax || swp.cx < 0)
  2944.          {
  2945.              swp.cx = cxClientMax ;
  2946.              swp.x = 0 ;
  2947.          }
  2948.  
  2949.           if ((swp.x + swp.cx) > (cxClientMax + cxSizeBorder))
  2950.              swp.x = cxClientMax + cxSizeBorder - swp.cx ;
  2951.  
  2952.          // Make sure y origin is within display boundaries.
  2953.          swp.y = swpConfig.y ;
  2954.          if (swp.y < -cySizeBorder)
  2955.              swp.y = 0 ;
  2956.  
  2957.          // Make sure window isn't too high, or negative value.
  2958.          swp.cy = swpConfig.cy ;
  2959.          if (swp.cy > cyClientMax || swp.cy < 0)
  2960.          {
  2961.              swp.cy = cyClientMax ;
  2962.              swp.y = 0 ;
  2963.          }
  2964.  
  2965.          if ((swp.y + swp.cy) > (cyClientMax + cySizeBorder))
  2966.              swp.y = cyClientMax + cySizeBorder - swp.cy ;
  2967.      }
  2968.  
  2969.      // No saved position -- move window to FCF_SHELLPOSITION location.
  2970.      else
  2971.      {
  2972.          // Get default window size and position.
  2973.          ulRC = WinQueryTaskSizePos (hab, 0, &swp) ;
  2974.          if (ulRC)
  2975.          {
  2976.              // Report error, and then ...
  2977.              return TRUE ;
  2978.          }
  2979.          swp.fl = SWP_ACTIVATE | SWP_MOVE | SWP_SIZE | SWP_SHOW ;
  2980.      }
  2981.  
  2982.      // Position and size this frame window.
  2983.      ulRC = WinSetWindowPos (hwndFrame, HWND_TOP,
  2984.        swp.x, swp.y, swp.cx, swp.cy, swp.fl) ;
  2985.      if (!ulRC)
  2986.      {
  2987.          // Report error, and then ...
  2988.          return TRUE ;
  2989.      }
  2990.  
  2991.      return FALSE ;
  2992.  }
  2993.  
  2994. Credit:  Wayne Kovsky 
  2995.  
  2996.  
  2997. ΓòÉΓòÉΓòÉ 8.12. How do you make a window float above all others? ΓòÉΓòÉΓòÉ
  2998.  
  2999. OK.  Here's a sample program showing floating windows (derived from dvipm). 
  3000. The advantages over the WM_TIMER approach [which was presented in v2.2 -ed] 
  3001. are: 
  3002.  
  3003. o there's no delay 
  3004. o repainting is minimized 
  3005. o avoids timing problems 
  3006. o the floating windows are not unconditionally moved to the very top (that is, 
  3007.   when moving the base window B (with floating window F) behind a window W, the 
  3008.   order of the windows is this: BFW, not BWF!) 
  3009.  
  3010. The excessive repainting caused by other solutions was quite annoying with 
  3011. dvipm as recomputing the dvipm status window is slow. 
  3012.  
  3013. Eberhard 
  3014.  
  3015. /* floatwin.c */
  3016.  
  3017. /* This program shows how to implement floating windows.  The source
  3018.    code works with both 16-bit and 32-bit C compilers.
  3019.  
  3020.    If the Z-order of the base window is changed, the floating window
  3021.    will be moved on top of the base window.
  3022.  
  3023.    Generalizing this approach to many windows floating on many windows
  3024.    (floating on many windows ...) is left as exercise. */
  3025.  
  3026. #define INCL_WIN
  3027. #define INCL_GPI
  3028. #include <os2.h>
  3029.  
  3030. /* Syntactic sugar for supporting both 16-bit and 32-bit compilers. */
  3031.  
  3032. #ifdef __32BIT__
  3033. #define MSG ULONG
  3034. #define FLAGS fl
  3035. #else
  3036. #define MSG USHORT
  3037. #define FLAGS fs
  3038. #endif
  3039. #ifndef NULLHANDLE
  3040. #define NULLHANDLE NULL
  3041. #endif
  3042.  
  3043. /* The original frame window procedure. */
  3044. static PFNWP pfOldBaseFrameProc = NULL;
  3045.  
  3046. /* The handle of the floating window. */
  3047. static HWND hwndFloat = NULLHANDLE;
  3048.  
  3049. /* This frame window procedure is used for subclassing base windows.
  3050.    When changing the Z-order of the frame window, the floating window
  3051.    is moved instead of the base window and the hwndInsertBehind field
  3052.    is modified to move the base window behind the floating window. */
  3053.  
  3054. MRESULT EXPENTRY
  3055. BaseFrameProc (HWND hwnd, MSG msg, MPARAM mp1, MPARAM mp2)
  3056. {
  3057.   PSWP pswp;
  3058.  
  3059.   switch (msg)
  3060.     {
  3061.     case WM_ADJUSTWINDOWPOS:
  3062.       pswp = PVOIDFROMMP (mp1);
  3063.       if ((pswp->FLAGS & SWP_ZORDER) && hwndFloat != NULLHANDLE
  3064.            && WinIsWindowVisible (hwndFloat))
  3065.         {
  3066.           WinSetWindowPos (hwndFloat, pswp->hwndInsertBehind,
  3067.                            0, 0, 0, 0, SWP_ZORDER);
  3068.           /* This is the trick! */
  3069.           pswp->hwndInsertBehind = hwndFloat;
  3070.         }
  3071.       break;
  3072.     }
  3073.   return pfOldBaseFrameProc (hwnd, msg, mp1, mp2);
  3074. }
  3075.  
  3076.  
  3077. /* Common client window procedure for base windows and floating
  3078.    windows.  Display TXT and use CLR for filling the background. */
  3079.  
  3080. MRESULT CommonClientWndProc (HWND hwnd, MSG msg, MPARAM mp1, MPARAM mp2,
  3081.                              PCH txt, COLOR clr)
  3082. {
  3083.   HPS hps;
  3084.   RECTL rcl;
  3085.  
  3086.   switch (msg)
  3087.     {
  3088.     case WM_PAINT:
  3089.       hps = WinBeginPaint (hwnd, 0L, 0L);
  3090.       WinQueryWindowRect (hwnd, &rcl);
  3091.       GpiSetColor (hps, CLR_DARKCYAN);
  3092.       GpiSetBackColor (hps, clr);
  3093.       WinDrawText (hps, -1, txt, &rcl, 0, 0,
  3094.                    DT_TEXTATTRS | DT_CENTER | DT_VCENTER | DT_ERASERECT);
  3095.       WinEndPaint (hps);
  3096.       return 0;
  3097.     }
  3098.   return WinDefWindowProc (hwnd, msg, mp1, mp2);
  3099. }
  3100.  
  3101.  
  3102. /* Client window procedure for floating windows. */
  3103.  
  3104. MRESULT EXPENTRY FloatClientWndProc (HWND hwnd, MSG msg, MPARAM mp1, MPARAM mp2)
  3105. {
  3106.   return CommonClientWndProc (hwnd, msg, mp1, mp2, "Floating Window", CLR_RED);
  3107. }
  3108.  
  3109. /* Client window procedure for base windows. */
  3110.  
  3111. MRESULT EXPENTRY BaseClientWndProc (HWND hwnd, MSG msg, MPARAM mp1, MPARAM mp2)
  3112. {
  3113.   return CommonClientWndProc (hwnd, msg, mp1, mp2, "Base Window", CLR_YELLOW);
  3114. }
  3115.  
  3116.  
  3117. /* Start here. */
  3118.  
  3119. int main (void)
  3120. {
  3121.   static char szBaseClientClass[] = "floatwin.base";
  3122.   static char szFloatClientClass[] = "floatwin.float";
  3123.   ULONG flFrameFlags;
  3124.   HAB hab;
  3125.   HMQ hmq;
  3126.   QMSG qmsg;
  3127.   HWND hwndBase;
  3128.  
  3129.   /* Initialize Presentation Manager. */
  3130.  
  3131.   hab = WinInitialize (0);
  3132.   hmq = WinCreateMsgQueue (hab, 0);
  3133.  
  3134.   /* Create client window classes. */
  3135.  
  3136.   WinRegisterClass (hab, szBaseClientClass, BaseClientWndProc,
  3137.                     CS_SIZEREDRAW, 0);
  3138.   WinRegisterClass (hab, szFloatClientClass, FloatClientWndProc,
  3139.                     CS_SIZEREDRAW, 0);
  3140.  
  3141.   /* Create the base window and the floating window.  Note: the
  3142.      windows are initially invisible. */
  3143.  
  3144.   flFrameFlags = (FCF_TITLEBAR      | FCF_SYSMENU |
  3145.                   FCF_SIZEBORDER    | FCF_MINMAX  |
  3146.                   FCF_TASKLIST);
  3147.  
  3148.   /* Create and subclass the base window. */
  3149.  
  3150.   hwndBase = WinCreateStdWindow (HWND_DESKTOP, 0,
  3151.                                  &flFrameFlags, szBaseClientClass,
  3152.                                  "floatwin - Base Window",
  3153.                                  0L, 0, 1, NULL);
  3154.   pfOldBaseFrameProc = WinSubclassWindow (hwndBase, BaseFrameProc);
  3155.  
  3156.   /* Create the floating window. */
  3157.  
  3158.   hwndFloat = WinCreateStdWindow (HWND_DESKTOP, 0,
  3159.                                   &flFrameFlags, szFloatClientClass,
  3160.                                   "floatwin - Floating Window",
  3161.                                   0L, 0, 1, NULL);
  3162.  
  3163.   /* Set the position, size and Z-order of the windows and make them
  3164.      visible.  It's important to use SWP_ZORDER for the base
  3165.      window. */
  3166.  
  3167.   WinSetWindowPos (hwndFloat, HWND_TOP, 10, 10, 300, 80,
  3168.                    SWP_SHOW | SWP_MOVE | SWP_SIZE | SWP_ZORDER);
  3169.   WinSetWindowPos (hwndBase, HWND_TOP, 100, 50, 300, 80,
  3170.                    SWP_SHOW | SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_ACTIVATE);
  3171.  
  3172.   /* The message loop. */
  3173.  
  3174.   while (WinGetMsg (hab, &qmsg, 0L, 0, 0))
  3175.     WinDispatchMsg (hab, &qmsg);
  3176.  
  3177.   /* Clean up. */
  3178.  
  3179.   WinDestroyWindow (hwndBase);
  3180.   WinDestroyWindow (hwndFloat);
  3181.   WinDestroyMsgQueue (hmq);
  3182.   WinTerminate (hab);
  3183.  
  3184.   return 0;
  3185. }
  3186.  
  3187.  
  3188. ΓòÉΓòÉΓòÉ 8.13. How to ensure the sizing's correct so the dlg "fits" in the notebook...? ΓòÉΓòÉΓòÉ
  3189.  
  3190. Override wpclsQuerySettingsPageSize (or some such verbage, I don't have docs at 
  3191. home).  I don't know if this API made it into the on-line docs, but it is 
  3192. definitely public (see \TOOLKT20\C\OS2H\WPOBJECT.H). There you are given the 
  3193. opportunity to adjust the size up to accomodate your dialog, if necessary. 
  3194.  
  3195. The PAGEINFO structure is used by the Settings page code to delay the loading 
  3196. of the dialog required for a page until the user turns to it for the first 
  3197. time.  It has the resource ID, module handle (which is incorrectly named in the 
  3198. structure, 'resid' or some nonsense, grr-r), dialog procedure, and pointer of 
  3199. your choice to receive on WM_INITDLG (most choose the object pointer, somSelf). 
  3200. When the user selects the notebook tab, WPS calls WinLoadDlg based on the 
  3201. parameters in PAGEINFO. 
  3202.  
  3203.  
  3204. ΓòÉΓòÉΓòÉ 8.14. How do I prevent Shutdown from stopping my app? ΓòÉΓòÉΓòÉ
  3205.  
  3206. In our application, the WM_CLOSE message processor determines the state of the 
  3207. application, issues all the "Are you sure?" questions, etc. If the close is to 
  3208. be continued, a WM_QUIT message is posted and a value of FALSE is returned. 
  3209. Otherwise a value of TRUE is returned. 
  3210.  
  3211. The window receiving the WMU_EndTask message handles it by posting a WM_CLOSE 
  3212. message to itself, and letting the WM_CLOSE processing handle it. The only 
  3213. reason it is not translated to a WM_CLOSE within the message loop is allow 
  3214. future use. This message requires no special handling. 
  3215.  
  3216. The window receiving the WMU_ShutDown message handles it by sending (not 
  3217. posting) a WM_CLOSE message to itself. If the WM_CLOSE message returns TRUE, 
  3218. then a WinCancelShutdown (hmq, FALSE) call is issued to cancel this instance of 
  3219. the shutdown. 
  3220.  
  3221. If you issue a WinCancelShutdown (hmq, TRUE), a WM_QUIT message will never be 
  3222. sent to your message queue, so will not have an opportunity to stop the 
  3223. shutdown.  This is intended for secondary message queues that do not have a 
  3224. message loop. 
  3225.  
  3226.   while (1) {
  3227.  
  3228.     HWND hwndClient;
  3229.  
  3230.     // Get next message from queue
  3231.     if (!WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0)) {
  3232.  
  3233.       // The WM_QUIT message has three sources:
  3234.       //   1. The task manager 'End task' pulldown
  3235.       //   2. System shutdown from desktop manager
  3236.       //   3. Posted by the application
  3237.  
  3238.       // This is a WM_QUIT message.  Check the window handle, if the
  3239.       // handle matches mp2, it is from switch list close
  3240.       if (qmsg.hwnd == HWNDFROMMP (qmsg.mp2)) {
  3241.  
  3242.         // This is from close on the task list, convert to our message
  3243.         qmsg.msg = WMU_EndTask;
  3244.  
  3245.         // Get the intended client's window handle
  3246.         if (!(hwndClient = WinWindowFromID (qmsg.hwnd, FID_CLIENT))) {
  3247.  
  3248.           // Failed to find client. No idea who this belongs to,
  3249.           // give it to default window for processing
  3250.           hwndClient = hwndDefault
  3251.         }
  3252.  
  3253.         // Otherwise, readdress the message to the appropriate client
  3254.         qmsg.hwnd = hwndClient;
  3255.  
  3256.         // We can use mp1 and mp2 for anything we want.
  3257.         // Currently, just clear both
  3258.         qmsg.mp1  = qmsg.mp2 = 0L;
  3259.  
  3260.       } else if (qmsg.hwnd == NULLHANDLE) {
  3261.  
  3262.         // This message is from shutdown,
  3263.         // Address it to default window for processing
  3264.         qmsg.hwnd = hwndDefault;
  3265.  
  3266.         // And set the message to our shutdown message,
  3267.         qmsg.msg = WMU_SysShutdown;
  3268.  
  3269.       } else {
  3270.  
  3271.         // If here, we posted the WM_QUIT message, so break out of
  3272.         // the message loop
  3273.         break;
  3274.       }
  3275.     }
  3276.  
  3277.     // This is not a WM_QUIT message, intercept all other
  3278.     // messages intended for the NULL window
  3279.     if (qmsg.hwnd == NULLHANDLE) {
  3280.  
  3281.       // Pass all NULL window messages to the NULL window handler
  3282.       NullMsg (qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2);
  3283.  
  3284.     } else {
  3285.  
  3286.       // This is not a WM_QUIT message, nor is it intended for the NULL
  3287.       // window.  Pass this message to the message filter hook for
  3288.       // processing.
  3289.       if (!WinCallMsgFilter (hab, (PQMSG) &qmsg, 0)) {
  3290.  
  3291.         // Filter hook has not cancelled the message, so dispatch
  3292.         // the message to the proper window
  3293.         WinDispatchMsg (hab, &qmsg);
  3294.       }
  3295.     }
  3296.   }
  3297.  
  3298. Credit:  Matt Osborn 
  3299.  
  3300.  
  3301. ΓòÉΓòÉΓòÉ 8.15. When I pass a structure to WinCreateWindow, sometimes it doesn't work! ΓòÉΓòÉΓòÉ
  3302.  
  3303. Put the size of the structure as the first word. 
  3304.  
  3305.  
  3306. ΓòÉΓòÉΓòÉ 8.16. How do I use type filtering in 2.0's open dlg? ΓòÉΓòÉΓòÉ
  3307.  
  3308. It's broken in 2.0GA, fixed in 2.0's service pak. 
  3309.  
  3310.  
  3311. ΓòÉΓòÉΓòÉ 8.17. When minimizing, my dialog box is overwriting my icon! ΓòÉΓòÉΓòÉ
  3312.  
  3313. In the WM_MINMAXFRAME message hide the offending control. 
  3314.  
  3315.     case WM_MINMAXFRAME:
  3316.       {
  3317.         PSWP pswp; /* pos change structure */
  3318.  
  3319.         /* hide list box when minimized so it doesn't overwrite icon */
  3320.         pswp = PVOIDFROMMP( mp1 );
  3321.         WinShowWindow(
  3322.           WinWindowFromID( hwnd, IDD_FILES ),
  3323.           !(pswp->fs & SWP_MINIMIZE)
  3324.         );
  3325.       }
  3326.       break;
  3327.  
  3328.  
  3329. ΓòÉΓòÉΓòÉ 8.18. How do I make a multi-column listbox? ΓòÉΓòÉΓòÉ
  3330.  
  3331. Use the container in details view.  If you just have to use a list box: 
  3332.  
  3333. Here is an extract from my dialog box procedure that produces a two-column list 
  3334. box. 
  3335.  
  3336. In this example there is only one list box, so I don't have to worry about 
  3337. which control is involved.  In this example, a blank is used to separate the 
  3338. first and second column.  You could use tabs or any other sort of separator 
  3339. character.  You could also draw anything you wanted in the list box item, 
  3340. including bit maps, colors, other fonts, etc. 
  3341.  
  3342. This is not a complete program, of course, but does show the details of 
  3343. handling a multi-column list box. 
  3344.  
  3345. /******************** Dialog Box Procedure ******************************/
  3346.  
  3347. MRESULT EXPENTRY SelectDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  3348. {
  3349.     HPS     hPS;                 /* Handle to the presentation space */
  3350.     FONTMETRICS FontMetrics;     /* Metrics of default font */
  3351.     CHAR    pszItemText[MAX_ITEM_TEXT_LENGTH];
  3352.     CHAR    *s;
  3353.     OWNERITEM FAR *poi;          /* Pointer to owner item structure */
  3354.     RECTL   rcl;                 /* Rectangle for writing */
  3355.     COLOR   clrForeGround;
  3356.     COLOR   clrBackGround;
  3357.  
  3358.     switch (msg)
  3359.         {
  3360.         case WM_INITDLG:   /* Initialize the list box */
  3361.  
  3362.             FillCfgListBox (hwnd);     /* Fill the list box */
  3363.  
  3364.             return (FALSE);
  3365.  
  3366.  
  3367.         case WM_MEASUREITEM:     /* Measure text height */
  3368.  
  3369.             hPS = WinGetPS (hwnd);     /* Get handle to presentation space */
  3370.             GpiQueryFontMetrics (hPS, (LONG) sizeof (FONTMETRICS),
  3371.                                  &FontMetrics);
  3372.             WinReleasePS (hPS);        /* Release the presentation space */
  3373.  
  3374.             return (FontMetrics.lMaxBaselineExt);
  3375.  
  3376.  
  3377.         case WM_DRAWITEM:      /* Draw a list box entry */
  3378.  
  3379.             poi = mp2;               /* Get address of owner item */
  3380.  
  3381.             if (poi->fsState == TRUE)  /* Is this cell to be highlighted? */
  3382.             {                          /* Yes, use highlight attributes */
  3383.                 clrForeGround = SYSCLR_HILITEFOREGROUND;
  3384.                 clrBackGround = SYSCLR_HILITEBACKGROUND;
  3385.             }
  3386.             else                       /* No, use normal attributes */
  3387.             {
  3388.                 clrForeGround = CLR_NEUTRAL;
  3389.                 clrBackGround = CLR_BACKGROUND;
  3390.             }
  3391.  
  3392.             WinSendMsg (poi->hwnd,     /* Get item text */
  3393.                         LM_QUERYITEMTEXT,
  3394.                         (MPARAM) MAKEULONG (poi->idItem,
  3395.                         MAX_ITEM_TEXT_LENGTH),
  3396.                         (MPARAM) pszItemText);
  3397.  
  3398.             rcl.xLeft    = poi->rclItem.xLeft;  /* Set co-ordinates */
  3399.             rcl.xRight    = poi->rclItem.xRight; /* of rectangle */
  3400.             rcl.yTop    = poi->rclItem.yTop;
  3401.             rcl.yBottom = poi->rclItem.yBottom;
  3402.  
  3403.             s = strchr (pszItemText, ' ');  /* Find first blank */
  3404.             if (s)
  3405.               *s = '\0';               /* Terminate first column here */
  3406.  
  3407.             WinDrawText (poi->hps,     /* Draw the first column */
  3408.                          -1,           /* Null-terminated string */
  3409.                          pszItemText,  /* File name is here */
  3410.                          &rcl,     /* Rectangle to draw in */
  3411.                          clrForeGround,/* Foreground color */
  3412.                          clrBackGround,/* Background color */
  3413.                          DT_LEFT | DT_VCENTER | DT_ERASERECT);
  3414.  
  3415.             if (s)               /* If there is a second column */
  3416.             {
  3417.               rcl.xLeft = 100;         /* It starts out here */
  3418.                                        /* Spacing calculations could be */
  3419.                                        /* much cleverer than this very */
  3420.                                        /* crude use of an absolute position */
  3421.                                        /* (which is not transportable */
  3422.                                        /* to different display types, as */
  3423.                                        /* between 8514 and VGA) */
  3424.                 s++;                   /* Point to beginning of text */
  3425.                 WinDrawText (poi->hps, /* Draw the second column */
  3426.                              -1,       /* Also a null-terminated string */
  3427.                              s,        /* File Description */
  3428.                              &rcl, /* Rectangle to draw in */
  3429.                              clrForeGround,  /* Colors are same as */
  3430.                              clrBackGround,  /* before */
  3431.                              DT_LEFT | DT_VCENTER);
  3432.             }
  3433.  
  3434.                 /* If fsState || fsStateOld and return TRUE, then */
  3435.                 /* control will invert the rectangle -- not what */
  3436.                 /* we want.  Tell control not do do anything like that! */
  3437.  
  3438.             poi->fsState = poi->fsStateOld = FALSE;
  3439.  
  3440.             return (TRUE); /* Say we did it */
  3441.  
  3442. ... case statements for rest of program ...
  3443.  
  3444. Credit:  Guy Scharf 
  3445.  
  3446.  
  3447. ΓòÉΓòÉΓòÉ 8.19. How do I create my own Master Help Index? ΓòÉΓòÉΓòÉ
  3448.  
  3449. I talked with the owner of the Master Index, and she said there is no problem 
  3450. with using a like index to view online documentation for your application. 
  3451. There are just a few catches: 
  3452.  
  3453.  1. The documentation must be compiled as an .HLP file and not an .INF file. 
  3454.     Note that this is the default for IPFC. 
  3455.  
  3456.  2. The tagged indexed entries must have the "global" attribute. For example: 
  3457.  
  3458.    :i1 global.giving examples 
  3459.  
  3460.    or: 
  3461.  
  3462.    :i1 id=examp global.giving examples 
  3463.  
  3464.  3. The Index executable is a WPS object, not a standalone application. You 
  3465.     will need to create your own copy of the object (instance) of class Mindex, 
  3466.     either by using a REXX script  (e.g. SysCreateObject()) or within your app 
  3467.     (e.g. WinCreateObject()). 
  3468.  
  3469.     For a REXX example: 
  3470.  
  3471.             CALL   SysCreateObject  "Mindex", "Title", "<WP_DESKTOP>",
  3472.                                     "INDEX=MYFILE;OBJECTID=<MY_INDEX>"
  3473.  
  3474.     where MYFILE can be an environmental variable set to the path or filespec 
  3475.     of your .HLP files, or it can be the actual filespec itself (e.g. 
  3476.     INDEX=c:\myapp\myfile.hlp ). Note too that files can be concatenated (e.g. 
  3477.     INDEX=c:\myapp\myfile.hlp+c:\yourapp\yourfile.hlp). 
  3478.  
  3479.  4. Objects of Mindex class CAN NOT be subclassed. There are no public methods 
  3480.     in this class and it must be used as is. 
  3481.  
  3482. Credit:  John Webb 
  3483.  
  3484.  
  3485. ΓòÉΓòÉΓòÉ 8.20. How do I change the font in an MLE? ΓòÉΓòÉΓòÉ
  3486.  
  3487. How do I change the font in an MLE?  WinSetPresParms doesn't work. 
  3488.  
  3489. This is a function I used in 1.x to set the font for an MLE (haven't ported it 
  3490. yet but it should be the same). I pass it the parent hwnd of the MLE, the MLE's 
  3491. id, a facename, a pointsize, the maximum height for an outline font, and 
  3492. fsSelection (FATTR_SEL_BOLD, etc). It first tries to match on pointsize and 
  3493. facename. If it can't it uses an outline font with the height requested. 
  3494.  
  3495.  VOID EXPENTRY UtlSetMleFont( HWND hwndParent, USHORT usMleId, PSZ szFacename,
  3496.                               USHORT usPointSize, LONG lMaxHeight,
  3497.                               USHORT fsSelection )
  3498.  {
  3499.      PFONTMETRICS pfm;
  3500.      HDC          hdc;
  3501.      HPS          hps;
  3502.      HWND         hwndMle;
  3503.      LONG         lHorzRes, lVertRes, lRequestFonts = 0, lNumberFonts;
  3504.      FATTRS       fat;
  3505.      SHORT        sOutlineIndex = -1;
  3506.      INT          i;
  3507.  
  3508.      (void) memset( &fat, 0, sizeof( FATTRS ) );
  3509.      fat.usRecordLength  = sizeof( FATTRS );
  3510.      fat.fsSelection     = fsSelection;
  3511.      strcpy( fat.szFacename, szFacename );
  3512.      hwndMle = WinWindowFromID( hwndParent, usMleId );
  3513.      hps = WinGetPS( hwndMle );
  3514.      hdc = GpiQueryDevice( hps );
  3515.      DevQueryCaps( hdc, CAPS_HORIZONTAL_FONT_RES, 1L, &lHorzRes );
  3516.      DevQueryCaps( hdc, CAPS_VERTICAL_FONT_RES,   1L, &lVertRes );
  3517.      lNumberFonts = GpiQueryFonts( hps, QF_PUBLIC, szFacename,
  3518.                                    &lRequestFonts, 0L, NULL);
  3519.      pfm = malloc( (SHORT) lNumberFonts * sizeof( FONTMETRICS ) );
  3520.      GpiQueryFonts( hps, QF_PUBLIC, szFacename,
  3521.                     &lNumberFonts, (LONG) sizeof( FONTMETRICS ), pfm );
  3522.      for( i = 0; i < (USHORT) lNumberFonts; i++ )
  3523.      {
  3524.          if( pfm[ i ].fsDefn & 1 )
  3525.          {
  3526.              sOutlineIndex = (SHORT) i;
  3527.              continue;
  3528.          }
  3529.  
  3530.          if (pfm[ i ].sXDeviceRes == (SHORT) lHorzRes &&
  3531.              pfm[ i ].sYDeviceRes == (SHORT) lVertRes &&
  3532.              pfm[ i ].sNominalPointSize == (SHORT) (usPointSize * 10) )
  3533.          {
  3534.              fat.lMatch          = pfm[ i ].lMatch;
  3535.              fat.lMaxBaselineExt = pfm[ i ].lMaxBaselineExt;
  3536.              fat.lAveCharWidth   = pfm[ i ].lAveCharWidth;
  3537.              break;
  3538.          }
  3539.      }
  3540.  
  3541.      if( i >= (USHORT) lNumberFonts )
  3542.          if( sOutlineIndex >= 0 )
  3543.              if( lMaxHeight )
  3544.              {
  3545.                  fat.fsFontUse = FATTR_FONTUSE_OUTLINE;
  3546.                  if( !(fat.usCodePage = pfm[ sOutlineIndex ].usCodePage) )
  3547.                      fat.usCodePage  = 850;
  3548.                  fat.lMaxBaselineExt = lMaxHeight;
  3549.                  WinSendMsg( hwndMle, MLM_SETFONT, MPFROMP( &fat ), 0 );
  3550.              }
  3551.      WinSendMsg( hwndMle, MLM_SETFONT, MPFROMP( &fat ), 0 );
  3552.      WinReleasePS( hps );
  3553.      free( pfm );
  3554.  }
  3555.  
  3556. Credit:  Rick Fishman 
  3557.  
  3558.  
  3559. ΓòÉΓòÉΓòÉ 8.21. Why can't I import files larger than 64KB into my MLE? ΓòÉΓòÉΓòÉ
  3560.  
  3561. A MLE can not import or export text in bigger chunks than 64K. The below code 
  3562. shows how to solve this. 
  3563.  
  3564. void Editor::impTxt(const char *filename)
  3565. {
  3566.   FILE *ptr;
  3567.   long dummy=-1;
  3568.   long result;
  3569.  
  3570.   ptr = fopen(filename,"rb");
  3571.   fseek(ptr,0,SEEK_END);
  3572.   unsigned long size = ftell(ptr);
  3573.  
  3574.   fseek(ptr,0,SEEK_SET);
  3575.   void *buf = malloc(0xF000);
  3576.  
  3577.   mle->sendEvent(MLM_SETIMPORTEXPORT, buf, (unsigned long)  0xF000);
  3578.  
  3579.   mle->sendEvent(MLM_FORMAT, MLFIE_CFTEXT, NULL);
  3580.  
  3581.   while (feof(ptr) == 0) {
  3582.     result = fread(buf, 1, 0xE000, ptr);
  3583.     mle->sendEvent(MLM_IMPORT, &dummy, result);
  3584.   }
  3585.   fclose(ptr);
  3586.   free(buf);
  3587. }
  3588.  
  3589. The same applies to export. If the MLE contains >64K text you have to export 
  3590. the text in chunks like this: 
  3591.  
  3592. void Editor:saveFile(void)
  3593. {
  3594.   IString filename;
  3595.   IEventData rc;
  3596.   IFileDialog:Settings settings;
  3597.  
  3598.   settings.setTitle("Save textfile");
  3599.   settings.setFileName(fname);
  3600.   settings.setOKButtonText("Save file");
  3601.   settings.setSaveAsDialog();
  3602.  
  3603.   IFileDialog file(desktopWindow(),this,settings,
  3604.                    IFileDialog:defaultStyle()
  3605.                    | IFileDialog:selectableListbox);
  3606.   if (file.pressedOK() == false)
  3607.     return ;
  3608.   filename = file.fileName();
  3609.   if (filename.size() == 0)
  3610.     return;
  3611.   mle->exportToFile(filename);
  3612.  
  3613.   void *buf = malloc(0xF000);
  3614.   long ppt=0;
  3615.  
  3616.   mle->sendEvent(MLM_SETIMPORTEXPORT, buf, (unsigned long)  0xF000);
  3617.  
  3618.   mle->sendEvent(MLM_FORMAT, MLFIE_NOTRANS, NULL);
  3619.   ofstream fil(filename);
  3620.  
  3621.   do
  3622.     {
  3623.       long amount = 0xE000;
  3624.       rc = mle->sendEvent(MLM_EXPORT, &ppt, &amount);
  3625.       fil.write((char *) buf, rc.asUnsignedLong());
  3626.     } while (rc.asUnsignedLong() > 0);
  3627. }
  3628.  
  3629. Credit: Ivar E. Hosteng 
  3630.  
  3631.  
  3632. ΓòÉΓòÉΓòÉ 8.22. How do I get PM screen size? ΓòÉΓòÉΓòÉ
  3633.  
  3634. By calling the function WinQuerySysValue() with the tags; SV_CYSCREEN and 
  3635. SV_CXSCREEN. One should always check screen size before creating windows in PM, 
  3636. and size to the right it width and height. PM does not guarantee that your 
  3637. window will be dimensioned right. Below is an example: 
  3638.  
  3639.         .
  3640.         .
  3641.         .
  3642.  
  3643.     lHeight = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN);
  3644.     lWidth  = WinQuerySysValue(HWND_DESKTOP,SV_CXSCREEN);
  3645.  
  3646.         .
  3647.         .
  3648.         .
  3649.  
  3650. With these values you size and position your window with WinSetWindowPos(). 
  3651.  
  3652. Credit: Andreas Almroth 
  3653.  
  3654.  
  3655. ΓòÉΓòÉΓòÉ 8.23. How do I attach Instance data to window created with WinCreateStdWindow? ΓòÉΓòÉΓòÉ
  3656.  
  3657. I always use the two call to WinCreateWindow() method,    instead of the 
  3658. WinCreateStdWindow() method,  because the latter does not allow you to set 
  3659. instance data before your winproc is called for the first time. 
  3660.  
  3661. Here's a cset/2 program (icc /Ss+ /W3 /Se /B"/pm:pm" foo.c): 
  3662.  
  3663.  #define INCL_PM
  3664.  #include <os2.h>
  3665.  
  3666.  typedef struct _mydata {
  3667.      HWND hwndFrame;
  3668.      HWND hwndClient;
  3669.      char whatever[100];
  3670.  }MYDATA;
  3671.  
  3672.  static MRESULT EXPENTRY WinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  3673.  {
  3674.      MYDATA *mine;
  3675.  
  3676.     mine = (MYDATA *)WinQueryWindowPtr(hwnd, 0);  // will be null for WM_CREATE
  3677.      switch(msg){
  3678.          case WM_CREATE:
  3679.              mine = (MYDATA *)mp1;
  3680.              WinSetWindowPtr(hwnd, 0, mine);
  3681.              break;
  3682.          case WM_ERASEBACKGROUND:
  3683.              return (MRESULT)TRUE;
  3684.          default:
  3685.             return WinDefWindowProc(hwnd, msg, mp1, mp2);
  3686.      }
  3687.      return 0;
  3688.  }
  3689.  
  3690.  void main(void)
  3691.  {
  3692.      HAB hab;
  3693.      HMQ hmq;
  3694.      QMSG qmsg;
  3695.      char *class = "foo";
  3696.      FRAMECDATA fcdata;  /* frame creation data */
  3697.      MYDATA mydat;
  3698.  
  3699.      hab = WinInitialize(0);
  3700.      hmq = WinCreateMsgQueue(hab, hmq);
  3701.  
  3702.      WinRegisterClass(hab, class, WinProc, 0, sizeof(MYDATA *));
  3703.  
  3704.      /* create frame window (WC_FRAME) */
  3705.      fcdata.cb = sizeof(FRAMECDATA);
  3706.      fcdata.flCreateFlags = FCF_TITLEBAR | FCF_SYSMENU |
  3707.                             FCF_SHELLPOSITION | FCF_TASKLIST |
  3708.                             FCF_SIZEBORDER | FCF_MINMAX ;
  3709.  
  3710.      fcdata.hmodResources = 0;
  3711.      fcdata.idResources   = 1;         /* resource id */
  3712.      mydat.hwndFrame = WinCreateWindow(HWND_DESKTOP, WC_FRAME, "Title",
  3713.                                        0, 0, 0, 0, 0,
  3714.                                        0,  /* no owner */
  3715.                                        HWND_TOP,fcdata.idResources,&fcdata,NULL);
  3716.  
  3717.      if(!mydat.hwndFrame)
  3718.          exit(3);
  3719.  
  3720.      /* WinProc() has not been called yet */
  3721.  
  3722.      /* Create Client window: */
  3723.      mydat.hwndClient = WinCreateWindow(mydat.hwndFrame, class, "text",
  3724.                          0, 0, 0, 0, 0,
  3725.                          mydat.hwndFrame,    /* frame is owner */
  3726.                          HWND_TOP, FID_CLIENT,
  3727.                          &mydat, /* passed as mp1 to wm_create */
  3728.                          NULL);
  3729.  
  3730.      WinShowWindow(mydat.hwndFrame, TRUE);
  3731.  
  3732.      while(WinGetMsg(hab, &qmsg, (HWND) NULL, 0, 0))
  3733.          WinDispatchMsg(hab, &qmsg);
  3734.  
  3735.  }
  3736.  
  3737. Credit:  Peter Fitzsimmons 
  3738.  
  3739.  
  3740. ΓòÉΓòÉΓòÉ 8.24. How do I get a list of fonts? ΓòÉΓòÉΓòÉ
  3741.  
  3742. Shown is code for For v1.3.  Petzold has had a nice series on fonts in PC MAG 
  3743. from about Nov 92-June 93. 
  3744.  
  3745. #define INCL_DEV
  3746. #define INCL_DOSMEMMGR
  3747. #define INCL_GPILCIDS
  3748. #define INCL_WINWINDOWMGR
  3749. #define INCL_WINLISTBOXES
  3750. #include <os2.h>
  3751. #include <stdio.h>
  3752.  
  3753. VOID EXPENTRY FntQueryList(hwnd)
  3754. HWND hwnd; // listbox handle
  3755.   {
  3756.   PFONTMETRICS pfm;
  3757.   HDC          hdc;
  3758.   HPS          hps;
  3759.   LONG         alDevInfo[2];
  3760.   LONG         lFonts;
  3761.   LONG         lFontCnt = 0L;
  3762.   CHAR         pch[64];
  3763.   SEL          sel;
  3764.   USHORT       i;
  3765.  
  3766.   hdc = WinOpenWindowDC(hwnd);
  3767.   DevQueryCaps(hdc, CAPS_HORIZONTAL_FONT_RES, 2L, alDevInfo);
  3768.   hps = WinGetPS(hwnd);
  3769.   lFonts = GpiQueryFonts(hps, QF_PUBLIC, (PSZ)0, &lFontCnt,
  3770.                          (LONG)sizeof(FONTMETRICS), (PFONTMETRICS)0 );
  3771.   DosAllocSeg((USHORT)lFonts * sizeof(FONTMETRICS), &sel, SEG_NONSHARED);
  3772.   pfm = (PFONTMETRICS)MAKEP(sel, 0);
  3773.   GpiQueryFonts(hps, QF_PUBLIC, (PSZ)0, &lFonts,
  3774.                 (LONG)sizeof(FONTMETRICS), pfm );
  3775.   for (i = 0; i < (USHORT)lFonts; i++) {
  3776.     if (!(pfm[i].fsDefn & FM_DEFN_OUTLINE)) {
  3777.       if ((pfm[i].sXDeviceRes == (SHORT)alDevInfo[0]) &&
  3778.           (pfm[i].sYDeviceRes == (SHORT)alDevInfo[1]) ) {
  3779.             sprintf(pch, "%2d.%s",
  3780.                     pfm[i].sNominalPointSize / 10,
  3781.                     pfm[i].szFacename );
  3782.         WinSendMsg(hwnd, LM_INSERTITEM,
  3783.                    MPFROMSHORT(LIT_END), MPFROMP(pch) );
  3784.         }
  3785.       }
  3786.     }
  3787.   DosFreeSeg(sel);
  3788.   WinReleasePS(hps);
  3789.   return;
  3790.   }
  3791.  
  3792.  
  3793. ΓòÉΓòÉΓòÉ 8.25. How do I create a folder in C and put my pgm in it? ΓòÉΓòÉΓòÉ
  3794.  
  3795. /* Create our folder on the desktop */
  3796.  
  3797. HOBJECT hFolder, hObject;
  3798.  
  3799. hFolder = WinCreateObject ("wpFolder", "My Folder",
  3800.                            "OBJECTID=<MY_FOLDER>", "<WP_DESKTOP>",
  3801.                            CO_REPLACEIFEXISTS);
  3802.  
  3803. /* Now, put our object into the folder. */
  3804.  
  3805. hObject = WinCreateObject ("wpProgram", "My Online Book",
  3806.                            "EXENAME=VIEW.EXE;PARAMETERS=MYBOOK.INF;\
  3807.                            OBJECTID=<MY_BOOK>", "<MY_FOLDER>",
  3808.                            CO_REPLACEIFEXISTS);
  3809.  
  3810. What that little code snippet does is create a folder called "My Folder"
  3811. on the desktop, and puts a program object for an online book in it.
  3812. Check out the documentation on the following functions for more
  3813. information:
  3814.  
  3815. WinCreateObject
  3816. wpSetup (for information on the setup string parameter to WinCreateObj)
  3817. WPFolder (for information on the setup strings of folders)
  3818. WPProgram programs etc.
  3819.  
  3820.  
  3821. ΓòÉΓòÉΓòÉ 8.26. How do I do it in REXX? ΓòÉΓòÉΓòÉ
  3822.  
  3823. You may have seen the Paradox 4.0 install script, which uses SysCreateObject to 
  3824. make a WPS object 
  3825.  
  3826. Hope they don't mind me posting a fragment of the script by: 
  3827.  
  3828. /* Rob Gordon  Borland International 6/8/92  */
  3829.  
  3830. title = "Paradox 4.0"
  3831. classname = 'WPProgram'
  3832. location = '<WP_DESKTOP>'
  3833. setup = 'PROGTYPE=WINDOWEDVDM;EXENAME='pdoxpath'paradox.exe;
  3834.   STARTUPDIR='pdoxpath';SET DPMI_DOS_API=ENABLED;
  3835.   SET DPMI_MEMORY_LIMIT=4;ICONFILE 'pdoxpath'pdoxos2.ico;'
  3836.  
  3837. BldObj:
  3838. call charout , 'Building : 'title
  3839. result = SysCreateObject(classname, title, location, setup)
  3840.  
  3841.  
  3842. ΓòÉΓòÉΓòÉ 8.27. How do I use the Font dialog (WinFontDlg)? ΓòÉΓòÉΓòÉ
  3843.  
  3844. FIRST:  make your stack huge (>32K)  It is sparsely allocated and you only use 
  3845. what you need. Here's some code: 
  3846.  
  3847.  FONTDLG fontdlg ;
  3848.  FONTMETRICS fm ;
  3849.  CHAR            szBuf [200] ;
  3850.  CHAR            szFamily [CCHMAXPATH] ;
  3851.  static CHAR     szTitle [] = "Fonts Dialog" ;
  3852.  static CHAR     szMsgBoxTitle [] = "Result from 'WinFontDlg ()'" ;
  3853.  static CHAR     szPreview [] = "We hold these truths to be self-evident ..." ;
  3854.  
  3855.  // Here, get an HPS and then do a WinQueryFontMetrics.
  3856.  // Continuing ...
  3857.  
  3858.  memset ((void *) &fontdlg, 0, sizeof (FONTDLG)) ;
  3859.  fontdlg.cbSize = sizeof (FONTDLG) ;
  3860.  fontdlg.hpsScreen = WinGetScreenPS (HWND_DESKTOP) ;
  3861.  fontdlg.hpsPrinter = NULLHANDLE ;
  3862.  fontdlg.pszTitle = szTitle ;
  3863.  fontdlg.pszPreview = szPreview ;
  3864.  fontdlg.pfnDlgProc = NULL ;
  3865.  strcpy (szFamily, fm.szFamilyname) ;
  3866.  fontdlg.pszFamilyname = szFamily ;
  3867.  fontdlg.usFamilyBufLen = sizeof (szFamily) ;
  3868.  fontdlg.fxPointSize = MAKEFIXED (fm.sNominalPointSize / 10, 0) ;
  3869.  fontdlg.fl = FNTS_CENTER | FNTS_HELPBUTTON |
  3870.      FNTS_INITFROMFATTRS | FNTS_NOSYNTHESIZEDFONTS |
  3871.      FNTS_RESETBUTTON ;
  3872.  fontdlg.sNominalPointSize = fm.sNominalPointSize ;
  3873.  fontdlg.flType = (LONG) fm.fsType ;
  3874.  fontdlg.clrFore = CLR_NEUTRAL ;
  3875.  fontdlg.clrBack = CLR_BACKGROUND ;
  3876.  fontdlg.usWeight = fm.usWeightClass ;
  3877.  fontdlg.usWidth = fm.usWidthClass ;
  3878.  
  3879.  hwndDlg = WinFontDlg (HWND_DESKTOP, hwnd, &fontdlg) ;
  3880.  
  3881. Credit: Wayne Kovsky 
  3882.  
  3883.  
  3884. ΓòÉΓòÉΓòÉ 8.28. How do I take control of frame sizing? ΓòÉΓòÉΓòÉ
  3885.  
  3886. I want to "subclass" the Window Frame Class to allow me to control the size of 
  3887. my main window when it's resized by the mouse. I want to control the steps it 
  3888. take to resize too, (ie: by 8x8 steps). 
  3889.  
  3890. --- CUT --- CUT ---- .H file --- CUT --- 
  3891.  
  3892. HWND APIENTRY WinCreateMBWindow(
  3893.  
  3894.   HWND hwndParent,
  3895.   ULONG flStyle,
  3896.   PULONG pflCreateFlags,
  3897.   PSZ pszClientClass,
  3898.   PSZ pszTitle,
  3899.   ULONG styleClient,
  3900.   HMODULE hmod,
  3901.   USHORT idResources,
  3902.   PHWND phwndClient);
  3903.  
  3904.  
  3905. #define HMODFROMMP(mp) ((USHORT)(ULONG)(mp))
  3906.  
  3907. #define MB_CHILD_SIZE  WM_USER+204
  3908.           //Sent from child to frame indicating the new
  3909.           //requested size of the child area.  (high&width in MP1)
  3910.           //If ChildMax is shrinking below current size,
  3911.           // frame is redused, and evt scroll bars is hidden.
  3912.           //If Child is growing
  3913.           //   MP2=True -> grows frame to contain maximized child
  3914.           //   MP2=False-> enables scroll bars, keeps size.
  3915.  
  3916. #define MB_FIX_N       0x1 //Fix north border when sizing
  3917. #define MB_FIX_E       0x2 //Fix east  border when sizing
  3918.  
  3919. #define MB_FIX_NE       0x3 //Fix north east corner when sizing
  3920. #define MB_FIX_SE       0x2 //Fix south east corner when sizing
  3921. #define MB_FIX_NW       0x1 //Fix north west corner when sizing
  3922. #define MB_FIX_SW       0x0 //Fix south west corner when sizing
  3923.  
  3924. #define MB_QCHILD_SIZE_MAX     WM_USER+205
  3925.            //Sent from frame to child to queryw
  3926.            //max size of the child area.  (h&w in MR)
  3927.            //Used when sizing to determin if scroll bars are ness.
  3928.  
  3929. #define MB_QCHILD_GRID     WM_USER+206
  3930.            //Sent from frame to child before tracking
  3931.            //Child supposed to return x&y granularity in MR
  3932.  
  3933. #define MB_CREATE          WM_USER+207  //Internally shipped command.
  3934.  
  3935. typedef struct _FRM_DTA { /* Fram data */
  3936.     PFNWP    oldProc;
  3937.     SHORT    nTrkCnr,nYSclHor,nXSclVer,nTitle;
  3938.     SHORT    xMax,yMax;    //Max size of Client in PIX
  3939.     SHORT    ScrMaxX,ScrMaxY;
  3940.     POINTL   ptlBdr;
  3941.     HWND     hVert,hHori;
  3942.     SHORT    xCur,yCur;    //Current size of Client in PIX
  3943.     SHORT    nCorner;      //Which corner is to be stable
  3944. } FRM_DTA;
  3945. typedef FRM_DTA FAR * PFRM_DTA;
  3946.  
  3947. --- CUT --- CUT --- .C file --- CUT --- CUT --- 
  3948.  
  3949. HWND    APIENTRY WinCreateMBWindow(HWND hParent, ULONG flStyle,
  3950.                                    PULONG pflCreate, PSZ pszClientClass,
  3951.                                    PSZ pszTitle, ULONG styleClient,
  3952.                                    HMODULE hmod,
  3953.                                    USHORT idResources, PHWND phClient)
  3954. {
  3955.   HWND         hFrame;
  3956.   PFRM_DTA     pFrm;
  3957.  
  3958.   hFrame = WinCreateStdWindow(hParent,flStyle,pflCreate,pszClientClass,
  3959.                               pszTitle,styleClient,hmod,idResources,phClient);
  3960.  
  3961.   //Allocate some storage for local parameters, and initialize it
  3962.   pFrm=malloc(sizeof( FRM_DTA));
  3963.   memset(pFrm,0,sizeof( FRM_DTA));
  3964.  
  3965.   WinSetWindowPtr(hFrame,QWL_USER,(PVOID) pFrm);
  3966.  
  3967.   pFrm->oldProc= WinSubclassWindow(hFrame,newFrameProc);
  3968.  
  3969.   //Now window is setup:
  3970.  
  3971.   WinSendMsg(hFrame,MB_CREATE,MP0,MP0);    //My own WM_CREATE
  3972.  
  3973.   WinShowWindow(hFrame,TRUE);
  3974.  
  3975.   WinUpdateWindow(hFrame);
  3976.   return hFrame;
  3977. }
  3978.  
  3979. VOID GetChildMax(HWND hFrame, PFRM_DTA    pFrm)
  3980. { MRESULT mr;
  3981.   mr = WinSendMsg(WinWindowFromID(hFrame,FID_CLIENT),
  3982.                   MB_QCHILD_SIZE_MAX,MP0,MP0);
  3983.   pFrm->xMax=SHORT1FROMMR(mr);
  3984.   pFrm->yMax=SHORT2FROMMR(mr);
  3985. }
  3986.  
  3987. #define CLIENT_PROVIDED  FALSE
  3988. #define FRAME_PROVIDED     TRUE
  3989.  
  3990. BOOL WinCalcFrameSWP(HWND hwnd, PSWP pSWP, BOOL bFrame)
  3991. { //    TRUE       Frame rectangle provided
  3992.   //    FALSE      Client-area rectangle provided.
  3993.   RECTL rcl;
  3994.   BOOL bSuccess;
  3995.  
  3996.   rcl.xLeft   = pSWP->x;
  3997.   rcl.yBottom = pSWP->y;
  3998.   rcl.xRight  = pSWP->x+pSWP->cx;
  3999.   rcl.yTop    = pSWP->y+pSWP->cy;
  4000.  
  4001.   bSuccess = WinCalcFrameRect(hwnd, &rcl, bFrame );
  4002.  
  4003.   pSWP->x  =(SHORT) rcl.xLeft;
  4004.   pSWP->y  =(SHORT) rcl.yBottom;
  4005.   pSWP->cx =(SHORT) (rcl.xRight-rcl.xLeft);
  4006.   pSWP->cy =(SHORT) (rcl.yTop  -rcl.yBottom);
  4007.  
  4008.   return(bSuccess);
  4009. }
  4010.  
  4011.  
  4012. VOID SclBarEnable(HWND hwnd, PSWP pSWP, PFRM_DTA  pFrm)
  4013. {
  4014.  
  4015.   .....
  4016.  
  4017.  Your routines to determine and en/disable scroll bars 
  4018.  
  4019.   .....
  4020. /*    Part of my code */
  4021.   swpClient = *(pSWP);
  4022.   WinCalcFrameSWP(hwnd, &swpClient, FRAME_PROVIDED);
  4023.   if (swpClient.cx >= pFrm->xMax-1)
  4024.   { //Turn off horisontal scroll bar
  4025.     WinSetParent(pFrm->hHori,HWND_OBJECT ,FALSE);
  4026.     nUpdt = FCF_HORZSCROLL;
  4027.   }  /* code for enabling left out..... */
  4028.  
  4029.   if (nUpdt != 0)
  4030.   {
  4031.     WinSendMsg (hwnd, WM_UPDATEFRAME, MPFROMSHORT(nUpdt), MP0);
  4032.   }
  4033. */
  4034. }
  4035.  
  4036. /***************** Start of frame subclass procedure *****************/
  4037.  
  4038. MRESULT  EXPENTRY newFrameProc( HWND hwnd, USHORT msg,
  4039. MPARAM mp1, MPARAM mp2 )
  4040.  
  4041. { PSWP        pSWP;
  4042.   PFNWP     oldProc;
  4043.   PFRM_DTA  pFrm;
  4044.  
  4045.   pFrm=(PFRM_DTA)WinQueryWindowPtr(hwnd,QWL_USER);
  4046.   oldProc=pFrm->oldProc;
  4047.  
  4048.   switch(msg)
  4049.   {
  4050.     case MB_CREATE:
  4051.       //Start hiding scroll bars
  4052.       pFrm->hVert  = WinWindowFromID(hwnd,FID_VERTSCROLL);
  4053.       WinSetParent(pFrm->hVert,HWND_OBJECT ,FALSE);
  4054.       pFrm->nYSclHor = 0;
  4055.     break;
  4056.  
  4057.     case WM_MINMAXFRAME:
  4058.     { SWP swpClient;
  4059.       pSWP=(PSWP) PVOIDFROMMP(mp1);
  4060.       pSWP->fs |= SWP_SIZE;
  4061.  
  4062.       GetChildMax(hwnd, pFrm);
  4063.  
  4064.       if (pSWP->fs & SWP_MAXIMIZE) //MaxiMizeing Operation
  4065.       {
  4066.         //tprintf("WM_MINMAXFRAME SWP_MAXIMIZE FS: %X┬á",pSWP->fs);
  4067.         if ((0!=pFrm->xMax) && (0!=pFrm->yMax))
  4068.         { //I have no data for all of screen, so act as Windowed OS/2
  4069.  
  4070.           memset(&swpClient,0,sizeof(swpClient));
  4071.           swpClient.cx=pFrm->xMax;
  4072.           swpClient.cy=pFrm->yMax;
  4073.           WinCalcFrameSWP(hwnd, &swpClient,CLIENT_PROVIDED);
  4074.  
  4075.           pSWP->cx = swpClient.cx;
  4076.           pSWP->cy = swpClient.cy;
  4077.  
  4078.           pSWP->y  = pFrm->ScrMaxY - swpClient.cy + (SHORT)pFrm->ptlBdr.y;
  4079.  
  4080.  
  4081.           SclBarEnable(hwnd, pSWP, pFrm);
  4082.  
  4083.           return MRFROMSHORT(FALSE);
  4084.         }
  4085.       }
  4086.  
  4087.       if (pSWP->fs & SWP_RESTORE) //MiniMizeing Operation
  4088.  
  4089. ??? (restore i guess) 
  4090.  
  4091.       {
  4092.         //tprintf("WM_MINMAXFRAME SWP_RESTORE FS: %X┬á",pSWP->fs);
  4093.         if ((0!=pFrm->xMax) && (0!=pFrm->yMax))  //Why do I need this?
  4094.         {
  4095.           return MRFROMSHORT(FALSE);
  4096.         }
  4097.       }
  4098.     }
  4099.     return (MRESULT)(*oldProc)(hwnd, msg, mp1, mp2);
  4100.  
  4101.  
  4102.     case WM_QUERYTRACKINFO:
  4103.     {
  4104.       PTRACKINFO pTI;
  4105.       LONG i;
  4106.  
  4107.       if (TF_MOVE <= SHORT1FROMMP(mp1))
  4108.       {
  4109.         pFrm->nTrkCnr= 0;
  4110.         return (MRESULT)(*oldProc)(hwnd, msg, mp1, mp2);
  4111.       }
  4112.  
  4113.       pTI = (PTRACKINFO) PVOIDFROMMP (mp2);  //Get structure pointer;
  4114.       //tprintf("@+WM_QUERYTRACKINFO FS: %X┬á",pTI->fs);
  4115.       if ((*oldProc)(hwnd, msg, mp1, mp2)==0) return MRFROMSHORT(FALSE);
  4116.  
  4117.       GetChildMax(hwnd, pFrm);
  4118.       if ((0!=pFrm->xMax) && (0!=pFrm->yMax))
  4119.       { //Setup track info structure
  4120.         pTI->ptlMaxTrackSize.x = (LONG) pFrm->xMax;
  4121.         pTI->ptlMaxTrackSize.y = (LONG) pFrm->yMax;
  4122.  
  4123.         WinCalcFrameRect(hwnd, &(pTI->rclTrack), FRAME_PROVIDED );
  4124.  
  4125.         { MRESULT mr;
  4126.           mr = WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),
  4127.                           MB_QCHILD_GRID,MP0,MP0);
  4128.           if (NULL!=mr)
  4129.           {
  4130.             pTI->cxGrid  = SHORT1FROMMR(mr);
  4131.             pTI->cyGrid  = SHORT2FROMMR(mr);
  4132.  
  4133.             //Setting height of client to integral cyGrid
  4134.             i = (pTI->rclTrack.yTop - pTI->rclTrack.yBottom)/pTI->cyGrid;
  4135.             pTI->rclTrack.yTop = i * pTI->cyGrid + pTI->rclTrack.yBottom;
  4136.  
  4137.             pTI->fs    |= TF_GRID;
  4138.             pFrm->nTrkCnr= WM_QUERYTRACKINFO;
  4139.             //Used in WM_ADJUSTWINODWPOS
  4140.           }
  4141.         }
  4142.       }
  4143.       return MRFROMSHORT(TRUE);
  4144.     }
  4145.     break;
  4146.  
  4147.     case WM_ADJUSTWINDOWPOS:
  4148.     { RECTL rcl;
  4149.       pSWP=(PSWP) PVOIDFROMMP(mp1);
  4150.  
  4151.       if (pSWP->fs & (SWP_SIZE | SWP_MOVE | SWP_MAXIMIZE))
  4152.       {
  4153.         GetChildMax(hwnd, pFrm);
  4154.         if (WM_QUERYTRACKINFO==pFrm->nTrkCnr)
  4155.           //As a result of tracking
  4156.         {
  4157.           //Go from client to frame values
  4158.           WinCalcFrameSWP(hwnd, pSWP, CLIENT_PROVIDED);
  4159.         }
  4160.  
  4161.         pFrm->nTrkCnr     = 0;
  4162.  
  4163.         SclBarEnable(hwnd, pSWP, pFrm);
  4164.       }
  4165.       return (MRESULT)(*oldProc)(hwnd, msg, mp1, mp2);
  4166.     }
  4167.     break;
  4168.  
  4169.     case MB_CHILD_SIZE:      //xCur,yCur
  4170.     { SWP swp;
  4171.  
  4172. ............. do your actions as responce to client resize request (Change of 
  4173. fontsize for instance) 
  4174.  
  4175.  
  4176.       return (MRESULT)TRUE;
  4177.     }
  4178.     break;
  4179.  
  4180.     default:
  4181.     break;
  4182.   }
  4183.   return (MRESULT)(*oldProc)(hwnd, msg, mp1, mp2);
  4184. }
  4185.  
  4186. A lot is deleted (Som is very application specific), but i hope you get the 
  4187. general picture. 
  4188.  
  4189. Credit:  Henrik Wahlberg 
  4190.  
  4191.  
  4192. ΓòÉΓòÉΓòÉ 8.29. How do I use the 16-bit EPM toolkit? ΓòÉΓòÉΓòÉ
  4193.  
  4194. Since there were a few requests, here are the changes I made to get the ESIMPLE 
  4195. example from the EPM Toolkit to work with the C-Set++ compiler. The ETK DLLs 
  4196. are 16-bit and need to be thunked to be called from a 32-bit app. Since I was 
  4197. playing around, some of the changes were not necessary to get the program to 
  4198. run.  Changes are in DIFF format. 
  4199.  
  4200. **** Changes to EDLL.H ****
  4201. 254a255
  4202. > #pragma pack(2)
  4203. 259,263c260,264
  4204. <    PSWP   pswp;         // positioning of edit window
  4205. <    PSZ    filename;     // file to be edited (with wildcard)
  4206. <    PVOID  hEditPtr;     // handle to editor pointer icon.
  4207. <    PVOID  hMarkPtr;     // handle to mark pointer icon.
  4208. <    PVOID  hEditorIcon;  // editor ICON.
  4209. >    PSWP _Seg16   pswp;         // positioning of edit window
  4210. >    PSZ _Seg16    filename;     // file to be edited (with wildcard)
  4211. >    HPOINTER  hEditPtr;  // handle to editor pointer icon.
  4212. >    HPOINTER  hMarkPtr;  // handle to mark pointer icon.
  4213. >    PVOID _Seg16  hEditorIcon;  // editor ICON.
  4214. 267,269c268,270
  4215. <    PSZ    exfile;       // pre-compiled macro code file (EPM.EX)
  4216. <    PSZ    topmkr;       // top and bottom of file marker
  4217. <    PSZ    botmkr;       //
  4218. ---
  4219. >    PSZ _Seg16    exfile;       // pre-compiled macro code file (EPM.EX)
  4220. >    PSZ _Seg16    topmkr;       // top and bottom of file marker
  4221. >    PSZ _Seg16    botmkr;       //
  4222. 271,272c272,273
  4223. <    PSZ    exsearchpath; // a set of paths to search for ex's files
  4224. <    PSZ    exe_path;     // path where the application started
  4225. ---
  4226. >    PSZ _Seg16    exsearchpath; // a set of paths to search for ex's files
  4227. >    PSZ _Seg16    exe_path;     // path where the application started
  4228. 275c276,277
  4229. < typedef EDITORINFO far *PEDITORINFO;
  4230. ---
  4231. > typedef EDITORINFO * PEDITORINFO;
  4232. > #pragma pack()
  4233. 280c282
  4234. < #define ETKENTRY _loadds
  4235. ---
  4236. > #define ETKENTRY CDECL16
  4237. 285,286c287,288
  4238. < PSZ     ETKENTRY EtkRegister( HAB hab, ULONG class_style );
  4239. < USHORT ETKENTRY EtkCreate( PEDITORINFO epm_p, PHWND hEwnd_p);
  4240. ---
  4241. > PSZ _Seg16    ETKENTRY EtkRegister( HAB hab, ULONG class_style );
  4242. > USHORT ETKENTRY EtkCreate( PEDITORINFO _Seg16 epm_p, PHWND _Seg16 hEwnd_p);
  4243. 304c306,307
  4244. < SHORT  ETKENTRY EtkSetSelection( HWND  hwndClient, LINE_INDEX_G  firstline,
  4245. ---
  4246. > SHORT  ETKENTRY EtkSetSelection( HWND  hwndClient, LINE_INDEX_G  firstline,
  4247. >    FIDType fileid);
  4248.  
  4249. **** Changes to ESIMPLE.C ****
  4250. 28a29,30
  4251. >
  4252. > #include "thunk.h"
  4253. 47a50
  4254. >    HWND hwndEditFrame;
  4255. 52c55
  4256. <
  4257. ---
  4258. >    swp.fl = SWP_MOVE | SWP_SIZE;
  4259. 58c61
  4260. <    epm.filename    = (PSZ)Fname;      // file to be edited (with wildca
  4261. ---
  4262. >    epm.filename    = Fname;           // file to be
  4263. > edited (with wildca
  4264. 64,65c67,70
  4265. <    epm.editorstyle = EDIT_STYLE_ACTIVATEFOCUS | EDIT_STYLE_DISABLEOWNERAFFECT
  4266. <                      EDIT_STYLE_CURSORON;
  4267. ---
  4268. >    epm.editorstyle = EDIT_STYLE_ACTIVATEFOCUS |
  4269. >                      EDIT_STYLE_CURSORON |
  4270. >                      EDIT_STYLE_STATUSLINE |
  4271. >                      EDIT_STYLE_MESSAGELINE;
  4272. 67,68c72,73
  4273. <    epm.pmstyle     = FCF_TITLEBAR | FCF_SIZEBORDER | FCF_VERTSCROLL;
  4274. <
  4275. ---
  4276. >    epm.pmstyle     = FCF_TITLEBAR | FCF_SIZEBORDER |
  4277. > FCF_VERTSCROLL | FCF_MIN
  4278. >    epm.font = TRUE;  // large font
  4279. 70,71c75,76
  4280. <    epm.topmkr      =                        // top and bottom file indicator
  4281. <    epm.botmkr      = (PSZ)" ╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧╤₧";
  4282. ---
  4283. >    epm.topmkr      = (PSZ)"<Top>";
  4284. > // top and bottom fi
  4285. >    epm.botmkr      = (PSZ)"<Bottom>";
  4286. 75c80
  4287. <
  4288. ---
  4289. >    epm.hini = NULLHANDLE;
  4290. 77,79c82,86
  4291. <    EtkCreate( (EDITORINFO far *)&epm, (PHWND)&hwndEdit );
  4292. <
  4293. <    return( (HWND)hwndEdit );
  4294. ---
  4295. >    EtkCreate( &epm, &hwndEdit );
  4296. >       hwndEditFrame = WinQueryWindow(hwndEdit, QW_PARENT);
  4297. >       WinSetWindowPos(hwndEditFrame, NULLHANDLE, swp.x, swp.y,
  4298. >           swp.cx, swp.cy, SWP_MOVE | SWP_SIZE);
  4299. >    return( hwndEdit );
  4300. 95c102
  4301. < MRESULT FAR PASCAL TestWndProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2
  4302. ---
  4303. > MRESULT EXPENTRY TestWndProc( HWND hwnd, USHORT msg,
  4304. > MPARAM mp1, MPARAM mp2 )
  4305. 144,146c151,155
  4306. <   case EPM_EDIT_ACTIVEHWND:
  4307. <      WinSetActiveWindow(HWND_DESKTOP,(HWND)mp1 );
  4308. <      break;
  4309. ---
  4310. > case EPM_EDIT_ACTIVEHWND:
  4311. >   {
  4312. >      WinSetActiveWindow(HWND_DESKTOP,(HWND)mp1 );
  4313. >   }
  4314. >   break;
  4315. 160c169
  4316. <                     (PSZ)mp1,
  4317. ---
  4318. >                     (PSZ)_DosSelToFlat(mp1),
  4319. 162c171
  4320. <                     NULL,
  4321. ---
  4322. >                     NULLHANDLE,
  4323. 235c244
  4324. <     hab = WinInitialize(NULL);              // Initialize app as a PM app
  4325. ---
  4326. >     hab = WinInitialize(NULLHANDLE);        // Initialize app as a PM app
  4327. 247c256
  4328. <
  4329.  
  4330. Credit:  Mat Kramer 
  4331.  
  4332.  
  4333. ΓòÉΓòÉΓòÉ 8.30. How do I get error info after using WinGetLastError()? ΓòÉΓòÉΓòÉ
  4334.  
  4335. One should only use WinGetLastError() after a bad return value, ERRORID is not 
  4336. always zeroed after a successful call to PM API. 
  4337.  
  4338. ShowError Function: 
  4339.  
  4340. /*
  4341.  * ShowError -- for debugging: outputs (via printf) the last error;
  4342.  *    to use this, redirect the output of this program to a file and
  4343.  *    check the results in that file.
  4344.  *    Updated to display the error text in a MESSAGE BOX; ID_MSGBOX must be
  4345.  *    defined.
  4346.  */
  4347.  void ShowError(void)
  4348.  {
  4349.     PERRINFO p;
  4350.     char *cp;
  4351.     extern HAB hab;   /* kinda kludgy, should be a parameter */
  4352.  
  4353.     printf("ShowError: ");
  4354.     if((p = WinGetErrorInfo(hab)) == NULL)
  4355.        printf("NO ERROR\n");
  4356.     else
  4357.     {
  4358.        printf("idError = %#X\n", p->idError);
  4359.        cp = (char *)((ULONG)p + *(ULONG *)((ULONG)p + p->offaoffszMsg));
  4360.        printf("\"%s\"\n", cp);
  4361.        WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (PSZ)cp, (PSZ)"Show Error",
  4362.                      ID_MSGBOX, MB_OK | MB_ICONEXCLAMATION);
  4363.        WinFreeErrorInfo(p);
  4364.     }
  4365.  }
  4366.  
  4367. Credit:  Justin V Frank 
  4368.  
  4369.  
  4370. ΓòÉΓòÉΓòÉ 8.31. Do you have code to save/restore the clipboard? ΓòÉΓòÉΓòÉ
  4371.  
  4372.  typedef struct _CLPBRDDATA // INFORMATION ABOUT A CLIPBOARD FORMAT
  4373.  {
  4374.     ULONG ulFormat; // The format type
  4375.     PVOID pvData;   // Pointer to the data for this format
  4376.  } CLPBRDDATA, *PCLPBRDDATA;
  4377.  
  4378.  //***************
  4379.  // Save formats
  4380.  //***************
  4381.  INT SaveClipboardData( HAB hab, PCLPBRDDATA *ppcd )
  4382.  {
  4383.     INT iFmtCount = 0;
  4384.  
  4385.     if( WinOpenClipbrd( hab ) )
  4386.     {
  4387.        ULONG ulNextFmt, ulPrevFmt = 0;
  4388.  
  4389.        ulNextFmt = WinEnumClipbrdFmts( hab, ulPrevFmt );
  4390.        while( ulNextFmt )
  4391.        {
  4392.           iFmtCount++;
  4393.           ulPrevFmt = ulNextFmt;
  4394.           ulNextFmt = WinEnumClipbrdFmts( hab, ulPrevFmt );
  4395.        }
  4396.  
  4397.        if( iFmtCount )
  4398.        {
  4399.           *ppcd = (PCLPBRDDATA) malloc( sizeof( CLPBRDDATA ) * iFmtCount );
  4400.           if( *ppcd )
  4401.           {
  4402.              memset( *ppcd, 0, sizeof( CLPBRDDATA ) * iFmtCount );
  4403.               if( !GetClipboardFmts( hab, *ppcd ) )
  4404.                  iFmtCount = 0;
  4405.           }
  4406.           else
  4407.           {
  4408.              iFmtCount = 0;
  4409.              Msg( "Out of memory in SaveClipboardData" );
  4410.           }
  4411.        }
  4412.        WinCloseClipbrd( hab );
  4413.     }
  4414.     else
  4415.        Msg( "SaveClipboardData could not open the clipboard" );
  4416.  
  4417.     return iFmtCount;
  4418.  }
  4419.  
  4420.  BOOL GetClipboardFmts( HAB hab, PCLPBRDDATA pcd )
  4421.  {
  4422.     BOOL  fSuccess = TRUE;
  4423.     ULONG ulNextFmt, ulPrevFmt = 0;
  4424.  
  4425.     ulNextFmt = WinEnumClipbrdFmts( hab, ulPrevFmt );
  4426.     while( ulNextFmt )
  4427.     {
  4428.        pcd->ulFormat = ulNextFmt;
  4429.        switch( ulNextFmt )
  4430.        {
  4431.           case CF_TEXT:
  4432.              StoreClipboardText( hab, pcd );
  4433.              break;
  4434.           case CF_BITMAP:
  4435.              StoreClipboardBmp( hab, pcd );
  4436.              break;
  4437.           case CF_METAFILE:
  4438.              StoreClipboardMeta( hab, pcd );
  4439.              break;
  4440.           default:
  4441.              break;
  4442.        }
  4443.  
  4444.        pcd++;
  4445.        ulPrevFmt = ulNextFmt;
  4446.        ulNextFmt = WinEnumClipbrdFmts( hab, ulPrevFmt );
  4447.     }
  4448.     return fSuccess;
  4449.  }
  4450.  
  4451.  VOID StoreClipboardText( HAB hab, PCLPBRDDATA pcd )
  4452.  {
  4453.     PSZ szClipText = (PSZ) WinQueryClipbrdData( hab, CF_TEXT );
  4454.     if( szClipText )
  4455.     {
  4456.        pcd->pvData = malloc( strlen( szClipText ) + 1 );
  4457.        if( pcd->pvData )
  4458.           strcpy( pcd->pvData, szClipText );
  4459.        else
  4460.           Msg( "Out of memory in StoreClipboardText" );
  4461.     }
  4462.     else
  4463.        Msg( "StoreClipboardText found no TEXT in the clipboard" );
  4464.  }
  4465.  
  4466.  VOID StoreClipboardBmp( HAB hab, PCLPBRDDATA pcd )
  4467.  {
  4468.     HBITMAP hbmClip = WinQueryClipbrdData( hab, CF_BITMAP );
  4469.     if( hbmClip )
  4470.        pcd->pvData = (PVOID) CopyBitmap( hab, hbmClip );
  4471.     else
  4472.        Msg( "StoreClipboardBmp found no BITMAP in the clipboard" );
  4473.  }
  4474.  
  4475.  VOID StoreClipboardMeta( HAB hab, PCLPBRDDATA pcd )
  4476.  {
  4477.     HMF hmfClip = WinQueryClipbrdData( hab, CF_METAFILE );
  4478.     if( hmfClip )
  4479.     {
  4480.        HMF hmfNew = GpiCopyMetaFile( hmfClip );
  4481.        if( hmfNew == GPI_ERROR )
  4482.           Msg( "StoreClipboardMeta GpiCopyMetaFile RC = %x",
  4483.           (USHORT) WinGetLastError( hab ) );
  4484.        else
  4485.           pcd->pvData = (PVOID) hmfNew;
  4486.     }
  4487.     else
  4488.        Msg( "StoreClipboardMeta found no METAFILE in the clipboard" );
  4489.  }
  4490.  
  4491.  //******************
  4492.  // Restore formats
  4493.  //******************
  4494.  VOID RestClipboardData( HAB hab, INT iFmtCount, PCLPBRDDATA pcd )
  4495.  {
  4496.     PCLPBRDDATA pcdSave = pcd;
  4497.     INT  i;
  4498.     BOOL fFormatsExist = FALSE;
  4499.  
  4500.     for( i = 0; i < iFmtCount; i++, pcd++ )
  4501.     {
  4502.        if( pcd->ulFormat && pcd->pvData )
  4503.        {
  4504.           fFormatsExist = TRUE;
  4505.           break;
  4506.        }
  4507.     }
  4508.  
  4509.     pcd = pcdSave;
  4510.     if( fFormatsExist )
  4511.        if( WinOpenClipbrd( hab ) )
  4512.        {
  4513.           WinEmptyClipbrd( hab );
  4514.           for( i = 0; i < iFmtCount; i++, pcd++ )
  4515.           {
  4516.              switch( pcd->ulFormat )
  4517.              {
  4518.                 case 0:
  4519.                    break;
  4520.                 case CF_TEXT:
  4521.                    if( pcd->pvData )
  4522.                    {
  4523.                       RestClipboardText( hab, pcd->pvData );
  4524.                       free( pcd->pvData );
  4525.                    }
  4526.                    break;
  4527.                 case CF_BITMAP:
  4528.                    if( pcd->pvData )
  4529.                    RestClipboardBmp( hab, (HBITMAP) pcd->pvData );
  4530.                    break;
  4531.                 case CF_METAFILE:
  4532.                    if( pcd->pvData )
  4533.                       RestClipboardMeta( hab, (HMF) pcd->pvData );
  4534.                    break;
  4535.                 default:
  4536.                    break;
  4537.              }
  4538.           }
  4539.           WinCloseClipbrd( hab );
  4540.        }
  4541.        else
  4542.           Msg( "RestClipboardData could not open the clipboard" );
  4543.     free( pcdSave );
  4544.  }
  4545.  
  4546.  VOID RestClipboardText( HAB hab, PSZ szTextIn )
  4547.  {
  4548.     PSZ szTextOut = NULL;
  4549.     ULONG ulRC =
  4550.     DosAllocSharedMem( (PVOID) &szTextOut, NULL,
  4551.                        strlen( szTextIn ) + 1,
  4552.                        PAG_WRITE | PAG_COMMIT | OBJ_GIVEABLE );
  4553.     if( !ulRC )
  4554.     {
  4555.        strcpy( szTextOut, szTextIn );
  4556.        if( !WinSetClipbrdData( hab, (ULONG) szTextOut, CF_TEXT,
  4557.                                CFI_POINTER ) )
  4558.           Msg( "RestClipboardText WinSetClipbrdData failed" );
  4559.     }
  4560.     else
  4561.        Msg( "RestClipboardText DosAllocSharedMem RC: %u", ulRC );
  4562.  }
  4563.  
  4564.  VOID RestClipboardBmp( HAB hab, HBITMAP hbm )
  4565.  {
  4566.   if( !WinSetClipbrdData( hab, (ULONG) hbm, CF_BITMAP, CFI_HANDLE ) )
  4567.      Msg( "RestClipboardBmp WinSetClipbrdData failed" );
  4568.  }
  4569.  
  4570.  VOID RestClipboardMeta( HAB hab, HMF hmf )
  4571.  {
  4572.   if( !WinSetClipbrdData( hab, (ULONG) hmf, CF_METAFILE, CFI_HANDLE ) )
  4573.      Msg( "RestClipboardMeta WinSetClipbrdData failed" );
  4574.  }
  4575.  
  4576.  HBITMAP CopyBitmap( HAB hab, HBITMAP hbmIn )
  4577.  {
  4578.     BITMAPINFOHEADER2 bmih;
  4579.     HBITMAP           hbmOut = NULLHANDLE;
  4580.     HDC               hdcIn = NULLHANDLE, hdcOut = NULLHANDLE;
  4581.     HPS               hpsIn = NULLHANDLE, hpsOut = NULLHANDLE;
  4582.     POINTL            aptl[ 3 ];
  4583.     SIZEL             sizel = {0,0};
  4584.  
  4585.     hdcIn = DevOpenDC( hab, OD_MEMORY, "*", 0, NULL, NULLHANDLE );
  4586.     if( !hdcIn )
  4587.     {
  4588.        Msg( "CopyBitmap DevOpenDC for hdcIn RC = %x",
  4589.             (USHORT) WinGetLastError( hab ) );
  4590.        goto BYEBYE;
  4591.     }
  4592.  
  4593.     hdcOut = DevOpenDC( hab, OD_MEMORY, "*", 0, NULL, NULLHANDLE );
  4594.     if( !hdcOut )
  4595.     {
  4596.        Msg( "CopyBitmap DevOpenDC for hdcOut RC = %x",
  4597.             (USHORT) WinGetLastError( hab ) );
  4598.        goto BYEBYE;
  4599.     }
  4600.  
  4601.     hpsIn  = GpiCreatePS( hab, hdcIn, &sizel,PU_PELS |
  4602.                           GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC );
  4603.     if( !hpsIn )
  4604.     {
  4605.        Msg( "CopyBitmap GpiCreatePS for hpsIn RC = %x",
  4606.             (USHORT) WinGetLastError( hab ) );
  4607.        goto BYEBYE;
  4608.     }
  4609.  
  4610.     hpsOut = GpiCreatePS( hab, hdcOut, &sizel,PU_PELS |
  4611.                           GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC );
  4612.     if( !hpsOut )
  4613.     {
  4614.        Msg( "CopyBitmap GpiCreatePS for hpsOut RC = %x",
  4615.             (USHORT) WinGetLastError( hab ) );
  4616.        goto BYEBYE;
  4617.     }
  4618.  
  4619.     bmih.cbFix = sizeof( BITMAPINFOHEADER2 );
  4620.     if( !GpiQueryBitmapInfoHeader( hbmIn, &bmih ) )
  4621.     {
  4622.        Msg( "CopyBitmap GpiQueryBitmapInfoHeader for hbmIn RC = %x",
  4623.             (USHORT) WinGetLastError( hab ) );
  4624.        goto BYEBYE;
  4625.     }
  4626.  
  4627.     hbmOut = GpiCreateBitmap( hpsOut, &bmih, 0, NULL, NULL );
  4628.     if( hbmOut )
  4629.     {
  4630.        if( HBM_ERROR == GpiSetBitmap( hpsIn, hbmIn ) )
  4631.        {
  4632.           Msg( "CopyBitmap GpiSetBitmap for hpsIn RC = %x",
  4633.                (USHORT) WinGetLastError( hab ) );
  4634.           hbmOut = NULLHANDLE;
  4635.           goto BYEBYE;
  4636.        }
  4637.  
  4638.        if( HBM_ERROR == GpiSetBitmap( hpsOut, hbmOut ) )
  4639.        {
  4640.           Msg( "CopyBitmap GpiSetBitmap for hpsOut RC = %x",
  4641.                (USHORT) WinGetLastError( hab ) );
  4642.           hbmOut = NULLHANDLE;
  4643.           goto BYEBYE;
  4644.        }
  4645.  
  4646.        aptl[ 0 ].x = 0;
  4647.        aptl[ 0 ].y = 0;
  4648.        aptl[ 1 ].x = bmih.cx;
  4649.        aptl[ 1 ].y = bmih.cy;
  4650.        aptl[ 2 ].x = 0;
  4651.        aptl[ 2 ].y = 0;
  4652.  
  4653.        if( GPI_ERROR == GpiBitBlt( hpsOut, hpsIn, 3, aptl, ROP_SRCCOPY,
  4654.                                    BBO_IGNORE ) )
  4655.        {
  4656.           Msg( "CopyBitmap GpiBitBlt for hpsOut RC = %x",
  4657.                (USHORT) WinGetLastError( hab ) );
  4658.           hbmOut = NULLHANDLE;
  4659.        }
  4660.     }
  4661.     else
  4662.        Msg( "CopyBitmap GpiCreateBitmap for hbmOut RC = %x",
  4663.             (USHORT) WinGetLastError( hab ) );
  4664.  
  4665.  BYEBYE:
  4666.  
  4667.     if( hpsIn )
  4668.        GpiDestroyPS( hpsIn );
  4669.     if( hpsOut )
  4670.        GpiDestroyPS( hpsOut );
  4671.     if( hdcIn )
  4672.        DevCloseDC( hdcIn );
  4673.     if( hdcOut )
  4674.        DevCloseDC( hdcOut );
  4675.     return hbmOut;
  4676.  }
  4677.  
  4678. Credit:  Rick Fishman 
  4679.  
  4680.  
  4681. ΓòÉΓòÉΓòÉ 8.32. How do I know what item was selected in a Combo box? ΓòÉΓòÉΓòÉ
  4682.  
  4683. Catch the LN_SELECT message from the combo box, then send an LM_QUERYSELECTION 
  4684. to get the index of the selection, then a LM_QUERYITEMTEXT to get the selected 
  4685. text. 
  4686.  
  4687. Credit:  Pete Norloff 
  4688.  
  4689.  
  4690. ΓòÉΓòÉΓòÉ 8.33. How do I get a bitmap into a dialog in a DLL? ΓòÉΓòÉΓòÉ
  4691.  
  4692. You've hit on a known problem with bitmaps in dialogs in dlls. This also used 
  4693. to be a problem for icons but that appears to be working now. 
  4694.  
  4695. First, define your bitmap in your dialog like this (notice no mention of 
  4696. SS_BITMAP). It is strictly text at this point. PM can handle this when loading 
  4697. the dialog: 
  4698.  
  4699. Below are all the files necessary to create dllbitmp.exe and dlgdll.dll. Dlgdll 
  4700. has the dialog box and bitmap. Dllbitmp.exe calls DllDialog() in dlgdll.dll to 
  4701. bring up the dialog box from the dll's resource file... 
  4702.  
  4703. DLLBITMP.C: 
  4704.  
  4705.  #define  INCL_GPI
  4706.  #define  INCL_WIN
  4707.  #include <os2.h>
  4708.  #include "dllbitmp.h"
  4709.  
  4710.  #define FRAME_FLAGS  (FCF_TASKLIST | FCF_TITLEBAR   |
  4711.                        FCF_MENU     | FCF_SYSMENU    |
  4712.                        FCF_MINMAX   | FCF_SIZEBORDER |
  4713.                        FCF_SHELLPOSITION)
  4714.  #define CLIENT_CLASS "DllBitmp"
  4715.  
  4716.  
  4717.  INT main( VOID );
  4718.  VOID EXPENTRY DllDialog( HWND );
  4719.  FNWP wpClient;
  4720.  
  4721.  
  4722.  INT main( VOID )
  4723.  {
  4724.     HAB   hab;
  4725.     HMQ   hmq;
  4726.     QMSG  qmsg;
  4727.     HWND  hwndFrame, hwndClient;
  4728.     ULONG flFrame = FRAME_FLAGS;
  4729.  
  4730.     hab = WinInitialize( 0 );
  4731.     hmq = WinCreateMsgQueue( hab, 0 );
  4732.     WinRegisterClass( hab, CLIENT_CLASS, wpClient, 0, 0 );
  4733.     hwndFrame = WinCreateStdWindow( HWND_DESKTOP, WS_VISIBLE,
  4734.                                     &flFrame,CLIENT_CLASS, NULL,
  4735.                                     0,NULLHANDLE, ID_RESOURCES,
  4736.                                     &hwndClient );
  4737.     while( WinGetMsg( hab, &qmsg, NULLHANDLE, 0, 0 ) )
  4738.        WinDispatchMsg( hab, &qmsg );
  4739.  
  4740.     WinDestroyWindow( hwndFrame );
  4741.     WinDestroyMsgQueue( hmq );
  4742.     WinTerminate( hab );
  4743.     return 0;
  4744.  }
  4745.  
  4746.  
  4747.  MRESULT EXPENTRY wpClient( HWND hwnd, ULONG msg,
  4748.                             MPARAM mp1, MPARAM mp2 )
  4749.  {
  4750.     switch( msg )
  4751.     {
  4752.        case WM_ERASEBACKGROUND:
  4753.           return (MRESULT) TRUE;
  4754.        case WM_COMMAND:
  4755.        switch( SHORT1FROMMP( mp1 ) )
  4756.        {
  4757.           case IDM_DOIT:
  4758.           {
  4759.              DllDialog( hwnd );
  4760.              return 0;
  4761.           }
  4762.        }
  4763.  
  4764.        break;
  4765.     }
  4766.     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  4767.  }
  4768.  
  4769. DLLBITMP.H: 
  4770.  
  4771.  #define ID_RESOURCES    1
  4772.  #define IDD_DOIT    100
  4773.  #define IDM_DOIT    110
  4774.  #define ID_BITMAP    1100
  4775.  #define ID_BITMAPID    1200
  4776.  
  4777. DLLBITMP.DEF: 
  4778.  
  4779.  NAME        DLLBITMP      WINDOWAPI
  4780.  PROTMODE
  4781.  HEAPSIZE    16384
  4782.  STACKSIZE    16384
  4783.  
  4784. DLLBITMP.RC: 
  4785.  
  4786.  #include <os2.h>
  4787.  #include "dllbitmp.h"
  4788.  
  4789.  
  4790.  MENU ID_RESOURCES
  4791.  {
  4792.      MENUITEM "!~DoIt", IDM_DOIT
  4793.  }
  4794.  
  4795. DLGDLL.C: 
  4796.  
  4797.  #define  INCL_DOS
  4798.  #define  INCL_GPI
  4799.  #define  INCL_WIN
  4800.  #include <os2.h>
  4801.  #include "dllbitmp.h"
  4802.  
  4803.  
  4804.  FNWP wpDlg;
  4805.  
  4806.  
  4807.  VOID EXPENTRY DllDialog( HWND hwnd )
  4808.  {
  4809.     HMODULE hmod;
  4810.  
  4811.     DosQueryModuleHandle( "DLGDLL", &hmod );
  4812.     WinDlgBox( HWND_DESKTOP, hwnd, wpDlg, hmod, IDD_DOIT, NULL );
  4813.  }
  4814.  
  4815.  
  4816.  MRESULT EXPENTRY wpDlg( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 )
  4817.  {
  4818.     switch (msg)
  4819.     {
  4820.        case WM_INITDLG:
  4821.        {
  4822.           HWND    hwndBmp = WinWindowFromID( hwndDlg, ID_BITMAPID );
  4823.           HPS     hps = WinGetPS( hwndDlg );
  4824.           HBITMAP hbm;
  4825.           HMODULE hmod;
  4826.  
  4827.           DosQuieryModuleHandle( "DLGDLL", &hmod );
  4828.           hbm = GpiLoadBitmap( hps, hmod, ID_BITMAP, 0, 0 );
  4829.           WinSetWindowBits(hwndBmp,QWL_STYLE,SS_BITMAP,SS_BITMAP | 0x7f);
  4830.           WinSendMsg( hwndBmp, SM_SETHANDLE, MPFROMP( hbm ), NULL );
  4831.           WinSetWindowULong( hwndDlg, QWL_USER, (ULONG) hbm );
  4832.           WinReleasePS( hps );
  4833.           break;
  4834.        }
  4835.        case WM_DESTROY:
  4836.        {
  4837.           HBITMAP hbm = (HBITMAP) WinQueryWindowULong(hwndDlg,QWL_USER );
  4838.           GpiDeleteBitmap( hbm );
  4839.           break;
  4840.        }
  4841.     }
  4842.     return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
  4843.  }
  4844.  
  4845. DLGDLL.DLG: 
  4846.  
  4847.  DLGTEMPLATE IDD_DOIT LOADONCALL MOVEABLE DISCARDABLE
  4848.  BEGIN
  4849.    DIALOG "", IDD_DOIT, 0, 0, 210, 154, FS_NOBYTEALIGN | FS_DLGBORDER |
  4850.               WS_VISIBLE | WS_CLIPSIBLINGS | WS_SAVEBITS, FCF_TITLEBAR
  4851.    BEGIN
  4852.        CONTROL "foo", ID_BITMAPID, 98, 56, 32, 32, WC_STATIC,
  4853.                SS_TEXT | DT_LEFT | DT_TOP | WS_VISIBLE
  4854.    END
  4855.  END
  4856.  
  4857. DLGDLL.DEF: 
  4858.  
  4859.  LIBRARY    DLGDLL        INITINSTANCE    TERMINSTANCE
  4860.  PROTMODE
  4861.  CODE        LOADONCALL
  4862.  DATA        LOADONCALL    MULTIPLE    NONSHARED
  4863.  EXPORTS    DllDialog
  4864.  
  4865. DLGDLL.RC: 
  4866.  
  4867.  #include <os2.h>
  4868.  #include "dllbitmp.h"
  4869.  
  4870.  
  4871.  BITMAP  ID_BITMAP "dlgdll.bmp"
  4872.  
  4873.  
  4874.  rcinclude dlgdll.dlg
  4875.  
  4876. MAKEFILE: 
  4877.  
  4878.  all: dlgdll.dll dllbitmp.exe
  4879.  
  4880.  dlgdll.dll: $*.obj $*.res
  4881.      link386 /NOI /NOE /MAP /DE /NOL $*, $*.dll,, os2386, $*
  4882.      rc $*.res $*.dll
  4883.      implib $*.lib $*.def
  4884.  
  4885.  dllbitmp.exe: $*.obj $*.def $*.res
  4886.      link386  /NOI /NOE /MAP /DE /NOL $*,,, os2386 dlgdll, $*
  4887.      rc $*.res $*.exe
  4888.  
  4889.  dllbitmp.obj: $*.c
  4890.      icc /Q+ /Ss /W3 /Kbcepr /Gm- /Gd- /Ge+ /Ti+ /O- /C $*.c
  4891.  
  4892.  dllbitmp.res: $*.rc
  4893.      rc -r $*
  4894.  
  4895.  dlgdll.obj: $*.c
  4896.      icc /Q+ /Ss /W3 /Kbcepr /Gm- /Gd- /Ge- /Ti+ /O- /C $*.c
  4897.  
  4898.  dlgdll.res: $*.rc $*.dlg
  4899.      rc -r $*
  4900.  
  4901. Credit:  Rick Fishman 
  4902.  
  4903.  
  4904. ΓòÉΓòÉΓòÉ 8.34. How does programming PM compare to programming X? ΓòÉΓòÉΓòÉ
  4905.  
  4906. Many people have said "PM is much cleaner."  Until I hear from someone I trust 
  4907. with extensive experience with both (I only know X), however, this FAQ will 
  4908. take no position. 
  4909.  
  4910. There was an unsubstantiated rumor that someone was porting an X library to 
  4911. OS/2 (X-Windows, not X-Mode or any other X), I dunno whether this has been 
  4912. substantiated or not. 
  4913.  
  4914. IBM and a few other manufacturers have built their own X servers for OS/2. 
  4915. [details?] 
  4916.  
  4917. [Colin Jensen...] 
  4918.  
  4919. I have some limited experience with X and PM.  Raw Xlib is harder to program 
  4920. than PM.  However most, if not all, of the X11 Toolkits are *easier* to use 
  4921. than PM.  I have experience comparing XView to PM. A friend of mine has 
  4922. experience with Windows versus Xt, and has the same opinion (Windows isn't that 
  4923. far off conceptually from PM). 
  4924.  
  4925.  
  4926. ΓòÉΓòÉΓòÉ 8.35. How do I put bitmaps on buttons? ΓòÉΓòÉΓòÉ
  4927.  
  4928. Stefan Gruendal (Stefan_Gruendel@wue.maus.de) writes: 
  4929.  
  4930. But to my question:  How do I build my own "smart icons", i.e. bitmaps on 
  4931. pushbuttons, that optically "move into the screen"? I didn't find any way to 
  4932. achieve this with the Toolkit's Dialog Editor.  But as mentioned above, I know 
  4933. there's a way. 
  4934.  
  4935. Starting with OS/2 2.x, a new button style was added - BS_ICON - which allows 
  4936. you to do what you are trying to accomplish.  It works, as far as I know, only 
  4937. for pushbuttons, and the icon or bitmap is taken from the resource file, whose 
  4938. resource id is specified in the pushbutton text. 
  4939.  
  4940. For example: 
  4941.  
  4942. In FOO.H: 
  4943.  
  4944. #define IDBM_BUTTON 256
  4945. #define IDPB_BUTTON 257
  4946.  
  4947. In FOO.RC: 
  4948.  
  4949. BITMAP IDBM_BUTTON BUTTON.BMP
  4950.  
  4951. In FOO.C: 
  4952.  
  4953. sprintf(achText,"#%d",IDBM_BUTTON);
  4954.  
  4955. hwndButton=WinCreateWindow(hwndClient,WC_BUTTON,achText,
  4956.                            WS_VISIBLE|BS_PUSHBUTTON|BS_ICON,
  4957.                            10,10,32,32,hwndClient,HWND_TOP,
  4958.                            IDPB_BUTTON,NULL,NULL);
  4959.  
  4960. The bitmap is stretched or compressed to fill the button. 
  4961.  
  4962. (Quoted almost directly from EDMI/2 Edition 1) 
  4963.  
  4964.  
  4965. ΓòÉΓòÉΓòÉ 8.36. Can a PM program tell if there's a previous instance of itself running? ΓòÉΓòÉΓòÉ
  4966.  
  4967. Raja Thiagarajan (sthiagar@bronze.ucs.indiana.edu) writes: 
  4968.  
  4969. Can a PM program tell if there's a previous instance of itself running?  In 
  4970. Win3.x (but apparently NOT Win32), there's a hPrevInst handle; is there an OS/2 
  4971. 2.x equivalent?  Basically, I'm thinking in terms of a program that would try 
  4972. to borrow resources from a previous instance if a previous instance is running. 
  4973. (Specifically, if my palette animation program gets started twice, the second 
  4974. instance oughta share palettes with the first instance!) 
  4975.  
  4976. What you're really asking is two questions: 
  4977.  
  4978.  1. How can I determine if a previous instance of my application is already 
  4979.     running? 
  4980.  2. How can I share resources between multiple instances of my application? 
  4981.  
  4982. There are some ways to achieve this; You can use semaphores or/and shared 
  4983. memory or the other method described below. Try to open your named semaphore, 
  4984. if it's there, your application is already running, else create a semaphore... 
  4985. To share data, use shared memory. There are some excellent examples in Schildt 
  4986. & Goosey "OS/2 Programming". 
  4987.  
  4988. To answer your first question, you need to enumerate all of the main windows 
  4989. present on the desktop, and figure out if any of them are yours. This is 
  4990. achieved using the following code: 
  4991.  
  4992. HWND queryAppInstance(PCHAR pchClassWanted)
  4993. {
  4994.    HENUM heEnum;
  4995.    HWND hwndTop;
  4996.    HWND hwndClient;
  4997.    CHAR achClass[256];
  4998.  
  4999.    heEnum=WinBeginEnumWindows(HWND_DESKTOP);
  5000.  
  5001.    hwndTop=WinGetNextWindow(heEnum);
  5002.    while (hwndTop!=NULLHANDLE) {
  5003.       hwndClient=WinWindowFromID(hwndTop,FID_CLIENT);
  5004.       if (hwndClient!=NULLHANDLE) {
  5005.          WinQueryClassName(hwndClient,sizeof(achClass),achClass);
  5006.          if (strcmp(achClass,pchClassWanted)==0) {
  5007.             WinEndEnumWindows(heEnum);
  5008.             return hwndClient;
  5009.          } /* endif */
  5010.       } /* endif */
  5011.  
  5012.       hwndTop=WinGetNextWindow(heEnum);
  5013.    } /* endwhile */
  5014.  
  5015.    WinEndEnumWindows(heEnum);
  5016.    return NULLHANDLE;
  5017. }
  5018.  
  5019. To answer your second question, the only way that I know of to share resources 
  5020. is to place them in a DLL.  The procedure to do this is as follows: 
  5021.  
  5022. o Create a dummy source file with an empty procedure in it. 
  5023. o Compile the source file and link as a DLL. 
  5024. o Add your resources to the DLL in the same manner as you would to an 
  5025.   executable. 
  5026.  
  5027. Then, when your application starts, you simply call WinLoadLibrary  (the 
  5028. preferred way) or DosLoadModule to load the DLL.  These functions return a 
  5029. handle to the DLL which must then be used in any function which loads resources 
  5030. (e.g. GpiLoadBitmap, WinLoadPointer, etc.). 
  5031.  
  5032. Note that this procedure does not require knowing the window handle of any 
  5033. previous instance of your application because OS/2 implements DLLs in a shared 
  5034. fashion (which I suspect is one of the reasons they were created in the first 
  5035. place).  All you need to know is the name of the DLL.  This technique can also 
  5036. be used to share resources between different applications. 
  5037.  
  5038. (Quoted almost directly from EDMI/2 Edition 1) 
  5039.  
  5040.  
  5041. ΓòÉΓòÉΓòÉ 8.37. How to avoid crash when using Drag and Drop? ΓòÉΓòÉΓòÉ
  5042.  
  5043. You can avoid this by doing; 
  5044.  
  5045. 1) Call any DRG*() function in your application
  5046. 2) Call DosLoadModule() to load the PMDRAG.DLL file
  5047.  
  5048. Credit: Q 
  5049.  
  5050.  
  5051. ΓòÉΓòÉΓòÉ 9. Miscellaneous Programming ΓòÉΓòÉΓòÉ
  5052.  
  5053. This section covers non-Presentation Manager programming. 
  5054.  
  5055.  
  5056. ΓòÉΓòÉΓòÉ 9.1. Explain the SYS_DLL keywords. ΓòÉΓòÉΓòÉ
  5057.  
  5058. Actually there are three key names that exist for the app name SYS_DLL. 
  5059.  
  5060. They are: 
  5061.  
  5062. LOAD 
  5063.           DLL loaded and ordinal 1 entry point called for every msg queue 
  5064.           created in the system 
  5065.  
  5066. LOADPERPROCESS 
  5067.           DLL loaded and ordinal 1 entry point called for only the first 
  5068.           message queue created on a process 
  5069.  
  5070. LOADONETIME 
  5071.           DLL loaded and ordinal 1 entry point called for only the shell's 
  5072.           message queue (the first PM queue in the system) 
  5073.  
  5074. You would use one over another depending on the type of initialization that you 
  5075. require.  Most DLL's only need to be initialized once for the system and are 
  5076. thus LOADONETIME, some DLLs like PMCTLS have per process initialization and 
  5077. thus are LOADPERPROCESS, and then there is the very rare case of DLLs that need 
  5078. to perform some function every time a message queue is created and these are 
  5079. specified as LOAD.  Note: that anything other than LOADONETIME is a significant 
  5080. performance hit on the system.  Note: also that in addition to your 
  5081. INITIALIZATION/TERMINATION function specified in the DEF file for your DLL 
  5082. (which is a new feature in 2.0), your ORDINAL 1 entry point in your DLL is also 
  5083. called.  Be careful with this as I have seen some pretty strange results if you 
  5084. have an ordinal 1 entry point that has nothing to do with initialization.  In 
  5085. addition, remember to never ever create a message queue inside of your 
  5086. initialization routine.  Always call WinQueryAnchorBlock if you need a HAB for 
  5087. some API. 
  5088.  
  5089. As for shared resources, if you need resources on multiple processes then they 
  5090. need to be created on multiple processes as they won't be valid on any process 
  5091. other than the one you loaded.  I believe that this is the reason PMCTLS is 
  5092. LOADPERPROCESS.  You have a few options here, 1) you can store your resources 
  5093. in shared memory, and 2) for icons you can call WinSetPoinerOwner to make your 
  5094. icons shared across the entire system. 
  5095.  
  5096.  
  5097. ΓòÉΓòÉΓòÉ 9.2. How do I start another session? ΓòÉΓòÉΓòÉ
  5098.  
  5099. This small program will start any program synchronously using 
  5100. DosStartSession(). The important thing is the queue. When you specify 
  5101. SSF_RELATED_CHILD and a TermQ name, OS/2 will write the return code to the 
  5102. specified queue when the session terminates. I use this in an event scheduler 
  5103. by creating a separate thread that does reads from the queue but you can just 
  5104. as easily block on the main thread to catch the return code. That will, in 
  5105. effect, provide for synchronous execution. Note that one problem with 
  5106. SSF_RELATED_CHILD is that if the program that started the child dies, so does 
  5107. the child. 
  5108.  
  5109.  #define  INCL_DOSERRORS
  5110.  #define  INCL_DOSPROCESS
  5111.  #define  INCL_DOSQUEUES
  5112.  #define  INCL_DOSSESMGR
  5113.  #include <os2.h>
  5114.  #include <stdio.h>
  5115.  #include <stdlib.h>
  5116.  #include <string.h>
  5117.  
  5118.  #define QUEUE_NAME    "\\QUEUES\\STRTSYNC.QUE"
  5119.  
  5120.  int main( int argc, char *argv[] );
  5121.  
  5122.  int main( int argc, char *argv[] )
  5123.  {
  5124.      APIRET rc;
  5125.      HQUEUE hque;
  5126.  
  5127.      if( argc < 2 )
  5128.          return 1;
  5129.  
  5130.      rc = DosCreateQueue( &hque, QUE_FIFO | QUE_CONVERT_ADDRESS, QUEUE_NAME );
  5131.      if( !rc )
  5132.      {
  5133.          STARTDATA   stdata;
  5134.          PID         pidSession;
  5135.          CHAR        szObjFail[ 50 ];
  5136.          ULONG       ulLength, idSession;
  5137.          REQUESTDATA rd;
  5138.          PUSHORT     pusInfo = NULL;
  5139.          BYTE        bPriority;
  5140.  
  5141.          (void) memset( &stdata, 0, sizeof( stdata ) );
  5142.  
  5143.          stdata.Length       = sizeof( STARTDATA );
  5144.          stdata.FgBg         = SSF_FGBG_FORE;
  5145.          stdata.TraceOpt     = SSF_TRACEOPT_NONE;
  5146.          stdata.PgmTitle     = "Rick's Program";
  5147.          stdata.InheritOpt   = SSF_INHERTOPT_SHELL;
  5148.          stdata.SessionType  = SSF_TYPE_DEFAULT;
  5149.          stdata.PgmControl   = SSF_CONTROL_VISIBLE;
  5150.          stdata.ObjectBuffer = szObjFail;
  5151.          stdata.ObjectBuffLen= sizeof( szObjFail );
  5152.          stdata.Related      = SSF_RELATED_CHILD;
  5153.          stdata.TermQ        = QUEUE_NAME;
  5154.          stdata.PgmName      = argv[ 1 ];
  5155.  
  5156.          rc = DosStartSession( &stdata, &idSession, &pidSession );
  5157.  
  5158.          if( rc && rc != ERROR_SMG_START_IN_BACKGROUND )
  5159.          {
  5160.              printf( "DosStartSession RC(%u)\n", rc );
  5161.              return (INT) rc;
  5162.          }
  5163.  
  5164.          rc = DosReadQueue( hque, &rd, &ulLength, (PPVOID) &pusInfo, 0,
  5165.                             DCWW_WAIT, &bPriority, 0 );
  5166.  
  5167.          if( rc && rc != ERROR_QUE_EMPTY )
  5168.          {
  5169.              printf( "DosReadQueue RC(%u)\n", rc );
  5170.              return (INT) rc;
  5171.          }
  5172.  
  5173.          printf( "RetCode from Session %u: %u\n",
  5174.                   pusInfo[ 0 ], pusInfo[ 1 ]);
  5175.  
  5176.          DosCloseQueue( hque );
  5177.      }
  5178.      else
  5179.      {
  5180.          printf( "DosCreateQueue RC(%u)\n", rc );
  5181.          return (INT) rc;
  5182.      }
  5183.  
  5184.      return 0;
  5185.  }
  5186.  
  5187. Credit:  Rick Fishman 
  5188.  
  5189.  
  5190. ΓòÉΓòÉΓòÉ 9.3. How do I check if a filename is valid? ΓòÉΓòÉΓòÉ
  5191.  
  5192. Here's some code that should help.  I found that you have to look at each 
  5193. return code to see if it's really an error.  This routine does do syntax 
  5194. checking, it's just a little more complicated than before :^) 
  5195.  
  5196. #define INCL_DOSFILEMGR
  5197. #define INCL_DOSERRORS
  5198. #include <os2.h>
  5199. #include <stdio.h>
  5200.  
  5201. int main( int argc, char **argv )
  5202. {
  5203.         int         rc;
  5204.         FILESTATUS3 piBuffer;
  5205.  
  5206.         if ( argc !=2 )
  5207.         {
  5208.                 printf( "Must pass filename on command line!\n");
  5209.                 return( -1 );
  5210.         }
  5211.         else
  5212.         {
  5213.                 printf( "Checking on %s, ", argv[ 1 ] );
  5214.                 rc = DosQueryPathInfo( (PSZ)argv[1], FIL_STANDARD, &piBuffer,
  5215.                                        sizeof(FILESTATUS3));
  5216.  
  5217.                 if ( rc == 0 )
  5218.                         printf( "syntax valid and file exists\n" );
  5219.                 else
  5220.                 if ( rc == ERROR_FILE_NOT_FOUND )
  5221.                         printf( "syntax valid and file doesn't exist.\n");
  5222.                 else
  5223.                 if ( rc == ERROR_PATH_NOT_FOUND )
  5224.                         printf( "syntax valid, somthing in path was not found\n");
  5225.                 else
  5226.                 {
  5227.                         printf( "bad, rc=%d, ",rc );
  5228.                         switch( rc )
  5229.                         {
  5230.                                 case ERROR_INVALID_DRIVE:
  5231.                                         printf( "drive name does not exist\n");
  5232.                                         break;
  5233.  
  5234.                                 case ERROR_INVALID_NAME:
  5235.                                         printf( "invalid syntax for drive name\n");
  5236.                                         break;
  5237.  
  5238.                                 case ERROR_FILENAME_EXCED_RANGE:
  5239.                                         printf( "dir name and/or filename too long\n");
  5240.                                         break;
  5241.  
  5242.                                 case ERROR_SHARING_VIOLATION:
  5243.                                         printf( "sharing violation\n");
  5244.                                         break;
  5245.  
  5246.                                 case ERROR_BUFFER_OVERFLOW:
  5247.                                         printf( "buffer overflow\n");
  5248.                                         break;
  5249.  
  5250.                                 case ERROR_INVALID_LEVEL:
  5251.                                         printf( "invalid level requested\n");
  5252.                                         break;
  5253.  
  5254.                                 case ERROR_INVALID_EA_NAME:
  5255.                                         printf( "invalid EA name\n");
  5256.                                         break;
  5257.  
  5258.                                 case ERROR_EA_LIST_INCONSISTENT:
  5259.                                         printf( "EA list inconsistent\n");
  5260.                                         break;
  5261.  
  5262.                                 default:
  5263.                                         printf("Undocumented return value.\n");
  5264.                         }
  5265.                         return( -1 );
  5266.             }
  5267.             return( 0 );
  5268.         }
  5269. }
  5270.  
  5271. Credit:  Mike Brown 
  5272.  
  5273.  
  5274. ΓòÉΓòÉΓòÉ 9.4. Why should I use _beginthread instead of DosCreateThread? ΓòÉΓòÉΓòÉ
  5275.  
  5276. You must if you want to use the C runtime library. 
  5277.  
  5278.  
  5279. ΓòÉΓòÉΓòÉ 9.5. How do I open a file that is already in use? ΓòÉΓòÉΓòÉ
  5280.  
  5281. Use DosOpen with OPEN_SHARE_DENYNONE. 
  5282.  
  5283. /* this will copy an open program */
  5284.  
  5285. #define INCL_NOPM
  5286. #define INCL_DOS
  5287. #include <os2.h>
  5288. #include <stdio.h>
  5289. #include <string.h>
  5290.  
  5291. void usage(void)
  5292. {
  5293.     printf("USAGE: CopyOpen <source file> <dest file>\n\n");
  5294.     printf("       This program,  unlike the normal copy and xcopy commands,\n");
  5295.     printf("       will copy an open file.\n");
  5296.     printf("NOTE:  Wildcards are not supported\n");
  5297. }
  5298.  
  5299. int cdecl main(int argc, char **argv)
  5300. {
  5301.     HFILE hf, hfOut;
  5302.     USHORT usAction, rc, bytesRead, bytesWriten ;
  5303.     static BYTE buf[4096];
  5304.     long total=0l;
  5305.     int error = FALSE;
  5306.  
  5307.     if(argc!=3){
  5308.         usage();
  5309.         return 1;
  5310.     }
  5311.     rc = DosOpen(strupr(argv[1]),
  5312.         &hf,
  5313.         &usAction,
  5314.         0L,
  5315.         FILE_NORMAL,
  5316.         FILE_OPEN,
  5317.         OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE,
  5318.         0L);
  5319.     if(rc){
  5320.         printf("SYS%04u: Could not open %s for read.\n", rc, argv[1]);
  5321.         return 3;
  5322.     }
  5323.     rc = DosOpen(strupr(argv[2]),
  5324.         &hfOut,
  5325.         &usAction,
  5326.         0L,
  5327.         FILE_NORMAL,
  5328.         FILE_CREATE | FILE_TRUNCATE,
  5329.         OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYREADWRITE,
  5330.         0L);
  5331.     if(rc){
  5332.         printf("SYS%04u: Could not open %s for write.\n", rc, argv[2]);
  5333.         return 3;
  5334.     }
  5335.     else{
  5336.         do{
  5337.             rc = DosRead(hf, buf, sizeof(buf), &bytesRead);
  5338.             if(!rc){
  5339.                rc = DosWrite(hfOut, buf, bytesRead, &bytesWriten);
  5340.                if(!rc) total += bytesWriten;
  5341.             }
  5342.         }while(!rc &&
  5343.                sizeof(buf) == bytesRead &&
  5344.                bytesRead == bytesWriten);
  5345.         if(rc){
  5346.             printf("SYS%04u: while copying.\n", rc);
  5347.             error = TRUE;
  5348.         }
  5349.         if(bytesRead != bytesWriten){
  5350.             printf("Disk full?\n");
  5351.             error = TRUE;
  5352.         }
  5353.         DosClose(hf);
  5354.         if(!error)
  5355.             printf("%lu bytes copied.\n", total);
  5356.     }
  5357.     return( error? 3 : 0);
  5358. }
  5359.  
  5360. Credit:  Peter Fitzsimmons 
  5361.  
  5362.  
  5363. ΓòÉΓòÉΓòÉ 9.6. Can we use Vio in v2.0? Where are the docs for it? ΓòÉΓòÉΓòÉ
  5364.  
  5365. Yes; check cdrom.com for PRCP.ZIP. 
  5366.  
  5367.  
  5368. ΓòÉΓòÉΓòÉ 9.7. Can I redirect stdin and stdout in a child process? ΓòÉΓòÉΓòÉ
  5369.  
  5370. This is what I use to redirect stderr, stdout to a file from a program I start 
  5371. using DosStartSession. You could do the same type of thing using a pipe. 
  5372.  
  5373.     ULONG  ulAction;
  5374.     ULONG  ulNew;
  5375.     HFILE  hfFile, hfNewStdOut = -1, hfNewStdErr = -1,
  5376.            hfStdOut = 1, hfStdErr = 2;
  5377.  
  5378.     // Open output file
  5379.     DosOpen( szOutputFile, &hfFile, &ulAction, 1, 0,
  5380.              FILE_OPEN | FILE_CREATE,
  5381.              OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, 0L );
  5382.     // Duplicate handles
  5383.     DosDupHandle( hfStdOut, phfNewStdOut );
  5384.     DosDupHandle( hfStdErr, phfNewStdErr );
  5385.     // Close existing handles for current process
  5386.     DosClose( hfStdOut );
  5387.     DosClose( hfStdErr );
  5388.     // Redirect existing handles to new file
  5389.     DosDupHandle( hfFile, &hfStdOut );
  5390.     DosDupHandle( hfFile, &hfStdErr );
  5391.     // Let started program inherit handles from parent
  5392.     stdata.InheritOpt = SSF_INHERITOPT_PARENT;
  5393.     // Start new session
  5394.     DosStartSession( &stdata, &ulSessionID, &pidSession );
  5395.     // Get back original handles
  5396.     DosDupHandle( hfNewStdOut, &hfStdOut );
  5397.     DosDupHandle( hfNewStdErr, &hfStdErr );
  5398.     // Close the duplicated handles - no longer needed
  5399.     DosClose( hfNewStdOut );
  5400.     DosClose( hfNewStdErr );
  5401.  
  5402. Credit:  Rick Fishman 
  5403.  
  5404.  
  5405. ΓòÉΓòÉΓòÉ 9.8. How do I use DosMon*() to stuff the kbd buf? ΓòÉΓòÉΓòÉ
  5406.  
  5407. Here's a mini app (all error handling, comments, etc. removed.) 
  5408.  
  5409. (also all this stuff to avoid compile warnings !!!!!). 
  5410.  
  5411. compile with: icc -Sm -Kabgioprx+ -Ss+ -W3 -Gs+ -Gf+ -O+ KEY.C
  5412. start with: detach key
  5413. stop with: F11 or CTRL-F10
  5414. test envir: OS/2 2.0GA+SP, C-Set++ CSD 22.
  5415. no other functionality.
  5416.  
  5417. orginal src part of my glorious DOS/OS2 1.x/OS2 2.0 keyboard roboter which 
  5418. inserts keys into the keyboard monitor queue controlled by an source file (mini 
  5419. language). 
  5420.  
  5421.    (C) Mario Semo 1777,1832,1967-92. 
  5422.  
  5423. ========= TOP OF FILE KEY.C ================ 
  5424.  
  5425. #define INCL_DOS
  5426. #define INCL_KBD
  5427. #define INCL_NOPM
  5428.  
  5429. #include<os2.h>
  5430. #include<stdio.h>
  5431. #include<conio.h>
  5432. #include<process.h>
  5433. #include<stdlib.h>
  5434. #include<string.h>
  5435.  
  5436. #define DosMonOpen  DOS16MONOPEN
  5437. #define DosMonClose DOS16MONCLOSE
  5438. #define DosMonReg   DOS16MONREG
  5439. #define DosMonRead  DOS16MONREAD
  5440. #define DosMonWrite DOS16MONWRITE
  5441.  
  5442. #define MONITOR_DEFAULT 0x0000
  5443. #define MONITOR_BEGIN   0x0001
  5444. #define MONITOR_END     0x0002
  5445.  
  5446. typedef SHANDLE HMONITOR;       /* hmon */
  5447. typedef HMONITOR *PHMONITOR;
  5448.  
  5449. #pragma pack(2)
  5450. typedef struct _MONIN {         /* mnin */
  5451.         USHORT cb;
  5452.         BYTE abReserved[18];
  5453.         BYTE abBuffer[108];
  5454. } MONIN;
  5455. typedef MONIN *PMONIN;
  5456.  
  5457. #pragma pack(2)
  5458. typedef struct _MONOUT {        /* mnout */
  5459.         USHORT cb;
  5460.         UCHAR buffer[18];
  5461.         BYTE abBuf[108];
  5462. } MONOUT;
  5463. typedef MONOUT *PMONOUT;
  5464.  
  5465. APIRET16 APIENTRY16 DosMonOpen(PSZ pszDevName, PHMONITOR phmon);
  5466. APIRET16 APIENTRY16 DosMonClose(HMONITOR hmon);
  5467. APIRET16 APIENTRY16 DosMonReg(HMONITOR hmon, PBYTE pbInBuf,
  5468.              PBYTE pbOutBuf, USHORT fPosition, USHORT usIndex);
  5469. APIRET16 APIENTRY16 DosMonRead(PBYTE pbInBuf, USHORT fWait,
  5470.                                PBYTE pbDataBuf,
  5471.                                PUSHORT pcbData);
  5472. APIRET16 APIENTRY16 DosMonWrite(PBYTE pbOutBuf, PBYTE pbDataBuf,
  5473.                                 USHORT cbData);
  5474.  
  5475. #define DosGetInfoSeg    DOS16GETINFOSEG
  5476. APIRET16 APIENTRY16 DosGetInfoSeg(PSEL pselGlobal, PSEL pselLocal);
  5477.  
  5478. #pragma pack(2)
  5479. typedef struct _GINFOSEG { /* gis */
  5480.         ULONG   time; ULONG   msecs; UCHAR   hour;
  5481.         UCHAR   minutes; UCHAR   seconds; UCHAR   hundredths;
  5482.         USHORT  timezone; USHORT cusecTimerInterval; UCHAR   day;
  5483.         UCHAR   month; USHORT  year; UCHAR   weekday;
  5484.         UCHAR   uchMajorVersion; UCHAR uchMinorVersion;
  5485.         UCHAR   chRevisionLetter; UCHAR   sgCurrent;
  5486.         UCHAR   sgMax; UCHAR   cHugeShift;
  5487.         UCHAR   fProtectModeOnly; USHORT pidForeground;
  5488.         UCHAR   fDynamicSched; UCHAR   csecMaxWait;
  5489.         USHORT  cmsecMinSlice; USHORT  cmsecMaxSlice;
  5490.         USHORT  bootdrive; UCHAR   amecRAS[32];
  5491.         UCHAR   csgWindowableVioMax; UCHAR   csgPMMax;
  5492. } GINFOSEG;
  5493. typedef GINFOSEG *PGINFOSEG;
  5494.  
  5495. static PGINFOSEG gdt;
  5496.  
  5497. #define MAKEPGINFOSEG(sel)  ((PGINFOSEG)MAKEP(sel, 0))
  5498. #define MAKEPLINFOSEG(sel)  ((PLINFOSEG)MAKEP(sel, 0))
  5499.  
  5500. #pragma pack(2)
  5501. typedef struct _keypacket
  5502.   {
  5503.    USHORT     mnflags;
  5504.    KBDKEYINFO cp;
  5505.    USHORT     ddflags;
  5506.   } KEYPACKET;
  5507.  
  5508.  
  5509. #define RELEASE     0x40
  5510. #define CTL_F10_KEY 103
  5511. #define F11_KEY     133
  5512.  
  5513. #pragma stack16(8192)
  5514. #pragma seg16(HKBD)
  5515. #pragma seg16(MONIN)
  5516. #pragma seg16(MONOUT)
  5517. #pragma seg16(KEYPACKET)
  5518.  
  5519. static HKBD KBDHandle = (HKBD)0;
  5520. static PGINFOSEG _Seg16 gdt;
  5521. static MONIN monInbuf = {0};
  5522. static MONOUT monOutbuf = {0};
  5523. static HEV hevThreadDone = (HEV)0;
  5524.  
  5525. static void _System keyboard_monitor(ULONG Dummy);
  5526.  
  5527. int main(int argc, char *argv[], char *envp[])
  5528. {
  5529.  SEL gdt_descriptor, ldt_descriptor;
  5530.  PID pidKeybrd;
  5531.  
  5532.  monInbuf.cb  = sizeof(MONIN);
  5533.  monOutbuf.cb = sizeof(MONOUT);
  5534.  
  5535.  DosGetInfoSeg(&gdt_descriptor, &ldt_descriptor);
  5536.  
  5537.  gdt = MAKEPGINFOSEG(gdt_descriptor);
  5538.  
  5539.  DosMonOpen ( "KBD$", &KBDHandle );
  5540.  
  5541.  DosCreateEventSem(NULL, &hevThreadDone,0,FALSE);
  5542.  
  5543.  if (DosCreateThread(&pidKeybrd, &keyboard_monitor, 0L, 2L, 12000L))
  5544.          DosExit(EXIT_PROCESS,0);
  5545.  
  5546.  DosWaitEventSem(hevThreadDone, (ULONG)SEM_INDEFINITE_WAIT);
  5547.  DosMonClose(KBDHandle);
  5548.  
  5549.  DosBeep(100,100);
  5550.  
  5551.  DosExit(EXIT_PROCESS,0);
  5552.  return(0);
  5553. }
  5554.  
  5555.  
  5556. static void _System keyboard_monitor(ULONG Dummy)
  5557. {
  5558.  KEYPACKET keybuff;
  5559.  USHORT count;
  5560.  
  5561.  DosSetPrty(PRTYS_THREAD, PRTYC_TIMECRITICAL,0, 0);
  5562.  
  5563.  DosMonReg( KBDHandle, (PBYTE)&monInbuf, (PBYTE)&monOutbuf,
  5564.             MONITOR_BEGIN, gdt->sgCurrent);
  5565.  
  5566.  DosSetPrty(PRTYS_THREAD, PRTYC_REGULAR,0, 0);
  5567.  
  5568.  for(keybuff.cp.chChar = 0; ; )
  5569.    {
  5570.     count = sizeof(keybuff);
  5571.     DosMonRead( (PBYTE)&monInbuf, IO_WAIT, (PBYTE)&keybuff, &count);
  5572.     if (!(keybuff.ddflags & RELEASE))
  5573.        {
  5574.         if(keybuff.cp.chChar == 0)
  5575.           {
  5576.            switch (keybuff.cp.chScan)
  5577.              {
  5578.               case CTL_F10_KEY   :
  5579.               case F11_KEY       :
  5580.                  DosPostEventSem(hevThreadDone);
  5581.                  DosExit(EXIT_THREAD,0);
  5582.                  break;
  5583.              }
  5584.           }
  5585.        }
  5586.     DosMonWrite((PBYTE)&monOutbuf,(PBYTE)&keybuff,count);
  5587.    }
  5588. }
  5589.  
  5590. Credit:  Mario Semo 
  5591.  
  5592.  
  5593. ΓòÉΓòÉΓòÉ 9.9. How do I determine what file system a drive uses? ΓòÉΓòÉΓòÉ
  5594.  
  5595. 16 bit:  DosQFsInfo().
  5596. 32 but:  DosQueryFSInfo()
  5597.  
  5598. The folling little 16 bit program produces the following output on my computer: 
  5599.  
  5600.  LOCAL  C:  FAT
  5601.  LOCAL  D:  HPFS
  5602.  LOCAL  E:  HPFS
  5603.  LOCAL  F:  FAT
  5604.  REMOTE P:  LAN   \\SERV1\C$
  5605.  REMOTE Q:  LAN   \\SERV1\D$
  5606.  REMOTE R:  LAN   \\SERV1\E$
  5607.  
  5608. Code.... 
  5609.  
  5610.  /* qdisk.c */
  5611.  #define INCL_NOPM
  5612.  #define INCL_DOS
  5613.  #include <os2.h>
  5614.  #include <stdio.h>
  5615.  #include <stdlib.h>
  5616.  
  5617.  
  5618.  void errorRC(USHORT rc)
  5619.  {
  5620.      char msg[256];
  5621.      USHORT bc;
  5622.      if(0 != (rc=DosGetMessage(NULL, 0, msg, sizeof(msg), rc,
  5623.                                "OSO001.MSG", &bc))) {
  5624.          printf("SYS%04u: Unable to access OSO001.MSG\n", rc);
  5625.      }
  5626.      else DosWrite(2, msg, bc, &bc);
  5627.  }
  5628.  
  5629.  void qdisk(char drv)
  5630.  {
  5631.      USHORT rc, len;
  5632.      char dev[3];
  5633.      void *buf;
  5634.      char *p;
  5635.  
  5636.      if(drv < 'C')
  5637.          return;
  5638.      sprintf(dev, "%c:", drv);
  5639.      buf = malloc(2048);
  5640.      len = 2048;
  5641.      rc = DosQFSAttach(dev, 0, FSAIL_QUERYNAME, buf, &len, 0L);
  5642.      if(rc){
  5643.          errorRC(rc);
  5644.          return;
  5645.      }
  5646.      switch((*(PUSHORT)buf)){
  5647.          case FSAT_CHARDEV  : printf("CHAR   "); break;
  5648.          case FSAT_PSEUDODEV: printf("DEV    "); break;
  5649.          case FSAT_LOCALDRV : printf("LOCAL  "); break;
  5650.          case FSAT_REMOTEDRV: printf("REMOTE "); break;
  5651.          default: printf("Unknown "); break;
  5652.      }
  5653.      p = buf;
  5654.      p += sizeof(USHORT);    /* itype */
  5655.      printf("%-3s ", p+sizeof(USHORT));
  5656.      p += (sizeof(USHORT) + (*(USHORT *)p) + 1);    /* cbName */
  5657.      printf("%-8s ", p+sizeof(USHORT));
  5658.      p += (sizeof(USHORT) + (*(USHORT *)p) + 1);    /* cbFSDName */
  5659.      if((*(USHORT *)p))                             /* cbFSAData */
  5660.          printf("%s", p+sizeof(USHORT));
  5661.      printf("\n");
  5662.      free(buf);
  5663.  }
  5664.  
  5665.  void cdecl main(void)
  5666.  {
  5667.      char drv;
  5668.      USHORT usDisk;
  5669.      ULONG ulDrives;
  5670.      DosQCurDisk(&usDisk, &ulDrives); /* gets current drive */
  5671.      for (drv = 'A'; drv <= 'Z'; drv++) {
  5672.          if (ulDrives & 1)              /* if the drive bit is set, */
  5673.              qdisk(drv);
  5674.          ulDrives >>= 1;
  5675.      }
  5676.  }
  5677.  
  5678. ps: DosQSysInfo() will return the max path length that your version of OS/2 
  5679. supports.  But since this API is specific to OS/2,  and not to a particular 
  5680. drive,  it does not answer your original question. 
  5681.  
  5682. Credit: Peter Fitzsimmons 
  5683.  
  5684.  
  5685. ΓòÉΓòÉΓòÉ 9.10. How do I get the error message from a DOS API call? ΓòÉΓòÉΓòÉ
  5686.  
  5687. For DOSAPI calls, you can issue a DosGetMessage as follows: 
  5688.  
  5689.    RC = DosXXXX(...);
  5690.    DosGetMessage(NULL,0,Msg,sizeof(Msg),RC,"OSO001.MSG",&Msg_Length);
  5691.  
  5692. Credit:  Ken Kahn 
  5693.  
  5694.  
  5695. ΓòÉΓòÉΓòÉ 9.11. How do I set an exception handler? ΓòÉΓòÉΓòÉ
  5696.  
  5697. /*
  5698.  * Simple example of an exception handler
  5699.  */
  5700.  
  5701. #define INCL_DOS
  5702. #include <os2.h>
  5703. #include <setjmp.h>
  5704. #include <stdio.h>
  5705. #include <string.h>
  5706.  
  5707. extern int main(void);
  5708.  
  5709.  /*
  5710.  * Exception registration record.  Stored on stack, with first
  5711.  * pointer to next registeration record, second pointer to
  5712.  * exception handler, and the rest defined by the author of
  5713.  * the exception handler.
  5714.  */
  5715.  
  5716. typedef struct {
  5717.   struct _EXCEPTIONREGISTRATIONRECORD * volatile prev_structure;
  5718.    _ERR * volatile ExceptionHandler;
  5719.    jmp_buf env;
  5720. } MYEXCEPTIONREGISTRATIONRECORD, *PMYEXCEPTIONREGISTRATIONRECORD;
  5721.  
  5722. /*
  5723.  * Exception handler that returns traps via longjmp().
  5724.  */
  5725.  
  5726. extern ULONG APIENTRY MyExceptionHandler
  5727.     (PEXCEPTIONREPORTRECORD pReportRecord,
  5728.     PEXCEPTIONREGISTRATIONRECORD pRegRecord,
  5729.     PCONTEXTRECORD pContextRecord, PVOID pReserved)
  5730. {
  5731.   ULONG rc = XCPT_CONTINUE_SEARCH;
  5732.  
  5733.   if (pReportRecord->ExceptionNum == XCPT_ACCESS_VIOLATION)
  5734.     longjmp(((PMYEXCEPTIONREGISTRATIONRECORD) pRegRecord)->env, -1);
  5735.  
  5736.   /*
  5737.    * If we return to here then we could not handle the exception.
  5738.    */
  5739.  
  5740.   return rc;
  5741. }
  5742.  
  5743. extern BOOL Trapper(PSZ psz)
  5744. {
  5745.   MYEXCEPTIONREGISTRATIONRECORD myExceptionRegRecord;
  5746.  
  5747.   /*
  5748.    * Insert my exception handler into the chain.
  5749.    */
  5750.  
  5751.   myExceptionRegRecord.prev_structure = NULL;
  5752.   myExceptionRegRecord.ExceptionHandler = MyExceptionHandler;
  5753.   DosSetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord);
  5754.  
  5755.   if (setjmp(myExceptionRegRecord.env))
  5756.     goto OnException;
  5757.  
  5758.   /*
  5759.    * Now go about my business in safety.
  5760.    */
  5761.  
  5762.   if (strlen(psz))
  5763.     printf("Trapper says okay to '%s'\n", psz);
  5764.   else
  5765.     printf("Trapper says it is empty\n");
  5766.  
  5767.   /*
  5768.    * I'm done, so unchain my exception handler.
  5769.    */
  5770.  
  5771.   DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD)&myExceptionRegRecord)
  5772.  
  5773.   return TRUE;
  5774.  
  5775.   /*
  5776.    * The code below is only executed if a trap occurs.
  5777.    */
  5778.  
  5779. OnException:
  5780.   printf("Trapper says 'ouch!'\n");
  5781.  
  5782.   DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD)&myExceptionRegRecord)
  5783.  
  5784.   return FALSE;
  5785. }
  5786.  
  5787. extern int main()
  5788. {
  5789.   Trapper("Hello");
  5790.   Trapper(NULL);
  5791.   Trapper("");
  5792.   Trapper((PSZ) 42);
  5793.   Trapper("Goodbye");
  5794.  
  5795.   return 0;
  5796. }
  5797.  
  5798. Credit:  Dan Kehn 
  5799.  
  5800.  
  5801. ΓòÉΓòÉΓòÉ 9.12. How can I determine a diskette format and if a disk is in a drive? ΓòÉΓòÉΓòÉ
  5802.  
  5803. Let's have a snippet from one of my functions: 
  5804.  
  5805. The 'ifdef M_I386's mean CSet/2 
  5806.  
  5807. --- snip --- 
  5808.  
  5809. EXPORT int GetFileSysAttach ( char cDrv, PVOID pInfo, UnsInt cbInfo )
  5810. {
  5811. CHAR szFileSys [4];
  5812.  
  5813.   szFileSys [0] = (CHAR) toupper ( cDrv );
  5814.   szFileSys [1] = ':';
  5815.   szFileSys [2] = '\0';
  5816.  
  5817.   DosError ( EXCEPTION_DISABLE );
  5818.  
  5819. #ifdef M_I386
  5820.   Errno = DosQueryFSAttach ( szFileSys, 0, FSAIL_QUERYNAME, pInfo, &cbInfo );
  5821. #else
  5822.   Errno = DosQFSAttach ( szFileSys, 0, FSAIL_QUERYNAME, pInfo, &cbInfo, 0L );
  5823. #endif
  5824.  
  5825.   DosError ( EXCEPTION_ENABLE );
  5826.   return Errno ? -1 : 0;
  5827. }
  5828.  
  5829.  
  5830. EXPORT    int    GetFileSysInfo ( PSZ pszFileSys, PFSysInfo pfsi )
  5831. {
  5832. USHORT    idDrv;
  5833. FSALLOCATE fsal;
  5834. FSINFO    fsinfo;
  5835. #ifdef M_I386
  5836. PFSQBUFFER2 fsq = NULL;
  5837. #else
  5838. PFSQBUFFER  fsq = NULL;
  5839. PUSHORT     pus;
  5840. #endif
  5841. CHAR    hbuf [L_FILENAME];
  5842. PCHAR   pch;
  5843. #ifndef _MT
  5844. BOOL    fProt = ProtectedMode ();
  5845. #else
  5846. #define fProt TRUE
  5847. #endif
  5848.  
  5849.   idDrv = tolower ( *pszFileSys ) - ('a' - 1);
  5850.  
  5851.   DosError ( EXCEPTION_DISABLE );
  5852.  
  5853.   if ( ! (Errno = DosQFSInfo ( idDrv, 1, (PBYTE) &fsal, sizeof ( fsal ) )) )
  5854.     Errno = DosQFSInfo ( idDrv, 2, (PBYTE) &fsinfo, sizeof ( fsinfo ) );
  5855.  
  5856.   DosError ( EXCEPTION_ENABLE );
  5857.  
  5858.   if ( Errno )
  5859.   {
  5860.     if ( Errno == ERROR_NO_VOLUME_LABEL )
  5861.       memset ( &fsinfo, 0, sizeof (fsinfo) );
  5862.     else
  5863.       return -1; // No disk inserted
  5864.   }
  5865.  
  5866.   if ( fProt )
  5867.   {
  5868.     if ( GetFileSysAttach ( (CHAR) (idDrv + 'a' - 1), hbuf, L_FILENAME ) )
  5869.       return -1;
  5870.  
  5871. #ifdef M_I386
  5872.     fsq = (PFSQBUFFER2) hbuf;
  5873. #else
  5874.     fsq = (PFSQBUFFER) hbuf;
  5875. #endif
  5876.   }
  5877.  
  5878.   DosError ( EXCEPTION_ENABLE );
  5879.  
  5880.   ...
  5881.  
  5882. --- snap --- 
  5883.  
  5884. I think it's more than you want, the fsal-struct contains the size information, 
  5885. but I think if you want to retrieve ALL information about a logical drive 
  5886. that's what you need. 
  5887.  
  5888. Credit:  Rainer Prem 
  5889.  
  5890.  
  5891. ΓòÉΓòÉΓòÉ 9.13. What do all those keywords mean when making a DLL? ΓòÉΓòÉΓòÉ
  5892.  
  5893. Okay, with the help of some of my peers, I've solved the mystery surrounding 
  5894. the seemingly redundant SINGLE/MULTIPLE and SHARED/NONSHARED attributes. 
  5895.  
  5896. First, some prep up work... 
  5897.  
  5898. Every DLL needs and gets a data segment ("automatic data segment"). It is the 
  5899. place where the DLL stores all its STATIC data--basically the data declared in 
  5900. the DLL module but declared outside any function AND (I venture) variables 
  5901. declared STATIC within a DLL function as well. The STACK is NOT!! part of a 
  5902. DLL's automatic data segment (thoug it seems to be for an EXE). The stack that 
  5903. is used when 'running' a DLL function is that of the calling thread. 
  5904.  
  5905. Now here's the clincher... 
  5906.  
  5907. DLLs CAN ALSO HAVE ADDITIONAL DATA SEGMENTS!! (as can EXEs, I imagine) 
  5908.  
  5909. Bingo! Now we understand why there are two different sets of 
  5910. attributes--specifically, NONE/SINGLE/MULTIPLE and SHARED/NONSHARED. Though 
  5911. they basically do the same thing, they APPLY to different things. 
  5912.  
  5913. NONE/SINGLE/MULTIPLE 
  5914.           applies to the one and only default data segment. This is the data 
  5915.           segment that is "automatically" created for your DLL (or EXE). I 
  5916.           imagine that for 90% of the DLLs written, this is the only type of 
  5917.           data segment that exists. Whether or not this data segment is shared 
  5918.           or whether a private copy is created for each linking application is 
  5919.           A DIRECT FUNCTION OF THIS ATTRIBUTE--'SINGLE'=it's shared, 
  5920.           'MULTIPLE'=everyone get's his own copy. 
  5921.  
  5922. SHARED/NONSHARED 
  5923.           This SETS THE DEFAULT!! FOR ALL DATA SEGMENTS other than the 
  5924.           "automatic" data segment. DEFAULT is the key word, because you can 
  5925.           specify, through the SEGMENTS statement, the characteristics of these 
  5926.           additional segments on an individual basis (which in all certainty, 
  5927.           override this value.) 
  5928.  
  5929. So...to answer my own question 
  5930.  
  5931. >could {someone} explain what the following statements would
  5932. >produce:
  5933. >
  5934. >        DATA MULTIPLE SHARED
  5935.  
  5936. Every application which links to the DLL will have it's own private copy of the 
  5937. automatic data segment. If the DLL has no additional data segments, the SHARED 
  5938. keyword is meaningless and can be omitted. If there are additional data 
  5939. segments, only one copy of each will exist and they will be shared by all 
  5940. applications (unless a SEGMENTS statement follows which overrides this default 
  5941. for a specific segment) 
  5942.  
  5943. >        or
  5944. >        DATA SINGLE NONSHARED
  5945.  
  5946. Every application which links to the DLL will share a single automatic data 
  5947. segment (hence, each app that affects the DLL STATIC data will affect it for 
  5948. all apps). If there are no additional data segments, the NONSHARED keyword is 
  5949. meaningless and can be omitted. If there are, a private copy will be created 
  5950. for each app (unless overriden by a SEGMENTS statement). 
  5951.  
  5952. Note that in the absence of BOTH a SINGLE/MUTLIPLE and SHARED/NONSHARED 
  5953. keyword, the default is for ALL data segments (automatic and additional ones) 
  5954. to be shared (i.e., only one copy). In the absence of one OR the other, but not 
  5955. both, the property of ALL data segments are mandated by the single keyword. In 
  5956. other words, 
  5957.  
  5958. DATA SINGLE
  5959.  and
  5960. DATA SHARED
  5961.  
  5962. do the same exact thing. 
  5963.  
  5964. Credit:  John Cortell 
  5965.  
  5966.  
  5967. ΓòÉΓòÉΓòÉ 9.14. Where can I find serial port sample code? ΓòÉΓòÉΓòÉ
  5968.  
  5969. Q)  Does anyone have any C sample code showing how to use the serial port under 
  5970. OS/2 using DosOpen() and DosDevIoCtl()? 
  5971.  
  5972. A) As a matter of fact, yes.  :-) 
  5973.  
  5974. -=-= extracted from a silly & specialized program =-=-=-=-==-=-=
  5975.  
  5976. /* dtp.c -- D-dial Terminal Program: the first hack */
  5977.  
  5978. //-- an annoying detail
  5979.  
  5980. #define INCL_BASE
  5981. #define INCL_DOSDEVIOCTL  /* docs lie, this is NOT included by BASE */
  5982. #include <os2.h>
  5983.  
  5984. //-- initialization (in main() as written)
  5985.  
  5986.     HFILE portFd;
  5987.     ULONG action;
  5988.  
  5989.     if (DosOpen("COM1", &portFd, &action, 0, FILE_NORMAL, FILE_OPEN,
  5990.       OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE, 0) != 0) {
  5991.         fprintf(stderr, "Open of COM1 failed\n");
  5992.         goto error0;
  5993.     }
  5994.  
  5995.     {    DCBINFO di;
  5996.         ULONG dummy;
  5997.  
  5998.         dummy = sizeof(di);
  5999.         if (DosDevIOCtl(portFd, IOCTL_ASYNC, ASYNC_GETDCBINFO, 0, 0, 0,
  6000.                         &di, sizeof(di), &dummy) != 0)
  6001.             fprintf(stderr, "DosDevIOCtl failed\n");
  6002.         else {
  6003.             fprintf(stderr, "Timeouts: read = %u, write = %u\n",
  6004.                     di.usWriteTimeout, di.usReadTimeout);
  6005.             fprintf(stderr, "Flag bytes: %02x, %02x, %02x\n",
  6006.                     di.fbCtlHndShake, di.fbFlowReplace, di.fbTimeout);
  6007.         }
  6008.         di.fbTimeout = (di.fbTimeout & ~(3 << 1)) | (2 << 1);
  6009.                                           /* rcv = wait-for-something */
  6010.         di.usReadTimeout = 250;
  6011.         dummy = sizeof(di);
  6012.         if (DosDevIOCtl(portFd, IOCTL_ASYNC, ASYNC_SETDCBINFO,
  6013.                         &di, sizeof(di), &dummy, 0, 0, 0) != 0)
  6014.             fprintf(stderr, "DosDevIOCtl failed to set parameters!\a\n");
  6015.     }
  6016.  
  6017.     if (initSerialOutput(portFd) != 0)
  6018.         goto error1;
  6019.  
  6020. //-- the "running" variable is sort of a relic, I think
  6021.  
  6022.     running = 1;
  6023.     if (_beginthread(serialInputThread, 0, 8192, (void *)portFd) < 0) {
  6024.         fprintf(stderr, "can't start serial input thread\n");
  6025.         goto error2;
  6026.     }
  6027.  
  6028.     if (_beginthread(serialOutputThread, 0, 8192, (void *)portFd) < 0) {
  6029.         fprintf(stderr, "can't start serial output thread\n");
  6030.         goto error2;
  6031.     }
  6032.  
  6033. //-- wrapup code
  6034.  
  6035.     shutdownSerialOutput();
  6036.     DosClose(portFd);
  6037.  
  6038. //-- the rest of this lives outside of main()...
  6039.  
  6040. //-- input side: gory details omitted
  6041.  
  6042. //-- the port has been setup in "wait for something" mode, so we can request
  6043. //-- more than one character at a time without blocking until the buffer is
  6044. //-- full.  At least, I *think* that's working now: this is used with 300 baud
  6045. //-- systems, so it's hard to tell <g>.  At least it isn't blocking until the
  6046. //-- buffer is filled...
  6047.  
  6048. /*  serialInputThread -- reads port, writes to text window
  6049. *
  6050. *   arg is the port's handle for reading
  6051. */
  6052. void serialInputThread(void *arg)
  6053. {
  6054.     HFILE inFd = (long)arg;
  6055.     FILE *logFile;
  6056.     UCHAR buf[10];
  6057.  
  6058.     ParserState ps = {0};
  6059.  
  6060.     logFile = fopen("dtp.log", "ab");
  6061.  
  6062.     for ( ; ; )
  6063.     {
  6064.         ULONG n;
  6065.         if (DosRead(inFd, buf, 10, &n) == 0)
  6066.         {
  6067.             ULONG i;
  6068.             for (i = 0; i <n; ++i)
  6069.             {
  6070.                 if (logFile != 0)
  6071.                     putc(buf[i], logFile);
  6072.                 if (runParser(&ps, buf[i]) != 0)
  6073.                     postChar(buf[i]);
  6074.             }
  6075.         }
  6076.     }
  6077. }
  6078.  
  6079. /* output side: I rather like this arrangement using queues
  6080.    except that I'd prefer an anonymous queue.
  6081.    For this, having the queue named in the
  6082.    filesystem's name space is at best a minor annoyance. */
  6083.  
  6084. /* * * *    SerialOutput subsystem
  6085. */
  6086.  
  6087. #define MAX_CHUNK_SIZE 50
  6088.  
  6089. typedef struct
  6090. {
  6091.     USHORT nUsed;
  6092.     UCHAR buf[MAX_CHUNK_SIZE];
  6093. } SO_CHUNK;
  6094.  
  6095. #define NUM_SO_CHUNKS 6
  6096.  
  6097.  
  6098. HQUEUE soQueue, freeQueue;
  6099.  
  6100.  
  6101. int initSerialOutput (HFILE outFd)
  6102. {
  6103.     (void) outFd;     /* reserved for more general version */
  6104.  
  6105.     if (DosCreateQueue
  6106.        (&soQueue, QUE_FIFO, "\\queues\\dtp\\soQueue") != 0)
  6107.     {
  6108.         fprintf(stderr, "Failed to create serial output queue\n");
  6109.         goto error0;
  6110.     }
  6111.     if (DosCreateQueue
  6112.        (&freeQueue, QUE_FIFO, "\\queues\\dtp\\freeQueue") != 0)
  6113.     {
  6114.         fprintf(stderr, "Failed to create serial free queue\n");
  6115.         goto error1;
  6116.     }
  6117.     {   SO_CHUNK *p = malloc(sizeof(SO_CHUNK) * NUM_SO_CHUNKS);
  6118.         int i;
  6119.         if (p == 0)
  6120.         {
  6121.             fprintf(stderr,
  6122.             "Failed to allocate memory for serial chunks\n");
  6123.             goto error1;
  6124.         }
  6125.         for (i = NUM_SO_CHUNKS; 0 < i; --i)
  6126.             if (DosWriteQueue(freeQueue, 0, sizeof(SO_CHUNK), p++, 0)
  6127.             != 0)
  6128.             {
  6129.                 fprintf(stderr, "Failed to initialize free queue\n");
  6130.                 goto error1;
  6131.             }
  6132.     }
  6133.  
  6134.     return 0;
  6135.  
  6136. error1:
  6137.     DosCloseQueue(soQueue);
  6138. error0:
  6139.     return -1;
  6140. }
  6141.  
  6142.  
  6143. void shutdownSerialOutput(void)
  6144. {
  6145.     DosCloseQueue(freeQueue);
  6146.     DosCloseQueue(soQueue);
  6147. }
  6148.  
  6149.  
  6150. void writeSerial(UCHAR const *buf, USHORT n)
  6151. {
  6152.  
  6153.     while (0 < n)
  6154.     {
  6155.         REQUESTDATA rd;
  6156.         ULONG dataLength;
  6157.         PVOID data;
  6158.         BYTE priority;
  6159.  
  6160.         if (DosReadQueue(freeQueue, &rd, &dataLength, &data,
  6161.                          0, DCWW_WAIT, &priority, 0) == 0)
  6162.         {
  6163.             SO_CHUNK *sc = data;
  6164.             USHORT m = MAX_CHUNK_SIZE;
  6165.             if (n < m)
  6166.                 m = n;
  6167.             memcpy(sc->buf, buf, m);
  6168.             sc->nUsed = m;
  6169.             DosWriteQueue(soQueue, 0, sizeof(SO_CHUNK), sc, 0);
  6170.             buf += m;
  6171.             n -= m;
  6172.         }
  6173.     }
  6174. }
  6175.  
  6176.  
  6177. void writeSerialString(UCHAR const *buf)
  6178. {
  6179.     writeSerial(buf, strlen(buf));
  6180. }
  6181.  
  6182.  
  6183. void serialOutputThread(void *arg)
  6184. {
  6185.     HFILE outFd = (long)arg;
  6186.     REQUESTDATA rd;
  6187.     ULONG dataLength;
  6188.     PVOID data;
  6189.     BYTE priority;
  6190.  
  6191.     for ( ; ; )
  6192.     {
  6193.         if (DosReadQueue(soQueue, &rd, &dataLength, &data,
  6194.                          0, DCWW_WAIT, &priority, 0) == 0)
  6195.         {
  6196.             if (rd.ulData == 0) {     /* simple data block */
  6197.                 ULONG dummy;
  6198.                 SO_CHUNK *sc = data;
  6199.                 DosWrite(outFd, sc->buf, sc->nUsed, &dummy);
  6200.                 DosWriteQueue(freeQueue, 0, sizeof(SO_CHUNK), sc, 0);
  6201.             }
  6202.             else
  6203.                 ;  /* anything else is a test, ignore it */
  6204.         }
  6205.     }
  6206. }
  6207.  
  6208. The intention was that control messages could be posted to the queue using null 
  6209. data packets (passing the actual message in the REQUESTDATA.ulData field); 
  6210. these would allow for controlling the port's baud rate and other settings. 
  6211. This seems to work under 2.0, and even appears to be intended to work (Deitel & 
  6212. Kogan's description), but I haven't done anything with it yet, as you can see. 
  6213. Haven't needed the facility yet... 
  6214.  
  6215. Credit:  Martin Maney 
  6216.  
  6217.  
  6218. ΓòÉΓòÉΓòÉ 9.15. How do I disable <Ctrl><Alt><Del>? ΓòÉΓòÉΓòÉ
  6219.  
  6220. You need to do a DosDevIOCtl with Category 4, Function 56. Use a 0xFFFF for the 
  6221. Hot Key ID.  Set the other values to 0. This will toggle <Ctrl><Alt><Del> and 
  6222. <Ctrl><Esc> and <Alt><Esc> on then off on the next call. Note that this does a 
  6223. little more than what you want since it also disables <Ctrl><Esc> and 
  6224. <Alt><Esc> so you may run into problems getting around your different sessions 
  6225. when you've got it disabled. Other than this there is NO WAY to disable 
  6226. <Ctrl><Alt><Del> under OS/2 and believe me, people have tried! 
  6227.  
  6228. Credit:  Mike Brown 
  6229.  
  6230.  
  6231. ΓòÉΓòÉΓòÉ 9.16. Why doesn't printf() produce output when I expect it to? ΓòÉΓòÉΓòÉ
  6232.  
  6233. For historical reasons, most Unix C libraries' stdio default to using line 
  6234. buffered streams, whereas most DOS and OS/2 C libraries' stdio default to using 
  6235. fully buffered streams.  ANSI C species that standard output should be line 
  6236. buffered when connected to an interactive device, but not all libraries are 
  6237. ANSI compliant.  You can control the buffering algorithm used for a particular 
  6238. stream with the setvbuf() function. 
  6239.  
  6240. If you didn't understand that paragraph, read on. 
  6241.  
  6242. printf() is part of the Standard I/O (stdio) library, which uses buffered 
  6243. streams for file IO.  ANSI C specifies three algorithms for deciding when to 
  6244. flush the buffer (i.e. when to print buffered data to the file): 
  6245.  
  6246. o not buffered.  Data is flushed to the file as soon as possible, usually 
  6247.   immediately after being received. 
  6248. o line buffered.  Data is flushed to the file when a newline is received (and 
  6249.   the newline is also flushed). 
  6250. o fully buffered.  Data is flushed to the file when the buffer is full. 
  6251.  
  6252. Buffered data is always flushed when the stream is closed or when fflush() is 
  6253. called.  Since standard output is flushed when main() exits, all data printed 
  6254. with printf() will appear at that time, if it has not already.  However, ANSI C 
  6255. does not require that a stream be flushed when scanf() is called on it. 
  6256. Therefore, if you print to a fully buffered stream and then request input on 
  6257. it, it is likely that the input will be read before the printed data appears. 
  6258.  
  6259. You can control the buffering algorithm used for a particular stream with the 
  6260. setvbuf() function.  For example, the statement setvbuf(stdout, NULL, _IOLBF, 
  6261. BUFSIZ) sets standard output to be line-buffered, which is what most Unix 
  6262. programmers expect.  Any decent C reference will cover all of this material. 
  6263.  
  6264. [Colin Jensen...] 
  6265.  
  6266. After reading one too many bug reports about this phenomena, the gcc/2 
  6267. maintainer changed its stdout to not-buffered whenever stdout is interactive. 
  6268. When stdout is sent to a pipe or file, stdout is still fully-buffered. 
  6269.  
  6270.  
  6271. ΓòÉΓòÉΓòÉ 9.17. How do I write an OS/2 device driver? ΓòÉΓòÉΓòÉ
  6272.  
  6273. The preferred method is to buy the OS/2 device driver kit (DDK) from IBM.  It 
  6274. contains samples for display, printer, SCSI, and other drivers. You can develop 
  6275. kernel and PM drivers.    NOTE:  The kernel debugger comes with the IBM Toolkit, 
  6276. sold separately. 
  6277.  
  6278. There's a book called Writing OS/2 2.0 Device Drivers in C from 
  6279. Van Nostrand-Reinhold and also IBM's flood of printed material. 
  6280.  
  6281. As reference to SCSI programming, check SCSI Programming FAQ, available at 
  6282. ftp.regent.e-technik.tu-muenchen.de 
  6283.  
  6284.  
  6285. RelatedInformation :
  6286.  
  6287. What are good reference books for programming in OS/2 and PM?
  6288.  
  6289.  
  6290. ΓòÉΓòÉΓòÉ 9.18. How do I change the master environment? ΓòÉΓòÉΓòÉ
  6291.  
  6292. Quick and simple answer: you don't. 
  6293.  
  6294. In OS/2 it is literally impossible for you to change the master environment 
  6295. from one of your programs.    To be able to do so would fatally disrupt the 
  6296. programming paradigm that has existed for ages:  Your program does not alter 
  6297. the master environment. Your program is the slave, not the master.  Therefore, 
  6298. no capability was built into OS/2 to facilitate this. 
  6299.  
  6300. There is, however, a kludge. 
  6301.  
  6302. As you know, a .CMD file can alter the master environment.  This is the nature 
  6303. of batch files (ok, so I'm a MS-DOG dinosaur and still call them batch files 
  6304. instead of command files or scripts).  Therefore, you can place a sequence of 
  6305. commands in the batch file that will take your program's output and alter the 
  6306. environment of your current shell. 
  6307.  
  6308. That's as close as you are gonna get to the master environment.  You can always 
  6309. create your own sort of environment variables, in the form of shared memory or 
  6310. named pipes. 
  6311.  
  6312.  
  6313. ΓòÉΓòÉΓòÉ 9.19. What is the best way to communicate between processes? ΓòÉΓòÉΓòÉ
  6314.  
  6315. There is more than one way - and you get to decide which is right for you! 
  6316.  
  6317. Shared Memory 
  6318.  
  6319. Shared memory is pretty self-explanatory.  It is a memory segment that is 
  6320. allocated by one program, and then made available to other programs. When all 
  6321. the programs are done with it, then it is disposed of.  You can name shared 
  6322. memory.  So if you want two programs to communicate, then let them look for 
  6323. memory with the same name and communicate that way. 
  6324.  
  6325. Named Pipes 
  6326.  
  6327. Named pipes are a lot like shared memory, but think of a named pipe as a file 
  6328. instead of a single block of memory.  Each process can create, read, write, and 
  6329. destroy a named pipe, much like you can a file. 
  6330.  
  6331. The difference between named pipes and shared memory is that a named pipe link 
  6332. is hot; With shared memory, data can be left in (as a sleeper, if you will), 
  6333. process 1 exits, process 2 accesses the data in memory, then deallocates the 
  6334. memory.  With shared memory, a process doesn't even have to exist to leave a 
  6335. message for another process. 
  6336.  
  6337. Queues 
  6338.  
  6339. An OS/2 queue is either a standard First-In First-Out (FIFO) queue 
  6340. data/operation structure, a LIFO structure, or a user-based-priority structure. 
  6341. However, OS/2 makes it unique because more than one process (or thread) can 
  6342. write to this queue. 
  6343.  
  6344.  
  6345. Related Information:
  6346.  
  6347. What is the best way to communicate between threads?
  6348.  
  6349.  
  6350. ΓòÉΓòÉΓòÉ 9.20. What is the best way to communicate between threads? ΓòÉΓòÉΓòÉ
  6351.  
  6352. The best way to communicate between threads is sometimes also the best way to 
  6353. communicate between processes.  However, when communicating between threads you 
  6354. can utilize two (very important) techniques: 
  6355.  
  6356. Semaphores 
  6357.  
  6358. In order to share application resources, and not write to the same space at the 
  6359. same time, you have to have some kind of flags that tell the thread when it 
  6360. should stop, when it should keep on going, and so on. Semaphores provide this 
  6361. capability.  Semaphores are not for passing data.  They merely exist as simple 
  6362. flags between threads and you should treat them as such. 
  6363.  
  6364. Global Variables 
  6365.  
  6366. "Hey Jeff - I thought this was supposed to be about nifty OS/2-specific 
  6367. tricks!"  It is!  You can now use those old nasty things, global variables, in 
  6368. new ways.  In conjunction with semaphores, you can pass data very easily 
  6369. between threads with global variables.  Here's a simple example: 
  6370.  
  6371.  1. Create a global variable called PassData. 
  6372.  2. Create a semaphore called OkToPassData. 
  6373.  3. Create a semaphore called DataPassed. 
  6374.  4. Have two threads work at the same time: 
  6375.  
  6376.     a. If the semaphore DataPassed is true: 
  6377.  
  6378.        1. Set the semaphore OkToPassData to false. 
  6379.        2. Read the data in the global. 
  6380.        3. Set the semaphore DataPassed to false. 
  6381.        4. Set the semaphore OkToPassData to true. 
  6382.  
  6383.     b. When a thread wants to pass data, wait for the semaphore to be clear. 
  6384.     c. Set the semaphore OkToPassData to false. 
  6385.     d. Put the data in the global. 
  6386.     e. Set the semaphore DataPassed to true. 
  6387.     f. Set the semaphore OkToPassData to true. 
  6388.  
  6389. Of course, there are issues of deadlock and other such nonsense that corporate 
  6390. chaps get paid to consider, but that's beyond the scope of this document. 
  6391.  
  6392.  
  6393. Related Information:
  6394.  
  6395. What is the best way to communicate between processes?
  6396.  
  6397.  
  6398. ΓòÉΓòÉΓòÉ 9.21. How to I write an IFS? ΓòÉΓòÉΓòÉ
  6399.  
  6400. Starting with Issue #3, EDM/2 started carrying a series about writing an IFS. 
  6401.  
  6402.  
  6403. ΓòÉΓòÉΓòÉ 9.22. How do I interface with OS/2's SCSI support? ΓòÉΓòÉΓòÉ
  6404.  
  6405. A complete description and sample code can be found at ftp archive; 
  6406.  
  6407. reseq.regent.e-technik.tu-muenchen.de 
  6408.  
  6409. in /pub/comp/os/os2/drivers/source/scsipg.zip. 
  6410.  
  6411.  
  6412. ΓòÉΓòÉΓòÉ 9.23. How do I program full-screen graphics? ΓòÉΓòÉΓòÉ
  6413.  
  6414. Several compilers come with their own VGA graphics libraries.  A 3rd party 
  6415. developer has even developed an SVGA library (with drivers) for emx/gcc. 
  6416.  
  6417. Full-screen graphics programming is nearly identical to full-screen DOS 
  6418. graphics programming, with the notable exception that you must lock and unlock 
  6419. the screen under OS/2 before you can use it. 
  6420.  
  6421. For fast direct-access screen graphics, check at ftp-os2.cdrom.com, the file 
  6422. dlib06.zip. 
  6423.  
  6424.  
  6425. ΓòÉΓòÉΓòÉ 9.24. How do I program MMPM/2 programs? ΓòÉΓòÉΓòÉ
  6426.  
  6427. IBM has created the MMPM/2 toolkit just for that.  However, if that is too much 
  6428. trouble for you, there is a simple REXX interface to MMPM/2 available in OS/2 
  6429. 2.1. 
  6430.  
  6431. IBM's Ultimedia Builder/2, Ultimedia Perfect Image/2, and Ultimedia Workplace/2 
  6432. are all in beta and scheduled to be released soon. 
  6433.  
  6434. For the Emx/GCC enviroment there is the mm4emx package by Marc Van Woerkom. 
  6435. mm4emx is freeware. All header and lib files included. 
  6436.  
  6437.  
  6438. ΓòÉΓòÉΓòÉ 9.25. How do I peripheral memory or an I/O port? ΓòÉΓòÉΓòÉ
  6439.  
  6440. The basic thing to do is either mark it as IOPL or surround it in a 16-bit 
  6441. module.    emx/gcc and other compilers include some macros and functions to assist 
  6442. you in doing this. 
  6443.  
  6444. Check the file IOPL32.ZIP at ftp.cdrom.com:/pub/os2/os2_x/programs 
  6445.  
  6446.  
  6447. ΓòÉΓòÉΓòÉ 10. Porting ΓòÉΓòÉΓòÉ
  6448.  
  6449. This section covers all aspects of porting programs. 
  6450.  
  6451.  
  6452. ΓòÉΓòÉΓòÉ 10.1. How do I port my DOS keyboard TSR to OS/2? ΓòÉΓòÉΓòÉ
  6453.  
  6454. Use keyboard monitors (for fullscreen sessions) or hooks for the PM session. 
  6455.  
  6456.  
  6457. ΓòÉΓòÉΓòÉ 10.2. How can I simulate (Unix feature) under OS/2? ΓòÉΓòÉΓòÉ
  6458.  
  6459.  1. fork 
  6460.  2. fork/exec 
  6461.  3. select 
  6462.  4. job control 
  6463.  
  6464. A working version of select() is included with the emx/gcc libraries. See the 
  6465. emx/gcc documentation for more information on its usage. 
  6466.  
  6467. A working version of fork() comes with the emx/gcc libraries.  The author 
  6468. cautions that this is not the way to multitask, though, because it eats up a 
  6469. lot of resources (since it literally duplicates the current process, leaving 
  6470. everything but the PID unchanged).  _beginthread() is the suggested solution if 
  6471. at all possible. 
  6472.  
  6473.  
  6474. ΓòÉΓòÉΓòÉ 10.3. How can I recompile public domain/shareware source code for OS/2? ΓòÉΓòÉΓòÉ
  6475.  
  6476. Most publicly available OS/2 programs come with binaries (since there is 
  6477. currently only one OS/2 architecture).  If you are porting source code from 
  6478. another system (for example, Unix), you will first need to acquire a compiler. 
  6479. See section 1 for information on compilers; in particular, note that the GNU C 
  6480. compiler is available. 
  6481.  
  6482. You should realize that many publicly available programs have already been 
  6483. ported to OS/2.  Check the many FTP sites carrying OS/2 programs before you 
  6484. reinvent any wheels (the OS/2 User's FAQ contains information on FTP site). 
  6485.  
  6486. Most Unix applications (through the use of emx/gcc) port with extreme ease; DOS 
  6487. and Windows applications are a tougher problem, and require many changes before 
  6488. they can be recompiled as a native OS/2 program. 
  6489.  
  6490. (It is interesting to note that MicroSoft C v6.0 will compile bound OS/2 
  6491. programs, which will run under DOS and OS/2 without modification.) 
  6492.  
  6493.  
  6494. Related Information:
  6495.  
  6496. How can I port my DOS program to OS/2?
  6497. How can I port my Windows program to OS/2?
  6498.  
  6499.  
  6500. ΓòÉΓòÉΓòÉ 10.4. How can I port my DOS program to OS/2? ΓòÉΓòÉΓòÉ
  6501.  
  6502. To the first approximation, you don't have to --- OS/2 2.x's DOS support is 
  6503. excellent, and your DOS program will probably just work; similarly, OS/2 2.x 
  6504. supports Windows 3.0 (and soon 3.1) programs.  See the OS/2 User's FAQ for 
  6505. details. 
  6506.  
  6507. [That was Barry Jaspan's opinion.  I believe that you should make every effort 
  6508. to recompile your existing DOS programs for OS/2 2.x.  They will run faster in 
  6509. many cases, and both (a) use less memory and (b) be able to use more memory 
  6510. than their DOS counterparts. - Jeff] 
  6511.  
  6512. If you truly want to port your DOS program over to OS/2, then study the 
  6513. libraries available to you.  The core code (if you wrote it correctly) will 
  6514. probably not change much.  You will just have to change the user interface 
  6515. stuff. 
  6516.  
  6517. If your program is a real simple one that uses standard input and output, then 
  6518. you will probably not make very many changes to your program when converting it 
  6519. to OS/2. 
  6520.  
  6521. You should also realize that neato and nifty DOS tricks (like grabbing an 
  6522. interrupt whenever you feel like it, or writing directly to almost anywhere) 
  6523. are completely out of the question. 
  6524.  
  6525.  
  6526. Related Information:
  6527.  
  6528. How can I port my Windows program to OS/2?
  6529.  
  6530.  
  6531. ΓòÉΓòÉΓòÉ 10.5. How can I port my Windows program to OS/2? ΓòÉΓòÉΓòÉ
  6532.  
  6533. A tool called Mirrors is available from Micrographx.  It does not currently 
  6534. support Windows 3.1-specific programs and calls.  (although you *can* call the 
  6535. functions in the new 3.1 DLLs) 
  6536.  
  6537. o Rough ports can be done in under 1 day, but a detailed port still costs you a 
  6538.   lot of effort. 
  6539. o The ported application is heavily dependent on the underlying OS/2 system. 
  6540.  
  6541. There are also several toolkits available that allow you to make calls to a 
  6542. common API library, and your source will work across the two platforms without 
  6543. any changes at all. 
  6544.  
  6545. However, if you want to bite the bullet and port it, then be prepared to make a 
  6546. lot of changes.  Just like porting regular DOS programs, you will have to scrap 
  6547. most, if not all, of your user interface.  Your core code, if modular and 
  6548. abstract enough, should come through the port relatively unscathed. 
  6549.  
  6550. SMART - by One-up Corp is also available on Developers Connection CD. 
  6551.  
  6552.  
  6553. Related Information:
  6554.  
  6555. How can I port my DOS program to OS/2?
  6556.  
  6557.  
  6558. ΓòÉΓòÉΓòÉ 11. Miscellaneous ΓòÉΓòÉΓòÉ
  6559.  
  6560. This section covers questions not covered in previous sections. 
  6561.  
  6562.  
  6563. ΓòÉΓòÉΓòÉ 11.1. Is OS/2 suitable for real time programs? ΓòÉΓòÉΓòÉ
  6564.  
  6565. Yes!  There is a special priority you can assign your programs 
  6566. (ForegroundServer Mode) via DosSetPriority() which will give your process 
  6567. (note, not thread, but process) the maximum allowable CPU time. 
  6568.  
  6569. Another route is to use DosEnterCritSec()/DosExitCritSec().  Calling the former 
  6570. will disable thread switching (hopefully for a short period of time), and 
  6571. calling the latter will enable thread switching again. 
  6572.  
  6573.  
  6574. ΓòÉΓòÉΓòÉ 11.2. What is available for multimedia programming under OS/2? ΓòÉΓòÉΓòÉ
  6575.  
  6576. The OS/2 2.x Multimedia package is now available.  Call the IBM Multimedia 
  6577. office at (800) 426-9402 ext. 150. 
  6578.  
  6579.  
  6580. ΓòÉΓòÉΓòÉ 11.3. What is available for AI/neural net programming under OS/2? ΓòÉΓòÉΓòÉ
  6581.  
  6582. LISP and XScheme are available from cdrom.com.  There are also some AI/neural 
  6583. net tools listed in tinf31.zip. 
  6584.  
  6585.  
  6586. Related Information:
  6587.  
  6588. Programming language availability
  6589.  
  6590.  
  6591. ΓòÉΓòÉΓòÉ 11.4. Special software offers ΓòÉΓòÉΓòÉ
  6592.  
  6593. Here are some of the OS/2 software products that represent particularly good 
  6594. values.  Most prices do not include shipping and handling. 
  6595.  
  6596. o Borland C++ for OS/2.  Available from Below Zero in Calgary (phone 
  6597.   800-461-2777, 403-547-0669, or FAX 403-547-1018) for about $136 U.S., 
  6598.   including shipping.  Add GST in Canada.  Below Zero will export outside North 
  6599.   America. 
  6600.  
  6601. o IBM PL/I.  Not everyone is a PL/I programmer, but IBM is offering free copies 
  6602.   of Workframe/2 with every purchase and free product videos. Phone 
  6603.   800-426-3346 ext. STL10 for more information on the two packages available. 
  6604.  
  6605. (Quoted almost directly from OS/2 General FAQ) 
  6606.  
  6607.  
  6608. ΓòÉΓòÉΓòÉ 11.5. Technical Support ΓòÉΓòÉΓòÉ
  6609.  
  6610. How can I get answers to my OS/2 questions? 
  6611.  
  6612. If your question is not answered in this List, post a note to the appropriate 
  6613. Usenet conference: 
  6614.  
  6615. Newsgroup                           Description 
  6616. comp.os.os2.advocacy                deals with opinions and speculation 
  6617. comp.os.os2.announce                carries important OS/2 announcements 
  6618. comp.os.os2.apps                    carries discussions related to finding or 
  6619.                                     using any application running under OS/2 
  6620. comp.os.os2.beta                    explores beta releases of OS/2 
  6621. comp.os.os2.bugs                    discusses possible bugs found in released 
  6622.                                     versions of the operating system 
  6623. comp.os.os2.games                   covers all question about OS/2 games 
  6624. comp.os.os2.misc                    is for any other OS/2-related discussion 
  6625. comp.os.os2.multimedia              fosters conversation about OS/2 multimedia 
  6626.                                     (including MMPM/2), 
  6627. comp.os.os2.networking              looks at general networking issues 
  6628. comp.os.os2.networking.misc         miscellaneous discussions about networking 
  6629. comp.os.os2.networking.tcp-ip       covers TCP/IP issues 
  6630. comp.os.os2.programmer.misc         addresses anything else related to OS/2 
  6631.                                     programming 
  6632. comp.os.os2.programmer.oop          covers object-oriented programming 
  6633.                                     discussions 
  6634. comp.os.os2.programmer.porting      helps programmers move applications over to 
  6635.                                     OS/2 from other operating systems and 
  6636.                                     environments 
  6637. comp.os.os2.programmer.tools        covers tools for OS/2 application 
  6638.                                     developing 
  6639. comp.os.os2.setup                   offers a place to talk about setup and 
  6640.                                     installation issues 
  6641. comp.os.os2.ver1x                   HAS BEEN REMOVED 
  6642. comp.lang.rexx                      discusses REXX programming 
  6643.  
  6644. These groups are also watched closely by OS/2 experts from IBM. 
  6645.  
  6646. A LISTSERVer distributes its own OS/2 conference by mail; send a single line 
  6647. message with the word HELP to listserv@cc1.kuleuven.ac.be for full 
  6648. instructions; or send the same message to listserv@frors12.circe.fr for 
  6649. information on an unedited mailing list.  To subscribe to the Multimedia 
  6650. Presentation Manager/2, send a single line message with the phrase SUBSCRIBE 
  6651. MMOS2-L (Your Name) to mail-server@knex.via.mind.org. 
  6652.  
  6653. Your local FidoNet BBS may carry OS/2 echo conferences and/or OS2NET. If not, 
  6654. ask your system operator to join them.  CompuServe (FIND OS/2) and Prodigy are 
  6655. also excellent resources. 
  6656.  
  6657. The IBM PC Co. BBS's (modem 404-835-6600) message areas, product database, and 
  6658. PS/2 Assistant file(s) are invaluable resources. Information on the new OS/2 
  6659. BBS is included in the OS/2 2.0 package. In the United States IBM has toll free 
  6660. technical support (phone 800-237-5511), an OS/2 Hotline (general information, 
  6661. orders, upgrades, phone 800-3-IBM-OS2; ask about OS/2 videotapes, T-shirts, and 
  6662. other accessories), the HelpWare Center (phone 800-PS2-2227), a software order 
  6663. line (phone 800-IBM-CALL), two FAX information services (phone 800-IBM-4FAX 
  6664. and/or 800-IBM-3395), and an educational inquiries line (phone 800-222-7257). 
  6665. In Canada phone IBM Personal Systems Software at 800-465-1234. 
  6666.  
  6667. Any of the regular DOS or Windows resources (e.g. books, magazines, 
  6668. shareware/freeware sources) will be useful since both environments come with 
  6669. OS/2 2.0. 
  6670.  
  6671. (taken from OS/2 General FAQ) 
  6672.  
  6673.  
  6674. Related Information:
  6675.  
  6676. Developer's Assistance Program
  6677.  
  6678.  
  6679. ΓòÉΓòÉΓòÉ 11.6. Developer's Assistance Program (DAP) ΓòÉΓòÉΓòÉ
  6680.  
  6681. OS/2 2.0 developers should contact the IBM Developer Assistance Program (phone 
  6682. 407-982-6408); membership is free.  (You may also join on CompuServe with GO 
  6683. OS2DAP.)  The OS/2 Professional Developer's Kit CD-ROM, containing a wide 
  6684. selection of development tools and code, and the OS/2 2.1 Beta CD-ROM are both 
  6685. available from IBM (phone 800-3-IBM-OS2 to order in the United States for 
  6686. between $15 and $20 each, shipping included; in Canada, phone 800-465-1234; in 
  6687. Australia, phone Rohaini Cain or Mike Voris at 13-2426 ext. 7684; elsewhere, 
  6688. contact the International OS/2 User Group by phoning 285-641175 in the U.K.) 
  6689. The OS/2 Device Driver Development Kit CD-ROM is also now available from IBM. 
  6690. To order phone 407-982-4239 (FAX 407-982-4218) in North America, 61-2-354-7684 
  6691. (FAX 61-2-354-7766) in most of the Far East and Pacific Rim, 81-3-5563-5897 
  6692. (FAX 81-3-5563-4957) in Japan, 81-2-528-1548 (FAX 82-2-528-1414) in Korea, 
  6693. 011-52-627-1846 (FAX 011-52-395-7812) in Latin America, or +49-69-6645-3318 in 
  6694. Germany. 
  6695.  
  6696. (taken from the OS/2 general FAQ) 
  6697.  
  6698.  
  6699. ΓòÉΓòÉΓòÉ 12. OS/2 Software Sources ΓòÉΓòÉΓòÉ
  6700.  
  6701. The following BBSes hold large OS/2 libraries: 
  6702.  
  6703.  
  6704.  Name                      Number
  6705.  
  6706.  Fernwood                  (203) 483-0348
  6707.  
  6708.  OS/2 Shareware            (703) 385-4325
  6709.  
  6710.  Bay Area OS/2             (510) 657-7948
  6711.  
  6712.  Gateway/2                 (314) 554-9313
  6713.  
  6714.  Greater Chicago Online    (708) 895-4042
  6715.  
  6716.  OS/2 Connection (San      (619) 549-4215
  6717.  Diego)
  6718.  
  6719.  OS/2 Las Vegas            (702) 433-5535
  6720.  
  6721.  IBM Germany               049-711-785-777
  6722.  
  6723.  IBM Germany (Another)     +49-69-6645-325
  6724.  
  6725.  IBM Denmark               45-42-88-72-22
  6726.  
  6727.  OS/2 UK                   0454-633197
  6728.  
  6729.  IBM UK                    0256-336655
  6730.  
  6731.  IBM Norway                47-66-99-94-50
  6732.  
  6733.  OS/2 Norway               47-22-38-09-49
  6734.  
  6735.  OS/2 Australia            61-2-241-2466
  6736.  
  6737. Check OS/2 FAQ for a more extensive list of ftp sites. 
  6738.  
  6739. (The monthly Worldwide OS/2 BBS Listing, available from these BBSes, lists 
  6740. others.)  The IBM PC Company BBS (modem 404-835-6600) has some 
  6741. shareware/freeware as well, along with CSDs and the PS/2 Assistant (an 
  6742. invaluable resource for locating almost any sort of information on OS/2). For 
  6743. information on IBM's new OS/2 BBS phone 800-547-1283.  IBM Canada maintains 
  6744. several support BBSes: 
  6745.  
  6746.    (416) 946-4255 
  6747.    (514) 938-3022 
  6748.    (604) 664-6464 
  6749.    (416) 946-4244 
  6750.  
  6751. The Usenet conference comp.binaries.os2 carries OS/2 software.  And several 
  6752. sites are available via anonymous ftp.  (No ftp?  Send a single line message 
  6753. with the word HELP to bitftp@pucc.bitnet or ftpmail@decwrl.dec.com to learn 
  6754. about ftp mail servers.)  Some are (with Internet node numbers and 
  6755. subdirectories): 
  6756.  
  6757.  
  6758.  Site                           IP Address      Home OS/2 Directory
  6759.  
  6760.  ftp.cdrom.com                  192.153.46.2    /pub/os2
  6761.  
  6762.  ftp-os2.nmsu.edu               128.123.35.151  pub/os2
  6763.  
  6764.  software.watson.ibm.com        129.34.139.5    pub/os2
  6765.  
  6766.  mtsg.ubc.ca                    137.82.27.1     os2
  6767.  
  6768.  access.usask.ca                128.233.3.1     pub/archives/os2
  6769.  
  6770.  luga.latrobe.edu.au            131.172.2.2     pub/os2
  6771.  
  6772.  funic.funet.fi                 128.214.6.100   pub/os2
  6773.  
  6774.  pdsoft.lancs.ac.uk             148.88.64.2     micros/ibmpc/os2
  6775.  
  6776.  ftp.uni-stuttgart.de           129.69.1.12     soft/os2
  6777.  
  6778.  src.doc.ic.ac.uk               146.169.2.1     computing/systems/os2
  6779.  
  6780.  zaphod.cs.uwindsor.ca          137.207.224.3   pub/local/os2
  6781.  
  6782.  ftp.luth.se                    130.240.18.2    pub/pc/os2
  6783.  
  6784.  src.doc.ic.ac.uk               146.169.2.1     computing/systems/os2
  6785.  mirrors ftp-os2.nmsu.edu/ftp.c
  6786.  
  6787.  pdsoft.lancs.edu.uk            148.88.64.2     micros/ibmpc/os2
  6788.  
  6789.  ftp.informatik.tu-muenchen.de  131.159.0.198   /pub/comp/os2
  6790.  
  6791. The cdrom.com library is available on CD-ROM from Walnut Creek (phone 
  6792. 510-947-5996).  EMS (phone 301-924-3594) offers an OS/2 shareware/freeware 
  6793. library on diskette. 
  6794.  
  6795. Other sources include CompuServe (FIND OS/2) and archive servers (send a single 
  6796. line message with the word HELP to listserv@cc1.kuleuven.ac.be or 
  6797. mail-server@rus.uni-stuttgart.de for more information, or use ftp). TRICKLE 
  6798. servers are also available outside the United States.  For more information on 
  6799. TRICKLE services, including automatic file subscription procedures, send a 
  6800. single line message with the word HELP to any one of the following sites 
  6801. nearest you: 
  6802.  
  6803. Country      Address 
  6804. Austria      TRICKLE@AWIWUW11.BITNET 
  6805. Belgium      TRICKLE@BANUFS11.BITNET 
  6806. Colombia     TRICKLE@UNALCOL.BITNET 
  6807. France       TRICKLE@FRMOP11.BITNET 
  6808. Germany      TRICKLE@DEARN.BITNET 
  6809. Israel       TRICKLE@TAUNIVM.BITNET 
  6810. Italy        TRICKLE@IMIPOLI.BITNET 
  6811. Netherlands  TRICKLE@HEARN.BITNET 
  6812. Sweden       TRICKLE@SEARN.BITNET 
  6813. Turkey       TRICKLE@TREARN.BITNET 
  6814.              TRICKLE@TRMETU.BITNET 
  6815.  
  6816. IBM has been releasing freely distributable employee written software (e.g. 
  6817. Visual REXX) and OS/2 patches to these sites. 
  6818.  
  6819. (The previous was taken almost verbatim from the OS/2 General FAQ) 
  6820.  
  6821.  
  6822. ΓòÉΓòÉΓòÉ 13. Bugs / Obtaining this FAQ / Contacting the Author ΓòÉΓòÉΓòÉ
  6823.  
  6824. Reporting Bugs and Errors in the FAQ 
  6825.  
  6826. With the advent of all this nifty hypertext IPF stuff, there are bound to be 
  6827. bugs and errors in this FAQ, simply by Murphy's Law.  (Anything that can go 
  6828. wrong, will go wrong)  If you find an error, however, insignificant, please 
  6829. send me a note (through one of the ways listed below) telling me what's wrong 
  6830. with the FAQ. 
  6831.  
  6832. Obtaining this FAQ 
  6833.  
  6834. This FAQ is distributed on a regular basis to: 
  6835.  
  6836.  1. cdrom.com, in /pub/os2/all/info/faq, on the Internet 
  6837.  
  6838. All other sites should receive this FAQ on a trickle-down basis from these 
  6839. sites. 
  6840.  
  6841. This FAQ is distributed in two versions, ASCII and INF.  The INF version is 
  6842. binary and viewable only by the VIEW.EXE program that comes with OS/2.  The 
  6843. ASCII version is text and is viewable by any program that can view text (which 
  6844. includes most word processors).  The filename is PFAQnn.ZIP, where 'nn' is the 
  6845. FAQ version. 
  6846.  
  6847. Contacting the Author 
  6848.  
  6849. I can be contacted in a multitude of ways: 
  6850.  
  6851. o Internet.  This is the preferred method.  E-mail me at 
  6852.   andreas@traci.almroth.pp.se. 
  6853.  
  6854. o Snail Mail 
  6855.  
  6856.    Andreas Almroth 
  6857.    Fanrik Stals Gata 153 
  6858.    S-754 39 UPPSALA 
  6859.    SWEDEN 
  6860.  
  6861.  
  6862. ΓòÉΓòÉΓòÉ 14. Credits ΓòÉΓòÉΓòÉ
  6863.  
  6864. The following people have contributed in numerous and not-so-numerous ways to 
  6865. this document to make it what it is today, and what it will be tomorrow.  Give 
  6866. a big round of applause for... 
  6867.  
  6868. o Barry Jaspan <bjaspan@athena.mit.edu> 
  6869. o Jeff Garzik <jgarzik@pantera.atl.ga.us> 
  6870. o Byers R E James <zoorejb@nusunix2.nus.sg> 
  6871. o Stefan Gruendal <Stefan_Gruendel@wue.maus.de> 
  6872. o Raja Thiagarajan <sthiagar@bronze.ucs.indiana.edu> 
  6873. o Larry Saloman <os2man@panix.com> 
  6874. o Timothy Sipples <sip1@kimbark.uchicago.edu> 
  6875. o Bob Smith <OECN_SMITH@MEC.OHIO.GOV> 
  6876. o Tim Francis <francis@vnet.IBM.COM> 
  6877. o Colin Jensen <cjensen@netcom.com> 
  6878. o Bill Henning <bhenning@wimsey.com> 
  6879. o Axel Uhl <auhl@fzi.de> 
  6880. o R. Mahoney <rmahoney@bix.com> 
  6881. o Frank Fuchs <ffu@softpro.de> 
  6882. o James J. Song <jjs@acd4.acd.com> 
  6883. o Morio Taneda <Morio_Taneda@ka.maus.de> 
  6884. o Timur Tabi <timur@seas.gwu.edu> 
  6885. o Paul Prescod <papresco@undergrad.math.uwaterloo.ca> 
  6886. o Rich Wales <richw@mks.com> 
  6887. o Craig Swanson <Craig_Swanson@f354.n202.z1.fidonet.org> 
  6888. o Ivar E. Hosteng <nit3ieh@odin.oslo.nit.no or nit3ieh@accsys.oslo.nit.no> 
  6889.  
  6890. Ok, so the list is a little short right now.  If you contributed to Barry's or 
  6891. Jeff's FAQ, and you are not listed here, then please send me your name and I'll 
  6892. be glad to include you in this list. 
  6893.  
  6894. I have obtained some information from sources other than people also. Besides 
  6895. being credited above, here is another list: 
  6896.  
  6897. o OS/2 Frequently Asked Questions List v2.1  (Available from cdrom.com in 
  6898.   os2/all/info/faq/faq21*.zip) 
  6899.  
  6900. o Electronic Developers' OS/2 Magazine  (Available from cdrom.com in 
  6901.   os2/all/info/edmi/*) 
  6902.