Skip to content

Commit 7308e61

Browse files
committed
Initial commit of Windows 1 Example Application.
0 parents  commit 7308e61

14 files changed

Lines changed: 456 additions & 0 deletions

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore compiled binaries
2+
*.exe
3+
*.map
4+
*.obj
5+
*.res

AboutDlg.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <windows.h>
2+
#include "aboutdlg.h"
3+
#include "resource.h"
4+
#include "globals.h"
5+
6+
/* Dialog procedure for our "about" dialog */
7+
BOOL FAR PASCAL AboutDialogProc(hwndDlg, uMsg, wParam, lParam)
8+
HWND hwndDlg;
9+
unsigned uMsg;
10+
WORD wParam;
11+
LONG lParam;
12+
{
13+
switch (uMsg)
14+
{
15+
case WM_COMMAND:
16+
{
17+
WORD id = wParam;
18+
19+
switch (id)
20+
{
21+
case IDOK:
22+
case IDCANCEL:
23+
{
24+
EndDialog(hwndDlg, id);
25+
return TRUE;
26+
}
27+
}
28+
break;
29+
}
30+
31+
case WM_INITDIALOG:
32+
return TRUE;
33+
}
34+
35+
return FALSE;
36+
}
37+
38+
/* Show our "about" dialog */
39+
void ShowAboutDialog(owner)
40+
HWND owner;
41+
{
42+
/* Create dialog callback thunk */
43+
FARPROC aboutProc = MakeProcInstance(AboutDialogProc, g_hInstance);
44+
45+
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), owner, aboutProc);
46+
47+
/* Free dialog callback thunk */
48+
FreeProcInstance(aboutProc);
49+
}

AboutDlg.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef ABOUTDLG_H
2+
#define ABOUTDLG_H
3+
4+
/* Dialog procedure for our "about" dialog */
5+
BOOL FAR PASCAL AboutDialogProc(HWND, unsigned, WORD, LONG);
6+
7+
/* Show our "about" dialog */
8+
void ShowAboutDialog(HWND);
9+
10+
#endif

App.ico

1.01 KB
Binary file not shown.

Globals.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef GLOBALS_H
2+
#define GLOBALS_H
3+
4+
/* Global instance handle */
5+
extern HANDLE g_hInstance;
6+
7+
#endif

License.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 <http://unlicense.org>

MainWnd.c

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#include <windows.h>
2+
#include <string.h>
3+
#include "mainwnd.h"
4+
#include "aboutdlg.h"
5+
#include "resource.h"
6+
#include "globals.h"
7+
8+
/* Main window class and title */
9+
static char MainWndClass[] = "Windows 1 Example Application";
10+
11+
/* Window procedure for our main window */
12+
LONG FAR PASCAL MainWndProc(hWnd, msg, wParam, lParam)
13+
HWND hWnd;
14+
unsigned msg;
15+
WORD wParam;
16+
LONG lParam;
17+
{
18+
switch (msg)
19+
{
20+
case WM_COMMAND:
21+
{
22+
WORD id = wParam;
23+
24+
switch (id)
25+
{
26+
case ID_HELP_ABOUT:
27+
{
28+
ShowAboutDialog(hWnd);
29+
break;
30+
}
31+
32+
case ID_FILE_EXIT:
33+
{
34+
DestroyWindow(hWnd);
35+
break;
36+
}
37+
38+
default:
39+
return DefWindowProc(hWnd, msg, wParam, lParam);
40+
}
41+
42+
break;
43+
}
44+
45+
case WM_GETMINMAXINFO:
46+
{
47+
/* Prevent our window from being sized too small */
48+
MINMAXINFO *minMax = (MINMAXINFO*) lParam;
49+
minMax->ptMinTrackSize.x = 220;
50+
minMax->ptMinTrackSize.y = 110;
51+
52+
break;
53+
}
54+
55+
/* Item from system menu has been invoked */
56+
case WM_SYSCOMMAND:
57+
{
58+
WORD id = wParam;
59+
60+
switch (id)
61+
{
62+
case ID_HELP_ABOUT:
63+
{
64+
ShowAboutDialog(hWnd);
65+
break;
66+
}
67+
68+
default:
69+
return DefWindowProc(hWnd, msg, wParam, lParam);
70+
}
71+
72+
break;
73+
}
74+
75+
case WM_DESTROY:
76+
{
77+
PostQuitMessage(0);
78+
break;
79+
}
80+
81+
default:
82+
return DefWindowProc(hWnd, msg, wParam, lParam);
83+
}
84+
85+
return 0;
86+
}
87+
88+
/* Register a class for our main window */
89+
BOOL RegisterMainWindowClass()
90+
{
91+
WNDCLASS wc;
92+
93+
memset(&wc, 0, sizeof(wc));
94+
95+
wc.lpfnWndProc = MainWndProc;
96+
wc.hInstance = g_hInstance;
97+
wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_APPICON));
98+
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
99+
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
100+
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
101+
wc.lpszClassName = MainWndClass;
102+
103+
return (RegisterClass(&wc)) ? TRUE : FALSE;
104+
}
105+
106+
/* Create an instance of our main window */
107+
HWND CreateMainWindow()
108+
{
109+
HWND hWnd;
110+
HMENU hSysMenu;
111+
112+
hWnd = CreateWindow(MainWndClass, MainWndClass, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
113+
320, 200, NULL, NULL, g_hInstance, NULL);
114+
115+
if (hWnd)
116+
{
117+
/* Add "about" to the system menu. */
118+
hSysMenu = GetSystemMenu(hWnd, FALSE);
119+
ChangeMenu(hSysMenu, 0, NULL, 999, MF_APPEND | MF_SEPARATOR);
120+
ChangeMenu(hSysMenu, 0, "About", ID_HELP_ABOUT, MF_APPEND | MF_STRING);
121+
}
122+
123+
return hWnd;
124+
}

MainWnd.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#ifndef MAINWND_H
2+
#define MAINWND_H
3+
4+
/* Window procedure for our main window */
5+
LONG FAR PASCAL MainWndProc(HWND, unsigned, WORD, LONG);
6+
7+
/* Register a class for our main window */
8+
BOOL RegisterMainWindowClass();
9+
10+
/* Create an instance of our main window */
11+
HWND CreateMainWindow();
12+
13+
/* Minimum and maximum window sizing */
14+
#ifndef WM_GETMINMAXINFO
15+
#define WM_GETMINMAXINFO 0x0024
16+
17+
typedef struct tagMINMAXINFO
18+
{
19+
POINT ptReserved;
20+
POINT ptMaxSize;
21+
POINT ptMaxPosition;
22+
POINT ptMinTrackSize;
23+
POINT ptMaxTrackSize;
24+
} MINMAXINFO;
25+
#endif
26+
27+
/* Button colour */
28+
#ifndef COLOR_BTNFACE
29+
#define COLOR_BTNFACE 15
30+
#endif
31+
32+
/* Overlapped window style */
33+
#ifndef WS_OVERLAPPEDWINDOW
34+
#define WS_OVERLAPPEDWINDOW WS_TILED | WS_CAPTION | WS_SYSMENU | WS_SIZEBOX | 0x00010000L | 0x00020000L
35+
#endif
36+
37+
/* Default window positioning */
38+
#ifndef CW_USEDEFAULT
39+
#define CW_USEDEFAULT ((int)0x8000)
40+
#endif
41+
42+
#endif

Readme.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Windows 1 Example Application
2+
3+
## Table of Contents
4+
5+
- [Introduction](#introduction)
6+
- [Terms of Use](#terms-of-use)
7+
- [Problems?](#problems)
8+
- [Changelog](#changelog)
9+
10+
## Introduction
11+
12+
This application is an example 16 bit Windows application written in C. It
13+
accompanies the
14+
[Building Win16 GUI Applications in C](http://www.transmissionzero.co.uk/computing/win16-apps-in-c/)
15+
article on [Transmission Zero](http://www.transmissionzero.co.uk/). The
16+
application runs under Windows 1 to Windows 3.11, and all versions of Windows NT
17+
which support Win16 apps (Windows NT 3.1 to at least the x86 version of Windows
18+
8.1). It does not run under Windows 9x (Windows 95 to Windows ME). The reason
19+
for this is not known at the moment.
20+
21+
To build the application with Microsoft C, open a command prompt, change to the
22+
directory containing the Makefile, and run "make Win1App". Note that you will
23+
need a very old version of the C compiler and Windows SDK to build the
24+
application. I built it with Microsoft C 4 (not to be confused with Visual C++
25+
4), but I believe it will compile with Microsoft C 5 as well. It cannot be built
26+
with newer tools, e.g. Visual C++ 1.52, and I'm not aware of any freely
27+
available tools you can use to build it.
28+
29+
## Terms of Use
30+
31+
Refer to "License.txt" for terms of use.
32+
33+
## Problems?
34+
35+
If you have any problems or questions, please ensure you have read this readme
36+
file and the
37+
[Building Win16 GUI Applications in C](http://www.transmissionzero.co.uk/computing/win16-apps-in-c/)
38+
article. If you are still having trouble, you can
39+
[get in contact](http://www.transmissionzero.co.uk/contact/).
40+
41+
## Changelog
42+
43+
1. 2014-11-09: Version 1.0
44+
- First release.
45+
46+
Transmission Zero
47+
2016-08-27

Resource.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef RESOURCE_H
2+
#define RESOURCE_H
3+
4+
#define IDI_APPICON 101
5+
#define IDR_MAINMENU 102
6+
#define IDR_ACCELERATOR 103
7+
#define IDD_ABOUTDIALOG 104
8+
#define ID_FILE_EXIT 40001
9+
#define ID_HELP_ABOUT 40002
10+
11+
#ifndef IDC_STATIC
12+
#define IDC_STATIC -1
13+
#endif
14+
15+
#ifndef DS_MODALFRAME
16+
#define DS_MODALFRAME 0x80L
17+
#endif
18+
19+
#endif

0 commit comments

Comments
 (0)