https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8a54e4c9f6d81e3ecc56f…
commit 8a54e4c9f6d81e3ecc56f7ffba52d008b49cd0c3
Author: Joachim Henze <Joachim.Henze(a)reactos.org>
AuthorDate: Sun Sep 17 20:50:04 2023 +0200
Commit: Joachim Henze <Joachim.Henze(a)reactos.org>
CommitDate: Sun Sep 17 20:50:04 2023 +0200
[TEMPLATES] Avoid (DLGPROC) casts
The type-system is supposed to be our friend, not our enemy.
I pushed this without PR, because the buildbots don't
build the templates by default. That requires
configure -DENABLE_ROSAPPS=1 -DENABLE_ROSAPPS_TEMPLATES=1
So no gain in running them. Greta Thunberg will appreciate the saved CPU-cycles to
fight global warming.
I verified it locally to compile without warnings on GCC8.4.0dbg x86
and it follows the same pattern as
0.4.15-dev-6626-g 806da4421c13becf47735ad33f18dafd542497df
which passed all the bots successfully. Also the x64 ones.
---
modules/rosapps/templates/dialog/dialog.c | 25 +++++++++++--------------
modules/rosapps/templates/dialog/memdlg.c | 8 +++-----
modules/rosapps/templates/mdi/about.c | 8 +++-----
3 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/modules/rosapps/templates/dialog/dialog.c
b/modules/rosapps/templates/dialog/dialog.c
index 0484e1854bd..ee3ec9a32c9 100644
--- a/modules/rosapps/templates/dialog/dialog.c
+++ b/modules/rosapps/templates/dialog/dialog.c
@@ -1,9 +1,7 @@
/*
* ReactOS Standard Dialog Application Template
*
- * dialog.c
- *
- * Copyright (C) 2002 Robert Dickenson <robd(a)reactos.org>
+ * Copyright (C) 2002 Robert Dickenson <robd(a)reactos.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -43,9 +41,9 @@ HWND hPage2;
HWND hPage3;
LRESULT CreateMemoryDialog(HINSTANCE, HWND hwndOwner, LPSTR lpszMessage);
-LRESULT CALLBACK PageWndProc1(HWND, UINT, WPARAM, LPARAM);
-LRESULT CALLBACK PageWndProc2(HWND, UINT, WPARAM, LPARAM);
-LRESULT CALLBACK PageWndProc3(HWND, UINT, WPARAM, LPARAM);
+INT_PTR CALLBACK PageWndProc1(HWND, UINT, WPARAM, LPARAM);
+INT_PTR CALLBACK PageWndProc2(HWND, UINT, WPARAM, LPARAM);
+INT_PTR CALLBACK PageWndProc3(HWND, UINT, WPARAM, LPARAM);
////////////////////////////////////////////////////////////////////////////////
@@ -64,9 +62,9 @@ static BOOL OnCreate(HWND hWnd, LONG lData)
// Create tab pages
hTabWnd = GetDlgItem(hWnd, IDC_TAB);
- hPage1 = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PAGE1), hWnd,
(DLGPROC)PageWndProc1);
- hPage2 = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PAGE2), hWnd,
(DLGPROC)PageWndProc2);
- hPage3 = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PAGE3), hWnd,
(DLGPROC)PageWndProc3);
+ hPage1 = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PAGE1), hWnd, PageWndProc1);
+ hPage2 = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PAGE2), hWnd, PageWndProc2);
+ hPage3 = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PAGE3), hWnd, PageWndProc3);
// Insert tabs
_tcscpy(szTemp, _T("Page One"));
@@ -117,7 +115,7 @@ void OnTabWndSelChange(void)
}
}
-LRESULT CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int idctrl;
LPNMHDR pnmh;
@@ -181,7 +179,6 @@ LRESULT CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam,
LPARAM lParam)
return 0;
}
-
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
@@ -193,7 +190,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
DialogData instData = { NULL, 34 };
hInst = hInstance;
- instData.hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_TABBED_DIALOG), NULL,
(DLGPROC)DlgProc, (LPARAM)&instData);
+ instData.hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_TABBED_DIALOG), NULL,
DlgProc, (LPARAM)&instData);
ShowWindow(instData.hWnd, SW_SHOW);
hAccel = LoadAccelerators(hInst, (LPCTSTR)IDR_ACCELERATOR);
while (GetMessage(&msg, NULL, 0, 0)) {
@@ -204,8 +201,8 @@ int APIENTRY WinMain(HINSTANCE hInstance,
}
#else
hInst = hInstance;
- DialogBox(hInst, (LPCTSTR)IDD_TABBED_DIALOG, NULL, (DLGPROC)DlgProc);
+ DialogBox(hInst, (LPCTSTR)IDD_TABBED_DIALOG, NULL, DlgProc);
//CreateMemoryDialog(hInst, GetDesktopWindow(), "CreateMemoryDialog");
#endif
- return 0;
+ return 0;
}
diff --git a/modules/rosapps/templates/dialog/memdlg.c
b/modules/rosapps/templates/dialog/memdlg.c
index dd95e49f425..cba4d349d1d 100644
--- a/modules/rosapps/templates/dialog/memdlg.c
+++ b/modules/rosapps/templates/dialog/memdlg.c
@@ -1,9 +1,7 @@
/*
* ReactOS Standard Dialog Application Template
*
- * memdlg.c
- *
- * Copyright (C) 2002 Robert Dickenson <robd(a)reactos.org>
+ * Copyright (C) 2002 Robert Dickenson <robd(a)reactos.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,7 +31,7 @@ extern HINSTANCE hInst;
////////////////////////////////////////////////////////////////////////////////
-LRESULT CALLBACK DialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
return 0;
}
@@ -144,7 +142,7 @@ LRESULT CreateMemoryDialog(HINSTANCE hinst, HWND hwndOwner, LPSTR
lpszMessage)
*lpw++ = 0; // no creation data
GlobalUnlock(hgbl);
- ret = DialogBoxIndirect(hinst, (LPDLGTEMPLATE)hgbl, hwndOwner,
(DLGPROC)DialogWndProc);
+ ret = DialogBoxIndirect(hinst, (LPDLGTEMPLATE)hgbl, hwndOwner, DialogWndProc);
if (ret == 0) {
TRACE(_T("DialogBoxIndirect() failed due to invalid handle to parent window:
0x%08X"), hwndOwner);
} else if (ret == -1) {
diff --git a/modules/rosapps/templates/mdi/about.c
b/modules/rosapps/templates/mdi/about.c
index 84191f02a93..5cb488ec473 100644
--- a/modules/rosapps/templates/mdi/about.c
+++ b/modules/rosapps/templates/mdi/about.c
@@ -1,9 +1,7 @@
/*
* ReactOS About Dialog Box
*
- * about.c
- *
- * Copyright (C) 2002 Robert Dickenson <robd(a)reactos.org>
+ * Copyright (C) 2002 Robert Dickenson <robd(a)reactos.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,7 +39,7 @@
extern HINSTANCE hInst;
-LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
lParam)
+INT_PTR CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM
lParam)
{
HWND hLicenseEditWnd;
TCHAR strLicense[0x1000];
@@ -64,6 +62,6 @@ LRESULT CALLBACK AboutDialogWndProc(HWND hDlg, UINT message, WPARAM
wParam, LPAR
void ShowAboutBox(HWND hWnd)
{
- DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, (DLGPROC)AboutDialogWndProc);
+ DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, AboutDialogWndProc);
}