home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / mswindo / programm / tools / 782 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  38.5 KB

  1. Xref: sparky comp.os.ms-windows.programmer.tools:782 comp.os.ms-windows.programmer.misc:1525 news.answers:2639
  2. Newsgroups: comp.os.ms-windows.programmer.tools,comp.os.ms-windows.programmer.misc,comp.windows.ms.programmer,news.answers
  3. Path: sparky!uunet!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watserv1!wes.on.ca!wes.on.ca!tomh
  4. From: tomh@wes.on.ca (Tom Haapanen)
  5. Subject: comp.os.ms-windows.programmer FAQ (Frequently Asked Questions)
  6. Reply-To: tomh@wes.on.ca (Tom Haapanen)
  7. Organization: Waterloo Engineering Software
  8. Date: Thu, 27 Aug 1992 12:53:28 GMT
  9. Approved: news-answers-request@MIT.Edu
  10. Message-ID: <1992Aug27.125328.29945@wes.on.ca>
  11. Followup-To: comp.windows.ms.programmer
  12. Sender: tomh@wes.on.ca (Tom Haapanen)
  13. Lines: 964
  14.  
  15. Archive-name: ms-winprog-faq
  16. Last-modified: 1992-06-19
  17. Related-archives: ms-windows-faq
  18.  
  19.  
  20. COPYRIGHT
  21.     This article is copyright 1990-1992 by Tom Haapanen.  It may be freely
  22.     copied and/or distributed in its entirety as long as this copyright
  23.     notice is not removed.  It may not be sold for profit or incorporated
  24.     into commercial products without the author's written permission.
  25.  
  26.  
  27. TABLE OF CONTENTS
  28.  
  29. 0.  Index
  30.  
  31. >>  1.  Windows newsgroups
  32.  
  33.     2.  Windows development tools
  34.     3.  Windows linkers 
  35.     4.  Windows debuggers 
  36.     5.  Windows RTF word processors 
  37.     6.  Windows SQL products
  38.     7.  Windows C++ class libraries
  39.  
  40.     8.  Windows extended memory handling
  41.     9.  Windows screen prints
  42.  
  43.    10.  Device driver development 
  44.     
  45.    11.  Hiding dialog box controls
  46.    12.  Adding controls to a non-dialog box window
  47.    13.  Using floating-point in Windows
  48.    14.  Changing button colors 
  49.    15.  Programming using large model 
  50.    16.  Linking .FON files
  51.    17.  Window background colors
  52.    18.  Subclassing control windows
  53.    19.  Changing the color palette in 16-color mode
  54.    20.  Allocating global memory in a DLL
  55.    21.  Determining the amount of physical memory
  56.    22.  Aligning columns in a listbox
  57.    23.  Keeping an application iconized or in a fixed-size window
  58.    24.  Modifying a right-justified menu entry
  59.    25.  What does 'new()' really do?
  60.    26.  Changing directories in a Windows application
  61.    27.  Is it possible to pass a structure back to Visual Basic from a DLL?
  62.    28.  How can I find out how many instances of my application are running?
  63.    29.  Is it possible to create an initially invisible MDI child window?
  64.    30.  Why am I getting NULL dialog box handles with BC++?
  65.    31.  How do I track down resources that I'm forgetting to free?
  66.    32.  Can I get TDW TP/Win to work with Windows 3.1?
  67.    33.  Why can't I print floating-point numbers with wsprintf()?
  68.    35.  Drag-and-drop printing using File Manager and Print Manage
  69.    36.  Generalized drag-and-drop
  70.    37.  Automatically exiting a dialog box on timeout
  71.    38.  Enumerating the icons in a Windows EXE or DLL
  72.    40.  Interpreting Dr. Watson logs
  73.    41.  Why does the Minimize button do strange things in a modal dialog?
  74.  
  75.    99.  Windows programmer's bibliography
  76.  
  77.    *** A companion posting can be found in comp.windows.ms **
  78.  
  79. ----------------------------------------------------------------------
  80.  
  81.  
  82. 1.  What are the newsgroups for windows?
  83.  
  84. >>  There are a total of eight newsgroups: 
  85.  
  86.     comp.os.ms-windows.advocacy
  87.         Adversarial discussions, arguments and comparisons to other systems.
  88.     comp.os.ms-windows.announce
  89.         A low-volume moderated group with announcements only, no discussions.
  90.     comp.os.ms-windows.apps
  91.         Discussions about the selection and use of Windows applications.
  92.     comp.os.ms-windows.setup
  93.         Questions and discussions about Windows setup, drivers and hardware.
  94.     comp.os.ms-windows.misc
  95.         All other discussions about Windows.
  96.  
  97.     comp.os.ms-windows.programmer.tools
  98.         Discussions about the selection and use of Windows development tools.
  99.     comp.os.ms-windows.programmer.win32
  100.         Discussions about the Win32 (Windows NT/Win32s) programming interface.
  101.     comp.os.ms-windows.programmer.misc
  102.         All other discussions about Windows software development.
  103.  
  104.     The following groups have been replaced by those shown above:
  105.     comp.windows.ms
  106.     comp.windows.ms.programmer
  107.  
  108.     The following groups are NOT for Microsoft Windows!
  109.     comp.windows.misc
  110.     comp.windows.news
  111.  
  112.  
  113.     --------------------
  114.  
  115.  
  116. 2.  What tools can I use to develop software for Windows?
  117.  
  118. >>  There are a number of options, which are summarized below:
  119.  
  120.     1.    Use the Microsoft Windows SDK (Software Development Kit).  This is
  121.         a necessity for heavy-duty application development.  The SDK is
  122.     designed for Microsoft C/C++ 5.1/6.0/7.0 and Microsoft Macro
  123.     Assembler 5.1/6.0, but it is possible to use it with other compilers,
  124.     such as Zortech C++ (but not including some Borland compilers).  If
  125.     you plan to use a non-Microsoft compiler, call Microsoft Technical
  126.     Support to obtain the free Supplemental Compiler Utilities disk. 
  127.     The following compilers are currently known to work:
  128.  
  129.     Compiler            Earliest  Current  Notes (see below)
  130.     -------------------------------    --------  -------  -----------------
  131.        - Borland C++            2.0      3.1       SDK+D3, 3.1, QW
  132.     - Metaware High C        2.4           32-bit
  133.     - Microsoft C/C++         5.1      7.0       SDK+D1, 3.1, QW
  134.     - Microsoft QuickC        2.0      2.0
  135.     - Microsoft QuickC for Windows    1.0      1.0       SDK+D2, QW
  136.     - Microway C            #           32-bit
  137.     - Topspeed C            #
  138.     - Turbo C++ for Windows        3.0      3.0       SDK+D2
  139.     - Watcom C            8.0      9.0       SDK+D
  140.     - Watcom C/386            8.0      9.0       32-bit, SDK+D
  141.     - Zortech C++            2.06      3.0       32-bit, SDK+D
  142.  
  143.     - Borland C++            2.0      3.1       SDK+D3, 3.1, QW
  144.     - Glockenspiel C++        #
  145.     - Microsoft C/C++        7.0      7.0       SDK+D1, 3.1, QW
  146.     - Topspeed C++            #
  147.     - Turbo C++ for Windows        3.0      3.0       SDK+D2
  148.     - Zortech C++            2.06      3.0       32-bit, SDK+D, QW
  149.  
  150.     - GFA Basic            1.0      1.0
  151.     - Microsoft Visual Basic    1.0      1.0       SDK+D4, 3.1, QW
  152.     - Realizer            1.0      1.0
  153.  
  154.     - Microsoft Fortran        5.1      5.1       QW
  155.     - Watcom Fortran        8.1      9.0       QW
  156.     - Watcom Fortran/386        8.1      9.0       32-bit, QW
  157.  
  158.     - Microsoft MASM         5.0      6.0
  159.  
  160.     - Microsoft Pascal        4.0      4.0
  161.     - Topspeed Pascal        #
  162.     - Turbo Pascal for Windows    1.0      1.0       SDK+D2, QW
  163.  
  164.     - Logitech Modula-2        4.0
  165.     - Stonybrook Modula-2        2.0
  166.     - Topspeed Modula-2        2.01
  167.  
  168.     - PDC Prolog            3.3
  169.     - Prolog/2            #
  170.  
  171.     - Microsoft COBOL        4.5      4.5       SDK, QW
  172.     - MicroFocus COBOL        2.4
  173.  
  174.     Notes:    
  175.         32-bit  Full 32-bit compiler with flat address space
  176.         3.1     API access includes new Windows 3.1 functionality
  177.         SDK        Includes full access to Windows API
  178.         SDK+D   As 'SDK', with full SDK manuals
  179.         SDK+D1  As 'SDK', with full SDK manuals (not with upgrade)
  180.         SDK+D2  As 'SDK', with limited SDK manuals
  181.         SDK+D3  As 'SDK', with limited SDK manuals (only with AF)
  182.         SDK+D4  As 'SDK', with limited SDK manuals (only with Prof. TK)
  183.         QW        Includes libraries for easy porting of DOS applications
  184.  
  185.     Most 'SDK' denoted products include online SDK documentation.
  186.  
  187.     Applications written using Borland C++ may not run in Windows 
  188.     3.0 Real Mode (due to linker restrictions).
  189.  
  190.     Some of the languages that will *NOT* work are:
  191.         - Microsoft QuickPascal, Basic, QuickBasic
  192.         - Borland Turbo C, Turbo C++, Turbo Pascal, Turbo Basic
  193.         - Watcom Basic, Pascal
  194.  
  195.  
  196.     2.    Use an integrated development environment.  There are a number of
  197.     these systems available; the following summarizes the known ones:
  198.  
  199.     a.  Actor.  $240 list ($500 for Actor Professional), free runtime.
  200.         An object-oriented programming environment, with C-like syntax.
  201.         It allows quick development of programs and/or prototypes, and
  202.         compiles into an "image" file (which can be combined into a 
  203.         standalone executable .EXE file).
  204.  
  205.     b.  Smalltalk/V for Windows.  $499 list, free runtime
  206.         An object-oriented programming environment, portable to OS/2 and
  207.         Macintosh.
  208.  
  209.     c.  Objectworks\Smalltalk for Windows.  $3500 list, $? runtime.
  210.         An object-oriented programming environment, portable to Macintosh,
  211.         Open Look and Motif.  Runtime license fees depend on quantity
  212.         required; prices range from $375 for one to below $100 for large
  213.         quantities.  Educational discounts available.
  214.  
  215.     d.  KnowledgePro for Windows.  $249 list, $? runtime.
  216.  
  217.     e.  Borland ObjectVision.  $395 list.
  218.         A form-oriented environment.  Lacks a "true" programming language.
  219.         Runtime package allows unlimited runtime distribution.
  220.  
  221.     f.  Asymetrix ToolBook.  $395 list, $495 unlimited runtime.
  222.         A HyperCard-like environment, including hypertext capabilities.
  223.         Current version is quite slow.  Includes a conversion utility
  224.         to create ToolBook books from HyperCard stacks.  Author's
  225.         Resource Kit includes tools plus a runtime distribution license.
  226.  
  227.     g.  Spinnaker PLUS.  $495 list, $495 runtime.
  228.         A Windows version of HyperCard, compatible with the Mac original.
  229.         At last report PLUS was incredibly slow on any normal system.
  230.  
  231.     h.  Windowcraft.  $295 list, $? runtime.
  232.         A graphical object-oriented application generator, compatible
  233.         with Hypercard stacks.
  234.  
  235.     i.  Golden Common Lisp Developer.  $1995 list, $200 (or less) runtime.
  236.         A Common Lisp-based object-oriented environment.  Full access
  237.         to the Windows API.
  238.     
  239.     j.  ObjectView.  $899 list, $? runtime.
  240.         Object-oriented system with graphics editor and SQL database
  241.         connectivity.
  242.  
  243.     k.  Liana.  $495 list (professional), $125 list (personal).
  244.         Integrated object-oriented system with classes and inheritance.
  245.         More C-like language than Actor.  Produces EXE files, but
  246.         requires DLL to be present for runtime.
  247.  
  248.     3.    Use W:CASE, WindowsMAKER, VZ Programmer, Winpro/3 or ProtoGen, all
  249.     of which generate C code for Windows.  This will still require the
  250.     use of the SDK (or, in some cases, the use of BC++).  There is also
  251.     available a shareware code generator UCB/WordPlan ,available on 
  252.     ftp.cica.indiana.edu, but it's considerably more limited in functio-
  253.     nality than the commercial products.  No runtime license fees.
  254.  
  255.     5.  Use EASEL/Windows.  This is an MIS-oriented package intended for
  256.     development of client-server or cooperative processing applications.
  257.     3270 connectivity, SQL, DDE, and Windows --- all for mere $7500.
  258.     
  259.  
  260. 3.  What linkers can be used for Windows programs?
  261.  
  262. >>  You can use link 5.10 (or greater), included on the Microsoft C 5.1/6.0
  263.     compiler disks, and available separately with the Supplemental Compiler
  264.     Utilities diskette (free) from Microsoft.  Other linkers that work for
  265.     Windows development are Optilink/Windows, Borland's tlink (with the
  266.     Borland-format object files) and Watcom's wlink.
  267.  
  268.  
  269. 4.  What debuggers can I use for Windows development?
  270.  
  271. >>  First of all, if you use an integrated package such as Actor, Smalltalk,
  272.     ToolBook or Visual Basic, you're limited to the debugging tools built
  273.     into those packages.  If you are using C, C++ or another conventional
  274.     language with Windows SDK, you have several choices.  
  275.     
  276.     1.    In real mode, you are limited to SYMDEB, which is pretty basic.  It
  277.         also requires the use of a second monitor (monochrome for most
  278.     machines, 8514/A for MCA machines) or a serial terminal.  SYMDEB
  279.     is included with the Windows SDK.
  280.  
  281.     2.    In standard mode, you can also use Codeview for Windows (CVW), which
  282.     is included with Windows SDK.  The CVW, which is similar to the DOS
  283.     version of Codeview, included with the SDK requires a secondary
  284.     monitor; a serial terminal can not be used (a single-monitor version,
  285.     CVW 3.05, is included with Microsoft C 6.0ax and later, and is also
  286.     available separately from Microsoft).  CVW is also included with
  287.     QuickC for Windows and Microsoft Fortran 5.1.
  288.  
  289.     Microsoft C/C++ 7.0 includes CVW/1 (from Nu-Mega Technologies) which
  290.     allows CVW to run in a window.  It is also available separately
  291.     (list price: $149) from Nu-Mega.
  292.  
  293.     3.    If you have a 386, you have an additional option of using WDEB386,
  294.         which provides some further debugging features over CVW, at the
  295.     expense of an antiquated user interface.  WDEB386, which is included
  296.     with the SDK, will work either with a secondary monitor or a serial
  297.     terminal.
  298.     
  299.     4.  If you are using Borland C++, you can use TDW.  TDW can do single-
  300.     screen debugging (not windowed, but screen-swapping), dual-monitor
  301.     debugging and remote (serial or NetBIOS) debugging.
  302.  
  303.     You can also use TDW with Microsoft-compatible compilers if you
  304.     use Borland'(supplied) s tools to convert the symbolic information
  305.     to the Borland format first.
  306.  
  307.     TDW's video support (when using single-screen debugging) is limited
  308.     to the following adapters and/or display modes:
  309.         CGA        640x200        
  310.         Hercules    720x348
  311.         EGA        640x350     
  312.         VGA        640x480
  313.         ATI VGA Wonder    640x480, 800x600
  314.         Tseng ET3000    640x480, 800x600, 1024x768
  315.         Tseng ET4000    640x480, 800x600, 1024x768
  316.  
  317.     5.    If you are using Zortech C++, you can use ZDBW.  ZDBW can do single-
  318.     screen debugging (not windowed, but screen-swapping) with most display
  319.     drivers, and can also do dual-monitor debugging.
  320.  
  321.     6.  Metaware C includes MDB, another Windows-based debugger.
  322.  
  323.     7.    Watcom compilers include their own WVideoW debugger.
  324.  
  325.     8.    Logitech's MultiScope (list: $500) is a fully graphical debugger
  326.     available for both OS/2 and Windows.
  327.     
  328.     9.  Nu-Mega's Soft-ICE (list: $386) provides advanced debugging features,
  329.     and works with both standard and Borland-format symbolic information.
  330.     
  331.     10. Periscope for Windows (list: $595) provides hardware debugging support for device driver development.  It requires the use of a remote computer for debugging.
  332.  
  333. 5.  What word processor can I use to create RTF files for the Windows SDK
  334.     Help Compiler?
  335.  
  336. >>  The following will create RTF files:
  337.     Ami Professional
  338.     JustWrite
  339.     Microsoft Works
  340.     Professional Write Plus
  341.     txt2rtf                    [shareware conversion tool]
  342.     Word for DOS
  343.     Word for Macintosh            [Mac]
  344.     Word for Windows
  345.     Word for Windows, Working Model        [limited file size]
  346.     WordPerfect for Windows
  347.     Wordstar for Windows
  348.     Wordstar Legacy
  349.     WriteNow                [Mac, NeXT]
  350.     Xantippe                [shareware hypertext tool]
  351.     You can also create them manually, as the RTF format is plain ASCII,
  352.     but this will very quickly get very awkward and very tedious.  There
  353.     is a description of the RTF format on ftp.cica.indiana.edu (Xantippe
  354.     can also be found on cica).
  355.  
  356.     Some conversion programs (including Doc-to-Doc) will also create RTF
  357.     files from other native word processor formats.
  358.  
  359.     NOTE: RTF files created with Word for Windows are not always 100% 
  360.     compatible with the SDK help compiler.  Use the 3.0B help compiler
  361.     update (available at ftp.cica as hc30b.zip) to avoid these problems.
  362.     It is not yet known whether the 3.1 SDK has problem with Word for
  363.     Windows 2.0 RTF files.
  364.  
  365.  
  366. 7.  What tools are available for SQL development under Windows?
  367.  
  368. >>  The following products provide SQL interfaces:
  369.     ADI SQL for Windows    [announced, not shipping]
  370.     db_VISTA III        [read-only]
  371.     Gupta SQL
  372.     Novell Netware SQL    [announced, not shipping]
  373.     Ocelot SQL for Windows    [one-time $500 distribution royalty]
  374.     Paradox            [requires Paradox SQL Link]
  375.     Progress        [integrated package, portable, runtime fee]
  376.     Q+E            [read-only]
  377.     Smalltalk\SQL        [for Objectworks\Smalltalk]
  378.     SQL Server         [includes DLL for Visual Basic]
  379.     XDB SQL C SDK
  380.  
  381.  
  382. 7.  What C++ class libraries are available for Windows programming?
  383.  
  384. >>  The following products provide C++ class libraries for Windows:
  385.  
  386.     Product           Company          Compiler support
  387.     ---------------------  ---------------------  -------------------------
  388.     Commonview           Glockenspiel Ltd.      Borland, Zortech
  389.     C++/Views           CNS, Inc.          Borland, Zortech
  390.     JTW               JT Software              Zortech
  391.     MS Foundation Classes  Microsoft          Microsoft
  392.     ObjectGraphics       WhiteWater Group        Borland
  393.     ObjectWindows       Borland          Borland
  394.     Tier 1           Sturmer Hauss Corp.      Borland, Zortech
  395.     Win++           Blaise Computing          Borland
  396.     XVT++           XVT Inc.              Borland, Zortech, Microsoft
  397.  
  398.     The XVT++ library requires the use of the XVT toolkit.  The Foundation
  399.     Classes are included with Microsoft C/C++ 7.0, and the ObjectWindows
  400.     Library is optional with the purchase of Borland C++ 3.0.
  401.  
  402.  
  403.     --------------------
  404.  
  405.  
  406. 8.  What does Windows do with my extended memory?  After I run Windows,
  407.     Norton SI reports that I don't have any extended memory.  Is this
  408.     a bug?
  409.  
  410. >>  No, it's not a bug.  Windows requires applications to access extended
  411.     memory using a mechanism known as "XMS".  This mechanism is implemented
  412.     in himem.sys.  If you have device=himem.sys in your config.sys, the
  413.     first XMS call (by Windows or SmartDrive, for example) will transfer
  414.     control of the extended memory to himem.sys, and thus make it in-
  415.     accessible to non-XMS applications.
  416.  
  417.  
  418. 9.  How can I take a snapshot of my Windows screen?
  419.  
  420. >>  Simple -- just pres PrtScr, and Windows will copy the image to the
  421.     clipboard, from where you can paste it into your favourite application.
  422.     Using Alt-PrtScr will take a snapshot of only your current window.
  423.  
  424.  
  425.     --------------------
  426.  
  427.  
  428. 10. What do I need to develop device drivers for Windows?
  429.  
  430. >>  You need to purchase the Windows Device Driver Kit (DDK).  It's available
  431.     direct from Microsoft, and costs $500.
  432.  
  433.  
  434.     --------------------
  435.  
  436.  
  437. 11. How can I hide dialog box controls?
  438.  
  439. >>  EnableWindow(GetDlgItem(hDlg, IDD_CONTROLTOHIDE), FALSE);
  440.     ShowWindow(GetDlgItem(hDlg, IDD_CONTROLTOHIDE), SW_HIDE);
  441.     UpdateWindow(GetDlgItem(hDlg, IDD_CONTROLTOHIDE));
  442.  
  443.  
  444. 12. How can I add pushbuttons and edit controls to a "normal" window which
  445.     is not a dialog box?
  446.  
  447. >>  You can do this by simply calling CreateWindow() with one of the pre-
  448.     defined child window control class names (see table 4.2 in the SDK
  449.     reference manual).
  450.  
  451.  
  452. 13. Why does compiling a Windows application with emulator floating-point
  453.     cause corrupted code segments when running on a non-87 machine?  And
  454.     should I use emulator or alternate floating-point math?
  455.  
  456. >>  The emulated floating point tries to used the coprocessor. When it does
  457.     not find one on startup, it patches the code to use the software floating
  458.     point. Patching does however not adapt the code-segment checksum, thus
  459.     the windows debugging version chokes when it horridly founds that some-
  460.     thing terrible must have happened to the code.  [This problem affects
  461.     only Real mode, and Windows 2.x.]
  462.  
  463.     Get rid of it by setting 'EnableSegmentChecksum=0' in the [debug]
  464.     section of WIN.INI; the problem only affects debugging versions of
  465.     Windows.
  466.  
  467.     The alternate math package is faster on non-x87 machines, but slower on
  468.     those equipped with a math chip.  Depending on your application, you
  469.     might want to ship either, or both.  Borland C++ does not support the
  470.     alternate math package, but it does have a "fast floats" option.
  471.  
  472.  
  473.     --------------------
  474.  
  475.  
  476. 14. How do I change the button colors?
  477.  
  478. >>  In Windows 3.0, the button face is defined by two colors. The grey
  479.     (white if ega) face and a dark grey (grey if ega) shadow.  The colors
  480.     also change when the button goes from a normal to pushed in state.  The
  481.     WM_CTLCOLOR message only allows you to change one color at a time so to
  482.     which of the button face colors should this apply?  (Windows 2 button
  483.     faces had only one color so it made sense.)
  484.  
  485.     Maybe something tricky could have been done by using the background
  486.     color for the shadow and foreground color for the face and perhaps
  487.     doing something strange to get the text color in another way... And how
  488.     do you return 2 brushes (you now need a foreground and a background
  489.     brush)?  Or maybe even better, make colors a property of the window and
  490.     some windows could have multiple color properties...
  491.  
  492.     Anyway, Windows doesn't look at the WM_CTLCOLOR message for buttons and
  493.     thus doesn't allow you to change the button colors.  Try it with a
  494.     listbox instead...  The only way to change button colors is to specify
  495.     ButtonColor=, ButtonShadow= and ButtonText= in the [Colors] section of
  496.     your win.ini file.
  497.  
  498.  
  499. 15. Why should I not use large model in my Windows application?  Can I do
  500.     it anyway?
  501.  
  502. >>  Yes, you can do it.  There are several problems with using large model,
  503.     though:
  504.     i.  Your program's data memory will be fixed in real mode.  Effectively,
  505.     your application will cripple any real-mode Windows system.  [Of
  506.     course, this problem doesn't exist with Windows 3.1!]
  507.     ii. Your application will run more slowly, since all your data must be
  508.     accessed through far pointers.
  509.     iii.You may only be able to have one instance of your application
  510.     active at any one time. This restriction is imposed by Windows on
  511.     applications with multiple static data segements: in large model,
  512.     that means most applications generated with C or C++.  Borland
  513.     C++ 3.0+ and Microsoft C/C++ 7.0 will attempt to keep your static
  514.     and global data in a single segment, so as long as that data does
  515.     not exceed 64K, you could run multiple instances of a large-model
  516.     application created using those compilers.
  517.  
  518.     You should consider very carefully before you decide that large model
  519.     is the only way to go; the preferred method is to use medium model, and
  520.     to allocate far data as required.  
  521.     
  522.     Another alternative is to use Watcom C/386 or Zortech C++ for develop-
  523.     ment; this will let you use a single 4GB segment, and 32-bit registers,
  524.     increasing your applications performace substantially (but limiting it
  525.     to running in 386 enhanced mode).
  526.  
  527.     Win32 (Windows NT and Win32s) will use the flat 32-bit programming model
  528.     exclusively for native applications.
  529.  
  530.  
  531. 16. I get errors linking fonts into a .FON file?  What's the problem?
  532.  
  533. >>  The linker provided with the Windows 3.0 SDK will produce the following
  534.     error when linking fonts:
  535.     Link Error L2049 no segments defined
  536.     The above LINK error is a bug in link. The fix is to run exehdr /r on the
  537.     .exe file, and then run rc on it. The Win3 SDK linker incorrectly detects
  538.     an error, and marks the resulting .exe file with some kind of error bit,
  539.     even though the rest of the exe file is ok. Exehdr /r will reset this
  540.     "error bit", after which rc will work just fine.
  541.  
  542.     An alternate fix is to use link4 from Windows 2.x SDK.
  543.  
  544.  
  545. 17. Should I use GetStockObject( GCW_WHITEBRUSH ) for my window background?
  546.  
  547. >>  Not unless you insist on a white background.  It is preferable to use
  548.     the Control Panel-defined window background color instead:
  549.     WinClass.hbrBackground = COLOR_WINDOW + 1;
  550.  
  551.  
  552. 18. The SDK Guide to Programming says that I shouldn't subclass standard
  553.     edit controls.  Why is this?
  554.  
  555. >>  That's not strictly true.  You can *subclass* them by having your own
  556.     window procedure handle the messages for the windows you create (using
  557.     SetWindowLong()).  What is definitely a bad idea is modify the *class
  558.     procedure* of a standard control (using SetClassLong()) and changing the
  559.     window procedure for *all* such windows, as this will affect all edit
  560.     controls in all applications currently running in the Windows session.
  561.  
  562.  
  563. 19. Is it possible to change the palette entries for a VGA running in
  564.     16 color mode?
  565.  
  566. >>  If you are using a standard driver, you will need to bypass Windows
  567.     to do it.  Microsoft will tell you to buy the DDK, but there is
  568.     another way.  Now, the Windows system palette maps onto the VGA
  569.     16-color palette as follows:
  570.  
  571.      VGAPAL    SYSPAL          VGAPAL     SYSPAL
  572.        00        00              08        07
  573.        01        01              09        13
  574.        02        02              10        14
  575.        03        03              11        15
  576.        04        04              12        16
  577.        05        05              13        17
  578.        06        06              14        18
  579.        07        12              15        19
  580.  
  581.      #define syspal(n) (n<7 ? n : (n>8 ? n+4 : (n=7 ? 12 : 7)))
  582.      #define vgapal(n) (n<7 ? n : (n>12 ? n-4 : (n=7 ? 8 : 7)))
  583.          
  584.     When you get a WM_SETFOCUS event, save the current state of the
  585.     hardware colormap and installs the one you want.  When you get a 
  586.     WM_KILLFOCUS event, restore the original palette. Don't use the 
  587.     pallette registers directly, though, just modify the color registers
  588.     that they point to.
  589.  
  590.  
  591. 20. How can I allocate global memory that's owned by a DLL?
  592.  
  593. >>  Basically, if you use GlobalAlloc in a DLL, the application that
  594.     called the DLL will own the object.  There is a way around this,
  595.     though: allocate the memory using the GMEM_DDESHARE flag; this
  596.     will make the allocating code segment (rather than the current task)
  597.     own the memory.
  598.  
  599.  
  600. 21. How do I determine how much physical memory is installed, in order
  601.     not to cause swapping in 386 Enhanced mode?
  602.  
  603.     You need to make a DPMI call to obtain that piece of information.  DPMI
  604.     call 0500h with ES:DI pointing to a 30h byte buffer returns the `Free
  605.     Memory Information':
  606.  
  607.     Offset      Description
  608.      00h        Largest available free block in bytes
  609.      04h        Maximum unlocked page allocation
  610.      08h        Maximum locked page allocation
  611.      0Ch        Linear address space size in pages
  612.      10h        Total number of unlocked pages
  613.      14h        Number of free pages
  614.      18h        Total number of physical pages
  615.      1Ch        Free linear address space in pages
  616.      20h        Size of paging file/partition in pages
  617.      24h-2Fh    Reserved
  618.  
  619.     The size of one page in bytes can be determined by function 0604h, which
  620.     returns the page size in bytes in BX:CX.  To call a DPMI function, invoke
  621.     the interrupt 31h. Carry bit will be clear if call was successful.
  622.  
  623.     The complete DPMI 0.9 specification is available free(!) at Intel Lite-
  624.     rature JP26, Santa Clara.  It's also available on ftp.cica.indiana.edu.
  625.  
  626.  
  627. 22. How do I align columns in a listbox?  The proportional font causes the
  628.     columns to be badly misaligned.
  629.  
  630. >>  In the resource file make sure the list box has the LBS_USETABSTOPS style.
  631.     When you add the items to the listbox, separate the fields with tabs.  
  632.     You can either use the default tab stops, or set your own by sending the
  633.     LBS_SETTABSTOPS message to the listbox. For more information, see SDK
  634.     Reference vol.1, page 6-44, and SDK Reference vol.2, page 8-43.  It is
  635.     also possible to use a fixed font, but the tabstop solution usually
  636.     ends up looking much better.
  637.  
  638.  
  639. 23. How can I force a window to stay iconic?  or to make it non-resizable?
  640.  
  641. >>  In order to make your app stay as an icon, you must process the
  642.     WM_QUERYOPEN message.  If you always return 0 for this message, you
  643.     indicate that the icon can not be opened into a ordinary window.
  644.  
  645.     To retain a fixed size, you must process the WM_GETMINMAXINFO message.
  646.     When you get it, modify the info pointed to by lParam:
  647.      LPPOINT lpSize = (LPPOINT)lParam;
  648.      lpSize[3].x = lpSize[4].x = theRightWidth;
  649.      lpSize[3].y = lpSize[4].y = theRightHeight;
  650.     If you don't want the window to be maximized or iconized, create it
  651.     with the ~WS_MAXIMIZEBOX and/or ~WS_MINIMIZEBOX styles, and disable
  652.     those items from the system menu, if there is one.  Also, you can
  653.     alternately disable resizing by creating the windows with ~WS_THICKFRAME,
  654.     and disabling the Size... item on the system menu.
  655.  
  656.  
  657. 24. How can I use \a to right-justify a menu entry at runtime?
  658.  
  659. >>  It's undocumented, but what you need is a 0x08 in the menu string.
  660.     The easiest way to do this is to place a \b in the string before the
  661.     right-justified part (either the text of the accelerator key).
  662.  
  663.     Incidentally, the Windows 3.0 CUA guidelines no longer call for right-
  664.     justifying the Help menu on the menu bar.
  665.  
  666.  
  667.  
  668. 25. What does 'new()' really end up doing in C++?
  669.  
  670. >>  In Borland C++ 2.0, and in 3.0's medium model, new() ends up calling
  671.     LocalAlloc(), allocating memory from your near 64K segment.  In 3.0's
  672.     large and compact models, however, it will make one GlobalAlloc and do
  673.     subsegment allocations to allow you access to the full memory without
  674.     making excessive demands on the system limit of 4096 (8192 in 386 enhan-
  675.     ced mode) global memory handles.
  676.  
  677.  
  678. 26. How do you change directories under Windows ?
  679.  
  680. >>  The easy way is to use DlgDirList().  You can specify zero for the
  681.     two ID fields.  You can use the current window ID for the dialog handle
  682.     field.  The standard C library function chdir() can also be used.
  683.  
  684.  
  685. 27. Is it possible to pass a structure back to Visual Basic from a DLL?
  686.  
  687. >>  The following description is courtesy of Todd Ogasawara, 1991 (reachable
  688.     at todd@pinhead.pegasus.com).  The code fragments were developed and
  689.     tested using Borland C++ 2.0 and Microsoft Visual Basic.
  690.  
  691.     1. Define a type that is a pointer to a structure.
  692.     typedef struct {
  693.         long    fsize;        // file size in bytes
  694.         char    ftime[25];    // last file access time string
  695.     } * fileStruct;
  696.  
  697.  
  698.     2. Sample function prototype declaration.
  699.     int FAR pascal FileInfo(char filename[], fileStruct);
  700.  
  701.  
  702.     3. Sample DLL C function that receives a filename in a char array from
  703.        Visual Basic and passes back file size (long) and file modification
  704.        date (char array) in a structure.
  705.  
  706.     // Get file info (access time & size)
  707.     int FAR pascal
  708.     FileInfo(char filename[], fileStruct far fileinfo)
  709.     {
  710.         struct stat    statbuf;
  711.         FILE   *stream;
  712.  
  713.         if (!(stream = fopen(filename, "r"))) {
  714.             return(-1);    // ERROR: cannot find named file
  715.         } else {
  716.             fstat(fileno(stream), &statbuf);
  717.             fclose(stream);
  718.         }
  719.  
  720.         fileinfo->fsize = statbuf.st_size;         /* file size */
  721.         strcpy(fileinfo->ftime,ctime(&statbuf.st_ctime)); /* access time */
  722.  
  723.         return(0);
  724.     }
  725.  
  726.  
  727.     4. Declare a Visual BASIC "user-defined type" (i.e., a "structure") that 
  728.        matches the structure declared in the DLL C code. See pages 260-261
  729.        of the Microsoft Visual BASIC Programmer's Guide for more information
  730.        about user-defined types.
  731.         ' type (structure) definition in GLOBAL.BAS
  732.         Type FileStruct
  733.         Fsize As Long
  734.         Ftime As String * 25
  735.         End Type
  736.  
  737.     5. Declare the function in your GLOBAL.BAS (or whatever you named the file 
  738.        you keep global information in). In this example a function is declared 
  739.        since the DLL C function returns a -1 to indicate an error and a 0 to
  740.        indicate success. Note that the filename is passed from Visual BASIC
  741.        to the DLL C function by value (ByVal) while the data in the DLL C
  742.        structure is passed to Visual BASIC by reference (As). See pages 379-387
  743.        of the Microsoft Visual BASIC Programmer's Guide for more information
  744.        about declaring and calling DLL routines.
  745.         ' declaration in GLOBAL.BAS
  746.         Declare Function FileInfo Lib "dosdll.dll" (ByVal FileName$, 
  747.         FileInf As FileStruct) As Integer
  748.  
  749.  
  750.     6. Example of using the DLL function 'FileInfo' in Visual BASIC.
  751.     If (Myfile.Filename = "") Then
  752.         Exit Sub
  753.     Else
  754.         ThisFileName$ = UCase$(Myfile.Filename)
  755.     End If
  756.     FileStatus% = FileInfo(ThisFileName$, FileStat)
  757.     ThisFileSize$ = Format$(FileStat.Fsize, "###,###,###") + " bytes"
  758.     ThisFileStat$ = Left$(FileStat.Ftime, 24)
  759.  
  760.  
  761. 28. How can I find out how many instances of my application are running?
  762.  
  763. >>> nNumInsts = GetModuleUsage(hInstance);
  764.  
  765.  
  766. 29. Is it possible to create an initially invisible MDI child window?
  767.  
  768. >>> Before creating the child window,
  769.     SendMessage( hClientWindow, WM_SETREDRAW, 0, 0L);
  770.  
  771.     Then, in your child window WM_CREATE processing,
  772.     ShowWindow( hChildWindow, SW_HIDE).
  773.     SendMessage( hClientWindow, WM_SETREDRAW, 1, 0L);
  774.  
  775.  
  776. 30. Why do I keep getting null dialog handles with Borland C++ unless I have
  777.     Turbo C++ running?
  778.  
  779. >>> Your dialog is probably of the "BorDlg" class, which requires code in
  780.     BWCC.DLL.  However, you have probably not done anything to force BWCC.DLL
  781.     to be loaded with your application, so the dialog manager cannot find the
  782.     necessary routines to draw the dialog.  The easiest way to force BWCC.DLL
  783.     to be loaded is to call BWCCGetVersion() at the very beginning of your 
  784.     application, and to link in BWCC.LIB.  Alternaly, you can do a
  785.     WinExec( "loadbwcc.exe" );
  786.     when you start up your application.
  787.  
  788.  
  789. 31. Does there exist a utility that will allow me to track down the resources
  790.     I am failing to free?
  791.  
  792. >>> There are several utilities available on ftp.cica.indiana.edu which will
  793.     monitor the heap and memory usage. Look for files ma.zip and ha.zip in
  794.     /pub/pc/win3/utils.
  795.  
  796.     The Windows 3.1 debug kernel (included with the SDK) also checks for
  797.     unfreed resources when an application exits.
  798.  
  799.  
  800. 32. Can I get TDW (Turbo Debugger for Windows) to work with Windows 3.1? 
  801.     What about Turbo Pascal for Windows?
  802.      
  803. >>> TDWIN31.ZIP and TPWN31.ZIP are now on wuarchive.wustl.edu in the directory
  804.     /mirrors/msdos/borland.  The former includes a WINDEBUG.DLL for running
  805.     TDW in Windows 3.1, and the latter contains updates to TPW to take
  806.     advantage of the new Windows 3.1 features.
  807.  
  808.     Borland expects to have full C++ and Turbo Pascal updates for Windows 3.1
  809.     available in the next few months.
  810.  
  811.  
  812. 33. Why can't I print floating-point numbers with wsprintf()?
  813.      
  814. >>> Because it was designed not to print them.  To print floating-point,
  815.     you must use sprintf().  Remember, though, that all strings passed
  816.     to wsprintf() should be cast to FAR!
  817.  
  818.  
  819. 35. How do I implement drag-and-drop printing using File Manager and Print
  820.     Manager?
  821.  
  822. >>  You will need to register your application in the registration database.
  823.     You can do this either using the Registration Editor, or the Reg* API
  824.     in Windows 3.1 SDK.  One of the simplest mechanisms is that used by
  825.     several Windows 3.1 applets -- print a file is the parameters are
  826.     "/p filename".  See the registration database for examples.
  827.  
  828.  
  829. 36.  But what about generalized drag-and-drop?
  830.  
  831. >>  You'll need SHELL.DLL, shipped with Windows 3.1.
  832.     - Either do DragAccept() or create the window as WS_EX_DROPFILES (0x10L)
  833.     - Wait for the WM_DROPFILES message (0x0233), which passes a handle to
  834.       something in wParam
  835.     - You can then issue  
  836.           WORD DragQueryFile(hDrop, 0xffff, NULL, 0)
  837.       to get the file count, and then
  838.           WORD DragQueryFile(HANDLE hDrop, WORD nFile, LPSTR sDest, WORD max)
  839.       for each of the dropped files
  840.     - Once you have finished call
  841.         DragFinish( hDrop )
  842.  
  843.     For Visual Basic, get the file DD.ZIP from CompuServe's MBASIC forum,
  844.     which lets you implement drag-and-drop from VB.  This file may also be
  845.     available at ftp.cica.indiana.edu.
  846.  
  847.  
  848. 37. How can I automatically exit a dialog box if the user doesn't do anything?
  849.  
  850. >>  Start a timer in WM_INITDIALOG. If your dialog box receives the WM_TIMER 
  851.     message, kill the timer and post yourself a WM_COMMAND messgae with 
  852.     wParam == IDOK. If the user presses any button, restart the timer. 
  853.  
  854.  
  855. 38. How can you enumerate the icons in a Windows EXE or DLL if you don't 
  856.     already know their names?
  857.  
  858. >>  In Windows 3.1, this is easy.  SHELL.DLL exports
  859.         HICON ExtractIcon(hInst, lpszExeName, nIcon)
  860.    This function returns a handle to the specified icon (where 0 is the 
  861.    default icon displayed by Program Manager), or the number of icons in the
  862.    file if you pass in an index of -1.  
  863.  
  864.    Better yet, SHELL.DLL also exports the function:
  865.        FindExecutable(lpszFile, lpszDir, lpszResult)
  866.    which will give you the executable associated with a given document file.
  867.    You can then extract the appropriate icon from that file.
  868.  
  869.  
  870. 40. How do I extract useful information from an end user's Dr. Watson log
  871.     file?
  872.  
  873. >>  The Dr. Watson log shows the contents of the registers when you appli-
  874.     cation crashed.  Even if you can't use it to determine contents of the
  875.     variables, you can pinpoint the location of the crash.
  876.  
  877.     Make sure you keep a copy of the .map file generated by the linker for
  878.     the version shipped to your customers; you can then look up the crash
  879.     location manually from this file when you receive a Dr. Watson log.  If
  880.     you linked a version with /CO /LI, the .map file will also contain
  881.     line number information, allowing you to pinpoint the line in your
  882.     program.
  883.  
  884.  
  885. 41. Why does the Minimize button appear to move when I click it in a
  886.     modal dialog?
  887.  
  888. >>  It's a bug in Windows 3.1.  To duplicate this, create a modal dialog
  889.     with the styles CAPTION, MODAL FRAME, MINIMIZE-BOX, activate the dialog,
  890.     press the Minimze button -- and watch it move to the top right corner,
  891.     on top of the modal frame!  The workaround: don't use a Minimize box
  892.     on a modal dialog...
  893.  
  894.  
  895.     --------------------
  896.  
  897.  
  898. 99. What books are there that I should be using for Windows programming?
  899.  
  900. >>  First of all, if you don't have an SDK, you'll want the SDK docs:
  901.  
  902.     Windows 3.1 SDK
  903.     ---------------
  904.     Windows Programmer's Reference, Volume 1: Overview
  905.         Microsoft Press, 1992
  906.     Windows Programmer's Reference, Volume 2: Functions
  907.         Microsoft Press, 1992
  908.     Windows Programmer's Reference, Volume 3: Messages and structures
  909.         Microsoft Press, 1992
  910.     Windows Programmer's Reference, Volume 4: Resources
  911.         Microsoft Press, 1992
  912.     Windows Guide to Programming
  913.         Microsoft Press, 1992
  914.     Windows Programming Tools
  915.         Microsoft Press, 1992
  916.     Windows User Interface Guidelines
  917.         Microsoft Press, 1992
  918.     Windows Multimedia Programmer's Guide
  919.         Microsoft Press, 1992
  920.     Windows Multimedia Programmer's Reference
  921.         Microsoft Press, 1992
  922.     Windows for Pen Computing Programmer's Reference
  923.         Microsoft Press, 1992
  924.     Windows Setup Toolkit
  925.         Microsoft Press, 1992
  926.  
  927.     Windows 3.0 SDK
  928.     ---------------
  929.     SDK Reference, Volume 1: Functions and messages
  930.         Microsoft Press, 1990, part no. 06856
  931.     SDK Reference, Volume 2: Resource scripts and file formats
  932.         Microsoft Press, 1990, part no. 06857
  933.     SDK Guide to Programming
  934.         Microsoft Press, 1990, part no. 06854
  935.     SDK Tools
  936.         Microsoft Press, 1990, part no. 06854
  937.     SAA CUA Advanced Interface Design Guide
  938.         IBM, 1989, part no. SC26-4582-0
  939.  
  940.     Win32 (Windows NT) API
  941.     ----------------------
  942.     Win32 API: An Overview
  943.         Microsoft Press, 1992
  944.     Win32 Programmer's Reference, Volume 1: Overview, functions (A-O)
  945.         Microsoft Press, 1992
  946.     Win32 Programmer's Reference, Volume 2: Functions (P-Z)
  947.         Microsoft Press, 1992
  948.  
  949.     User Interface Guidelines
  950.     -------------------------
  951.     Windows User Interface Guidelines     [Windows 3.1, Windows NT]
  952.         Microsoft Press, 1992
  953.     SAA CUA Advanced Interface Design Guide [Windows 3.0, OS/2 1.x]
  954.         IBM, 1989, part no. SC26-4582-0
  955.     SAA CUA'91 Design Guide         [OS/2 2.0]
  956.         IBM, 1991, part no. SC34-4289, $10.00
  957.     SAA CUA'91 Reference             [OS/2 2.0]
  958.         IBM, 1991, part no. SC34-4290, $18.25
  959.  
  960.     Third-party Books
  961.     -----------------
  962.     Charles Petzold: Programming Windows, 2e
  963.         Microsoft Press, 1990, ISBN 1-55615-264-7
  964.     Jeffrey M. Richter: Windows 3: A Developer's Guide
  965.         M&T Books, 1991, ISBN 1-55851-164-4
  966.        Daniel A. Norton: Writing Windows Device Drivers
  967.         Addison-Wesley, 1991, ISBN ?, $29.95
  968.     Peter Norton and Paul Yao: Windows 3.0 Power Programming Techniques
  969.         Bantam Books, 1991, ISBN ?, $29.95
  970.     Richard Wilton: Microsoft Windows 3 Developer's Workshop
  971.         Microsoft Press, 1991, ISBN ?, $24.95
  972.  
  973.  
  974.     --------------------
  975.  
  976. [ \tom haapanen      "i don't even know what street canada is on" -- al capone ]
  977. [ tomh@wes.on.ca                     "trust the programmer" -- ansi c standard ]
  978. [ waterloo engineering software          "to thine own self be true" -- hamlet ]
  979.