Use C++ type conversion instead of C-Style conversion

This commit is contained in:
Don HO 2016-07-10 02:21:15 +02:00
parent 59238e5a2e
commit 1e38c628bc
24 changed files with 82 additions and 86 deletions

View File

@ -151,11 +151,11 @@ void Process::listenerStdOut()
while (goOn) while (goOn)
{ // got data { // got data
memset(bufferOut,0x00,MAX_LINE_LENGTH + 1); memset(bufferOut,0x00,MAX_LINE_LENGTH + 1);
int taille = sizeof(bufferOut) - sizeof(TCHAR); int size = sizeof(bufferOut) - sizeof(TCHAR);
Sleep(50); Sleep(50);
if (!::PeekNamedPipe(_hPipeOutR, bufferOut, taille, &outbytesRead, &bytesAvail, NULL)) if (!::PeekNamedPipe(_hPipeOutR, bufferOut, size, &outbytesRead, &bytesAvail, NULL))
{ {
bytesAvail = 0; bytesAvail = 0;
goOn = false; goOn = false;
@ -164,7 +164,7 @@ void Process::listenerStdOut()
if (outbytesRead) if (outbytesRead)
{ {
result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL); result = :: ReadFile(_hPipeOutR, bufferOut, size, &outbytesRead, NULL);
if ((!result) && (outbytesRead == 0)) if ((!result) && (outbytesRead == 0))
{ {
goOn = false; goOn = false;
@ -202,7 +202,6 @@ void Process::listenerStdErr()
BOOL result = 0; BOOL result = 0;
HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent")); HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent"));
int taille = 0;
TCHAR bufferErr[MAX_LINE_LENGTH + 1]; TCHAR bufferErr[MAX_LINE_LENGTH + 1];
int nExitCode = STILL_ACTIVE; int nExitCode = STILL_ACTIVE;
@ -212,11 +211,11 @@ void Process::listenerStdErr()
while (goOn) while (goOn)
{ // got data { // got data
memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1); memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1);
taille = sizeof(bufferErr) - sizeof(TCHAR); size_t size = sizeof(bufferErr) - sizeof(TCHAR);
Sleep(50); Sleep(50);
DWORD errbytesRead; DWORD errbytesRead;
if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL)) if (!::PeekNamedPipe(_hPipeErrR, bufferErr, size, &errbytesRead, &bytesAvail, NULL))
{ {
bytesAvail = 0; bytesAvail = 0;
goOn = false; goOn = false;
@ -225,7 +224,7 @@ void Process::listenerStdErr()
if (errbytesRead) if (errbytesRead)
{ {
result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL); result = :: ReadFile(_hPipeErrR, bufferErr, size, &errbytesRead, NULL);
if ((!result) && (errbytesRead == 0)) if ((!result) && (errbytesRead == 0))
{ {
goOn = false; goOn = false;

View File

@ -86,11 +86,11 @@ protected:
//UINT _pid; // process ID assigned by caller //UINT _pid; // process ID assigned by caller
static DWORD WINAPI staticListenerStdOut(void * myself){ static DWORD WINAPI staticListenerStdOut(void * myself){
((Process *)myself)->listenerStdOut(); static_cast<Process *>(myself)->listenerStdOut();
return 0; return 0;
}; };
static DWORD WINAPI staticListenerStdErr(void * myself) { static DWORD WINAPI staticListenerStdErr(void * myself) {
((Process *)myself)->listenerStdErr(); static_cast<Process *>(myself)->listenerStdErr();
return 0; return 0;
}; };
void listenerStdOut(); void listenerStdOut();

View File

@ -5964,10 +5964,11 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
// random seed generation needs only one time. // random seed generation needs only one time.
srand((unsigned int)time(NULL)); srand((unsigned int)time(NULL));
HWND hNpp = ((TextPlayerParams *)params)->_nppHandle; TextPlayerParams* textPlayerParams = static_cast<TextPlayerParams*>(params);
ScintillaEditView *pCurrentView = ((TextPlayerParams *)params)->_pCurrentView; HWND hNpp = textPlayerParams->_nppHandle;
const char *text2display = ((TextPlayerParams *)params)->_text2display; ScintillaEditView *pCurrentView = textPlayerParams->_pCurrentView;
bool shouldBeTrolling = ((TextPlayerParams *)params)->_shouldBeTrolling; const char *text2display = textPlayerParams->_text2display;
bool shouldBeTrolling = textPlayerParams->_shouldBeTrolling;
// Open a new document // Open a new document
::SendMessage(hNpp, NPPM_MENUCOMMAND, 0, IDM_FILE_NEW); ::SendMessage(hNpp, NPPM_MENUCOMMAND, 0, IDM_FILE_NEW);
@ -6042,7 +6043,7 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
} }
//writeLog(TEXT("c:\\tmp\\log.txt"), "\n\n\n\n"); //writeLog(TEXT("c:\\tmp\\log.txt"), "\n\n\n\n");
const char * quoter = ((TextPlayerParams *)params)->_quoter; const char * quoter = textPlayerParams->_quoter;
string quoter_str = quoter; string quoter_str = quoter;
size_t pos = quoter_str.find("Anonymous"); size_t pos = quoter_str.find("Anonymous");
if (pos == string::npos) if (pos == string::npos)
@ -6075,15 +6076,16 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
DWORD WINAPI Notepad_plus::threadTextTroller(void *params) DWORD WINAPI Notepad_plus::threadTextTroller(void *params)
{ {
WaitForSingleObject(((TextTrollerParams *)params)->_mutex, INFINITE); TextTrollerParams *textTrollerParams = static_cast<TextTrollerParams *>(params);
WaitForSingleObject(textTrollerParams->_mutex, INFINITE);
// random seed generation needs only one time. // random seed generation needs only one time.
srand((unsigned int)time(NULL)); srand((unsigned int)time(NULL));
ScintillaEditView *pCurrentView = ((TextTrollerParams *)params)->_pCurrentView; ScintillaEditView *pCurrentView = textTrollerParams->_pCurrentView;
const char *text2display = ((TextTrollerParams *)params)->_text2display; const char *text2display = textTrollerParams->_text2display;
HWND curScintilla = pCurrentView->getHSelf(); HWND curScintilla = pCurrentView->getHSelf();
BufferID targetBufID = ((TextTrollerParams *)params)->_targetBufID; BufferID targetBufID = textTrollerParams->_targetBufID;
for (size_t i = 0, len = strlen(text2display); i < len; ++i) for (size_t i = 0, len = strlen(text2display); i < len; ++i)
{ {
@ -6097,7 +6099,7 @@ DWORD WINAPI Notepad_plus::threadTextTroller(void *params)
BufferID currentBufID = pCurrentView->getCurrentBufferID(); BufferID currentBufID = pCurrentView->getCurrentBufferID();
if (currentBufID != targetBufID) if (currentBufID != targetBufID)
{ {
ReleaseMutex(((TextTrollerParams *)params)->_mutex); ReleaseMutex(textTrollerParams->_mutex);
return TRUE; return TRUE;
} }
::SendMessage(curScintilla, SCI_APPENDTEXT, 1, (LPARAM)charToShow); ::SendMessage(curScintilla, SCI_APPENDTEXT, 1, (LPARAM)charToShow);
@ -6148,7 +6150,7 @@ DWORD WINAPI Notepad_plus::threadTextTroller(void *params)
::SendMessage(pCurrentView->getHSelf(), SCI_DELETEBACK, 0, 0); ::SendMessage(pCurrentView->getHSelf(), SCI_DELETEBACK, 0, 0);
} }
ReleaseMutex(((TextTrollerParams *)params)->_mutex); ReleaseMutex(textTrollerParams->_mutex);
return TRUE; return TRUE;
} }

View File

@ -529,7 +529,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{ {
case COPYDATA_PARAMS: case COPYDATA_PARAMS:
{ {
CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData; // CmdLineParams object from another instance CmdLineParams *cmdLineParam = reinterpret_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
{ {
@ -810,7 +810,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (!wParam) if (!wParam)
return 0; return 0;
TaskListInfo * tli = (TaskListInfo *)wParam; TaskListInfo * tli = reinterpret_cast<TaskListInfo *>(wParam);
getTaskListInfo(tli); getTaskListInfo(tli);
if (lParam != 0) if (lParam != 0)

View File

@ -41,7 +41,7 @@ using namespace std;
DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params) DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
{ {
MonitorInfo *monitorInfo = (MonitorInfo *)params; MonitorInfo *monitorInfo = static_cast<MonitorInfo *>(params);
Buffer *buf = monitorInfo->_buffer; Buffer *buf = monitorInfo->_buffer;
HWND h = monitorInfo->_nppHandle; HWND h = monitorInfo->_nppHandle;

View File

@ -3105,16 +3105,14 @@ void NppParameters::feedUserSettings(TiXmlNode *settingsRoot)
void NppParameters::feedUserKeywordList(TiXmlNode *node) void NppParameters::feedUserKeywordList(TiXmlNode *node)
{ {
const TCHAR * udlVersion = _userLangArray[_nbUserLang - 1]->_udlVersion.c_str(); const TCHAR * udlVersion = _userLangArray[_nbUserLang - 1]->_udlVersion.c_str();
const TCHAR * keywordsName = nullptr;
TCHAR *kwl = nullptr;
int id = -1; int id = -1;
for (TiXmlNode *childNode = node->FirstChildElement(TEXT("Keywords")); for (TiXmlNode *childNode = node->FirstChildElement(TEXT("Keywords"));
childNode ; childNode ;
childNode = childNode->NextSibling(TEXT("Keywords"))) childNode = childNode->NextSibling(TEXT("Keywords")))
{ {
keywordsName = (childNode->ToElement())->Attribute(TEXT("name")); const TCHAR * keywordsName = (childNode->ToElement())->Attribute(TEXT("name"));
kwl = nullptr; TCHAR *kwl = nullptr;
TiXmlNode *valueNode = childNode->FirstChild(); TiXmlNode *valueNode = childNode->FirstChild();
if (valueNode) if (valueNode)
@ -3183,14 +3181,13 @@ void NppParameters::feedUserKeywordList(TiXmlNode *node)
void NppParameters::feedUserStyles(TiXmlNode *node) void NppParameters::feedUserStyles(TiXmlNode *node)
{ {
const TCHAR *styleName = NULL;
int id = -1; int id = -1;
for (TiXmlNode *childNode = node->FirstChildElement(TEXT("WordsStyle")); for (TiXmlNode *childNode = node->FirstChildElement(TEXT("WordsStyle"));
childNode ; childNode ;
childNode = childNode->NextSibling(TEXT("WordsStyle"))) childNode = childNode->NextSibling(TEXT("WordsStyle")))
{ {
styleName = (childNode->ToElement())->Attribute(TEXT("name")); const TCHAR *styleName = (childNode->ToElement())->Attribute(TEXT("name"));
if (styleName) if (styleName)
{ {
if (globalMappper().styleIdMapper.find(styleName) != globalMappper().styleIdMapper.end()) if (globalMappper().styleIdMapper.find(styleName) != globalMappper().styleIdMapper.end())

View File

@ -185,7 +185,7 @@ struct sessionFileInfo : public Position
int _encoding = -1; int _encoding = -1;
generic_string _backupFilePath; generic_string _backupFilePath;
time_t _originalFileLastModifTimestamp; time_t _originalFileLastModifTimestamp = 0;
}; };
@ -490,7 +490,7 @@ public:
{ {
if (this != &ls) if (this != &ls)
{ {
*((StyleArray *)this) = ls; *(static_cast<StyleArray *>(this)) = ls;
this->_lexerName = ls._lexerName; this->_lexerName = ls._lexerName;
this->_lexerDesc = ls._lexerDesc; this->_lexerDesc = ls._lexerDesc;
this->_lexerUserExt = ls._lexerUserExt; this->_lexerUserExt = ls._lexerUserExt;

View File

@ -612,7 +612,7 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin
if (res) if (res)
{ {
Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath); Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath);
BufferID id = (BufferID) newBuf; BufferID id = static_cast<BufferID>(newBuf);
newBuf->_id = id; newBuf->_id = id;
if (backupFileName != NULL) if (backupFileName != NULL)
@ -1222,7 +1222,7 @@ BufferID FileManager::newEmptyDocument()
Document doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); //this already sets a reference for filemanager Document doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); //this already sets a reference for filemanager
Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str()); Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str());
BufferID id = (BufferID)newBuf; BufferID id = static_cast<BufferID>(newBuf);
newBuf->_id = id; newBuf->_id = id;
_buffers.push_back(newBuf); _buffers.push_back(newBuf);
++_nrBufs; ++_nrBufs;
@ -1240,7 +1240,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d
if (!dontRef) if (!dontRef)
_pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, doc); //set reference for FileManager _pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, doc); //set reference for FileManager
Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str()); Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str());
BufferID id = (BufferID)newBuf; BufferID id = static_cast<BufferID>(newBuf);
newBuf->_id = id; newBuf->_id = id;
_buffers.push_back(newBuf); _buffers.push_back(newBuf);
++_nrBufs; ++_nrBufs;

View File

@ -77,7 +77,7 @@ public:
size_t getNrBuffers() { return _nrBufs; }; size_t getNrBuffers() { return _nrBufs; };
int getBufferIndexByID(BufferID id); int getBufferIndexByID(BufferID id);
Buffer * getBufferByIndex(size_t index); Buffer * getBufferByIndex(size_t index);
Buffer * getBufferByID(BufferID id) {return (Buffer*)id;} Buffer * getBufferByID(BufferID id) {return static_cast<Buffer*>(id);}
void beNotifiedOfBufferChange(Buffer * theBuf, int mask); void beNotifiedOfBufferChange(Buffer * theBuf, int mask);

View File

@ -82,7 +82,7 @@ bool DocTabView::activateBuffer(BufferID buffer)
BufferID DocTabView::activeBuffer() BufferID DocTabView::activeBuffer()
{ {
int index = getCurrentTabIndex(); int index = getCurrentTabIndex();
return (BufferID)getBufferByIndex(index); return static_cast<BufferID>(getBufferByIndex(index));
} }
@ -94,7 +94,7 @@ BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) //-1 if not fo
for(size_t i = 0; i < _nbItem; ++i) for(size_t i = 0; i < _nbItem; ++i)
{ {
::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie)); ::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie));
BufferID id = (BufferID)tie.lParam; BufferID id = reinterpret_cast<BufferID>(tie.lParam);
Buffer * buf = MainFileManager->getBufferByID(id); Buffer * buf = MainFileManager->getBufferByID(id);
if (!lstrcmp(fullfilename, buf->getFullPathName())) if (!lstrcmp(fullfilename, buf->getFullPathName()))
{ {
@ -113,7 +113,7 @@ int DocTabView::getIndexByBuffer(BufferID id)
for(int i = 0; i < (int)_nbItem; ++i) for(int i = 0; i < (int)_nbItem; ++i)
{ {
::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie)); ::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast<LPARAM>(&tie));
if ((BufferID)tie.lParam == id) if (reinterpret_cast<BufferID>(tie.lParam) == id)
return i; return i;
} }
return -1; return -1;
@ -127,7 +127,7 @@ BufferID DocTabView::getBufferByIndex(size_t index)
tie.mask = TCIF_PARAM; tie.mask = TCIF_PARAM;
::SendMessage(_hSelf, TCM_GETITEM, index, reinterpret_cast<LPARAM>(&tie)); ::SendMessage(_hSelf, TCM_GETITEM, index, reinterpret_cast<LPARAM>(&tie));
return (BufferID)tie.lParam; return reinterpret_cast<BufferID>(tie.lParam);
} }

View File

@ -143,8 +143,8 @@ size_t Printer::doPrint(bool justDoIt)
TEXTMETRIC tm; TEXTMETRIC tm;
int fontSize = nppGUI._printSettings._headerFontSize?nppGUI._printSettings._headerFontSize:9; int fontSize = nppGUI._printSettings._headerFontSize?nppGUI._printSettings._headerFontSize:9;
int fontWeight = nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL; int fontWeight = nppGUI._printSettings._headerFontStyle & (FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL);
int isFontItalic = nppGUI._printSettings._headerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE; int isFontItalic = nppGUI._printSettings._headerFontStyle & (FONTSTYLE_ITALIC?TRUE:FALSE);
const TCHAR *fontFace = (nppGUI._printSettings._headerFontName != TEXT(""))?nppGUI._printSettings._headerFontName.c_str():TEXT("Arial"); const TCHAR *fontFace = (nppGUI._printSettings._headerFontName != TEXT(""))?nppGUI._printSettings._headerFontName.c_str():TEXT("Arial");
int headerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); int headerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72);
@ -165,8 +165,8 @@ size_t Printer::doPrint(bool justDoIt)
headerLineHeight = tm.tmHeight + tm.tmExternalLeading; headerLineHeight = tm.tmHeight + tm.tmExternalLeading;
fontSize = nppGUI._printSettings._footerFontSize?nppGUI._printSettings._footerFontSize:9; fontSize = nppGUI._printSettings._footerFontSize?nppGUI._printSettings._footerFontSize:9;
fontWeight = nppGUI._printSettings._footerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL; fontWeight = nppGUI._printSettings._footerFontStyle & (FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL);
isFontItalic = nppGUI._printSettings._footerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE; isFontItalic = nppGUI._printSettings._footerFontStyle & (FONTSTYLE_ITALIC?TRUE:FALSE);
fontFace = (nppGUI._printSettings._footerFontName != TEXT(""))?nppGUI._printSettings._footerFontName.c_str():TEXT("Arial"); fontFace = (nppGUI._printSettings._footerFontName != TEXT(""))?nppGUI._printSettings._footerFontName.c_str():TEXT("Arial");
//::MessageBox(NULL, itoa(nppGUI._printSettings._footerFontStyle, , 10), TEXT("footer"), MB_OK); //::MessageBox(NULL, itoa(nppGUI._printSettings._footerFontStyle, , 10), TEXT("footer"), MB_OK);
@ -340,12 +340,11 @@ size_t Printer::doPrint(bool justDoIt)
_pSEView->showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, false); _pSEView->showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, false);
size_t pageNum = 1; size_t pageNum = 1;
bool printPage;
const TCHAR pageVar[] = TEXT("$(CURRENT_PRINTING_PAGE)"); const TCHAR pageVar[] = TEXT("$(CURRENT_PRINTING_PAGE)");
while (lengthPrinted < lengthDoc) while (lengthPrinted < lengthDoc)
{ {
printPage = (!(_pdlg.Flags & PD_PAGENUMS) || bool printPage = (!(_pdlg.Flags & PD_PAGENUMS) ||
(pageNum >= _pdlg.nFromPage) && (pageNum <= _pdlg.nToPage)); (pageNum >= _pdlg.nFromPage) && (pageNum <= _pdlg.nToPage));
if (!justDoIt) if (!justDoIt)

View File

@ -69,7 +69,7 @@ INT_PTR CALLBACK ColourPopup::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LP
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
ColourPopup *pColourPopup = (ColourPopup *)(lParam); ColourPopup *pColourPopup = reinterpret_cast<ColourPopup *>(lParam);
pColourPopup->_hSelf = hwnd; pColourPopup->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam);
pColourPopup->run_dlgProc(message, wParam, lParam); pColourPopup->run_dlgProc(message, wParam, lParam);

View File

@ -782,12 +782,11 @@ void WordStyleDlg::setVisualFromStyleList()
//-- font style : bold & italic //-- font style : bold & italic
isEnable = false; isEnable = false;
int isBold, isItalic, isUnderline;
if (style._fontStyle != STYLE_NOT_USED) if (style._fontStyle != STYLE_NOT_USED)
{ {
isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED; int isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED;
isItalic = (style._fontStyle & FONTSTYLE_ITALIC)?BST_CHECKED:BST_UNCHECKED; int isItalic = (style._fontStyle & FONTSTYLE_ITALIC)?BST_CHECKED:BST_UNCHECKED;
isUnderline = (style._fontStyle & FONTSTYLE_UNDERLINE)?BST_CHECKED:BST_UNCHECKED; int isUnderline = (style._fontStyle & FONTSTYLE_UNDERLINE)?BST_CHECKED:BST_UNCHECKED;
::SendMessage(_hCheckBold, BM_SETCHECK, isBold, 0); ::SendMessage(_hCheckBold, BM_SETCHECK, isBold, 0);
::SendMessage(_hCheckItalic, BM_SETCHECK, isItalic, 0); ::SendMessage(_hCheckItalic, BM_SETCHECK, isItalic, 0);
::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0); ::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0);

View File

@ -287,7 +287,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
{ {
Gripper *pGripper = new Gripper; Gripper *pGripper = new Gripper;
pGripper->init(_hInst, _hParent); pGripper->init(_hInst, _hParent);
pGripper->startGrip((DockingCont*)lParam, this); pGripper->startGrip(reinterpret_cast<DockingCont*>(lParam), this);
break; break;
} }
@ -355,12 +355,12 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
case DMM_DOCK: case DMM_DOCK:
case DMM_FLOAT: case DMM_FLOAT:
{ {
toggleActiveTb((DockingCont*)lParam, message); toggleActiveTb(reinterpret_cast<DockingCont*>(lParam), message);
return FALSE; return FALSE;
} }
case DMM_CLOSE: case DMM_CLOSE:
{ {
tTbData TbData = *((DockingCont*)lParam)->getDataOfActiveTb(); tTbData TbData = *(reinterpret_cast<DockingCont*>(lParam))->getDataOfActiveTb();
LRESULT res = SendNotify(TbData.hClient, DMN_CLOSE); // Be sure the active item is OK with closing LRESULT res = SendNotify(TbData.hClient, DMN_CLOSE); // Be sure the active item is OK with closing
if (res == 0) // Item will be closing? if (res == 0) // Item will be closing?
::PostMessage(_hParent, WM_ACTIVATE, WA_ACTIVE, 0); // Tell editor to take back focus ::PostMessage(_hParent, WM_ACTIVATE, WA_ACTIVE, 0); // Tell editor to take back focus
@ -368,12 +368,12 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l
} }
case DMM_FLOATALL: case DMM_FLOATALL:
{ {
toggleVisTb((DockingCont*)lParam, DMM_FLOAT); toggleVisTb(reinterpret_cast<DockingCont*>(lParam), DMM_FLOAT);
return FALSE; return FALSE;
} }
case DMM_DOCKALL: case DMM_DOCKALL:
{ {
toggleVisTb((DockingCont*)lParam, DMM_DOCK); toggleVisTb(reinterpret_cast<DockingCont*>(lParam), DMM_DOCK);
return FALSE; return FALSE;
} }
case DMM_GETIMAGELIST: case DMM_GETIMAGELIST:
@ -699,10 +699,9 @@ void DockingManager::showDockableDlg(HWND hDlg, BOOL view)
void DockingManager::showDockableDlg(TCHAR* pszName, BOOL view) void DockingManager::showDockableDlg(TCHAR* pszName, BOOL view)
{ {
tTbData *pTbData = NULL;
for (size_t i = 0, len = _vContainer.size(); i < len; ++i) for (size_t i = 0, len = _vContainer.size(); i < len; ++i)
{ {
pTbData = _vContainer[i]->findToolbarByName(pszName); tTbData *pTbData = _vContainer[i]->findToolbarByName(pszName);
if (pTbData != NULL) if (pTbData != NULL)
{ {
_vContainer[i]->showToolbar(pTbData, view); _vContainer[i]->showToolbar(pTbData, view);

View File

@ -652,7 +652,7 @@ struct SortZones final
void FunctionMixParser::parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName) void FunctionMixParser::parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
{ {
vector< pair<int, int> > commentZones, scannedZones, nonCommentZones, nonScannedZones; vector< pair<int, int> > commentZones, scannedZones, nonScannedZones;
getCommentZones(commentZones, begin, end, ppEditView); getCommentZones(commentZones, begin, end, ppEditView);
classParse(foundInfos, scannedZones, commentZones, begin, end, ppEditView, classStructName); classParse(foundInfos, scannedZones, commentZones, begin, end, ppEditView, classStructName);

View File

@ -2015,10 +2015,10 @@ INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR
wsprintf(intStr, TEXT("%d"), nppGUI._printSettings._footerFontSize); wsprintf(intStr, TEXT("%d"), nppGUI._printSettings._footerFontSize);
::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTSIZE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)intStr); ::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTSIZE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)intStr);
::SendDlgItemMessage(_hSelf, IDC_CHECK_HBOLD, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD?TRUE:FALSE, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_HBOLD, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & (FONTSTYLE_BOLD ? TRUE : FALSE), 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_HITALIC, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_HITALIC, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & (FONTSTYLE_ITALIC ? TRUE : FALSE), 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_FBOLD, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & FONTSTYLE_BOLD?TRUE:FALSE, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_FBOLD, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & (FONTSTYLE_BOLD ? TRUE : FALSE), 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_FITALIC, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_FITALIC, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & (FONTSTYLE_ITALIC ? TRUE : FALSE), 0);
varList.push_back(strCouple(TEXT("Full file name path"), TEXT("$(FULL_CURRENT_PATH)"))); varList.push_back(strCouple(TEXT("Full file name path"), TEXT("$(FULL_CURRENT_PATH)")));
varList.push_back(strCouple(TEXT("File name"), TEXT("$(FILE_NAME)"))); varList.push_back(strCouple(TEXT("File name"), TEXT("$(FILE_NAME)")));

View File

@ -71,9 +71,7 @@ class TiXmlNode;
class ProjectPanel : public DockingDlgInterface { class ProjectPanel : public DockingDlgInterface {
public: public:
ProjectPanel(): DockingDlgInterface(IDD_PROJECTPANEL),\ ProjectPanel(): DockingDlgInterface(IDD_PROJECTPANEL) {};
_hToolbarMenu(NULL), _hWorkSpaceMenu(NULL), _hProjectMenu(NULL),\
_hFolderMenu(NULL), _hFileMenu(NULL){};
void init(HINSTANCE hInst, HWND hPere) { void init(HINSTANCE hInst, HWND hPere) {
@ -113,11 +111,14 @@ public:
protected: protected:
TreeView _treeView; TreeView _treeView;
HIMAGELIST _hImaLst; HIMAGELIST _hImaLst;
HWND _hToolbarMenu; HWND _hToolbarMenu = nullptr;
HMENU _hWorkSpaceMenu, _hProjectMenu, _hFolderMenu, _hFileMenu; HMENU _hWorkSpaceMenu = nullptr;
HMENU _hProjectMenu = nullptr;
HMENU _hFolderMenu = nullptr;
HMENU _hFileMenu = nullptr;
generic_string _workSpaceFilePath; generic_string _workSpaceFilePath;
generic_string _selDirOfFilesFromDirDlg; generic_string _selDirOfFilesFromDirDlg;
bool _isDirty; bool _isDirty = false;
void initMenus(); void initMenus();
void destroyMenus(); void destroyMenus();

View File

@ -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 = (CReadChangesRequest*)lpOverlapped->hEvent; CReadChangesRequest* pBlock = reinterpret_cast<CReadChangesRequest*>(lpOverlapped->hEvent);
if (dwErrorCode == ERROR_OPERATION_ABORTED) if (dwErrorCode == ERROR_OPERATION_ABORTED)
{ {

View File

@ -111,7 +111,7 @@ public:
static unsigned int WINAPI ThreadStartProc(LPVOID arg) static unsigned int WINAPI ThreadStartProc(LPVOID arg)
{ {
CReadChangesServer* pServer = (CReadChangesServer*)arg; CReadChangesServer* pServer = static_cast<CReadChangesServer*>(arg);
pServer->Run(); pServer->Run();
return 0; return 0;
} }
@ -119,14 +119,14 @@ public:
// Called by QueueUserAPC to start orderly shutdown. // Called by QueueUserAPC to start orderly shutdown.
static void CALLBACK TerminateProc(__in ULONG_PTR arg) static void CALLBACK TerminateProc(__in ULONG_PTR arg)
{ {
CReadChangesServer* pServer = (CReadChangesServer*)arg; CReadChangesServer* pServer = reinterpret_cast<CReadChangesServer*>(arg);
pServer->RequestTermination(); pServer->RequestTermination();
} }
// Called by QueueUserAPC to add another directory. // Called by QueueUserAPC to add another directory.
static void CALLBACK AddDirectoryProc(__in ULONG_PTR arg) static void CALLBACK AddDirectoryProc(__in ULONG_PTR arg)
{ {
CReadChangesRequest* pRequest = (CReadChangesRequest*)arg; CReadChangesRequest* pRequest = reinterpret_cast<CReadChangesRequest*>(arg);
pRequest->m_pServer->AddDirectory(pRequest); pRequest->m_pServer->AddDirectory(pRequest);
} }

View File

@ -177,7 +177,7 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
StaticDialog *pStaticDlg = (StaticDialog *)(lParam); StaticDialog *pStaticDlg = reinterpret_cast<StaticDialog *>(lParam);
pStaticDlg->_hSelf = hwnd; pStaticDlg->_hSelf = hwnd;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam);
::GetWindowRect(hwnd, &(pStaticDlg->_rc)); ::GetWindowRect(hwnd, &(pStaticDlg->_rc));

View File

@ -186,7 +186,7 @@ int VerticalFileSwitcherListView::newItem(BufferID bufferID, int iView)
void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID) void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID)
{ {
Buffer *buf = (Buffer *)bufferID; Buffer *buf = static_cast<Buffer *>(bufferID);
TCHAR fn[MAX_PATH]; TCHAR fn[MAX_PATH];
lstrcpy(fn, ::PathFindFileName(buf->getFileName())); lstrcpy(fn, ::PathFindFileName(buf->getFileName()));
@ -259,7 +259,7 @@ void VerticalFileSwitcherListView::activateItem(BufferID bufferID, int iView)
int VerticalFileSwitcherListView::add(BufferID bufferID, int iView) int VerticalFileSwitcherListView::add(BufferID bufferID, int iView)
{ {
int index = ListView_GetItemCount(_hSelf); int index = ListView_GetItemCount(_hSelf);
Buffer *buf = (Buffer *)bufferID; Buffer *buf = static_cast<Buffer *>(bufferID);
const TCHAR *fileName = buf->getFileName(); const TCHAR *fileName = buf->getFileName();
TaskLstFnStatus *tl = new TaskLstFnStatus(iView, 0, fileName, 0, (void *)bufferID); TaskLstFnStatus *tl = new TaskLstFnStatus(iView, 0, fileName, 0, (void *)bufferID);

View File

@ -543,7 +543,7 @@ void WindowsDlg::onGetMinMaxInfo(MINMAXINFO* lpMMI)
LRESULT WindowsDlg::onWinMgr(WPARAM wp, LPARAM lp) LRESULT WindowsDlg::onWinMgr(WPARAM wp, LPARAM lp)
{ {
NMWINMGR &nmw = *(NMWINMGR *)lp; NMWINMGR &nmw = *reinterpret_cast<NMWINMGR *>(lp);
if (nmw.code==NMWINMGR::GET_SIZEINFO) { if (nmw.code==NMWINMGR::GET_SIZEINFO) {
switch(wp) switch(wp)
{ {
@ -739,20 +739,19 @@ void WindowsDlg::doSortToTabs()
NMWINDLG nmdlg; NMWINDLG nmdlg;
nmdlg.type = WDT_SORT; nmdlg.type = WDT_SORT;
nmdlg.hwndFrom = _hSelf; nmdlg.hwndFrom = _hSelf;
//nmdlg.curSel = curSel;
nmdlg.curSel = _idxMap[curSel]; nmdlg.curSel = _idxMap[curSel];
nmdlg.code = WDN_NOTIFY; nmdlg.code = WDN_NOTIFY;
UINT n = nmdlg.nItems = ListView_GetItemCount(_hList); nmdlg.nItems = ListView_GetItemCount(_hList);
nmdlg.Items = new UINT[nmdlg.nItems]; nmdlg.Items = new UINT[nmdlg.nItems];
vector<int> key;
key.resize(n, 0x7fffffff); for(int i=-1, j=0;; ++j)
for(int i=-1, j=0;; ++j) { {
i = ListView_GetNextItem(_hList, i, LVNI_ALL); i = ListView_GetNextItem(_hList, i, LVNI_ALL);
if (i == -1) break; if (i == -1)
break;
nmdlg.Items[j] = _idxMap[i]; nmdlg.Items[j] = _idxMap[i];
if (i == curSel) if (i == curSel)
nmdlg.curSel = j; nmdlg.curSel = j;
key[j] = i;
} }
SendMessage(_hParent, WDN_NOTIFY, 0, LPARAM(&nmdlg)); SendMessage(_hParent, WDN_NOTIFY, 0, LPARAM(&nmdlg));

View File

@ -583,7 +583,8 @@ void Accelerator::updateFullMenu() {
::DrawMenuBar(_hMenuParent); ::DrawMenuBar(_hMenuParent);
} }
void Accelerator::updateMenuItemByCommand(CommandShortcut csc) { void Accelerator::updateMenuItemByCommand(CommandShortcut csc)
{
int cmdID = (int)csc.getID(); int cmdID = (int)csc.getID();
// Ensure that the menu item checks set prior to this update remain in affect. // Ensure that the menu item checks set prior to this update remain in affect.
@ -641,9 +642,9 @@ void recordedMacroStep::PlayBack(Window* pNotepad, ScintillaEditView *pEditView)
else else
{ {
char ansiBuffer[3];
if (_macroType == mtUseSParameter) if (_macroType == mtUseSParameter)
{ {
char ansiBuffer[3];
::WideCharToMultiByte(static_cast<UINT>(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, ansiBuffer, 3, NULL, NULL); ::WideCharToMultiByte(static_cast<UINT>(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, ansiBuffer, 3, NULL, NULL);
auto lParam = reinterpret_cast<LPARAM>(ansiBuffer); auto lParam = reinterpret_cast<LPARAM>(ansiBuffer);
pEditView->execute(_message, _wParameter, lParam); pEditView->execute(_message, _wParameter, lParam);

View File

@ -36,7 +36,7 @@
#include <deque> #include <deque>
struct RecentItem { struct RecentItem {
int _id; int _id = 0;
generic_string _name; generic_string _name;
RecentItem(const TCHAR * name) : _name(name) {}; RecentItem(const TCHAR * name) : _name(name) {};
}; };