[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 806da4421c
which passed all the bots successfully. Also the x64 ones.
This commit is contained in:
Joachim Henze 2023-09-17 20:50:04 +02:00
parent 806da4421c
commit 8a54e4c9f6
3 changed files with 17 additions and 24 deletions

View file

@ -1,9 +1,7 @@
/*
* ReactOS Standard Dialog Application Template
*
* dialog.c
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
* Copyright (C) 2002 Robert Dickenson <robd@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;
}

View file

@ -1,9 +1,7 @@
/*
* ReactOS Standard Dialog Application Template
*
* memdlg.c
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
* Copyright (C) 2002 Robert Dickenson <robd@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) {

View file

@ -1,9 +1,7 @@
/*
* ReactOS About Dialog Box
*
* about.c
*
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
* Copyright (C) 2002 Robert Dickenson <robd@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);
}