home *** CD-ROM | disk | FTP | other *** search
- Copyright (C) 1992 MetaWare Incorporated. All Rights Reserved.
-
- MetaWare 32-Bit Windows 3.0 Application Development Kit
- April 1992
-
- ------------------------------------------------------------------------------
- NOTE: Important for Distribution of Applications
-
- The dynamic link library MWSUPDLL.DLL is called by all applications
- developed with the ADK. If you develop programs for resale and
- distribution, you must include MWSUPDLL.DLL with each of the products
- you distribute. There is NO royalty attached to using this file.
- ------------------------------------------------------------------------------
-
-
- Table of Contents
- -----------------
- 1. Introduction
- 2. Installation and Set-Up
- 3. 32-bit DLLs
- 4. Call16() Function
- 5. Debugging in Windows -- MDBW v1.3
- 6. Make Utility
- 7. Required Source Code Changes
- 8. Changes to the Documentation
- 9. Windows Problems
- 10. Known Problems
-
-
- 1. Introduction
- ---------------
-
- With the MetaWare Windows 3.0 Application Development Kit (ADK), plus a High C
- compiler, and Microsoft Windows 3.0, you can develop and run 32-bit
- applications in the Windows 3.0 386 enhanced-mode environment.
-
- We are now shipping the Microsoft 3.0 Resource Compiler so you can develop 32-
- bit Windows applications without Microsoft Windows SDK.
-
- Compatibility with Microsoft Windows 3.1 is under development and will be
- implemented in the next release.
-
-
- 2. Installation and Set-Up
- --------------------------
-
- The MetaWare Windows ADK is installed on top of your High C/C++ compiler
- installation. The resulting installed software can generate both 32-bit
- Windows applications and non-Windows extended-DOS applications.
-
-
- 3. 32-bit DLLs
- --------------
-
- The MetaWare ADK supports creating 32-bit dynamic link libraries (DLLs). See
- the ...\win\sdk\select directory for example source code. A DLL is compiled
- separately from your main Windows application, and is not linked directly with
- your program until execution. You can use Windows function calls to load the
- DLL into memory, and obtain the address of a function in the library that you
- want to call. See the Windows Application Developer's Guide for more
- information.
-
-
- 4. Call16() function
- --------------------
-
- MetaWare's 32-bit Windows Application Development Kit provides you with the
- ability to load 16-bit dynamic link libraries (DLLs). After a DLL is loaded,
- you can obtain the address of a function in the DLL, and call it using the
- ADK's Call16() function.
-
-
- 5. Debugger in Windows -- MDBW
- -------------------------------
-
- The Windows ADK includes a Windows version of MetaWare's 32-Bit Source-Level
- Debugger, MDBW. MDBW is designed to allow source-level debugging of the 32-
- bit protected-mode programs generated by the Windows ADK. MDBW is hosted on
- Windows 3.0 to allow you to debug your applications within the Windows 3.0
- environment. MDBW includes the files MWDEBUG.DLL and VMW32D.386.
-
- * Configuring Windows 3.0 for Debugging
-
- To use the debugger, you must edit your WINDOWS\SYSTEM.INI file to include
- the following line:
-
- [386Enh]
- DEVICE=vmw32d.386
-
- * Modifying configuration file MDBW.ENV and help files.
-
- Set environment variable MDBWENV to the location of file MDBW.ENV,
- and environment variable MDBWHELP to the directory in which the help
- files reside. For example:
-
- set MDBWENV=c:\hc386\bin\mdbw.env
- set MDBWHELP=c:\hc386\bin
-
- By default, the debugger looks for its configuration file (MDBW.CNF) and
- its help files (MDBW.TXT, MDBW.BOD, and MDBW.IDX) in the directory in which
- the debugger executable is found.
-
-
- * Known problems.
-
- - MDBW is not yet compatible with Windows 3.1.
-
- - The RELOAD command does not work under Windows 3.0.
-
- - MDBW may be unstable if the application exits with an error.
- If you are unable to restart MDBW, exit out of Windows and
- restart.
-
- - DOS program SHARE.EXE may cause a program load to fail.
-
- - Multiple breakpoints at one address are not supported.
-
- - CALLSTACK cannot display register-based arguments.
-
-
- 6. Make Utility
- ---------------
-
- The MetaWare make utility MWMAKE is a protected-mode make based on popular
- UNIX versions of make. Currently, a bug exists in the handling of default
- rules. The supplied makefiles avoid the use of default rules.
-
-
- 7. Required Source Code Changes
- -------------------------------
-
- The following source code changes are required when you port a 16-bit Windows
- program to run under the MetaWare 32-bit Windows ADK.
-
- * LocalAlloc() and LocalLock() return far pointers. Variables that are
- assigned the return value of a LocalAlloc() or LocalLock() call should be
- declared as type "LPSTR" or "LP48STR" (or an equivalent type).
-
- * Some windows applications use the type "unsigned" in place of the type
- "WORD". On a 32-bit platform, "unsigned" is four bytes long, while "WORD"
- is two bytes long. Therefore, functions declared as, for example:
-
- LONG (FAR PASCAL *lpfnWndProc)(HWND, unsigned, WORD, LONG);
-
- should instead be declared as:
-
- LONG (FAR PASCAL *lpfnWndProc)(HWND, WORD, WORD, LONG);
-
- * Occurrences of <TYPE> FAR * should be changed to LP<TYPE>. For example, if
- your program declares a variable:
-
- CREATESTRUCT FAR * pCS;
-
- you should modify the declaration to be:
-
- LPCREATESTRUCT pCS;
-
- The LP types are declared in the Windows header files.
-
- * The behavior of DebugBreak() has been modified slightly, to allow a program
- that contains calls to DebugBreak() to be run outside of a debugger.
- Normally, if a program calls DebugBreak() while being run outside of a
- debugger, the machine will hang. We have modified DebugBreak() such that it
- will not execute an "int 3" instruction unless it is run under the MetaWare
- debugger for Windows, MDBW. If you wish to have DebugBreak() execute an
- "int 3" instruction regardless of whether the program is running under the
- debugger, you have two options:
-
- 1) Set the environment variable DEBUGBREAK to any value. If this variable
- is detected in the environment, all calls to DebugBreak() will execute
- an "int 3" instruction.
-
- 2) Replace calls to DebugBreak() with calls to _mwDebugBreak().
- _mwDebugBreak() will always execute an "int 3" instruction.
-
- * If you use function SetWindowLong() to change the message-handling function
- for a window, you must use a function pointer returned from
- MakeProcInstance() as the third parameter. For example:
-
- extern void function();
- FARPROC pfunc = MakeProcInstance(function,hInst);
- SetWindowLong(hWnd,GWL_WNDPROC,pfunc);
-
- Failure to do this will cause your program to crash.
-
- * The MakeProcInstance() function in the MetaWare ADK returns a 16:16 pointer.
- Usually this pointer is passed along to Windows.
-
- ...
- case IDM_ABOUT:
- lpProcAbout = MakeProcInstance(About, hInst);
- DialogBox(hInst, "AboutBox", hWnd, lpProcAbout);
- FreeProcInstance(lpProcAbout);
- break;
- ...
-
- If you need to call this address directly, you must use the Call16()
- function, which allows your program to call 16:16 pointers-to-functions.
- For example:
-
- extern BOOL FAR PASCAL PrintDlgProc (HWND, WORD, WORD, DWORD);
- FARPROC lpfnPrintDlgProc ;
-
- lpfnPrintDlgProc = MakeProcInstance (PrintDlgProc, hInst) ;
- ...
- #ifdef __HIGHC__
- Call16(lpfnPrintDlgProc,"wwwd", hWnd, message, wParam, lParam);
- #else
- lpfnPrintDlgProc(hWnd, message, wParam, lParam);
- #endif
-
- See the Application Developer's Guide for more information about Call16().
-
- * Keep in mind that on a 32-bit platform an "int" is four bytes long, instead
- of two bytes as it is on a 16-bit platform. If you make assumptions about
- the size of integer variables, you should use either "short" or "long"
- rather than "int". If you notice problems in your program that seem to be
- caused by a variable having an unexpected value, be sure to check the size
- of that variable. You may need to change "int" variables to be of type
- "short".
-
-
- 8. Changes to the Documentation
- -------------------------------
-
- The Application Developer's Guide states that for messages where one of the
- message parameters is a pointer, the program must use BRK_FP() to convert the
- pointer from a 16:16 pointer to a 16:32 pointer.
-
- There are three exceptions to this rule: for messages WM_NCCREATE, WM_CREATE,
- and WM_MDICREATE, the fourth parameter, "lParam", is a pointer to a structure
- (CREATESTRUCT or MDICREATESTRUCT). These structures contain members that are
- themselves pointers. Because these members must be converted into 16:32
- pointers, the MetaWare supervisor must allocate memory on the local heap, and
- create a new copy of the structure with translated member values. Therefore,
- the lParam for these three messages is a 0:32 pointer, not a 16:16 pointer.
- Do not try to convert lParam into a 16:32 pointer with BRK_FP().
-
- For example, the documentation implies that the following code should be used
- to access the CREATESTRUCT structure pointed to by the lParam parameter of the
- WM_CREATE message:
-
- long FAR PASCAL WndProc(HWND hWnd, WORD message, WORD wParam, DWORD lParam){
- switch (message) {
- case WM_CREATE: {
- LPCREATESTRUCT lpCreateStruct = (LPCREATESTRUCT) BRK_FP(lParam);
- }
- }
- ...
- }
-
- Use instead:
-
- long FAR PASCAL WndProc(HWND hWnd, WORD message, WORD wParam, DWORD lParam){
- switch (message) {
- case WM_CREATE: {
- LPCREATESTRUCT lpCreateStruct = (LPCREATESTRUCT) lParam;
- }
- ...
- }
- ...
- }
-
- The type LPCREATESTRUCT is defined in windows.h to be a near pointer rather
- than a far pointer. If you need a far pointer to a CREATESTRUCT, use type
- LP48CREATESTRUCT. Structure MDICREATESTRUCT is handled similarly.
-
-
- 9. Windows Problems
- -------------------
-
- If you experience a large number of "Unrecoverable Application Error" messages
- when running Windows programs, check the following in your CONFIG.SYS file:
-
- * set FILES to at least 30; preferably 40
-
- * set your environment to at least 1024 bytes, preferably 2048; with the line:
-
- SHELL=command.com /e:2048
-
-
- 10. Known Problems
- -------------------
-
- * On some machines, you may experience problems using the debugger MDBW with
- various device drivers, memory-resident programs (TSRs), or local area
- networks. If you cannot load a program to debug, or cannot get the
- debugger to execute, try changing your CONFIG.SYS and/or AUTOEXEC.BAT files
- to temporarily eliminate the network or device drivers. Then reboot and
- try the debugger again.
-
- * If you currently have EMM386 installed in your CONFIG.SYS file, you must
- remove it prior to using the MetaWare compilers. There is a conflict
- between Phar Lap's V3.0 and V4.0 DOS extenders and EMM386.
-
- * You may notice that if you run a Windows program many times without
- rebooting your machine, occasionally the program will start up, but never
- display a window. The Windows task switcher thinks that the program is
- running, and it is actually running. At the present time, we have not
- determined the cause of this anomalous behavior. If you encounter this
- behavior, simply reboot your machine. The program will run properly after
- the machine has been rebooted. This behavior is rare, and should not be a
- problem under normal conditions.
-
- * If you develop Windows applications that use large bitmaps, you may
- experience errors when trying to open bitmap files larger than 64k. This
- problem will be corrected in a future release.