Safer C++ conversion
use static_cast instead of reinterpret_cast
This commit is contained in:
parent
f8a24efa90
commit
e76c929137
@ -335,7 +335,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||||||
|
|
||||||
if (_toReduceTabBar)
|
if (_toReduceTabBar)
|
||||||
{
|
{
|
||||||
HFONT hf = reinterpret_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
|
HFONT hf = static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
|
||||||
|
|
||||||
if (hf)
|
if (hf)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT Message,
|
|||||||
{
|
{
|
||||||
// First message we get the ptr of instantiated object
|
// First message we get the ptr of instantiated object
|
||||||
// then stock it into GWLP_USERDATA index in order to retrieve afterward
|
// then stock it into GWLP_USERDATA index in order to retrieve afterward
|
||||||
Notepad_plus_Window *pM30ide = reinterpret_cast<Notepad_plus_Window *>((reinterpret_cast<LPCREATESTRUCT>(lParam))->lpCreateParams);
|
Notepad_plus_Window *pM30ide = static_cast<Notepad_plus_Window *>((reinterpret_cast<LPCREATESTRUCT>(lParam))->lpCreateParams);
|
||||||
pM30ide->_hSelf = hwnd;
|
pM30ide->_hSelf = hwnd;
|
||||||
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pM30ide);
|
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pM30ide);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -524,7 +524,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
{
|
{
|
||||||
case COPYDATA_PARAMS:
|
case COPYDATA_PARAMS:
|
||||||
{
|
{
|
||||||
CmdLineParams *cmdLineParam = reinterpret_cast<CmdLineParams *>(pCopyData->lpData); // CmdLineParams object from another instance
|
CmdLineParams *cmdLineParam = static_cast<CmdLineParams *>(pCopyData->lpData); // CmdLineParams object from another instance
|
||||||
auto cmdLineParamsSize = static_cast<size_t>(pCopyData->cbData); // CmdLineParams size from another instance
|
auto cmdLineParamsSize = static_cast<size_t>(pCopyData->cbData); // CmdLineParams size from another instance
|
||||||
if (sizeof(CmdLineParams) == cmdLineParamsSize) // make sure the structure is the same
|
if (sizeof(CmdLineParams) == cmdLineParamsSize) // make sure the structure is the same
|
||||||
{
|
{
|
||||||
@ -544,7 +544,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
|
|
||||||
case COPYDATA_FILENAMESA:
|
case COPYDATA_FILENAMESA:
|
||||||
{
|
{
|
||||||
char *fileNamesA = reinterpret_cast<char *>(pCopyData->lpData);
|
char *fileNamesA = static_cast<char *>(pCopyData->lpData);
|
||||||
CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams();
|
CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams();
|
||||||
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
||||||
const wchar_t *fileNamesW = wmc->char2wchar(fileNamesA, CP_ACP);
|
const wchar_t *fileNamesW = wmc->char2wchar(fileNamesA, CP_ACP);
|
||||||
@ -554,7 +554,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
|||||||
|
|
||||||
case COPYDATA_FILENAMESW:
|
case COPYDATA_FILENAMESW:
|
||||||
{
|
{
|
||||||
wchar_t *fileNamesW = reinterpret_cast<wchar_t *>(pCopyData->lpData);
|
wchar_t *fileNamesW = static_cast<wchar_t *>(pCopyData->lpData);
|
||||||
CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams();
|
CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams();
|
||||||
loadCommandlineParams(fileNamesW, &cmdLineParams);
|
loadCommandlineParams(fileNamesW, &cmdLineParams);
|
||||||
break;
|
break;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
class Notepad_plus;
|
class Notepad_plus;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
typedef Buffer* BufferID; //each buffer has unique ID by which it can be retrieved
|
typedef Buffer* BufferID; //each buffer has unique ID by which it can be retrieved
|
||||||
#define BUFFER_INVALID (BufferID)0
|
#define BUFFER_INVALID reinterpret_cast<BufferID>(0)
|
||||||
|
|
||||||
typedef sptr_t Document;
|
typedef sptr_t Document;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ void ListView::init(HINSTANCE hInst, HWND parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
||||||
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticProc));
|
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(staticProc)));
|
||||||
|
|
||||||
DWORD exStyle = ListView_GetExtendedListViewStyle(_hSelf);
|
DWORD exStyle = ListView_GetExtendedListViewStyle(_hSelf);
|
||||||
exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT ;
|
exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT ;
|
||||||
|
@ -52,7 +52,7 @@ void TreeView::init(HINSTANCE hInst, HWND parent, int treeViewID)
|
|||||||
TreeView_SetItemHeight(_hSelf, itemHeight);
|
TreeView_SetItemHeight(_hSelf, itemHeight);
|
||||||
|
|
||||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
||||||
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticProc));
|
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(staticProc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ VOID CALLBACK CReadChangesRequest::NotificationCompletion(
|
|||||||
DWORD dwNumberOfBytesTransfered, // number of bytes transferred
|
DWORD dwNumberOfBytesTransfered, // number of bytes transferred
|
||||||
LPOVERLAPPED lpOverlapped) // I/O information buffer
|
LPOVERLAPPED lpOverlapped) // I/O information buffer
|
||||||
{
|
{
|
||||||
CReadChangesRequest* pBlock = reinterpret_cast<CReadChangesRequest*>(lpOverlapped->hEvent);
|
CReadChangesRequest* pBlock = static_cast<CReadChangesRequest*>(lpOverlapped->hEvent);
|
||||||
|
|
||||||
if (dwErrorCode == ERROR_OPERATION_ABORTED)
|
if (dwErrorCode == ERROR_OPERATION_ABORTED)
|
||||||
{
|
{
|
||||||
|
@ -118,14 +118,14 @@ HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplat
|
|||||||
if (!hDlgTemplate)
|
if (!hDlgTemplate)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
DLGTEMPLATE *pDlgTemplate = reinterpret_cast<DLGTEMPLATE *>(::LockResource(hDlgTemplate));
|
DLGTEMPLATE *pDlgTemplate = static_cast<DLGTEMPLATE *>(::LockResource(hDlgTemplate));
|
||||||
if (!pDlgTemplate)
|
if (!pDlgTemplate)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Duplicate Dlg Template resource
|
// Duplicate Dlg Template resource
|
||||||
unsigned long sizeDlg = ::SizeofResource(_hInst, hDialogRC);
|
unsigned long sizeDlg = ::SizeofResource(_hInst, hDialogRC);
|
||||||
HGLOBAL hMyDlgTemplate = ::GlobalAlloc(GPTR, sizeDlg);
|
HGLOBAL hMyDlgTemplate = ::GlobalAlloc(GPTR, sizeDlg);
|
||||||
*ppMyDlgTemplate = reinterpret_cast<DLGTEMPLATE *>(::GlobalLock(hMyDlgTemplate));
|
*ppMyDlgTemplate = static_cast<DLGTEMPLATE *>(::GlobalLock(hMyDlgTemplate));
|
||||||
|
|
||||||
::memcpy(*ppMyDlgTemplate, pDlgTemplate, sizeDlg);
|
::memcpy(*ppMyDlgTemplate, pDlgTemplate, sizeDlg);
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTrad
|
|||||||
++_nbCtrl;
|
++_nbCtrl;
|
||||||
|
|
||||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
||||||
_tabBarDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)TabBarPlus_Proc));
|
_tabBarDefaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(TabBarPlus_Proc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGFONT LogFont;
|
LOGFONT LogFont;
|
||||||
|
@ -69,7 +69,7 @@ void TaskList::init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst, int nbItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
||||||
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticProc));
|
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(staticProc)));
|
||||||
|
|
||||||
DWORD exStyle = ListView_GetExtendedListViewStyle(_hSelf);
|
DWORD exStyle = ListView_GetExtendedListViewStyle(_hSelf);
|
||||||
exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT ;
|
exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT ;
|
||||||
|
@ -116,7 +116,7 @@ INT_PTR CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP
|
|||||||
{
|
{
|
||||||
case LVN_GETDISPINFO:
|
case LVN_GETDISPINFO:
|
||||||
{
|
{
|
||||||
LV_ITEM &lvItem = reinterpret_cast<LV_DISPINFO*>((LV_DISPINFO FAR *)lParam)->item;
|
LV_ITEM &lvItem = reinterpret_cast<LV_DISPINFO*>(reinterpret_cast<LV_DISPINFO FAR *>(lParam))->item;
|
||||||
|
|
||||||
TaskLstFnStatus & fileNameStatus = _taskListInfo._tlfsLst[lvItem.iItem];
|
TaskLstFnStatus & fileNameStatus = _taskListInfo._tlfsLst[lvItem.iItem];
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ void ToolTip::init(HINSTANCE hInst, HWND hParent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
||||||
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticWinProc));
|
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(staticWinProc)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ void VerticalFileSwitcherListView::init(HINSTANCE hInst, HWND parent, HIMAGELIST
|
|||||||
}
|
}
|
||||||
|
|
||||||
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
|
||||||
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticProc));
|
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(staticProc)));
|
||||||
|
|
||||||
ListView_SetExtendedListViewStyle(_hSelf, LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT | LVS_EX_INFOTIP);
|
ListView_SetExtendedListViewStyle(_hSelf, LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT | LVS_EX_INFOTIP);
|
||||||
ListView_SetItemCountEx(_hSelf, 50, LVSICF_NOSCROLL);
|
ListView_SetItemCountEx(_hSelf, 50, LVSICF_NOSCROLL);
|
||||||
|
Loading…
Reference in New Issue
Block a user