home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 1.ddi / DOC / README.WIN < prev    next >
Encoding:
Text File  |  1992-04-21  |  11.6 KB  |  308 lines

  1.      Copyright (C) 1992 MetaWare Incorporated.  All Rights Reserved.
  2.  
  3.          MetaWare 32-Bit Windows 3.0 Application Development Kit
  4.                                April 1992
  5.  
  6. ------------------------------------------------------------------------------
  7. NOTE:  Important for Distribution of Applications
  8.  
  9.        The dynamic link library MWSUPDLL.DLL is called by all applications
  10.        developed with the ADK.  If you develop programs for resale and
  11.        distribution, you must include MWSUPDLL.DLL with each of the products
  12.        you distribute.  There is NO royalty attached to using this file.
  13. ------------------------------------------------------------------------------
  14.  
  15.  
  16. Table of Contents
  17. -----------------
  18.   1. Introduction
  19.   2. Installation and Set-Up
  20.   3. 32-bit DLLs
  21.   4. Call16() Function
  22.   5. Debugging in Windows -- MDBW v1.3
  23.   6. Make Utility
  24.   7. Required Source Code Changes
  25.   8. Changes to the Documentation
  26.   9. Windows Problems
  27.  10. Known Problems
  28.  
  29.  
  30. 1. Introduction
  31. ---------------
  32.  
  33. With the MetaWare Windows 3.0 Application Development Kit (ADK), plus a High C
  34. compiler, and Microsoft Windows 3.0, you can develop and run 32-bit
  35. applications in the Windows 3.0 386 enhanced-mode environment.
  36.  
  37. We are now shipping the Microsoft 3.0 Resource Compiler so you can develop 32-
  38. bit Windows applications without Microsoft Windows SDK.
  39.  
  40. Compatibility with Microsoft Windows 3.1 is under development and will be
  41. implemented in the next release.
  42.  
  43.  
  44. 2. Installation and Set-Up
  45. --------------------------
  46.  
  47. The MetaWare Windows ADK is installed on top of your High C/C++ compiler
  48. installation.  The resulting installed software can generate both 32-bit
  49. Windows applications and non-Windows extended-DOS applications.
  50.  
  51.  
  52. 3. 32-bit DLLs
  53. --------------
  54.  
  55. The MetaWare ADK supports creating 32-bit dynamic link libraries (DLLs).  See
  56. the ...\win\sdk\select directory for example source code.  A DLL is compiled
  57. separately from your main Windows application, and is not linked directly with
  58. your program until execution.  You can use Windows function calls to load the
  59. DLL into memory, and obtain the address of a function in the library that you
  60. want to call.  See the Windows Application Developer's Guide for more
  61. information.
  62.  
  63.  
  64. 4. Call16() function
  65. --------------------
  66.  
  67. MetaWare's 32-bit Windows Application Development Kit provides you with the
  68. ability to load 16-bit dynamic link libraries (DLLs).  After a DLL is loaded,
  69. you can obtain the address of a function in the DLL, and call it using the
  70. ADK's Call16() function.
  71.  
  72.  
  73. 5. Debugger in Windows -- MDBW
  74. -------------------------------
  75.  
  76. The Windows ADK includes a Windows version of MetaWare's 32-Bit Source-Level
  77. Debugger, MDBW.  MDBW is designed to allow source-level debugging of the 32-
  78. bit protected-mode programs generated by the Windows ADK.  MDBW is hosted on
  79. Windows 3.0 to allow you to debug your applications within the Windows 3.0
  80. environment.  MDBW includes the files MWDEBUG.DLL and VMW32D.386.
  81.  
  82. *  Configuring Windows 3.0 for Debugging
  83.  
  84.    To use the debugger, you must edit your WINDOWS\SYSTEM.INI file to include
  85.    the following line:
  86.  
  87.       [386Enh]
  88.       DEVICE=vmw32d.386
  89.  
  90. *  Modifying configuration file MDBW.ENV and help files.
  91.  
  92.    Set environment variable MDBWENV to the location of file MDBW.ENV,
  93.    and environment variable MDBWHELP to the directory in which the help
  94.    files reside.  For example:
  95.  
  96.       set MDBWENV=c:\hc386\bin\mdbw.env
  97.       set MDBWHELP=c:\hc386\bin
  98.  
  99.    By default, the debugger looks for its configuration file (MDBW.CNF) and
  100.    its help files (MDBW.TXT, MDBW.BOD, and MDBW.IDX) in the directory in which
  101.    the debugger executable is found.
  102.  
  103.  
  104. *  Known problems.
  105.  
  106.    - MDBW is not yet compatible with Windows 3.1.
  107.  
  108.    - The RELOAD command does not work under Windows 3.0.
  109.  
  110.    - MDBW may be unstable if the application exits with an error.
  111.      If you are unable to restart MDBW, exit out of Windows and
  112.      restart.
  113.  
  114.    - DOS program SHARE.EXE may cause a program load to fail.
  115.  
  116.    - Multiple breakpoints at one address are not supported.
  117.  
  118.    - CALLSTACK cannot display register-based arguments.
  119.  
  120.  
  121. 6. Make Utility
  122. ---------------
  123.  
  124. The MetaWare make utility MWMAKE is a protected-mode make based on popular
  125. UNIX versions of make.  Currently, a bug exists in the handling of default
  126. rules.  The supplied makefiles avoid the use of default rules.
  127.  
  128.  
  129. 7. Required Source Code Changes
  130. -------------------------------
  131.  
  132. The following source code changes are required when you port a 16-bit Windows
  133. program to run under the MetaWare 32-bit Windows ADK.
  134.  
  135. * LocalAlloc() and LocalLock() return far pointers.  Variables that are
  136.   assigned the return value of a LocalAlloc() or LocalLock() call should be
  137.   declared as type "LPSTR" or "LP48STR" (or an equivalent type).
  138.  
  139. * Some windows applications use the type "unsigned" in place of the type
  140.   "WORD".  On a 32-bit platform, "unsigned" is four bytes long, while "WORD"
  141.   is two bytes long.  Therefore, functions declared as, for example:
  142.  
  143.      LONG (FAR PASCAL *lpfnWndProc)(HWND, unsigned, WORD, LONG);
  144.  
  145.   should instead be declared as:
  146.  
  147.      LONG (FAR PASCAL *lpfnWndProc)(HWND, WORD, WORD, LONG);
  148.  
  149. * Occurrences of <TYPE> FAR * should be changed to LP<TYPE>.  For example, if
  150.   your program declares a variable:
  151.  
  152.      CREATESTRUCT FAR * pCS;
  153.  
  154.   you should modify the declaration to be:
  155.  
  156.      LPCREATESTRUCT pCS;
  157.  
  158.   The LP types are declared in the Windows header files.
  159.  
  160. * The behavior of DebugBreak() has been modified slightly, to allow a program
  161.   that contains calls to DebugBreak() to be run outside of a debugger.
  162.   Normally, if a program calls DebugBreak() while being run outside of a
  163.   debugger, the machine will hang.  We have modified DebugBreak() such that it
  164.   will not execute an "int 3" instruction unless it is run under the MetaWare
  165.   debugger for Windows, MDBW.  If you wish to have DebugBreak() execute an
  166.   "int 3" instruction regardless of whether the program is running under the
  167.   debugger, you have two options:
  168.  
  169.   1)  Set the environment variable DEBUGBREAK to any value.  If this variable
  170.       is detected in the environment, all calls to DebugBreak() will execute
  171.       an "int 3" instruction.
  172.  
  173.   2)  Replace calls to DebugBreak() with calls to _mwDebugBreak().
  174.       _mwDebugBreak() will always execute an "int 3" instruction.
  175.  
  176. * If you use function SetWindowLong() to change the message-handling function
  177.   for a window, you must use a function pointer returned from
  178.   MakeProcInstance() as the third parameter.  For example:
  179.  
  180.      extern void function();
  181.      FARPROC pfunc = MakeProcInstance(function,hInst);
  182.      SetWindowLong(hWnd,GWL_WNDPROC,pfunc);
  183.  
  184.   Failure to do this will cause your program to crash.
  185.  
  186. * The MakeProcInstance() function in the MetaWare ADK returns a 16:16 pointer.
  187.   Usually this pointer is passed along to Windows.
  188.  
  189.      ...
  190.      case IDM_ABOUT:
  191.          lpProcAbout = MakeProcInstance(About, hInst);
  192.          DialogBox(hInst, "AboutBox", hWnd, lpProcAbout);
  193.          FreeProcInstance(lpProcAbout);
  194.          break;
  195.      ...
  196.  
  197.   If you need to call this address directly, you must use the Call16()
  198.   function, which allows your program to call 16:16 pointers-to-functions.
  199.   For example:
  200.  
  201.      extern BOOL FAR PASCAL PrintDlgProc (HWND, WORD, WORD, DWORD);
  202.      FARPROC     lpfnPrintDlgProc ;
  203.  
  204.      lpfnPrintDlgProc = MakeProcInstance (PrintDlgProc, hInst) ;
  205.      ...
  206.      #ifdef __HIGHC__
  207.      Call16(lpfnPrintDlgProc,"wwwd", hWnd, message, wParam, lParam);
  208.      #else
  209.      lpfnPrintDlgProc(hWnd, message, wParam, lParam);
  210.      #endif
  211.  
  212.   See the Application Developer's Guide for more information about Call16().
  213.  
  214. * Keep in mind that on a 32-bit platform an "int" is four bytes long, instead
  215.   of two bytes as it is on a 16-bit platform.  If you make assumptions about
  216.   the size of integer variables, you should use either "short" or "long"
  217.   rather than "int".  If you notice problems in your program that seem to be
  218.   caused by a variable having an unexpected value, be sure to check the size
  219.   of that variable.  You may need to change "int" variables to be of type
  220.   "short".
  221.  
  222.  
  223. 8. Changes to the Documentation
  224. -------------------------------
  225.  
  226. The Application Developer's Guide states that for messages where one of the
  227. message parameters is a pointer, the program must use BRK_FP() to convert the
  228. pointer from a 16:16 pointer to a 16:32 pointer.
  229.  
  230. There are three exceptions to this rule: for messages WM_NCCREATE, WM_CREATE,
  231. and WM_MDICREATE, the fourth parameter, "lParam", is a pointer to a structure
  232. (CREATESTRUCT or MDICREATESTRUCT).  These structures contain members that are
  233. themselves pointers.  Because these members must be converted into 16:32
  234. pointers, the MetaWare supervisor must allocate memory on the local heap, and
  235. create a new copy of the structure with translated member values.  Therefore,
  236. the lParam for these three messages is a 0:32 pointer, not a 16:16 pointer.
  237. Do not try to convert lParam into a 16:32 pointer with BRK_FP().
  238.  
  239. For example, the documentation implies that the following code should be used
  240. to access the CREATESTRUCT structure pointed to by the lParam parameter of the
  241. WM_CREATE message:
  242.  
  243.   long FAR PASCAL WndProc(HWND hWnd, WORD message, WORD wParam, DWORD lParam){
  244.     switch (message) {
  245.       case WM_CREATE: {
  246.         LPCREATESTRUCT lpCreateStruct = (LPCREATESTRUCT) BRK_FP(lParam);
  247.         }
  248.       }
  249.     ...
  250.     }
  251.  
  252. Use instead:
  253.  
  254.   long FAR PASCAL WndProc(HWND hWnd, WORD message, WORD wParam, DWORD lParam){
  255.     switch (message) {
  256.       case WM_CREATE: {
  257.         LPCREATESTRUCT lpCreateStruct = (LPCREATESTRUCT) lParam;
  258.         }
  259.       ...
  260.       }
  261.     ...
  262.     }
  263.  
  264. The type LPCREATESTRUCT is defined in windows.h to be a near pointer rather
  265. than a far pointer.  If you need a far pointer to a CREATESTRUCT, use type
  266. LP48CREATESTRUCT.  Structure MDICREATESTRUCT is handled similarly.
  267.  
  268.  
  269. 9. Windows Problems
  270. -------------------
  271.  
  272. If you experience a large number of "Unrecoverable Application Error" messages
  273. when running Windows programs, check the following in your CONFIG.SYS file:
  274.  
  275. * set FILES to at least 30; preferably 40
  276.  
  277. * set your environment to at least 1024 bytes, preferably 2048; with the line:
  278.  
  279.      SHELL=command.com /e:2048
  280.  
  281.  
  282. 10. Known Problems
  283. -------------------
  284.  
  285. *  On some machines, you may experience problems using the debugger MDBW with
  286.    various device drivers, memory-resident programs (TSRs), or local area
  287.    networks.  If you cannot load a program to debug, or cannot get the
  288.    debugger to execute, try changing your CONFIG.SYS and/or AUTOEXEC.BAT files
  289.    to temporarily eliminate the network or device drivers.  Then reboot and
  290.    try the debugger again.
  291.  
  292. *  If you currently have EMM386 installed in your CONFIG.SYS file, you must
  293.    remove it prior to using the MetaWare compilers.  There is a conflict
  294.    between Phar Lap's V3.0 and V4.0 DOS extenders and EMM386.
  295.  
  296. *  You may notice that if you run a Windows program many times without
  297.    rebooting your machine, occasionally the program will start up, but never
  298.    display a window.  The Windows task switcher thinks that the program is
  299.    running, and it is actually running.  At the present time, we have not
  300.    determined the cause of this anomalous behavior.  If you encounter this
  301.    behavior, simply reboot your machine.  The program will run properly after
  302.    the machine has been rebooted.  This behavior is rare, and should not be a
  303.    problem under normal conditions.
  304.  
  305. *  If you develop Windows applications that use large bitmaps, you may
  306.    experience errors when trying to open bitmap files larger than 64k.  This
  307.    problem will be corrected in a future release.
  308.