Frequently Asked Questions about Windows 3.0

TABLE OF CONTENTS

0.  Index

>>  1.  Windows newsgroups

    2.  Windows development tools
    3.  Windows linkers 
    4.  Windows debuggers 
    5.  Windows RTF word processors 
    6.  Windows SQL products
    7.  Windows C++ class libraries

    8.  Windows extended memory handling
    9.  Windows screen prints

   10.  Device driver development 
    
   11.  Hiding dialog box controls
   12.  Adding controls to a non-dialog box window
   13.  Using floating-point in Windows
   14.  Changing button colors 
   15.  Programming using large model 
   16.  Linking .FON files
   17.  Window background colors
   18.	Subclassing control windows
   19.  Changing the color palette in 16-color mode
   20.  Allocating global memory in a DLL
   21.  Determining the amount of physical memory
   22.  Aligning columns in a listbox
   23.  Keeping an application iconized or in a fixed-size window
   24.  Modifying a right-justified menu entry

   25.  Windows programmer's bibliography

   *** A companion posting can be found in comp.windows.ms **

----------------------------------------------------------------------


1.  Why are there two newsgroups for windows?

>>  comp.windows.ms.programmer is for discussion about developing
    Windows software.  It is not intended for discussions about 
    Windows software or for questions about the Foobar SVGA drivers.
    comp.windows.ms is for any Windows discussions that do not concern
    development of Windows software.


    --------------------


2.  What tools can I use to develop software for Windows?

>>  There are a number of options, which are summarized below:

    1.	Use the Microsoft Windows SDK (Software Development Kit).  This is
    	a necessity for heavy-duty application development.  The SDK is
	designed for Microsoft C 5.1/6.0 and Microsoft Macro Assembler 5.1/6.0,
	but it is possible to use it with other compilers, such as Zortech
	C++ (but not including most Borland compilers).  If you plan to use
	a non-Microsoft compiler, call Microsoft Technical Support to
	obtain the free Supplemental Compiler Utilities disk.  The following
	compilers are currently known to work:
	    - Microsoft C 			5.1+
	    - Microsoft QuickC			2.0
	    - Microsoft QuickCfor Windows	1.0
	    - Topspeed C			#
	    - Watcom C				8.0
	    - Watcom C/386 for Windows		8.0

	    - Borland C++			2.0
	    - Glockenspiel C++			?.?
	    - Topspeed C++			#
	    - Zortech C++			2.06+

	    - GFA Basic				1.0
	    - Microsoft Visual Basic		1.0
	    - Realizer				1.0

	    - Microsoft Fortran			5.1
	    - Watcom Fortran			8.1	[announced]
	    - Watcom Fortran/386 for Windows	8.1	[announced]

	    - Microsoft MASM 			5.0+

	    - Microsoft Pascal			4.0
	    - Topspeed Pascal			#
	    - Turbo Pascal for Windows		1.0

	    - Stonybrook Modula-2		2.0+
	    - Topspeed Modula-2			2.01+

	    - Microsoft COBOL			4.5
	    - MicroFocus COBOL			2.4+

	Of these the following include their own Windows libraries, and
	do not require you to purchase a Windows SDK (although you will
	need to buy the SDK documentation, which is available
	separately; of the following packages, only Zortech C++
	includes the Windows SDK reference manuals).
	    - Borland C++  		- Turbo Pascal for Windows
	    - Microsoft Cobol 		- Visual Basic
	    - QuickC for Windows 	- Zortech C++
	A Windows SDK/Microsoft C bundle is also available at a reduced price.

	The following also include the Microsoft QuickWin libraries (or
	equivalent), allowing rapid conversion of DOS character applications
	into the Windows environment:
	    - Microsoft Cobol 		- Microsoft Fortran
	    - QuickC for Windows	- Turbo Pascal for Windows
	
	Applications written using Borland C++ may not run in Windows 
	3.0 Real Mode (due to linker problems), nor do they permit the
	use of huge pointers.

	Some of the languages that will *NOT* work are:
	    - Microsoft Fortran, QuickPascal, Basic, QuickBasic
	    - Borland Turbo C, Turbo C++, Turbo Pascal, Turbo Basic
	    - Watcom Basic, Pascal
	    - Logitech Modula-2


    2.	Use an integrated development environment.  There are a number of
	these systems available; the following summarizes the known ones:

	a.  Actor.  $495 list ($99 special), free runtime
	    An object-oriented programming environment, with C-like syntax.
	    It allows quick development of programs and/or prototypes, and
	    compiles into an "image" file.  This must be distributed along
	    with actor.exe; however, it is possible to combine these into
	    a single .exe if you have the Whitewater Resource Toolkit.

	b.  Smalltalk/V for Windows.  $500 list, free runtime
	    An object-oriented programming environment, portable to OS/2 and
	    Macintosh.

	c.  Objectworks\Smalltalk for Windows.  $2000 (?) list, runtime $*
	    An object-oriented programming environment, portable to Macintosh,
	    Open Look and Motif.  Runtime license fees depend on quantity
	    required; prices range from $375 for one to below $100 for large
	    quantities.

	d.  KnowledgePro for Windows.

	e.  Borland ObjectVision.  $395 list ($99 special), runtime $395
	    A form-oriented environment.  Lacks a "true" programming language.
	    Runtime package allows unlimited runtime distribution.

	f.  Asymetrix ToolBook.  $395 list, runtime [ARK] $495.
	    A HyperCard-like environment, including hypertext capabilities.
	    Current version is quite slow.  Includes a conversion utility
	    to create ToolBook books from HyperCard stacks.  Author's
	    Resource Kit includes tools plus a runtime distribution license.

	g.  Spinnaker PLUS.  ? list, ? runtime.
	    A Windows version of HyperCard, compatible with the Mac original.

	h.  Windowcraft.  ? list, ? runtime.
	    [Does anyone have any details about this?]

    3.	Use W:CASE, WindowsMAKER, VZ Programmer, Winpro/3 or ProtoGen, all
	of which generate C code for Windows.  This will still require the
	use of the SDK (or, in some cases, the use of BC++).  There is also
	available a shareware code generator UCB/WordPlan ,available on 
	cica.cica.indiana.edu, but it's considerably more limited in functio-
	nality than the commercial products.  No runtime license fees.

    5.  Use EASEL/Windows.  This is an MIS-oriented package intended for
	development of client-server or cooperative processing applications.
	3270 connectivity, SQL, DDE, and Windows --- all for mere $7500.
    

3.  What linkers can be used for Windows programs?

>>  You can use link 5.10 (or greater), included on the Microsoft C 5.1/6.0
    compiler disks, and available separately with the Supplemental Compiler
    Utilities diskette (free) from Microsoft.  Other linkers that work for
    Windows development are Optilink/Windows, Borland's tlink and Watcom's
    wlink.


4.  What debuggers can I use for Windows development?

>>  First of all, if you use Actor, Smalltalk or ToolBook, you're limited
    to the debugging tools built into those packages.  If you are using
    C, C++ or another conventional language with Windows SDK, you have
    several choices.  
    
    1.	In real mode, you are limited to SYMDEB, which is pretty basic.  It
    	also requires the use of a second monitor (monochrome for most
	machines, 8514/A for MCA machines) or a serial terminal.  SYMDEB
	is included with the Windows SDK.

    2.	In standard mode, you can also use Codeview for Windows (CVW), which
	is included with Windows SDK, or Logitech's MultiScope (list: $500).
	The CVW, which is similar to the DOS version of Codeview, included
	with the SDK requires a secondary monitor; a serial terminal can 
	not be used (a single-monitor version, CVW 3.05, is included with
	Microsoft C 6.0ax, and is also available separately from Microsoft).
	CVW is included with the Windows SDK; MultiScope is a separate product.
	Watcom compilers include their own WVideoW debugger.

	There is also a product called CV/1 (list: $149), which allows you
	to use CVW without a second monitor.

    3.	If you have a 386, you have an additional option of using WDEB386,
        which provides some further debugging features over CVW, at the
	expense of an antiquated user interface.  WDEB386, which is included
	with the SDK, will work either with a secondary monitor or a serial
	terminal.
    
    If you are using Borland C++, you can use TDW.  TDW can do single-
    screen debugging (not windowed, but screen-swapping), but only if
    you are using the standard VGA driver; it will NOT work with higher-
    resolution display drivers.  You may also use TDW for dual-monitor 
    debugging; high resolutions work OK in that case.


5.  What word processor can I use to create RTF files for the Windows SDK
    Help Compiler?

>>  The following will create RTF files:
	Ami Professional  			[RTF compatibility problems]
	JustWrite
	Microsoft Works
	Professional Write Plus
	txt2rtf					[shareware conversion tool]
	Word for DOS
	Word for Macintosh			[Mac]
	Word for Windows
	Word for Windows, Working Model		[limited file size]
	WordPerfect 				[using wp2rtf.arc macros]
	WriteNow				[Mac, NeXT]
	Xantippe				[shareware hypertext tool]
    You can also create them manually, as the RTF format is plain ASCII,
    but this will very quickly get very awkward and very tedious.  There
    is a description of the RTF format on cica.cica.indiana.edu (Xantippe
    and txt2rtf can also be found on cica).

    Some conversion programs (including Doc-to-Doc) will also create RTF
    files from other native word processor formats.


7.  What tools are available for SQL development under Windows?

>>  The following products provide SQL interfaces:
	ADI SQL for Windows	[announced, not shipping]
	db_VISTA III		[read-only]
	Gupta SQL
	Novell Netware SQL	[announced, not shipping]
	Ocelot SQL for Windows	[one-time $500 distribution royalty]
	Paradox			[requires SQL Link]
	Q+E			[read-only]
	XDB SQL C SDK


8.  What C++ class libraries are available for Windows programming?

>>  The following products provide C++ class libraries for Windows:

	Product		Company			Compiler support
	-------------	---------------------	----------------------------
	Commonview	Glockenspiel Ltd.	Borland, Zortech
	C++/Views	CNS, Inc.		Borland, Zortech
	XVT++		XVT Inc.	    	Borland, Zortech (req. XVT)
	Tier 1		Sturmer Hauss Corp.	Borland, Zortech
	JTW		JT Software	    	Zortech
	Win++		Blaise Computing    	Borland


    --------------------


8.  What does Windows do with my extended memory?  After I run Windows,
    Norton SI reports that I don't have any extended memory.  Is this
    a bug?

>>  No, it's not a bug.  Windows requires applications to access extended
    memory using a mechanism known as "XMS".  This mechanism is implemented
    in himem.sys.  If you have device=himem.sys in your config.sys, the
    first XMS call (by Windows or SmartDrive, for example) will transfer
    control of the extended memory to himem.sys, and thus make it in-
    accessible to non-XMS applications.


9.  How can I take a snapshot of my Windows screen?

>>  Simple -- just pres PrtScr, and Windows will copy the image to the
    clipboard, from where you can paste it into your favourite application.
    Using Alt-PrtScr will take a snapshot of only your current window.


    --------------------


10. What do I need to develop device drivers for Windows?

>>  You need to purchase the Windows Device Driver Kit (DDK).  It's available
    direct from Microsoft, and costs $500.


    --------------------


11. How can I hide dialog box controls?

>>  EnableWindow(GetDlgItem(hDlg, IDD_CONTROLTOHIDE), FALSE);
    ShowWindow(GetDlgItem(hDlg, IDD_CONTROLTOHIDE), SW_HIDE);
    UpdateWindow(GetDlgItem(hDlg, IDD_CONTROLTOHIDE));


12. How can I add pushbuttons and edit controls to a "normal" window which
    is not a dialog box?

>>  You can do this by simply calling CreateWindow() with one of the pre-
    defined child window control class names (see table 4.2 in the SDK
    reference manual).


13. Why does compiling a Windows application with emulator floating-point
    cause corrupted code segments when running on a non-87 machine?  And
    should I use emulator or alternate floating-point math?

>>  The emulated floating point tries to used the coprocessor. When it does
    not find one on startup, it patches the code to use the software floating
    point. Patching does however not adapt the code-segment checksum, thus
    the windows debugging version chokes when it horridly founds that some-
    thing terrible must have happened to the code.  [This problem affects
    only Real mode, and Windows 2.x.]

    Get rid of it by setting 'EnableSegmentChecksum=0' in the [debug]
    section of WIN.INI; the problem only affects debugging versions of
    Windows.

    The alternate math package is faster on non-x87 machines, but slower on
    those equipped with a math chip.  Depending on your application, you
    might want to ship either, or both.  Borland C++ does not support the
    alternate math package.


    --------------------


14. How do I change the button colors?

>>  In Windows 3.0, the button face is defined by two colors. The grey
    (white if ega) face and a dark grey (grey if ega) shadow.  The colors
    also change when the button goes from a normal to pushed in state.  The
    WM_CTLCOLOR message only allows you to change one color at a time so to
    which of the button face colors should this apply?  (Windows 2 button
    faces had only one color so it made sense.)

    Maybe something tricky could have been done by using the background
    color for the shadow and foreground color for the face and perhaps
    doing something strange to get the text color in another way... And how
    do you return 2 brushes (you now need a foreground and a background
    brush)?  Or maybe even better, make colors a property of the window and
    some windows could have multiple color properties...

    Anyway, Windows doesn't look at the WM_CTLCOLOR message for buttons and
    thus doesn't allow you to change the button colors.  Try it with a
    listbox instead...  The only way to change button colors is to specify
    ButtonColor=, ButtonShadow= and ButtonText= in the [Colors] section of
    your win.ini file.


15. Why should I not use large model in my Windows application?  Can I do
    it anyway?

>>  Yes, you can do it.  There are several problems with using large model,
    though:
    i.  Your program's data memory will be fixed in real mode.  Effectively,
	your application will cripple any real-mode Windows system.
    ii. You will only be able to have one instance of your application
	active at any one time.
    iii.Your application will run more slowly.

    You should consider very carefully before you decide that large model
    is the only way to go; the preferred method is to use medium model, and
    to allocate far data as required.  
    
    Another alternative is to use Watcom C/386 for development; this will
    let you use a single 4GB segment, and 32-bit registers, increasing your
    applications performace substantially (but limiting it to running in 
    386 enhanced mode).


16. I get errors linking fonts into a .FON file?  What's the problem?

>>  The linker provided with the Windows 3.0 SDK will produce the following
    error when linking fonts:
	Link Error L2049 no segments defined
    The above LINK error is a bug in link. The fix is to run exehdr /r on the
    .exe file, and then run rc on it. The Win3 SDK linker incorrectly detects
    an error, and marks the resulting .exe file with some kind of error bit,
    even though the rest of the exe file is ok. Exehdr /r will reset this
    "error bit", after which rc will work just fine.

    An alternate fix is to use link4 from Windows 2.x SDK.


17. Should I use GetStockObject( GCW_WHITEBRUSH ) for my window background?

>>  Not unless you insist on a white background.  It is preferable to use
    the Control Panel-defined window background color instead:
	WinClass.hbrBackground = COLOR_WINDOW + 1;


18. The SDK Guide to Programming says that I shouldn't subclass standard
    edit controls.  Why is this?

>>  That's not strictly true.  You can *subclass* them by having your own
    window procedure handle the messages for the windows you create.  What
    is definitely a bad idea is *superclassing* a standard control by doing
    a SetClassLong() to change the window procedure for *all* such windows,
    as this will affect all edit controls in all applications currently
    running in the Windows session.


19. Is it possible to change the palette entries for a VGA running in
    16 color mode?

>>  If you are using a standard driver, you will need to bypass Windows
    to do it.  Microsoft will tell you to buy the DDK, but there is
    another way.  Now, the Windows system palette maps onto the VGA
    16-color palette as follows:

     VGAPAL    SYSPAL          VGAPAL     SYSPAL
       00        00              08        07
       01        01              09        13
       02        02              10        14
       03        03              11        15
       04        04              12        16
       05        05              13        17
       06        06              14        18
       07        12              15        19

     #define syspal(n) (n<7 ? n : (n>8 ? n+4 : (n=7 ? 12 : 7)))
     #define vgapal(n) (n<7 ? n : (n>12 ? n-4 : (n=7 ? 8 : 7)))
         
    When you get a WM_SETFOCUS event, save the current state of the
    hardware colormap and installs the one you want.  When you get a 
    WM_KILLFOCUS event, restore the original palette. Don't use the 
    pallette registers directly, though, just modify the color registers
    that they point to.


20. How can I allocate global memory that's owned by a DLL?

>>  Basically, if you use GlobalAlloc in a DLL, the application that
    called the DLL will own the object.  There is a way around this,
    though: allocate the memory using the GMEM_DDESHARE flag; this
    will make the allocating code segment (rather than the current task)
    own the memory.


21. How do I determine how much physical memory is installed, in order
    not to cause swapping in 386 Enhanced mode?

    You need to make a DPMI call to obtain that piece of information.  DPMI
    call 0500h with ES:DI pointing to a 30h byte buffer returns the `Free
    Memory Information':

    Offset      Description
     00h        Largest available free block in bytes
     04h        Maximum unlocked page allocation
     08h        Maximum locked page allocation
     0Ch        Linear address space size in pages
     10h        Total number of unlocked pages
     14h        Number of free pages
     18h        Total number of physical pages
     1Ch        Free linear address space in pages
     20h        Size of paging file/partition in pages
     24h-2Fh    Reserved

    The size of one page in bytes can be determined by function 0604h, which
    returns the page size in bytes in BX:CX.  To call a DPMI function, invoke
    the interrupt 31h. Carry bit will be clear if call was successful.

    The complete DPMI 0.9 specification is available free(!) at Intel Lite-
    rature JP26, Santa Clara.  It's also available on cica.cica.indiana.edu.


22. How do I aling columns in a listbox?  The proportional font causes the
    columns to be badly misaligned.

>>  In the resource file make sure the list box has the LBS_USETABSTOPS style.
    When you add the items to the listbox, separate the fields with tabs.  
    You can either use the default tab stops, or set your own by sending the
    listboxI always used the LB_SETTABSTOPS message.  For more information,
    see SDK Reference vol.1, page 6-44, and SDK Reference vol.2, page 8-43.
    It is also possible to use a fixed font, but the tabstop solution usually
    ends up looking much better.


23. How can I force a window to stay iconic?  or to make it non-resizable?

>>  In order to make your app stay as an icon, you must process the
    WM_QUERYOPEN message.  If you always return 0 for this message, you
    indicate that the icon can not be opened into a ordinary window.

    To retain a fixed size, you must process the WM_GETMINMAXINFO message.
    When you get it, modify the info pointed to by lParam:
	 LPPOINT lpSize = (LPPOINT)lParam;
	 lpSize[3].x = lpSize[4].x = theRightWidth;
	 lpSize[3].y = lpSize[4].y = theRightHeight;
    If you don't want the window to be maximized or iconized, create it
    with the ~WS_MAXIMIZEBOX and/or ~WS_MINIMIZEBOX styles, and disable
    those items from the system menu, if there is one.  Also, you can
    alternately disable resizing by creating the windows with ~WS_THICKFRAME,
    and disabling the Size... item on the system menu.


24. How can I use \a to right-justify a menu entry at runtime?

>>  It's undocumented, but what you need is a 0x08 in the menu string.
    The easiest way to do this is to place a \b in the string before the
    right-justified part (either the text of the accelerator key).

    Incidentally, the Windows 3.0 CUA guidelines no longer call for right-
    justifying the Help menu on the menu bar.


    --------------------


25. What books are there that I should be using for Windows programming?

>>  First of all, if you don't have an SDK, you'll want the SDK docs:
	SDK Reference -- Volume 1
		Microsoft Press, 1990, part no. 06856
	SDK Reference -- Volume 2
		Microsoft Press, 1990, part no. 06857
	SDK Guide to Programming
		Microsoft Press, 1990, part no. 06854
	SDK Tools
		Microsoft Press, 1990, part no. 06854
	SAA CUA Advanced Interface Design Guide
		IBM, 1989, part no. SC26-4582-0

    Then you can get into the "aftermarket" books:
	Charles Petzold: Programming Windows, 2e
		Microsoft Press, 1990, ISBN 1-55615-264-7
	Jeffrey M. Richter: Windows 3: A Developer's Guide
		M&T Books, 1991, ISBN 1-55851-164-4


    --------------------


75a76
> 	    - Microsoft QuickCfor Windows	1.0
102c103
< 	    - Microsoft COBOL			4.0
---
> 	    - Microsoft COBOL			4.5
105,111c106,120
< 	Of these, Borland C++, Visual Basic, Turbo Pascal for Windows and
< 	Zortech C++ (version 3.0 only) include their own Windows libraries,
< 	and do not require you to purchase a Windows SDK (although you will
< 	need to buy the SDK documentation, which is available separately; of
< 	the aforemenmtioned packages, only Zortech C++ includes the Windows
< 	SDK reference manuals).  The Windows SDK is also available in a 
< 	bundle with Microsoft C 6.0ax, at a reduced price.
---
> 	Of these the following include their own Windows libraries, and
> 	do not require you to purchase a Windows SDK (although you will
> 	need to buy the SDK documentation, which is available
> 	separately; of the following packages, only Zortech C++
> 	includes the Windows SDK reference manuals).
> 	    - Borland C++  		- Turbo Pascal for Windows
> 	    - Microsoft Cobol 		- Visual Basic
> 	    - QuickC for Windows 	- Zortech C++
> 	A Windows SDK/Microsoft C bundle is also available at a reduced price.
> 
> 	The following also include the Microsoft QuickWin libraries (or
> 	equivalent), allowing rapid conversion of DOS character applications
> 	into the Windows environment:
> 	    - Microsoft Cobol 		- Microsoft Fortran
> 	    - QuickC for Windows	- Turbo Pascal for Windows

[ \tom haapanen --- university of waterloo --- tom@mims-iris.waterloo.edu ]
[ "i don't even know what street canada is on"               -- al capone ]
[ "trust the programmer"                               -- ansi c standard ]
