-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1cbea49
commit a301ab0
Showing
20 changed files
with
650 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "aboutdlg.h" | ||
#include "resource.h" | ||
#include "globals.h" | ||
|
||
/* Dialog procedure for our "about" dialog */ | ||
BOOL CALLBACK AboutDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) | ||
{ | ||
switch (uMsg) | ||
{ | ||
case WM_COMMAND: | ||
{ | ||
WORD id = wParam; | ||
|
||
switch (id) | ||
{ | ||
case IDOK: | ||
case IDCANCEL: | ||
{ | ||
EndDialog(hwndDlg, id); | ||
return TRUE; | ||
} | ||
} | ||
break; | ||
} | ||
|
||
case WM_INITDIALOG: | ||
return TRUE; | ||
} | ||
|
||
return FALSE; | ||
} | ||
|
||
/* Show our "about" dialog */ | ||
void ShowAboutDialog(HWND owner) | ||
{ | ||
/* Create dialog callback thunk */ | ||
FARPROC aboutProc = MakeProcInstance(&AboutDialogProc, g_hInstance); | ||
|
||
DialogBox(g_hInstance, MAKEINTRESOURCE(IDD_ABOUTDIALOG), owner, aboutProc); | ||
|
||
/* Free dialog callback thunk */ | ||
FreeProcInstance(aboutProc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef ABOUTDLG_H | ||
#define ABOUTDLG_H | ||
|
||
#include <windows.h> | ||
|
||
/* Dialog procedure for our "about" dialog */ | ||
BOOL CALLBACK AboutDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); | ||
|
||
/* Show our "about" dialog */ | ||
void ShowAboutDialog(HWND owner); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef GLOBALS_H | ||
#define GLOBALS_H | ||
|
||
#include <windows.h> | ||
|
||
/* Global instance handle */ | ||
extern HINSTANCE g_hInstance; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#include "mainwnd.h" | ||
#include "aboutdlg.h" | ||
#include "resource.h" | ||
#include "globals.h" | ||
|
||
/* Main window class and title */ | ||
static const char MainWndClass[] = "Win16 Example Application"; | ||
|
||
/* Window procedure for our main window */ | ||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | ||
{ | ||
switch (msg) | ||
{ | ||
case WM_COMMAND: | ||
{ | ||
WORD id = wParam; | ||
|
||
switch (id) | ||
{ | ||
case ID_HELP_ABOUT: | ||
{ | ||
ShowAboutDialog(hWnd); | ||
break; | ||
} | ||
|
||
case ID_FILE_EXIT: | ||
{ | ||
DestroyWindow(hWnd); | ||
break; | ||
} | ||
|
||
default: | ||
return DefWindowProc(hWnd, msg, wParam, lParam); | ||
} | ||
|
||
break; | ||
} | ||
|
||
case WM_GETMINMAXINFO: | ||
{ | ||
/* Prevent our window from being sized too small */ | ||
MINMAXINFO *minMax = (MINMAXINFO*) lParam; | ||
minMax->ptMinTrackSize.x = 220; | ||
minMax->ptMinTrackSize.y = 110; | ||
|
||
break; | ||
} | ||
|
||
/* Item from system menu has been invoked */ | ||
case WM_SYSCOMMAND: | ||
{ | ||
WORD id = wParam; | ||
|
||
switch (id) | ||
{ | ||
case ID_HELP_ABOUT: | ||
{ | ||
ShowAboutDialog(hWnd); | ||
break; | ||
} | ||
|
||
default: | ||
return DefWindowProc(hWnd, msg, wParam, lParam); | ||
} | ||
|
||
break; | ||
} | ||
|
||
case WM_DESTROY: | ||
{ | ||
PostQuitMessage(0); | ||
break; | ||
} | ||
|
||
default: | ||
return DefWindowProc(hWnd, msg, wParam, lParam); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
/* Register a class for our main window */ | ||
BOOL RegisterMainWindowClass() | ||
{ | ||
WNDCLASS wc = {0}; | ||
|
||
wc.lpfnWndProc = &MainWndProc; | ||
wc.hInstance = g_hInstance; | ||
wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_APPICON)); | ||
wc.hCursor = LoadCursor(NULL, IDC_ARROW); | ||
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); | ||
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU); | ||
wc.lpszClassName = MainWndClass; | ||
|
||
return (RegisterClass(&wc)) ? TRUE : FALSE; | ||
} | ||
|
||
/* Create an instance of our main window */ | ||
HWND CreateMainWindow() | ||
{ | ||
HWND hWnd; | ||
HMENU hSysMenu; | ||
|
||
hWnd = CreateWindowEx(0, MainWndClass, MainWndClass, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, | ||
320, 200, NULL, NULL, g_hInstance, NULL); | ||
|
||
if (hWnd) | ||
{ | ||
/* Add "about" to the system menu */ | ||
hSysMenu = GetSystemMenu(hWnd, FALSE); | ||
InsertMenu(hSysMenu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); | ||
InsertMenu(hSysMenu, 6, MF_BYPOSITION, (UINT) ID_HELP_ABOUT, "About"); | ||
} | ||
|
||
return hWnd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef MAINWND_H | ||
#define MAINWND_H | ||
|
||
#include <windows.h> | ||
|
||
/* Window procedure for our main window */ | ||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); | ||
|
||
/* Register a class for our main window */ | ||
BOOL RegisterMainWindowClass(); | ||
|
||
/* Create an instance of our main window */ | ||
HWND CreateMainWindow(); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
# This Makefile will build the Win16 test application. | ||
# This Makefile will build the Win16 Example application | ||
|
||
HEADERS = Resource.h Callback.h | ||
OBJS = WinMain.obj Callback.obj | ||
RES = Resource.res | ||
|
||
CC = cl16.exe | ||
CC = cl | ||
CFLAGS = /nologo /c /D NDEBUG /D WINVER=0x0300 /G3swf /Os /W3 /Zp /FPi87 | ||
LINK = link16.exe | ||
RC = rc16.exe | ||
EXE = Win16App.exe | ||
DEF = Win16App.def | ||
LINK = link | ||
RC = rc | ||
|
||
OBJS = WinMain.obj MainWnd.obj AboutDlg.obj | ||
|
||
# Rules | ||
all: Win16App.exe | ||
|
||
Win16App.exe: $(OBJS) $(RES) $(DEF) | ||
$(LINK) /nologo /align:16 $(OBJS),$(EXE),,libw.lib slibcew.lib,$(DEF) | ||
$(RC) /nologo /30 $(RES) $(EXE) | ||
Win16App.exe: | ||
$(LINK) /nologo /align:16 $(OBJS),Win16App.exe,,libw.lib slibcew.lib,Win16App.def | ||
$(RC) /nologo /30 Resource.res Win16App.exe | ||
|
||
clean: | ||
del $(OBJS) $(RES) $(EXE) Win16App.map | ||
@del *.obj *.res *.map Win16App.exe 2> NUL | ||
|
||
%.obj: %.c $(HEADERS) | ||
%.obj: | ||
$(CC) $(CFLAGS) $< | ||
|
||
Resource.res: | ||
$(RC) /nologo /r Resource.rc | ||
|
||
# Dependencies | ||
Win16App.exe: $(OBJS) Resource.res Win16App.def | ||
AboutDlg.obj: AboutDlg.c AboutDlg.h Resource.h Globals.h | ||
MainWnd.obj: MainWnd.c MainWnd.h AboutDlg.h Resource.h Globals.h | ||
WinMain.obj: WinMain.c MainWnd.h Resource.h Globals.h | ||
Resource.res: Resource.rc App.ico Resource.h | ||
$(RC) /nologo /r resource.rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef RESOURCE_H | ||
#define RESOURCE_H | ||
|
||
#define IDI_APPICON 101 | ||
#define IDR_MAINMENU 102 | ||
#define IDR_ACCELERATOR 103 | ||
#define IDD_ABOUTDIALOG 104 | ||
#define ID_FILE_EXIT 40001 | ||
#define ID_HELP_ABOUT 40002 | ||
|
||
#ifndef IDC_STATIC | ||
#define IDC_STATIC -1 | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.