├── .gitignore ├── AboutDlg.c ├── AboutDlg.h ├── App.ico ├── Globals.h ├── License.txt ├── MainWnd.c ├── MainWnd.h ├── Readme.md ├── Resource.h ├── Resource.rc ├── Win16App.def ├── Win16App.mak ├── Win16App.tgt ├── Win16App.ver ├── Win16App.wpj └── WinMain.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore compiler output 2 | *.bsc 3 | *.crf 4 | *.bnd 5 | *.exe 6 | *.lk1 7 | *.map 8 | *.obj 9 | *.pdb 10 | *.res 11 | *.sbr 12 | *.sym 13 | 14 | # Ignore Visual Studio files 15 | *.aps 16 | *.vcw 17 | *.wsp 18 | 19 | # Ignore Watcom files 20 | *.mk 21 | *.mk1 -------------------------------------------------------------------------------- /AboutDlg.c: -------------------------------------------------------------------------------- 1 | #include "AboutDlg.h" 2 | #include "Globals.h" 3 | #include "Resource.h" 4 | 5 | /* Dialog procedure for our "about" dialog */ 6 | BOOL CALLBACK AboutDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 7 | { 8 | switch (uMsg) 9 | { 10 | case WM_COMMAND: 11 | { 12 | WORD id = wParam; 13 | 14 | switch (id) 15 | { 16 | case IDOK: 17 | case IDCANCEL: 18 | { 19 | EndDialog(hwndDlg, id); 20 | return TRUE; 21 | } 22 | } 23 | break; 24 | } 25 | 26 | case WM_INITDIALOG: 27 | { 28 | return TRUE; 29 | } 30 | } 31 | 32 | return FALSE; 33 | } 34 | 35 | /* Show our "about" dialog */ 36 | void ShowAboutDialog(HWND owner) 37 | { 38 | DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), owner, &AboutDialogProc); 39 | } 40 | -------------------------------------------------------------------------------- /AboutDlg.h: -------------------------------------------------------------------------------- 1 | #ifndef ABOUTDLG_H 2 | #define ABOUTDLG_H 3 | 4 | #include 5 | 6 | /* Dialog procedure for our "about" dialog */ 7 | BOOL CALLBACK __export AboutDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 8 | 9 | /* Show our "about" dialog */ 10 | void ShowAboutDialog(HWND owner); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /App.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/Win16-Example-Application/7e93a45392008f64a52a9bc3250603ac6b8f6a0c/App.ico -------------------------------------------------------------------------------- /Globals.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBALS_H 2 | #define GLOBALS_H 3 | 4 | #include 5 | 6 | /* Global instance handle */ 7 | extern HINSTANCE g_hInstance; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /MainWnd.c: -------------------------------------------------------------------------------- 1 | #include "AboutDlg.h" 2 | #include "Globals.h" 3 | #include "MainWnd.h" 4 | #include "Resource.h" 5 | 6 | /* Main window class and title */ 7 | static const char MainWndClass[] = "Win16 Example Application"; 8 | 9 | /* Window procedure for our main window */ 10 | LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 11 | { 12 | switch (msg) 13 | { 14 | case WM_COMMAND: 15 | { 16 | WORD id = wParam; 17 | 18 | switch (id) 19 | { 20 | case ID_HELP_ABOUT: 21 | { 22 | ShowAboutDialog(hWnd); 23 | return 0; 24 | } 25 | 26 | case ID_FILE_EXIT: 27 | { 28 | DestroyWindow(hWnd); 29 | return 0; 30 | } 31 | } 32 | break; 33 | } 34 | 35 | case WM_GETMINMAXINFO: 36 | { 37 | /* Prevent our window from being sized too small */ 38 | MINMAXINFO FAR* minMax = (MINMAXINFO FAR*)lParam; 39 | minMax->ptMinTrackSize.x = 220; 40 | minMax->ptMinTrackSize.y = 110; 41 | 42 | return 0; 43 | } 44 | 45 | /* Item from system menu has been invoked */ 46 | case WM_SYSCOMMAND: 47 | { 48 | WORD id = wParam; 49 | 50 | switch (id) 51 | { 52 | /* Show "about" dialog on about system menu item */ 53 | case ID_HELP_ABOUT: 54 | { 55 | ShowAboutDialog(hWnd); 56 | return 0; 57 | } 58 | } 59 | break; 60 | } 61 | 62 | case WM_DESTROY: 63 | { 64 | PostQuitMessage(0); 65 | return 0; 66 | } 67 | } 68 | 69 | return DefWindowProc(hWnd, msg, wParam, lParam); 70 | } 71 | 72 | /* Register a class for our main window */ 73 | BOOL RegisterMainWindowClass() 74 | { 75 | WNDCLASS wc; 76 | 77 | /* Class for our main window */ 78 | wc.style = 0; 79 | wc.lpfnWndProc = &MainWndProc; 80 | wc.cbClsExtra = 0; 81 | wc.cbWndExtra = 0; 82 | wc.hInstance = g_hInstance; 83 | wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_APPICON)); 84 | wc.hCursor = LoadCursor(NULL, IDC_ARROW); 85 | wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); 86 | wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU); 87 | wc.lpszClassName = MainWndClass; 88 | 89 | return (RegisterClass(&wc)) ? TRUE : FALSE; 90 | } 91 | 92 | /* Create an instance of our main window */ 93 | HWND CreateMainWindow() 94 | { 95 | /* Create instance of main window */ 96 | HWND hWnd = CreateWindowEx(0, MainWndClass, MainWndClass, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 320, 200, 97 | NULL, NULL, g_hInstance, NULL); 98 | 99 | if (hWnd) 100 | { 101 | /* Add "about" to the system menu */ 102 | HMENU hSysMenu = GetSystemMenu(hWnd, FALSE); 103 | InsertMenu(hSysMenu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); 104 | InsertMenu(hSysMenu, 6, MF_BYPOSITION, ID_HELP_ABOUT, "About"); 105 | } 106 | 107 | return hWnd; 108 | } 109 | -------------------------------------------------------------------------------- /MainWnd.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWND_H 2 | #define MAINWND_H 3 | 4 | #include 5 | 6 | /* Window procedure for our main window */ 7 | LRESULT CALLBACK __export MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 8 | 9 | /* Register a class for our main window */ 10 | BOOL RegisterMainWindowClass(void); 11 | 12 | /* Create an instance of our main window */ 13 | HWND CreateMainWindow(void); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # Win16 Example Application 2 | 3 | ## Table of Contents 4 | 5 | - [Introduction](#introduction) 6 | - [Building the Application](#building-the-application) 7 | - [Smart Callbacks](#smart-callbacks) 8 | - [Terms of Use](#terms-of-use) 9 | - [Known Problems](#known-problems) 10 | - [Changelog](#changelog) 11 | 12 | ## Introduction 13 | 14 | This application is an example 16 bit Windows application written in C. It 15 | accompanies the 16 | [Building Win16 GUI Applications in C](http://www.transmissionzero.co.uk/computing/win16-apps-in-c/) 17 | article on [Transmission Zero](http://www.transmissionzero.co.uk/). 18 | 19 | The application runs under Windows 3.0 to Windows ME, and all versions of 20 | Windows NT which support Win16 apps (Windows NT 3.1 to at least the x86 version 21 | of Windows 10). It does not run under Windows 1 or 2, but there is a 22 | [Windows 1 Version](https://github.com/TransmissionZero/Windows-1-Example-Application) 23 | which is compatible with Windows 1 and 2 (but not compatible with Windows 9x). 24 | 25 | The application can be built using Visual C++ 1.5x. You can 26 | [download Visual C++ 1.52](https://my.visualstudio.com/Downloads?pid=140) if you 27 | have a Visual Studio Subscription. If you don't have a subscription, you can 28 | download the 29 | [Windows Server 2003 DDK](http://download.microsoft.com/download/9/0/f/90f019ac-8243-48d3-91cf-81fc4093ecfd/1830_usa_ddk.iso) 30 | which contains the 16 bit command line tools (most of which are from Visual C++ 31 | 1.52). The 16 bit binaries can be found in "bin\bin16" of the installed DDK, 32 | include files in "inc\inc16", and lib files in "lib\lib16". A number of the 33 | binaries come in two versions, one with and one without a "16" suffix, e.g. 34 | "cl.exe" and "cl16.exe". Despite the different filenames, the file contents are 35 | identical. 36 | 37 | The application can also be built with [Open Watcom](http://openwatcom.org/), 38 | which is free to download. 39 | 40 | With a few small changes to the Makefile, the application will build with 41 | Microsoft C / C++ 7.0 and the Windows 3.1 SDK. It won't build with the Windows 42 | 3.0 SDK because the headers don't define some of the required types, and it does 43 | not have the "ver.h" header which is required for the version information 44 | resource. 45 | 46 | ## Building the Application 47 | 48 | To build the application with the Microsoft Visual C++ 1.5x GUI, go to 49 | "project", "open", then open "Win16App.mak". To choose a debug or release build, 50 | go to "options" then "project". The project can be built using the "build" or 51 | "rebuild" toolbar items, or via the "project" menu. 52 | 53 | To build the application from the command line with Visual C++ 1.5x, launch a 54 | command prompt, run the "MSVCVARS.BAT" file which can be found in the Visual C++ 55 | "bin" directory, and then navigate to the directory containing the Makefile. Run 56 | "nmake /f Win16App.mak" to build. This also works with the Windows Server 2003 57 | DDK, but instead of running "MSVCVARS.BAT", you will need to add the "bin16" 58 | directory to your "%PATH%" environment variable, "inc16" to "%INCLUDE%", and 59 | "lib16" to "%LIB%". 60 | 61 | To build the application in [Open Watcom](http://openwatcom.org/), open the 62 | project up in the IDE, and choose the "Make" option from the "Targets" menu. You 63 | can switch between debug and release builds by going to "Targets", "Target 64 | Options", and choosing "Use Development Switches" or "Use Release Switches". 65 | 66 | ## Smart Callbacks 67 | 68 | This application makes use of so-called "smart callbacks". This means the data segment register is loaded from the 69 | stack segment register on entry to any callback function which is called by Windows. The result of this is that it is 70 | not necessary to list the callback functions in the application's module definition file, and it is not necessary to use 71 | "MakeProcInstance" to create a thunk when (e.g.) displaying a dialog box. In Visual C++ this is achieved by marking 72 | callback functions with the "__export" modifier, and using the "/GA /GEs /GEm" compiler options (optimise far function 73 | epilogs, load DS from SS, and increment BP on entry to the callback--required only for real mode stack walking support). 74 | You can also use the "/GEf" option, which means all far functions are given the code to load DS from SS regardless of 75 | whether they are callback functions. This is slightly less efficient, but does mean that callback functions don't 76 | require the "__export" modifier. 77 | 78 | Open Watcom does the same thing, but uses the "-zWs" compiler option to include the segment loading code. 79 | 80 | Refer to the [Windows 1 Version](https://github.com/TransmissionZero/Windows-1-Example-Application) for an example 81 | application which uses "MakeProcInstance" rather than smart callbacks. 82 | 83 | ## Terms of Use 84 | 85 | Refer to "License.txt" for terms of use. 86 | 87 | ## Known Problems 88 | 89 | The Open Watcom build of the application doesn't work correctly under Windows 90 | 3.0 when running in Real Mode. The application will start but the menu is 91 | missing and the about dialog won't display. I've found Open Watcom to be a bit 92 | hit and miss, where certain seemingly harmless changes of compiler option result 93 | in an application which crashes, so it may be possible to fix this by changing 94 | the compiler options. It runs fine under Windows 3.0 in Standard Mode and 386 95 | Enhanced Mode. 96 | 97 | The Open Watcom build of the application has optimisations switched off. With 98 | optimisations enabled, the application crashes on startup. 99 | 100 | If you have any other problems or questions, please ensure you have read this 101 | readme file and the 102 | [Building Win16 GUI Applications in C](http://www.transmissionzero.co.uk/computing/win16-apps-in-c/) 103 | article. If you are still having trouble, you can 104 | [get in contact](http://www.transmissionzero.co.uk/contact/). 105 | 106 | ## Changelog 107 | 108 | 5. 2017-05-21: Version 1.4 109 | - Removed unnecessary whitespace from source files. 110 | - Corrected min / max window size handling, which should have been using a far 111 | pointer for the MINMAXINFO struct. 112 | - Removed the original Makefile as it just duplicates the functionality of the 113 | Visual C++ Makefile. 114 | - Various updates to compiler and linker options to ensure consistency between 115 | Visual C++ and Open Watcom builds. 116 | 117 | 4. 2014-11-09: Version 1.3 118 | - Added a Makefile project for use with the Visual C++ GUI. 119 | - Refactored some of the code to split the source code files by functionality. 120 | 121 | 3. 2013-09-07: Version 1.2 122 | - Removed superfluous LOWORD() macros which had been applied to WPARAMs. 123 | 124 | 2. 2013-08-26: Version 1.1 125 | - Added a VERSIONINFO resource to the executable, so that version information 126 | can be viewed in File Manager or Windows Explorer. 127 | - Open Watcom build now runs in Windows 3.0 (but not in real mode). 128 | - Ensured all source files are no more than 8.3 characters long. 129 | 130 | 1. 2011-07-06: Version 1.0 131 | - First release. 132 | 133 | Transmission Zero 134 | 2017-05-21 135 | -------------------------------------------------------------------------------- /Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // App Studio generated include file. 3 | // Used by RESOURCE.RC 4 | // 5 | #define IDI_APPICON 100 6 | #define IDR_MAINMENU 101 7 | #define IDR_ACCELERATOR 102 8 | #define IDD_ABOUTDIALOG 103 9 | #define ID_FILE_EXIT 200 10 | #define ID_HELP_ABOUT 300 11 | #define IDC_STATIC -1 12 | 13 | // Next default values for new objects 14 | // 15 | #ifdef APSTUDIO_INVOKED 16 | #ifndef APSTUDIO_READONLY_SYMBOLS 17 | 18 | #define _APS_NEXT_RESOURCE_VALUE 104 19 | #define _APS_NEXT_COMMAND_VALUE 301 20 | #define _APS_NEXT_CONTROL_VALUE 1000 21 | #define _APS_NEXT_SYMED_VALUE 101 22 | #endif 23 | #endif 24 | -------------------------------------------------------------------------------- /Resource.rc: -------------------------------------------------------------------------------- 1 | //Microsoft App Studio generated resource script. 2 | // 3 | #include "Resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #define APSTUDIO_HIDDEN_SYMBOLS 11 | #include "windows.h" 12 | #undef APSTUDIO_HIDDEN_SYMBOLS 13 | 14 | 15 | ///////////////////////////////////////////////////////////////////////////////////// 16 | #undef APSTUDIO_READONLY_SYMBOLS 17 | 18 | 19 | ////////////////////////////////////////////////////////////////////////////// 20 | // 21 | // Icon 22 | // 23 | 24 | IDI_APPICON ICON DISCARDABLE "APP.ICO" 25 | 26 | ////////////////////////////////////////////////////////////////////////////// 27 | // 28 | // Menu 29 | // 30 | 31 | IDR_MAINMENU MENU DISCARDABLE 32 | BEGIN 33 | POPUP "&File" 34 | BEGIN 35 | MENUITEM "E&xit", ID_FILE_EXIT 36 | END 37 | POPUP "&Help" 38 | BEGIN 39 | MENUITEM "&About", ID_HELP_ABOUT 40 | END 41 | END 42 | 43 | 44 | ////////////////////////////////////////////////////////////////////////////// 45 | // 46 | // Dialog 47 | // 48 | 49 | IDD_ABOUTDIALOG DIALOG DISCARDABLE 0, 0, 147, 67 50 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU 51 | CAPTION "About" 52 | FONT 8, "MS Sans Serif" 53 | BEGIN 54 | ICON IDI_APPICON,IDC_STATIC,7,7,20,20 55 | LTEXT "Win16 Example application.",IDC_STATIC,34,7,91,8 56 | LTEXT "\2512017 Transmission Zero",IDC_STATIC,34,17,86,8 57 | DEFPUSHBUTTON "OK",IDOK,90,46,50,14,WS_GROUP 58 | END 59 | 60 | 61 | ////////////////////////////////////////////////////////////////////////////// 62 | // 63 | // Accelerator 64 | // 65 | 66 | IDR_ACCELERATOR ACCELERATORS DISCARDABLE 67 | BEGIN 68 | "a", ID_HELP_ABOUT, ASCII, ALT, NOINVERT 69 | END 70 | 71 | #ifdef APSTUDIO_INVOKED 72 | ////////////////////////////////////////////////////////////////////////////// 73 | // 74 | // TEXTINCLUDE 75 | // 76 | 77 | 1 TEXTINCLUDE DISCARDABLE 78 | BEGIN 79 | "Resource.h\0" 80 | END 81 | 82 | 2 TEXTINCLUDE DISCARDABLE 83 | BEGIN 84 | "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" 85 | "#include ""windows.h""\r\n" 86 | "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" 87 | "\r\n" 88 | "\0" 89 | END 90 | 91 | 3 TEXTINCLUDE DISCARDABLE 92 | BEGIN 93 | "#include ""Win16App.ver""\r\n" 94 | "\0" 95 | END 96 | 97 | ///////////////////////////////////////////////////////////////////////////////////// 98 | #endif // APSTUDIO_INVOKED 99 | 100 | 101 | #ifndef APSTUDIO_INVOKED 102 | //////////////////////////////////////////////////////////////////////////////// 103 | // 104 | // Generated from the TEXTINCLUDE 3 resource. 105 | // 106 | #include "Win16App.ver" 107 | 108 | ///////////////////////////////////////////////////////////////////////////////////// 109 | #endif // not APSTUDIO_INVOKED 110 | 111 | -------------------------------------------------------------------------------- /Win16App.def: -------------------------------------------------------------------------------- 1 | NAME WIN16APP 2 | DESCRIPTION 'Win16 Example Application' 3 | EXETYPE WINDOWS 3.00 4 | REALMODE 5 | STUB 'WINSTUB.EXE' 6 | CODE MOVEABLE PRELOAD DISCARDABLE 7 | DATA MOVEABLE PRELOAD MULTIPLE 8 | HEAPSIZE 1024 9 | STACKSIZE 4096 10 | -------------------------------------------------------------------------------- /Win16App.mak: -------------------------------------------------------------------------------- 1 | # Microsoft Visual C++ generated build script - Do not modify 2 | 3 | PROJ = WIN16APP 4 | DEBUG = 0 5 | PROGTYPE = 0 6 | CALLER = 7 | ARGS = 8 | DLLS = 9 | D_RCDEFINES = /d_DEBUG 10 | R_RCDEFINES = /dNDEBUG 11 | ORIGIN = MSVC 12 | ORIGIN_VER = 1.00 13 | PROJPATH = UNKNOWN 14 | USEMFC = 0 15 | CC = cl 16 | CPP = cl 17 | CXX = cl 18 | CCREATEPCHFLAG = 19 | CPPCREATEPCHFLAG = 20 | CUSEPCHFLAG = 21 | CPPUSEPCHFLAG = 22 | FIRSTC = ABOUTDLG.C 23 | FIRSTCPP = 24 | RC = rc 25 | CFLAGS_D_WEXE = /nologo /W3 /Gf /Zi /Od /D "WINVER"="0x0300" /D "_DEBUG" /FR /GA /GEs /GEm /Fd"WIN16APP.PDB" 26 | CFLAGS_R_WEXE = /nologo /W3 /Gf /O1 /D "WINVER"="0x0300" /D "NDEBUG" /FR /GA /GEs /GEm 27 | LFLAGS_D_WEXE = /NOLOGO /NOD /PACKC:61440 /ALIGN:16 /ONERROR:NOEXE /CO 28 | LFLAGS_R_WEXE = /NOLOGO /NOD /PACKC:61440 /ALIGN:16 /ONERROR:NOEXE 29 | LIBS_D_WEXE = oldnames libw slibcew commdlg.lib olecli.lib olesvr.lib shell.lib 30 | LIBS_R_WEXE = oldnames libw slibcew commdlg.lib olecli.lib olesvr.lib shell.lib 31 | RCFLAGS = /nologo 32 | RESFLAGS = /nologo /30 33 | RUNFLAGS = 34 | DEFFILE = WIN16APP.DEF 35 | OBJS_EXT = 36 | LIBS_EXT = 37 | !if "$(DEBUG)" == "1" 38 | CFLAGS = $(CFLAGS_D_WEXE) 39 | LFLAGS = $(LFLAGS_D_WEXE) 40 | LIBS = $(LIBS_D_WEXE) 41 | MAPFILE = nul 42 | RCDEFINES = $(D_RCDEFINES) 43 | !else 44 | CFLAGS = $(CFLAGS_R_WEXE) 45 | LFLAGS = $(LFLAGS_R_WEXE) 46 | LIBS = $(LIBS_R_WEXE) 47 | MAPFILE = nul 48 | RCDEFINES = $(R_RCDEFINES) 49 | !endif 50 | !if [if exist MSVC.BND del MSVC.BND] 51 | !endif 52 | SBRS = ABOUTDLG.SBR \ 53 | MAINWND.SBR \ 54 | WINMAIN.SBR 55 | 56 | 57 | ABOUTDLG_DEP = aboutdlg.h \ 58 | globals.h \ 59 | resource.h 60 | 61 | 62 | MAINWND_DEP = aboutdlg.h \ 63 | globals.h \ 64 | mainwnd.h \ 65 | resource.h 66 | 67 | 68 | RESOURCE_RCDEP = resource.h \ 69 | app.ico 70 | 71 | 72 | WINMAIN_DEP = globals.h \ 73 | mainwnd.h \ 74 | resource.h 75 | 76 | 77 | all: $(PROJ).EXE $(PROJ).BSC 78 | 79 | ABOUTDLG.OBJ: ABOUTDLG.C $(ABOUTDLG_DEP) 80 | $(CC) $(CFLAGS) $(CCREATEPCHFLAG) /c ABOUTDLG.C 81 | 82 | MAINWND.OBJ: MAINWND.C $(MAINWND_DEP) 83 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c MAINWND.C 84 | 85 | RESOURCE.RES: RESOURCE.RC $(RESOURCE_RCDEP) 86 | $(RC) $(RCFLAGS) $(RCDEFINES) -r RESOURCE.RC 87 | 88 | WINMAIN.OBJ: WINMAIN.C $(WINMAIN_DEP) 89 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c WINMAIN.C 90 | 91 | 92 | $(PROJ).EXE:: RESOURCE.RES 93 | 94 | $(PROJ).EXE:: ABOUTDLG.OBJ MAINWND.OBJ WINMAIN.OBJ $(OBJS_EXT) $(DEFFILE) 95 | echo >NUL @<<$(PROJ).CRF 96 | ABOUTDLG.OBJ + 97 | MAINWND.OBJ + 98 | WINMAIN.OBJ + 99 | $(OBJS_EXT) 100 | $(PROJ).EXE 101 | $(MAPFILE) 102 | $(LIBS) 103 | $(DEFFILE); 104 | << 105 | link $(LFLAGS) @$(PROJ).CRF 106 | $(RC) $(RESFLAGS) RESOURCE.RES $@ 107 | @copy $(PROJ).CRF MSVC.BND 108 | 109 | $(PROJ).EXE:: RESOURCE.RES 110 | if not exist MSVC.BND $(RC) $(RESFLAGS) RESOURCE.RES $@ 111 | 112 | run: $(PROJ).EXE 113 | $(PROJ) $(RUNFLAGS) 114 | 115 | 116 | $(PROJ).BSC: $(SBRS) 117 | bscmake @<< 118 | /o$@ $(SBRS) 119 | << 120 | -------------------------------------------------------------------------------- /Win16App.tgt: -------------------------------------------------------------------------------- 1 | 40 2 | targetIdent 3 | 0 4 | MProject 5 | 1 6 | MComponent 7 | 0 8 | 2 9 | WString 10 | 4 11 | WEXE 12 | 3 13 | WString 14 | 5 15 | w_6en 16 | 1 17 | 0 18 | 0 19 | 4 20 | MCommand 21 | 0 22 | 5 23 | MCommand 24 | 0 25 | 6 26 | MItem 27 | 12 28 | Win16App.exe 29 | 7 30 | WString 31 | 4 32 | WEXE 33 | 8 34 | WVList 35 | 4 36 | 9 37 | MVState 38 | 10 39 | WString 40 | 7 41 | WINLINK 42 | 11 43 | WString 44 | 11 45 | ?????Stack: 46 | 0 47 | 12 48 | WString 49 | 4 50 | 4096 51 | 0 52 | 13 53 | MCState 54 | 14 55 | WString 56 | 7 57 | WINLINK 58 | 15 59 | WString 60 | 34 61 | ?????Requires Windows 3.0 or later 62 | 0 63 | 1 64 | 16 65 | MVState 66 | 17 67 | WString 68 | 7 69 | WINLINK 70 | 18 71 | WString 72 | 11 73 | ?????Stack: 74 | 1 75 | 19 76 | WString 77 | 4 78 | 4096 79 | 0 80 | 20 81 | MCState 82 | 21 83 | WString 84 | 7 85 | WINLINK 86 | 22 87 | WString 88 | 34 89 | ?????Requires Windows 3.0 or later 90 | 1 91 | 1 92 | 23 93 | WVList 94 | 1 95 | 24 96 | ActionStates 97 | 25 98 | WString 99 | 5 100 | &Make 101 | 26 102 | WVList 103 | 0 104 | -1 105 | 1 106 | 1 107 | 0 108 | 27 109 | WPickList 110 | 13 111 | 28 112 | MItem 113 | 3 114 | *.c 115 | 29 116 | WString 117 | 4 118 | COBJ 119 | 30 120 | WVList 121 | 14 122 | 31 123 | MRState 124 | 32 125 | WString 126 | 3 127 | WCC 128 | 33 129 | WString 130 | 21 131 | ?????Compiler default 132 | 1 133 | 0 134 | 34 135 | MVState 136 | 35 137 | WString 138 | 3 139 | WCC 140 | 36 141 | WString 142 | 19 143 | ?????Other options: 144 | 1 145 | 37 146 | WString 147 | 4 148 | -zWs 149 | 0 150 | 38 151 | MRState 152 | 39 153 | WString 154 | 3 155 | WCC 156 | 40 157 | WString 158 | 21 159 | ?????Compiler default 160 | 1 161 | 0 162 | 41 163 | MRState 164 | 42 165 | WString 166 | 3 167 | WCC 168 | 43 169 | WString 170 | 25 171 | ?????Inline with emulator 172 | 1 173 | 1 174 | 44 175 | MRState 176 | 45 177 | WString 178 | 3 179 | WCC 180 | 46 181 | WString 182 | 16 183 | ??6??Small model 184 | 1 185 | 1 186 | 47 187 | MRState 188 | 48 189 | WString 190 | 3 191 | WCC 192 | 49 193 | WString 194 | 16 195 | ??6??Large model 196 | 1 197 | 0 198 | 50 199 | MRState 200 | 51 201 | WString 202 | 3 203 | WCC 204 | 52 205 | WString 206 | 21 207 | ?????Compiler default 208 | 0 209 | 0 210 | 53 211 | MVState 212 | 54 213 | WString 214 | 3 215 | WCC 216 | 55 217 | WString 218 | 19 219 | ?????Other options: 220 | 0 221 | 56 222 | WString 223 | 4 224 | -zWs 225 | 0 226 | 57 227 | MRState 228 | 58 229 | WString 230 | 3 231 | WCC 232 | 59 233 | WString 234 | 21 235 | ?????No optimizations 236 | 0 237 | 1 238 | 60 239 | MRState 240 | 61 241 | WString 242 | 3 243 | WCC 244 | 62 245 | WString 246 | 26 247 | ?????Fastest possible code 248 | 0 249 | 0 250 | 63 251 | MRState 252 | 64 253 | WString 254 | 3 255 | WCC 256 | 65 257 | WString 258 | 21 259 | ?????Compiler default 260 | 0 261 | 0 262 | 66 263 | MRState 264 | 67 265 | WString 266 | 3 267 | WCC 268 | 68 269 | WString 270 | 25 271 | ?????Inline with emulator 272 | 0 273 | 1 274 | 69 275 | MRState 276 | 70 277 | WString 278 | 3 279 | WCC 280 | 71 281 | WString 282 | 16 283 | ??6??Small model 284 | 0 285 | 1 286 | 72 287 | MRState 288 | 73 289 | WString 290 | 3 291 | WCC 292 | 74 293 | WString 294 | 16 295 | ??6??Large model 296 | 0 297 | 0 298 | 75 299 | WVList 300 | 0 301 | -1 302 | 1 303 | 1 304 | 0 305 | 76 306 | MItem 307 | 10 308 | AboutDlg.c 309 | 77 310 | WString 311 | 4 312 | COBJ 313 | 78 314 | WVList 315 | 0 316 | 79 317 | WVList 318 | 0 319 | 28 320 | 1 321 | 1 322 | 0 323 | 80 324 | MItem 325 | 9 326 | MainWnd.c 327 | 81 328 | WString 329 | 4 330 | COBJ 331 | 82 332 | WVList 333 | 0 334 | 83 335 | WVList 336 | 0 337 | 28 338 | 1 339 | 1 340 | 0 341 | 84 342 | MItem 343 | 9 344 | WinMain.c 345 | 85 346 | WString 347 | 4 348 | COBJ 349 | 86 350 | WVList 351 | 0 352 | 87 353 | WVList 354 | 0 355 | 28 356 | 1 357 | 1 358 | 0 359 | 88 360 | MItem 361 | 3 362 | *.h 363 | 89 364 | WString 365 | 3 366 | NIL 367 | 90 368 | WVList 369 | 0 370 | 91 371 | WVList 372 | 0 373 | -1 374 | 1 375 | 1 376 | 0 377 | 92 378 | MItem 379 | 10 380 | AboutDlg.h 381 | 93 382 | WString 383 | 3 384 | NIL 385 | 94 386 | WVList 387 | 0 388 | 95 389 | WVList 390 | 0 391 | 88 392 | 1 393 | 1 394 | 0 395 | 96 396 | MItem 397 | 9 398 | Globals.h 399 | 97 400 | WString 401 | 3 402 | NIL 403 | 98 404 | WVList 405 | 0 406 | 99 407 | WVList 408 | 0 409 | 88 410 | 1 411 | 1 412 | 0 413 | 100 414 | MItem 415 | 9 416 | MainWnd.h 417 | 101 418 | WString 419 | 3 420 | NIL 421 | 102 422 | WVList 423 | 0 424 | 103 425 | WVList 426 | 0 427 | 88 428 | 1 429 | 1 430 | 0 431 | 104 432 | MItem 433 | 10 434 | Resource.h 435 | 105 436 | WString 437 | 3 438 | NIL 439 | 106 440 | WVList 441 | 0 442 | 107 443 | WVList 444 | 0 445 | 88 446 | 1 447 | 1 448 | 0 449 | 108 450 | MItem 451 | 5 452 | *.ico 453 | 109 454 | WString 455 | 3 456 | NIL 457 | 110 458 | WVList 459 | 0 460 | 111 461 | WVList 462 | 0 463 | -1 464 | 1 465 | 1 466 | 0 467 | 112 468 | MItem 469 | 7 470 | App.ico 471 | 113 472 | WString 473 | 3 474 | NIL 475 | 114 476 | WVList 477 | 0 478 | 115 479 | WVList 480 | 0 481 | 108 482 | 1 483 | 1 484 | 0 485 | 116 486 | MItem 487 | 4 488 | *.rc 489 | 117 490 | WString 491 | 5 492 | WRESC 493 | 118 494 | WVList 495 | 0 496 | 119 497 | WVList 498 | 0 499 | -1 500 | 1 501 | 1 502 | 0 503 | 120 504 | MItem 505 | 11 506 | Resource.rc 507 | 121 508 | WString 509 | 5 510 | WRESC 511 | 122 512 | WVList 513 | 0 514 | 123 515 | WVList 516 | 0 517 | 116 518 | 1 519 | 1 520 | 0 521 | -------------------------------------------------------------------------------- /Win16App.ver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TransmissionZero/Win16-Example-Application/7e93a45392008f64a52a9bc3250603ac6b8f6a0c/Win16App.ver -------------------------------------------------------------------------------- /Win16App.wpj: -------------------------------------------------------------------------------- 1 | 40 2 | projectIdent 3 | 0 4 | VpeMain 5 | 1 6 | WRect 7 | 0 8 | 0 9 | 10270 10 | 9969 11 | 2 12 | MProject 13 | 3 14 | MCommand 15 | 0 16 | 4 17 | MCommand 18 | 0 19 | 1 20 | 5 21 | WFileName 22 | 12 23 | Win16App.tgt 24 | 6 25 | WVList 26 | 1 27 | 7 28 | VComponent 29 | 8 30 | WRect 31 | 0 32 | 0 33 | 1871 34 | 8365 35 | 0 36 | 0 37 | 9 38 | WFileName 39 | 12 40 | Win16App.tgt 41 | 0 42 | 12 43 | 7 44 | -------------------------------------------------------------------------------- /WinMain.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Globals.h" 3 | #include "MainWnd.h" 4 | #include "Resource.h" 5 | 6 | /* Global instance handle */ 7 | HINSTANCE g_hInstance = NULL; 8 | 9 | /* Our application entry point */ 10 | int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 11 | { 12 | HWND hWnd; 13 | HACCEL hAccelerators; 14 | MSG msg; 15 | 16 | /* Assign global HINSTANCE */ 17 | g_hInstance = hInstance; 18 | 19 | /* Register our main window class, or error */ 20 | if (!hPrevInstance && !RegisterMainWindowClass()) 21 | { 22 | MessageBox(NULL, "Error registering main window class.", "Error", MB_ICONHAND | MB_OK); 23 | return 0; 24 | } 25 | 26 | /* Create our main window, or error */ 27 | if (!(hWnd = CreateMainWindow())) 28 | { 29 | MessageBox(NULL, "Error creating main window.", "Error", MB_ICONHAND | MB_OK); 30 | return 0; 31 | } 32 | 33 | /* Load accelerators */ 34 | hAccelerators = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR)); 35 | 36 | /* Show main window and force a paint */ 37 | ShowWindow(hWnd, nCmdShow); 38 | UpdateWindow(hWnd); 39 | 40 | /* Main message loop */ 41 | while (GetMessage(&msg, NULL, 0, 0) > 0) 42 | { 43 | if (!TranslateAccelerator(hWnd, hAccelerators, &msg)) 44 | { 45 | TranslateMessage(&msg); 46 | DispatchMessage(&msg); 47 | } 48 | } 49 | 50 | return (int)msg.wParam; 51 | } 52 | --------------------------------------------------------------------------------