From 09c6736145ecd0ecc731e6d915a8cbfa6d771a3a Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sun, 13 Apr 2014 12:20:31 +0000 Subject: [PATCH] [SHELL32] - Use C++-style casts. Patch by Ivan Rodionov. CORE-7698 #resolve svn path=/trunk/; revision=62737 --- reactos/dll/win32/shell32/autocomplete.cpp | 4 ++-- reactos/dll/win32/shell32/desktop.cpp | 5 ++--- reactos/dll/win32/shell32/drvdefext.cpp | 10 +++++----- reactos/dll/win32/shell32/enumidlist.cpp | 2 +- reactos/dll/win32/shell32/filedefext.cpp | 8 ++++---- reactos/dll/win32/shell32/folders/recyclebin.cpp | 2 +- reactos/dll/win32/shell32/newmenu.cpp | 4 ++-- reactos/dll/win32/shell32/openwithmenu.cpp | 8 ++++---- reactos/dll/win32/shell32/shelllink.cpp | 10 +++++----- reactos/dll/win32/shell32/shlview.cpp | 2 +- 10 files changed, 27 insertions(+), 28 deletions(-) diff --git a/reactos/dll/win32/shell32/autocomplete.cpp b/reactos/dll/win32/shell32/autocomplete.cpp index 8d1352e620b..f7d27dcdf78 100644 --- a/reactos/dll/win32/shell32/autocomplete.cpp +++ b/reactos/dll/win32/shell32/autocomplete.cpp @@ -256,7 +256,7 @@ HRESULT WINAPI CAutoComplete::SetOptions(DWORD dwFlag) */ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CAutoComplete *pThis = (CAutoComplete *)GetPropW(hwnd, autocomplete_propertyW);;//GetWindowLongPtrW(hwnd, GWLP_USERDATA); + CAutoComplete *pThis = static_cast(GetPropW(hwnd, autocomplete_propertyW));//GetWindowLongPtrW(hwnd, GWLP_USERDATA); LPOLESTR strs; HRESULT hr; WCHAR hwndText[255]; @@ -488,7 +488,7 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM LRESULT APIENTRY CAutoComplete::ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CAutoComplete *pThis = (CAutoComplete *)GetWindowLongPtrW(hwnd, GWLP_USERDATA); + CAutoComplete *pThis = reinterpret_cast(GetWindowLongPtrW(hwnd, GWLP_USERDATA)); WCHAR *msg; int sel, len; diff --git a/reactos/dll/win32/shell32/desktop.cpp b/reactos/dll/win32/shell32/desktop.cpp index 58b95e20872..cc0b8d8808d 100644 --- a/reactos/dll/win32/shell32/desktop.cpp +++ b/reactos/dll/win32/shell32/desktop.cpp @@ -389,8 +389,7 @@ LRESULT CALLBACK CDesktopBrowser::ProgmanWindowProc(IN HWND hwnd, IN UINT uMsg, if (uMsg != WM_NCCREATE) { - pThis = (CDesktopBrowser*)GetWindowLongPtrW(hwnd, - 0); + pThis = reinterpret_cast(GetWindowLongPtrW(hwnd, 0)); if (pThis == NULL) goto DefMsgHandler; } @@ -554,7 +553,7 @@ HANDLE WINAPI SHCreateDesktop(IShellDesktopTray *ShellDesk) */ BOOL WINAPI SHDesktopMessageLoop(HANDLE hDesktop) { - CDesktopBrowser *Desk = (CDesktopBrowser *)hDesktop; + CDesktopBrowser *Desk = static_cast(hDesktop); if (Desk == NULL || Desk->Tag != SHDESK_TAG) { diff --git a/reactos/dll/win32/shell32/drvdefext.cpp b/reactos/dll/win32/shell32/drvdefext.cpp index 2379c058ff5..d24fcb87228 100644 --- a/reactos/dll/win32/shell32/drvdefext.cpp +++ b/reactos/dll/win32/shell32/drvdefext.cpp @@ -339,7 +339,7 @@ CDrvDefExt::GeneralPageProc( if (ppsp == NULL) break; - CDrvDefExt *pDrvDefExt = (CDrvDefExt*)ppsp->lParam; + CDrvDefExt *pDrvDefExt = reinterpret_cast(ppsp->lParam); SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pDrvDefExt); pDrvDefExt->InitGeneralPage(hwndDlg); return TRUE; @@ -350,7 +350,7 @@ CDrvDefExt::GeneralPageProc( if (pDrawItem->CtlID >= 14013 && pDrawItem->CtlID <= 14015) { - CDrvDefExt *pDrvDefExt = (CDrvDefExt*)GetWindowLongPtr(hwndDlg, DWLP_USER); + CDrvDefExt *pDrvDefExt = reinterpret_cast(GetWindowLongPtr(hwndDlg, DWLP_USER)); pDrvDefExt->PaintStaticControls(hwndDlg, pDrawItem); return TRUE; } @@ -361,7 +361,7 @@ CDrvDefExt::GeneralPageProc( case WM_COMMAND: if (LOWORD(wParam) == 14010) /* Disk Cleanup */ { - CDrvDefExt *pDrvDefExt = (CDrvDefExt*)GetWindowLongPtr(hwndDlg, DWLP_USER); + CDrvDefExt *pDrvDefExt = reinterpret_cast(GetWindowLongPtr(hwndDlg, DWLP_USER)); WCHAR wszBuf[256]; DWORD cbBuf = sizeof(wszBuf); @@ -395,7 +395,7 @@ CDrvDefExt::GeneralPageProc( if (lppsn->hdr.code == PSN_APPLY) { - CDrvDefExt *pDrvDefExt = (CDrvDefExt*)GetWindowLongPtr(hwndDlg, DWLP_USER); + CDrvDefExt *pDrvDefExt = reinterpret_cast(GetWindowLongPtr(hwndDlg, DWLP_USER)); WCHAR wszBuf[256]; if (GetDlgItemTextW(hwndDlg, 14000, wszBuf, _countof(wszBuf))) @@ -432,7 +432,7 @@ CDrvDefExt::ExtraPageProc( { WCHAR wszBuf[MAX_PATH]; DWORD cbBuf = sizeof(wszBuf); - CDrvDefExt *pDrvDefExt = (CDrvDefExt*)GetWindowLongPtr(hwndDlg, DWLP_USER); + CDrvDefExt *pDrvDefExt = reinterpret_cast(GetWindowLongPtr(hwndDlg, DWLP_USER)); switch(LOWORD(wParam)) { diff --git a/reactos/dll/win32/shell32/enumidlist.cpp b/reactos/dll/win32/shell32/enumidlist.cpp index 203fb12010d..ee7394effae 100644 --- a/reactos/dll/win32/shell32/enumidlist.cpp +++ b/reactos/dll/win32/shell32/enumidlist.cpp @@ -45,7 +45,7 @@ BOOL IEnumIDListImpl::AddToEnumList(LPITEMIDLIST pidl) if (!pidl) return FALSE; - pNew = (ENUMLIST *)SHAlloc(sizeof(ENUMLIST)); + pNew = static_cast(SHAlloc(sizeof(ENUMLIST))); if (pNew) { /*set the next pointer */ diff --git a/reactos/dll/win32/shell32/filedefext.cpp b/reactos/dll/win32/shell32/filedefext.cpp index e64c1c1104f..82a666435cb 100644 --- a/reactos/dll/win32/shell32/filedefext.cpp +++ b/reactos/dll/win32/shell32/filedefext.cpp @@ -626,7 +626,7 @@ CFileDefExt::GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %S\n", hwndDlg, lParam, ppsp->lParam); - CFileDefExt *pFileDefExt = (CFileDefExt*)ppsp->lParam; + CFileDefExt *pFileDefExt = reinterpret_cast(ppsp->lParam); SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pFileDefExt); pFileDefExt->InitGeneralPage(hwndDlg); break; @@ -634,7 +634,7 @@ CFileDefExt::GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case WM_COMMAND: if (LOWORD(wParam) == 14024) /* Opens With - Change */ { - CFileDefExt *pFileDefExt = (CFileDefExt*)GetWindowLongPtr(hwndDlg, DWLP_USER); + CFileDefExt *pFileDefExt = reinterpret_cast(GetWindowLongPtr(hwndDlg, DWLP_USER)); OPENASINFO oainfo; oainfo.pcszFile = pFileDefExt->m_wszPath; oainfo.pcszClass = NULL; @@ -654,7 +654,7 @@ CFileDefExt::GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam; if (lppsn->hdr.code == PSN_APPLY) { - CFileDefExt *pFileDefExt = (CFileDefExt*)GetWindowLongPtr(hwndDlg, DWLP_USER); + CFileDefExt *pFileDefExt = reinterpret_cast(GetWindowLongPtr(hwndDlg, DWLP_USER)); /* Update attributes first */ DWORD dwAttr = GetFileAttributesW(pFileDefExt->m_wszPath); @@ -826,7 +826,7 @@ CFileDefExt::VersionPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %x\n", hwndDlg, lParam, ppsp->lParam); - CFileDefExt *pFileDefExt = (CFileDefExt*)ppsp->lParam; + CFileDefExt *pFileDefExt = reinterpret_cast(ppsp->lParam); return pFileDefExt->InitVersionPage(hwndDlg); } case WM_COMMAND: diff --git a/reactos/dll/win32/shell32/folders/recyclebin.cpp b/reactos/dll/win32/shell32/folders/recyclebin.cpp index 648debf6a47..9b1a3895832 100644 --- a/reactos/dll/win32/shell32/folders/recyclebin.cpp +++ b/reactos/dll/win32/shell32/folders/recyclebin.cpp @@ -231,7 +231,7 @@ static LPITEMIDLIST _ILCreateRecycleItem(PDELETED_FILE_DETAILS_W pFileDetails) BOOL WINAPI CRecycleBinEnum::CBEnumRecycleBin(IN PVOID Context, IN HANDLE hDeletedFile) { - return ((CRecycleBinEnum *)Context)->CBEnumRecycleBin(hDeletedFile); + return static_cast(Context)->CBEnumRecycleBin(hDeletedFile); } BOOL WINAPI CRecycleBinEnum::CBEnumRecycleBin(IN HANDLE hDeletedFile) diff --git a/reactos/dll/win32/shell32/newmenu.cpp b/reactos/dll/win32/shell32/newmenu.cpp index 7c5f853f1d4..53dc802fa4c 100644 --- a/reactos/dll/win32/shell32/newmenu.cpp +++ b/reactos/dll/win32/shell32/newmenu.cpp @@ -165,7 +165,7 @@ CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPCWSTR pwszExt) return NULL; /* Create new item */ - SHELLNEW_ITEM *pNewItem = (SHELLNEW_ITEM *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SHELLNEW_ITEM)); + SHELLNEW_ITEM *pNewItem = static_cast(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SHELLNEW_ITEM))); if (!pNewItem) { free(pData); @@ -225,7 +225,7 @@ CNewMenu::LoadAllItems() if (!m_pLinkItem) { - m_pLinkItem = (SHELLNEW_ITEM *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SHELLNEW_ITEM)); + m_pLinkItem = static_cast(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SHELLNEW_ITEM))); if (m_pLinkItem) { m_pLinkItem->Type = SHELLNEW_TYPE_NULLFILE; diff --git a/reactos/dll/win32/shell32/openwithmenu.cpp b/reactos/dll/win32/shell32/openwithmenu.cpp index 6648a78d85e..02e5b9fd8c4 100644 --- a/reactos/dll/win32/shell32/openwithmenu.cpp +++ b/reactos/dll/win32/shell32/openwithmenu.cpp @@ -297,9 +297,9 @@ COpenWithList::SApp *COpenWithList::AddInternal(LPCWSTR pwszFilename) /* Create new item */ if (!m_pApp) - m_pApp = (SApp*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(m_pApp[0])); + m_pApp = static_cast(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(m_pApp[0]))); else - m_pApp = (SApp*)HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m_pApp, (m_cApp + 1)*sizeof(m_pApp[0])); + m_pApp = static_cast(HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m_pApp, (m_cApp + 1)*sizeof(m_pApp[0]))); if (!m_pApp) { ERR("Allocation failed\n"); @@ -989,13 +989,13 @@ VOID COpenWithDialog::Accept() INT_PTR CALLBACK COpenWithDialog::DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - COpenWithDialog *pThis = (COpenWithDialog*)GetWindowLongPtr(hwndDlg, DWLP_USER); + COpenWithDialog *pThis = reinterpret_cast(GetWindowLongPtr(hwndDlg, DWLP_USER)); switch(uMsg) { case WM_INITDIALOG: { - COpenWithDialog *pThis = (COpenWithDialog*)lParam; + COpenWithDialog *pThis = reinterpret_cast(lParam); pThis->Init(hwndDlg); return TRUE; diff --git a/reactos/dll/win32/shell32/shelllink.cpp b/reactos/dll/win32/shell32/shelllink.cpp index 4982f7da306..6c63a77a2a9 100644 --- a/reactos/dll/win32/shell32/shelllink.cpp +++ b/reactos/dll/win32/shell32/shelllink.cpp @@ -359,7 +359,7 @@ static HRESULT Stream_ReadChunk(IStream* stm, LPVOID *data) if (FAILED(hr) || count != sizeof(size)) return E_FAIL; - chunk = (sized_chunk *)HeapAlloc(GetProcessHeap(), 0, size); + chunk = static_cast(HeapAlloc(GetProcessHeap(), 0, size)); if (!chunk) return E_OUTOFMEMORY; @@ -421,7 +421,7 @@ static HRESULT Stream_LoadLocation(IStream *stm, if (FAILED(hr)) return hr; - LOCATION_INFO *loc = (LOCATION_INFO*) p; + LOCATION_INFO *loc = reinterpret_cast(p); if (loc->dwTotalSize < sizeof(LOCATION_INFO)) { HeapFree(GetProcessHeap(), 0, p); @@ -721,7 +721,7 @@ static HRESULT Stream_WriteLocationInfo(IStream* stm, LPCWSTR path, DWORD total_size = sizeof(*loc) + volume_info_size + path_size + final_path_size; /* create pointers to everything */ - loc = (LOCATION_INFO *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, total_size); + loc = static_cast(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, total_size)); vol = (LOCAL_VOLUME_INFO*) &loc[1]; LPSTR szLabel = (LPSTR) &vol[1]; LPSTR szPath = &szLabel[label_size]; @@ -1954,7 +1954,7 @@ INT_PTR CALLBACK ExtendedShortcutProc(HWND hwndDlg, UINT uMsg, INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CShellLink *pThis = (CShellLink *)GetWindowLongPtr(hwndDlg, DWLP_USER); + CShellLink *pThis = reinterpret_cast(GetWindowLongPtr(hwndDlg, DWLP_USER)); switch(uMsg) { @@ -1966,7 +1966,7 @@ INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM TRACE("ShellLink_DlgProc (WM_INITDIALOG hwnd %p lParam %p ppsplParam %x)\n", hwndDlg, lParam, ppsp->lParam); - pThis = (CShellLink *)ppsp->lParam; + pThis = reinterpret_cast(ppsp->lParam); SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pThis); TRACE("sArgs: %S sComponent: %S sDescription: %S sIcoPath: %S sPath: %S sPathRel: %S sProduct: %S sWorkDir: %S\n", pThis->sArgs, pThis->sComponent, pThis->sDescription, diff --git a/reactos/dll/win32/shell32/shlview.cpp b/reactos/dll/win32/shell32/shlview.cpp index 5afc0e85fe5..d36822506b4 100644 --- a/reactos/dll/win32/shell32/shlview.cpp +++ b/reactos/dll/win32/shell32/shlview.cpp @@ -816,7 +816,7 @@ BOOLEAN CDefView::LV_RenameItem(LPCITEMIDLIST pidlOld, LPCITEMIDLIST pidlNew) INT CALLBACK CDefView::fill_list( LPVOID ptr, LPVOID arg ) { LPITEMIDLIST pidl = (LPITEMIDLIST)ptr; - CDefView *pThis = (CDefView *)arg; + CDefView *pThis = static_cast(arg); /* in a commdlg This works as a filemask*/ if (pThis->IncludeObject(pidl) == S_OK) pThis->LV_AddItem(pidl);