Skip to content

Commit

Permalink
Header files added. DLGPROC callback functions change of signature.
Browse files Browse the repository at this point in the history
- malloc/free/realloc/calloc/rand/min/max/qsort required includes with Microsoft Visual Studio Community 2019
Version 16.9.4
- DLGPROC signature return changed to INT_PTR (from BOOL)
  • Loading branch information
recombinant committed May 9, 2021
1 parent a7966f0 commit 57a295b
Show file tree
Hide file tree
Showing 62 changed files with 232 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"windows.h": "c"
}
}
41 changes: 34 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -617,25 +617,52 @@ add_executable(Metafile WIN32 "Chapter 18 Metafiles/MetaFile/Metafile.c")

# ================================================================== Chapter 19

add_executable(MDIDemo WIN32 "Chapter 19 The Multiple-Document Interface/MDIDemo/MDIDemo.c")
add_executable(MDIDemo WIN32 "Chapter 19 The Multiple-Document Interface/MDIDemo/MDIDemo.c"
"Chapter 19 The Multiple-Document Interface/MDIDemo/Resource.h"
"Chapter 19 The Multiple-Document Interface/MDIDemo/MDIDemo.rc")

# ================================================================== Chapter 20

add_executable(BigJob1 WIN32 "Chapter 20 Multitasking and Multithreading/BigJob1/BigJob1.c")
add_executable(BigJob2 WIN32 "Chapter 20 Multitasking and Multithreading/BigJob2/BigJob2.c")

add_executable(Multi1 WIN32 "Chapter 20 Multitasking and Multithreading/Multi1/Multi1.c")
add_executable(Multi2 WIN32 "Chapter 20 Multitasking and Multithreading/Multi2/Multi2.c")
add_executable(RndRctMT WIN32 "Chapter 20 Multitasking and Multithreading/RndRectMT/RndRctMT.c")

# ================================================================== Chapter 21

add_executable(RndRctMT WIN32 "Chapter 20 Multitasking and Multithreading/RndRectMT/RndRctMT.c")
add_executable(EdrTest WIN32 "Chapter 21 Dynamic-Link Libraries/EdrTest/EdrTest.c"
"Chapter 21 Dynamic-Link Libraries/EdrTest/EdrLib.c")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_library(EdrLib SHARED)
if (WIN32)
target_sources(EdrLib PRIVATE "Chapter 21 Dynamic-Link Libraries/EdrTest/EdrLib.c"
"Chapter 21 Dynamic-Link Libraries/EdrTest/EdrLib.h")
# target_link_libraries()
endif()

add_executable(EdrTest WIN32 "Chapter 21 Dynamic-Link Libraries/EdrTest/EdrTest.c")
target_link_libraries(EdrTest EdrLib)

#add_subdirectory("Chapter 21 Dynamic-Link Libraries/EdrTest")

add_executable(ShowBit WIN32 "Chapter 21 Dynamic-Link Libraries/ShowBit/ShowBit.c"
"Chapter 21 Dynamic-Link Libraries/ShowBit/BitLib.c")
"Chapter 21 Dynamic-Link Libraries/ShowBit/BitLib.c"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Resource.h"
"Chapter 21 Dynamic-Link Libraries/ShowBit/BitLib.rc"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Bitmap1.bmp"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Bitmap2.bmp"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Bitmap3.bmp"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Bitmap4.bmp"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Bitmap5.bmp"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Bitmap6.bmp"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Bitmap7.bmp"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Bitmap8.bmp"
"Chapter 21 Dynamic-Link Libraries/ShowBit/Bitmap9.bmp")

add_executable(StrProg WIN32 "Chapter 21 Dynamic-Link Libraries/StrProg/StrProg.c"
"Chapter 21 Dynamic-Link Libraries/StrProg/StrLib.c")
"Chapter 21 Dynamic-Link Libraries/StrProg/StrLib.c"
"Chapter 21 Dynamic-Link Libraries/StrProg/StrLib.h"
"Chapter 21 Dynamic-Link Libraries/StrProg/Resource.h"
"Chapter 21 Dynamic-Link Libraries/StrProg/StrProg.rc")

# ================================================================== Chapter 22

Expand Down
4 changes: 2 additions & 2 deletions Chapter 01 Getting Started/01 HelloMsg/HelloMsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
//#include <tchar.h>

int WINAPI _tWinMain(
int WINAPI WinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ PTSTR pCmdLine,
Expand Down
1 change: 1 addition & 0 deletions Chapter 06 The Keyboard/05 Typer/Typer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <malloc.h>

#define BUFFER(x,y) *(pBuffer + y * cxBuffer + x)

Expand Down
6 changes: 3 additions & 3 deletions Chapter 11 Dialog Boxes/About1/About1.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*------------------------------------------
s/*------------------------------------------
ABOUT1.C -- About Box Demo Program No. 1
(c) Charles Petzold, 1998
------------------------------------------*/
Expand All @@ -10,7 +10,7 @@
#include "Resource.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI _tWinMain(
_In_ HINSTANCE hInstance,
Expand Down Expand Up @@ -87,7 +87,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hwnd, message, wParam, lParam);
}

BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message,
INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch (message)
Expand Down
4 changes: 2 additions & 2 deletions Chapter 11 Dialog Boxes/About2/About2.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "Resource.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);

int iCurrentColor = IDC_BLACK,
iCurrentFigure = IDC_RECT;
Expand Down Expand Up @@ -130,7 +130,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hwnd, message, wParam, lParam);
}

BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message,
INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
static HWND hCtrlBlock;
Expand Down
4 changes: 2 additions & 2 deletions Chapter 11 Dialog Boxes/About3/About3.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "Resource.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK EllipPushWndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI _tWinMain(
Expand Down Expand Up @@ -100,7 +100,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hwnd, message, wParam, lParam);
}

BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message,
INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch (message)
Expand Down
4 changes: 2 additions & 2 deletions Chapter 11 Dialog Boxes/Colors2/Colors2.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <tchar.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK ColorScrDlg(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK ColorScrDlg(HWND, UINT, WPARAM, LPARAM);

HWND hDlgModeless;

Expand Down Expand Up @@ -83,7 +83,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hwnd, message, wParam, lParam);
}

BOOL CALLBACK ColorScrDlg(HWND hDlg, UINT message,
INT_PTR CALLBACK ColorScrDlg(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
static int iColor[3];
Expand Down
1 change: 1 addition & 0 deletions Chapter 11 Dialog Boxes/PopPad3/PopFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commdlg.h>
#include <malloc.h>

static OPENFILENAME ofn;

Expand Down
4 changes: 3 additions & 1 deletion Chapter 11 Dialog Boxes/PopPad3/PopFind.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <windows.h>
#include <commdlg.h>
#include <tchar.h> // for _tcsstr (strstr for Unicode & non-Unicode)
#include <malloc.h>

#define MAX_STRING_LEN 256

Expand Down Expand Up @@ -67,7 +68,6 @@ BOOL PopFindFindText(HWND hwndEdit, int* piSearchOffset, LPFINDREPLACE pfr)
// Search the document for the find string

pstrPos = _tcsstr(pstrDoc + *piSearchOffset, pfr->lpstrFindWhat);
free(pstrDoc);

// Return an error code if the string cannot be found

Expand All @@ -84,6 +84,8 @@ BOOL PopFindFindText(HWND hwndEdit, int* piSearchOffset, LPFINDREPLACE pfr)
SendMessage(hwndEdit, EM_SETSEL, iPos, *piSearchOffset);
SendMessage(hwndEdit, EM_SCROLLCARET, 0, 0);

free(pstrDoc);

return TRUE;
}

Expand Down
1 change: 1 addition & 0 deletions Chapter 12 The Clipboard/ClipText/ClipText.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define WIN32_LEAN_AND_MEAN
#include <tchar.h>
#include <windows.h>
#include <malloc.h>
#include "Resource.h"

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
Expand Down
1 change: 1 addition & 0 deletions Chapter 13 Using the Printer/FormFeed/GetPrnDC.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winspool.h>
#include <malloc.h>

HDC GetPrinterDC(void)
{
Expand Down
3 changes: 2 additions & 1 deletion Chapter 13 Using the Printer/PopPrnt/PopPrnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commdlg.h>
#include <malloc.h>
#include "Resource.h"

BOOL bUserAbort;
HWND hDlgPrint;

BOOL CALLBACK PrintDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK PrintDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(lParam);
Expand Down
Binary file added Chapter 13 Using the Printer/PopPrnt/RCa05108
Binary file not shown.
2 changes: 1 addition & 1 deletion Chapter 13 Using the Printer/Print3/Print3.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TCHAR szCaption[] = TEXT("Print Program 3 (Dialog Box)");
BOOL bUserAbort;
HWND hDlgPrint;

BOOL CALLBACK PrintDlgProc(HWND hDlg, UINT message,
INT_PTR CALLBACK PrintDlgProc(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch (message)
Expand Down
1 change: 1 addition & 0 deletions Chapter 14 Bitmaps and Bitblts/Scramble/Scramble.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define WIN32_LEAN_AND_MEAN
#include <tchar.h>
#include <windows.h>
#include <stdlib.h>

#define NUM 300

Expand Down
2 changes: 2 additions & 0 deletions Chapter 15 The Device Independent Bitmap/Apollo11/Apollo11.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <math.h>
#include <malloc.h>
#include "../ShowDib1/DibFile.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
Expand Down
1 change: 1 addition & 0 deletions Chapter 15 The Device Independent Bitmap/DibConv/DibConv.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <commdlg.h>
#include <windowsx.h>
#include <tchar.h>
#include <malloc.h>
#include "./Resource.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <tchar.h>
#include <windows.h>
#include <commdlg.h>
#include <malloc.h>
#include "./Resource.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
Expand Down
1 change: 1 addition & 0 deletions Chapter 15 The Device Independent Bitmap/DibSect/DibSect.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <commdlg.h>
#include <windowsx.h>
#include <tchar.h>
#include <malloc.h>
#include "Resource.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
Expand Down
2 changes: 2 additions & 0 deletions Chapter 15 The Device Independent Bitmap/SeqDisp/SeqDisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <windows.h>
#include <tchar.h>
#include <commdlg.h>
#include <malloc.h>
#include <math.h>
#include "./Resource.h"

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commdlg.h>
#include <malloc.h>
#include "DibFile.h"

static OPENFILENAME ofn;
Expand Down
2 changes: 2 additions & 0 deletions Chapter 15 The Device Independent Bitmap/ShowDib1/ShowDib1.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <windowsx.h>
#include <tchar.h>
#include <commdlg.h>
#include <malloc.h>
#include <math.h>
#include "DibFile.h"
#include "./Resource.h"

Expand Down
2 changes: 2 additions & 0 deletions Chapter 15 The Device Independent Bitmap/ShowDib2/Showdib2.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <windowsx.h>
#include <commdlg.h>
#include <tchar.h>
#include <malloc.h>
#include <math.h>
#include "../ShowDib1/DibFile.h"
#include "Resource.h"

Expand Down
1 change: 1 addition & 0 deletions Chapter 16 The Palette Manager/Bounce/Bounce.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <malloc.h>

#define ID_TIMER 1

Expand Down
1 change: 1 addition & 0 deletions Chapter 16 The Palette Manager/Dibble/DibHelp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <malloc.h>
#include "DibHelp.h"

#define HDIB_SIGNATURE (* (int *) "Dib ")
Expand Down
1 change: 1 addition & 0 deletions Chapter 16 The Palette Manager/Dibble/DibPal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
#include "DibHelp.h"
#include "DibPal.h"

Expand Down
1 change: 1 addition & 0 deletions Chapter 16 The Palette Manager/Grays2/Grays2.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <malloc.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

Expand Down
1 change: 1 addition & 0 deletions Chapter 16 The Palette Manager/Grays3/Grays3.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <malloc.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

Expand Down
1 change: 1 addition & 0 deletions Chapter 16 The Palette Manager/Pipes/Pipes.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <malloc.h>

#define ID_TIMER 1

Expand Down
2 changes: 2 additions & 0 deletions Chapter 16 The Palette Manager/ShowDib3/PackeDib.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <malloc.h>
#include <math.h>

/*---------------------------------------------------------
PackedDibLoad: Load DIB File as Packed-Dib Memory Block
Expand Down
1 change: 1 addition & 0 deletions Chapter 16 The Palette Manager/ShowDib3/ShowDib3.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <windowsx.h>
#include <tchar.h>
#include <commdlg.h>
#include <malloc.h>
#include "../ShowDib3/PackeDib.h"
#include "Resource.h"

Expand Down
1 change: 1 addition & 0 deletions Chapter 16 The Palette Manager/ShowDib4/ShowDib4.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <windowsx.h>
#include <tchar.h>
#include <commdlg.h>
#include <malloc.h>
#include "../ShowDib3/PackeDib.h"
#include "Resource.h"

Expand Down
1 change: 1 addition & 0 deletions Chapter 16 The Palette Manager/ShowDib5/ShowDib5.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <windowsx.h>
#include <tchar.h>
#include <commdlg.h>
#include <malloc.h>
#include "../ShowDib3/PackeDib.h"
#include "Resource.h"

Expand Down
Loading

0 comments on commit 57a295b

Please sign in to comment.