diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 52bb6f615..a9ba46be7 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -59,6 +59,15 @@ void writeLog(const TCHAR *logFileName, const char *log2write) fclose(f); } +// Set a call back with the handle after init to set the path. +// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp +static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData) +{ + if (uMsg == BFFM_INITIALIZED) + ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData); + return 0; +}; + void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr) { // This code was copied and slightly modifed from: @@ -163,7 +172,7 @@ void ScreenRectToClientRect(HWND hWnd, RECT* rect) rect->bottom = pt.y; }; -int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep) +int filter(unsigned int code, struct _EXCEPTION_POINTERS *) { if (code == EXCEPTION_ACCESS_VIOLATION) return EXCEPTION_EXECUTE_HANDLER; @@ -412,7 +421,7 @@ TCHAR *BuildMenuFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename) if (pos < 9) { *itr++ = '&'; - *itr++ = '1' + pos; + *itr++ = '1' + (TCHAR)pos; } else if (pos == 9) { @@ -448,7 +457,7 @@ TCHAR *BuildMenuFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename) else { TCHAR cnvName[MAX_PATH*2]; - const TCHAR *s1 = convertFileName(cnvName, filename); + convertFileName(cnvName, filename); PathCompactPathEx(itr, filename, len - (itr-buffer), 0); } return buffer; diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index ec2604dc1..54cada0a7 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -77,15 +77,6 @@ void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr = NULL); -// Set a call back with the handle after init to set the path. -// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp -static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData) -{ - if (uMsg == BFFM_INITIALIZED) - ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData); - return 0; -}; - void systemMessage(const TCHAR *title); //DWORD ShortToLongPathName(LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer); void printInt(int int2print); @@ -131,6 +122,10 @@ protected: size_t _multiByteAllocLen; wchar_t *_wideCharStr; size_t _wideCharAllocLen; + +private: + // Since there's no public ctor, we need to void the default assignment operator. + WcharMbcsConvertor& operator= (const WcharMbcsConvertor&); }; diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index f70bdb18b..a4b57116f 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -234,7 +234,7 @@ bool PluginsManager::getShortcutByCmdID(int cmdID, ShortcutKey *sk) for (size_t i = 0 ; i < pluginCmdSCList.size() ; i++) { - if (pluginCmdSCList[i].getID() == cmdID) + if (pluginCmdSCList[i].getID() == (unsigned long)cmdID) { const KeyCombo & kc = pluginCmdSCList[i].getKeyCombo(); if (kc._key == 0x00) @@ -281,14 +281,14 @@ void PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName) if (_pluginInfos[i]->_funcItems[j]._pShKey) { ShortcutKey & sKey = *(_pluginInfos[i]->_funcItems[j]._pShKey); - PluginCmdShortcut pcs(Shortcut(itemName.c_str(), sKey._isCtrl, sKey._isAlt, sKey._isShift, sKey._key), cmdID, _pluginInfos[i]->_moduleName, j); + PluginCmdShortcut pcs(Shortcut(itemName.c_str(), sKey._isCtrl, sKey._isAlt, sKey._isShift, sKey._key), (unsigned char)cmdID, _pluginInfos[i]->_moduleName, (unsigned short)j); pluginCmdSCList.push_back(pcs); itemName += TEXT("\t"); itemName += pcs.toString(); } else { //no ShortcutKey is provided, add an disabled shortcut (so it can still be mapped, Paramaters class can still index any changes and the toolbar wont funk out - PluginCmdShortcut pcs(Shortcut(itemName.c_str(), false, false, false, 0x00), cmdID, _pluginInfos[i]->_moduleName, j); //VK_NULL and everything disabled, the menu name is left alone + PluginCmdShortcut pcs(Shortcut(itemName.c_str(), false, false, false, 0x00), (unsigned char)cmdID, _pluginInfos[i]->_moduleName, (unsigned short)j); //VK_NULL and everything disabled, the menu name is left alone pluginCmdSCList.push_back(pcs); } ::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION, cmdID, itemName.c_str()); diff --git a/PowerEditor/src/MISC/Process/Process.cpp b/PowerEditor/src/MISC/Process/Process.cpp index 5b13582f2..d0cd903f6 100644 --- a/PowerEditor/src/MISC/Process/Process.cpp +++ b/PowerEditor/src/MISC/Process/Process.cpp @@ -183,7 +183,7 @@ void Process::listenerStdOut() ::ResumeThread(_hProcessThread); - while (true) + for(;;) { // got data memset(bufferOut,0x00,MAX_LINE_LENGTH + 1); //memset(bufferErr,0x00,MAX_LINE_LENGTH + 1); @@ -243,7 +243,7 @@ void Process::listenerStdErr() ::ResumeThread(_hProcessThread); - while (true) + for(;;) { // got data memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1); taille = sizeof(bufferErr) - sizeof(TCHAR); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 9871203d7..df4abcd6d 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -114,9 +114,11 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p _toolIcons = toolIconsDocRoot->FirstChild(TEXT("NotepadPlus")); if (_toolIcons) { - if ((_toolIcons = _toolIcons->FirstChild(TEXT("ToolBarIcons")))) + _toolIcons = _toolIcons->FirstChild(TEXT("ToolBarIcons")); + if (_toolIcons) { - if ((_toolIcons = _toolIcons->FirstChild(TEXT("Theme")))) + _toolIcons = _toolIcons->FirstChild(TEXT("Theme")); + if (_toolIcons) { const TCHAR *themeDir = (_toolIcons->ToElement())->Attribute(TEXT("pathPrefix")); @@ -1002,7 +1004,6 @@ void Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg) int i = 0; Lang *l = NppParameters::getInstance()->getLangFromIndex(i++); - LangType curl = _pEditView->getCurrentBuffer()->getLangType(); while (l) { @@ -1044,7 +1045,7 @@ void Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg) const TCHAR *filters = stringFilters.c_str(); if (filters[0]) { - int nbExt = fDlg.setExtsFilter(getLangDesc(lid, true).c_str(), filters); + fDlg.setExtsFilter(getLangDesc(lid, true).c_str(), filters); } } l = (NppParameters::getInstance())->getLangFromIndex(i++); @@ -1244,7 +1245,7 @@ bool Notepad_plus::fileSaveAs(BufferID id, bool isSaveCopy) } } -bool Notepad_plus::fileRename(BufferID id, int curView) +bool Notepad_plus::fileRename(BufferID id) { BufferID bufferID = id; if (id == BUFFER_INVALID) @@ -1267,7 +1268,7 @@ bool Notepad_plus::fileRename(BufferID id, int curView) } -bool Notepad_plus::fileDelete(BufferID id, int curView) +bool Notepad_plus::fileDelete(BufferID id) { BufferID bufferID = id; if (id == BUFFER_INVALID) @@ -1689,7 +1690,6 @@ bool Notepad_plus::replaceInFiles() _pEditView = &_invisibleEditView; Document oldDoc = _invisibleEditView.execute(SCI_GETDOCPOINTER); Buffer * oldBuf = _invisibleEditView.getCurrentBuffer(); //for manually setting the buffer, so notifications can be handled properly - Buffer * pBuf = NULL; HANDLE CancelThreadHandle = NULL; vector patterns2Match; @@ -2948,7 +2948,6 @@ void Notepad_plus::addHotSpot(bool docIsModifing) int isUnderline = _pEditView->execute(SCI_STYLEGETUNDERLINE, idStyle); hotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); - int fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; if (urlAction == 2) hotspotStyle._fontStyle |= FONTSTYLE_UNDERLINE; @@ -3225,8 +3224,8 @@ void Notepad_plus::command(int id) //_subEditView.execute(SCI_ENDUNDOACTION); //::SetCursor(originalCur); - _mainEditView.execute(SCI_SETCURSOR, (LPARAM)SC_CURSORNORMAL); - _subEditView.execute(SCI_SETCURSOR, (LPARAM)SC_CURSORNORMAL); + _mainEditView.execute(SCI_SETCURSOR, (WPARAM)SC_CURSORNORMAL); + _subEditView.execute(SCI_SETCURSOR, (WPARAM)SC_CURSORNORMAL); _recordingMacro = false; _runMacroDlg.initMacroList(); @@ -4280,8 +4279,6 @@ void Notepad_plus::command(int id) _aboutDlg.doDialog(); if (isFirstTime && _nativeLangA) { - const char *lang = (_nativeLangA->ToElement())->Attribute("name"); - if (_nativeLangEncoding == CP_BIG5) { char *authorName = "«J¤µ§^"; @@ -4435,7 +4432,7 @@ void Notepad_plus::command(int id) case IDM_LANG_YAML : case IDM_LANG_USER : { - setLanguage(id, menuID2LangType(id)); + setLanguage(menuID2LangType(id)); } break; @@ -4526,7 +4523,7 @@ void Notepad_plus::command(int id) } else if ((id >= IDM_LANG_EXTERNAL) && (id <= IDM_LANG_EXTERNAL_LIMIT)) { - setLanguage(id, (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL)); + setLanguage((LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL)); } else if ((id >= ID_MACRO) && (id < ID_MACRO_LIMIT)) { @@ -4640,7 +4637,7 @@ void Notepad_plus::command(int id) } -void Notepad_plus::setLanguage(int id, LangType langType) { +void Notepad_plus::setLanguage(LangType langType) { //Add logic to prevent changing a language when a document is shared between two views //If so, release one document bool reset = false; @@ -4849,7 +4846,6 @@ void Notepad_plus::activateDoc(int pos) void Notepad_plus::updateStatusBar() { - Buffer * buf = _pEditView->getCurrentBuffer(); TCHAR strLnCol[64]; wsprintf(strLnCol, TEXT("Ln : %d Col : %d Sel : %d"),\ (_pEditView->getCurrentLineNumber() + 1), \ @@ -5214,11 +5210,11 @@ void Notepad_plus::removeBufferFromView(BufferID id, int whichOne) { } else { toActivate = active; //activate the 'active' index. Since we remove the tab first, the indices shift (on the right side) } - tabToClose->deletItemAt(index); //delete first + tabToClose->deletItemAt((size_t)index); //delete first activateBuffer(tabToClose->getBufferByIndex(toActivate), whichOne); //then activate. The prevent jumpy tab behaviour } } else { - tabToClose->deletItemAt(index); + tabToClose->deletItemAt((size_t)index); } MainFileManager->closeBuffer(id, viewToClose); @@ -5599,28 +5595,32 @@ void Notepad_plus::changeMenuLang(generic_string & pluginsTrans, generic_string ::ModifyMenu(_mainMenuHandle, id, MF_BYPOSITION, 0, name); #endif } - else if (idName = element->Attribute("idName")) + else { - const char *name = element->Attribute("name"); - if (!strcmp(idName, "Plugins")) + idName = element->Attribute("idName"); + if (idName) { + const char *name = element->Attribute("name"); + if (!strcmp(idName, "Plugins")) + { #ifdef UNICODE - const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); - pluginsTrans = nameW; + const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); + pluginsTrans = nameW; #else - pluginsTrans = name; + pluginsTrans = name; #endif - } - else if (!strcmp(idName, "Window")) - { + } + else if (!strcmp(idName, "Window")) + { #ifdef UNICODE - const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); - windowTrans = nameW; + const wchar_t *nameW = wmc->char2wchar(name, _nativeLangEncoding); + windowTrans = nameW; #else - windowTrans = name; -#endif + windowTrans = name; + #endif + } } - } + } } TiXmlNodeA *menuCommandsRoot = mainMenu->FirstChild("Commands"); @@ -6441,7 +6441,7 @@ void Notepad_plus::changeShortcutLang() if (index > -1 && index < mainSize) { //valid index only const char *name = element->Attribute("name"); CommandShortcut & csc = mainshortcuts[index]; - if (csc.getID() == id) + if (csc.getID() == (unsigned long)id) { #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); @@ -8221,7 +8221,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa mainVerStr[j] = '\0'; auxVerStr[k] = '\0'; - int mainVer, auxVer = 0; + int mainVer = 0, auxVer = 0; if (mainVerStr) mainVer = generic_atoi(mainVerStr); if (auxVerStr) @@ -8267,7 +8267,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } _pEditView->execute(SCI_BEGINUNDOACTION); - while (true) + for(;;) { for (Macro::iterator step = m.begin(); step != m.end(); step++) step->PlayBack(this, _pEditView); @@ -9070,7 +9070,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } break; case WDT_SORT: - if (nmdlg->nItems != _pDocTab->nbItem()) //sanity check, if mismatch just abort + if (nmdlg->nItems != (unsigned int)_pDocTab->nbItem()) //sanity check, if mismatch just abort break; //Collect all buffers std::vector tempBufs; @@ -9602,19 +9602,8 @@ bool Notepad_plus::str2Cliboard(const TCHAR *str2cpy) //This function is destructive bool Notepad_plus::emergency(generic_string emergencySavedDir) { - bool filestatus = false; - bool dumpstatus = false; - do { - if (::CreateDirectory(emergencySavedDir.c_str(), NULL) == FALSE && ::GetLastError() != ERROR_ALREADY_EXISTS) { - break; - } - - filestatus = dumpFiles(emergencySavedDir.c_str(), TEXT("File")); - - } while (false); - - bool status = filestatus;// && dumpstatus; - return status; + ::CreateDirectory(emergencySavedDir.c_str(), NULL); + return dumpFiles(emergencySavedDir.c_str(), TEXT("File")); } bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) { diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 823c917e2..f0af32906 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -156,8 +156,8 @@ public: bool fileSave(BufferID id = BUFFER_INVALID); bool fileSaveAll(); bool fileSaveAs(BufferID id = BUFFER_INVALID, bool isSaveCopy = false); - bool fileDelete(BufferID id = BUFFER_INVALID, int curView = -1); - bool fileRename(BufferID id = BUFFER_INVALID, int curView = -1); + bool fileDelete(BufferID id = BUFFER_INVALID); + bool fileRename(BufferID id = BUFFER_INVALID); bool addBufferToView(BufferID id, int whichOne); bool moveBuffer(BufferID id, int whereTo); //assumes whereFrom is otherView(whereTo) @@ -536,11 +536,12 @@ private: void checkLangsMenu(int id) const ; - void setLanguage(int id, LangType langType); + void setLanguage(LangType langType); enum LangType menuID2LangType(int cmdID); - int getFolderMarginStyle() const { + int getFolderMarginStyle() const + { if (::GetMenuState(_mainMenuHandle, IDM_VIEW_FOLDERMAGIN_SIMPLE, MF_BYCOMMAND) == MF_CHECKED) return IDM_VIEW_FOLDERMAGIN_SIMPLE; @@ -672,7 +673,7 @@ private: ::OpenClipboard(_hSelf); HANDLE clipboardData = ::GetClipboardData(clipFormat); - int len = ::GlobalSize(clipboardData); + ::GlobalSize(clipboardData); LPVOID clipboardDataPtr = ::GlobalLock(clipboardData); generic_string clipboardStr = (const TCHAR *)clipboardDataPtr; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 6a760ed68..097e5bf49 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -328,6 +328,41 @@ ScintillaKeyDefinition scintKeyDefs[] = { //array of accelerator keys for all po //{TEXT("SCI_STYLECLEARALL"), SCI_STYLECLEARALL, false, false, false, 0, 0}, // }; + +static int strVal(const TCHAR *str, int base) { + if (!str) return -1; + if (!str[0]) return 0; + + TCHAR *finStr; + int result = generic_strtol(str, &finStr, base); + if (*finStr != '\0') + return -1; + return result; +}; + +static int decStrVal(const TCHAR *str) { + return strVal(str, 10); +}; + +static int hexStrVal(const TCHAR *str) { + return strVal(str, 16); +}; + +static int getKwClassFromName(const TCHAR *str) { + if (!lstrcmp(TEXT("instre1"), str)) return LANG_INDEX_INSTR; + if (!lstrcmp(TEXT("instre2"), str)) return LANG_INDEX_INSTR2; + if (!lstrcmp(TEXT("type1"), str)) return LANG_INDEX_TYPE; + if (!lstrcmp(TEXT("type2"), str)) return LANG_INDEX_TYPE2; + if (!lstrcmp(TEXT("type3"), str)) return LANG_INDEX_TYPE3; + if (!lstrcmp(TEXT("type4"), str)) return LANG_INDEX_TYPE4; + if (!lstrcmp(TEXT("type5"), str)) return LANG_INDEX_TYPE5; + + if ((str[1] == '\0') && (str[0] >= '0') && (str[0] <= '8')) // up to KEYWORDSET_MAX + return str[0] - '0'; + + return -1; +}; + #ifdef UNICODE #include "localizationString.h" @@ -378,7 +413,8 @@ bool LocalizationSwitcher::switchToLang(wchar_t *lang2switch) const generic_string ThemeSwitcher::getThemeFromXmlFileName(const TCHAR *xmlFullPath) const { - if (xmlFullPath == TEXT("")) return xmlFullPath; + if (!xmlFullPath[0]) + return xmlFullPath; TCHAR fn[MAX_PATH]; lstrcpy(fn, ::PathFindFileName(xmlFullPath)); PathRemoveExtension(fn); @@ -393,14 +429,13 @@ winVer getWindowsVersion() OSVERSIONINFOEX osvi; SYSTEM_INFO si; PGNSI pGNSI; - BOOL bOsVersionInfoEx; ZeroMemory(&si, sizeof(SYSTEM_INFO)); ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) ) + BOOL bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *)&osvi); + if (!bOsVersionInfoEx) { osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) @@ -1131,7 +1166,7 @@ void NppParameters::initMenuKeys() for(int i = 0; i < nrCommands; i++) { wkd = winKeyDefs[i]; - Shortcut sc( (wkd.specialName?wkd.specialName:TEXT("")), wkd.isCtrl, wkd.isAlt, wkd.isShift, wkd.vKey); + Shortcut sc((wkd.specialName?wkd.specialName:TEXT("")), wkd.isCtrl, wkd.isAlt, wkd.isShift, (unsigned char)wkd.vKey); _shortcuts.push_back( CommandShortcut(sc, wkd.functionId) ); } } @@ -1142,19 +1177,23 @@ void NppParameters::initScintillaKeys() { //Warning! Matching function have to be consecutive ScintillaKeyDefinition skd; - size_t prevIndex = -1; + int prevIndex = -1; int prevID = -1; - for(int i = 0; i < nrCommands; i++) { + for(int i = 0; i < nrCommands; i++) + { skd = scintKeyDefs[i]; - if (skd.functionId == prevID) { + if (skd.functionId == prevID) + { KeyCombo kc; kc._isCtrl = skd.isCtrl; kc._isAlt = skd.isAlt; kc._isShift = skd.isShift; - kc._key = skd.vKey; + kc._key = (unsigned char)skd.vKey; _scintillaKeyCommands[prevIndex].addKeyCombo(kc); - } else { - _scintillaKeyCommands.push_back(ScintillaKeyMap(Shortcut(skd.name, skd.isCtrl, skd.isAlt, skd.isShift, skd.vKey), skd.functionId, skd.redirFunctionId)); + } + else + { + _scintillaKeyCommands.push_back(ScintillaKeyMap(Shortcut(skd.name, skd.isCtrl, skd.isAlt, skd.isShift, (unsigned char)skd.vKey), skd.functionId, skd.redirFunctionId)); prevIndex++; } prevID = skd.functionId; @@ -1597,7 +1636,7 @@ void NppParameters::feedShortcut(TiXmlNode *node) int len = (int)_shortcuts.size(); for(int i = 0; i < len; i++) { - if (_shortcuts[i].getID() == id) + if (_shortcuts[i].getID() == (unsigned short)id) { //found our match getShortcuts(childNode, _shortcuts[i]); addUserModifiedIndex(i); @@ -1642,13 +1681,13 @@ void NppParameters::getActions(TiXmlNode *node, Macro & macro) continue; int msg = 0; - const TCHAR *msgStr = (childNode->ToElement())->Attribute(TEXT("message"), &msg); + (childNode->ToElement())->Attribute(TEXT("message"), &msg); int wParam = 0; - const TCHAR *wParamStr = (childNode->ToElement())->Attribute(TEXT("wParam"), &wParam); + (childNode->ToElement())->Attribute(TEXT("wParam"), &wParam); int lParam = 0; - const TCHAR *lParamStr = (childNode->ToElement())->Attribute(TEXT("lParam"), &lParam); + (childNode->ToElement())->Attribute(TEXT("lParam"), &lParam); const TCHAR *sParam = (childNode->ToElement())->Attribute(TEXT("sParam")); if (!sParam) @@ -1747,7 +1786,7 @@ void NppParameters::feedScintKeys(TiXmlNode *node) for(size_t i = 0; i < len; i++) { ScintillaKeyMap & skmOrig = _scintillaKeyCommands[i]; - if (skmOrig.getScintillaKeyID() == scintKey &&skmOrig.getMenuCmdID() == menuID) + if (skmOrig.getScintillaKeyID() == (unsigned long)scintKey && skmOrig.getMenuCmdID() == menuID) { //Found matching command _scintillaKeyCommands[i].clearDups(); @@ -1778,7 +1817,7 @@ void NppParameters::feedScintKeys(TiXmlNode *node) str = (nextNode->ToElement())->Attribute(TEXT("Key"), &key); if (!str) continue; - kc._key = key; + kc._key = (unsigned char)key; _scintillaKeyCommands[i].addKeyCombo(kc); } break; @@ -1815,7 +1854,7 @@ bool NppParameters::getShortcuts(TiXmlNode *node, Shortcut & sc) if (!keyStr) return false; - sc = Shortcut(name, isCtrl, isAlt, isShift, key); + sc = Shortcut(name, isCtrl, isAlt, isShift, (unsigned char)key); return true; } @@ -2907,8 +2946,8 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (fuckUp) _nppGUI._appPos = oldRect; - - if (val = element->Attribute(TEXT("isMaximized"))) + val = element->Attribute(TEXT("isMaximized")); + if (val) { _nppGUI._isMaximized = (lstrcmp(val, TEXT("yes")) == 0); } @@ -2925,7 +2964,8 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (element->Attribute(TEXT("lang"), &i)) _nppGUI._newDocDefaultSettings._lang = (LangType)i; - if (val = element->Attribute(TEXT("openAnsiAsUTF8"))) + val = element->Attribute(TEXT("openAnsiAsUTF8")); + if (val) _nppGUI._newDocDefaultSettings._openAnsiAsUtf8 = (lstrcmp(val, TEXT("yes")) == 0); } @@ -3252,7 +3292,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) else if (!lstrcmp(nm, TEXT("stylerTheme"))) { const TCHAR *themePath = element->Attribute(TEXT("path")); - if (themePath != NULL && themePath != TEXT("")) + if (themePath != NULL && themePath[0]) _nppGUI._themeName.assign(themePath); } } @@ -3453,8 +3493,8 @@ void NppParameters::feedDockingManager(TiXmlNode *node) dlgElement->Attribute(TEXT("prev"), &prev); bool isVisible = false; - const TCHAR *val = NULL; - if (val = dlgElement->Attribute(TEXT("isVisible"))) + const TCHAR *val = dlgElement->Attribute(TEXT("isVisible")); + if (val) { isVisible = (lstrcmp(val, TEXT("yes")) == 0); } @@ -3541,7 +3581,6 @@ bool NppParameters::writeGUIParams() bool maitainIndentExist = false; bool MRUExist = false; bool backExist = false; - bool saveOpenFileInSameDirExist = false; bool URLExist = false; bool globalOverrideExist = false; bool autocExist = false; @@ -4532,8 +4571,6 @@ void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & g void NppParameters::writeStyle2Element(Style & style2Wite, Style & style2Sync, TiXmlElement *element) { - const TCHAR *styleName = element->Attribute(TEXT("name")); - if (HIBYTE(HIWORD(style2Wite._fgColor)) != 0xFF) { int rgbVal = RGB2int(style2Wite._fgColor); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index bcccd8c8e..60e4d7a33 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -215,41 +215,6 @@ struct DockingManagerData { } }; -static int strVal(const TCHAR *str, int base) { - if (!str) return -1; - if (!str[0]) return 0; - - TCHAR *finStr; - int result = generic_strtol(str, &finStr, base); - if (*finStr != '\0') - return -1; - return result; -}; - -static int decStrVal(const TCHAR *str) { - return strVal(str, 10); -}; - -static int hexStrVal(const TCHAR *str) { - return strVal(str, 16); -}; - - -static int getKwClassFromName(const TCHAR *str) { - if (!lstrcmp(TEXT("instre1"), str)) return LANG_INDEX_INSTR; - if (!lstrcmp(TEXT("instre2"), str)) return LANG_INDEX_INSTR2; - if (!lstrcmp(TEXT("type1"), str)) return LANG_INDEX_TYPE; - if (!lstrcmp(TEXT("type2"), str)) return LANG_INDEX_TYPE2; - if (!lstrcmp(TEXT("type3"), str)) return LANG_INDEX_TYPE3; - if (!lstrcmp(TEXT("type4"), str)) return LANG_INDEX_TYPE4; - if (!lstrcmp(TEXT("type5"), str)) return LANG_INDEX_TYPE5; - - if ((str[1] == '\0') && (str[0] >= '0') && (str[0] <= '8')) // up to KEYWORDSET_MAX - return str[0] - '0'; - - return -1; -}; - const int FONTSTYLE_BOLD = 1; const int FONTSTYLE_ITALIC = 2; const int FONTSTYLE_UNDERLINE = 4; @@ -1346,7 +1311,7 @@ private: winVer _winVersion; - static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, int FontType, LPARAM lParam) { + static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *, int, LPARAM lParam) { vector *pStrVect = (vector *)lParam; size_t vectSize = pStrVect->size(); diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index a83b4855d..b58972cc2 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -110,8 +110,8 @@ void Buffer::setFileName(const TCHAR *fn, LangType defaultLang) ext += 1; // Define User Lang firstly - const TCHAR *langName = NULL; - if ((langName = pNppParamInst->getUserDefinedLangNameFromExt(ext))) + const TCHAR *langName = pNppParamInst->getUserDefinedLangNameFromExt(ext); + if (langName) { newLang = L_USER; lstrcpy(_userLangExt, langName); @@ -399,7 +399,6 @@ void FileManager::closeBuffer(BufferID id, ScintillaEditView * identifier) { int index = getBufferIndexByID(id); Buffer * buf = getBufferByIndex(index); - int oldRefs = buf->_references; int refs = buf->removeReference(identifier); if (!refs) { //buffer can be deallocated @@ -459,9 +458,11 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc) { buf->setUnicodeMode(encoding); //determine buffer properties - BufferID retval = _nextBufferID++; + _nextBufferID++; return id; - } else { //failed loading, release document + } + else //failed loading, release document + { if (ownDoc) _pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, doc); //Failure, so release document return BUFFER_INVALID; @@ -520,7 +521,7 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy) { Buffer * buffer = getBufferByID(id); bool isHidden = false; bool isSys = false; - DWORD attrib; + DWORD attrib = 0; TCHAR fullpath[MAX_PATH]; ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); @@ -602,7 +603,7 @@ BufferID FileManager::newEmptyDocument() newBuf->_id = id; _buffers.push_back(newBuf); _nrBufs++; - BufferID retval = _nextBufferID++; + _nextBufferID++; return id; } @@ -618,7 +619,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d newBuf->_id = id; _buffers.push_back(newBuf); _nrBufs++; - BufferID retval = _nextBufferID; + if (!dontIncrease) _nextBufferID++; return id; diff --git a/PowerEditor/src/ScitillaComponent/DocTabView.cpp b/PowerEditor/src/ScitillaComponent/DocTabView.cpp index c97cca42d..a770d7479 100644 --- a/PowerEditor/src/ScitillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScitillaComponent/DocTabView.cpp @@ -49,7 +49,7 @@ void DocTabView::addBuffer(BufferID buffer) { void DocTabView::closeBuffer(BufferID buffer) { int indexToClose = getIndexByBuffer(buffer); - deletItemAt(indexToClose); + deletItemAt((size_t)indexToClose); ::SendMessage(_hParent, WM_SIZE, 0, 0); } diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 1eb72a0a8..6a146e6d3 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -94,7 +94,7 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int bool Searching::readBase(const TCHAR * str, int * value, int base, int size) { int i = 0, temp = 0; *value = 0; - TCHAR max = '0' + base - 1; + TCHAR max = '0' + (TCHAR)base - 1; TCHAR current; while(i < size) { current = str[i]; @@ -149,7 +149,11 @@ void Searching::displaySectionCentered(int posStart, int posEnd, ScintillaEditVi LONG FindReplaceDlg::originalFinderProc = NULL; +#ifdef UNICODE +void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool) +#else void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUTF8) +#endif { if (!hCombo) return; if (!lstrcmp(txt2add, TEXT(""))) return; @@ -157,7 +161,7 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT int i = 0; #ifdef UNICODE - i = ::SendMessage(hCombo, CB_FINDSTRINGEXACT, -1, (LPARAM)txt2add); + i = ::SendMessage(hCombo, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2add); if (i != CB_ERR) // found { ::SendMessage(hCombo, CB_DELETESTRING, i, 0); @@ -221,8 +225,11 @@ void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUT #endif ::SendMessage(hCombo, CB_SETCURSEL, i, 0); } - +#ifdef UNICODE +generic_string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool) const +#else generic_string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool isUnicode) const +#endif { TCHAR str[FINDREPLACE_MAXLENGTH]; #ifdef UNICODE @@ -400,7 +407,7 @@ void FindReplaceDlg::saveFindHistory() void FindReplaceDlg::saveComboHistory(int id, int maxcount, int & oldcount, generic_string **pStrings) { int i, count; - bool isUnicode = false; + HWND hCombo; TCHAR text[FINDREPLACE_MAXLENGTH]; @@ -1147,7 +1154,6 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, FindOption *options, } } - bool isRegExp = pOptions->_searchType == FindRegex; int flags = Searching::buildSearchFlags(pOptions); (*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags); @@ -1250,12 +1256,8 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl { //For the rare re exp case. ex: replace ^ by AAA int start = int((*_ppEditView)->execute(SCI_GETTARGETSTART)); - int end = int((*_ppEditView)->execute(SCI_GETTARGETEND)); - int foundTextLen = (end >= start)?end - start:start - end; int replacedLen = (*_ppEditView)->replaceTargetRegExMode(pTextReplace); - - //if (!foundTextLen) (*_ppEditView)->execute(SCI_SETSEL, start, start + replacedLen); } else @@ -1951,7 +1953,7 @@ void FindIncrementDlg::display(bool toShow) const } #define SHIFTED 0x8000 -BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { switch (message) { @@ -2027,7 +2029,7 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM if (!isFound) { CharacterRange range = (*(_pFRDlg->_ppEditView))->getSelection(); - (*(_pFRDlg->_ppEditView))->execute(SCI_SETSEL, -1, range.cpMin); + (*(_pFRDlg->_ppEditView))->execute(SCI_SETSEL, (WPARAM)-1, range.cpMin); } } @@ -2096,7 +2098,7 @@ void FindIncrementDlg::addToRebar(ReBar * rebar) { if(_pRebar) return; - HWND hRebar = rebar->getHSelf(); + _pRebar = rebar; RECT client; getClientRect(client); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index 2f182b516..b145ac63a 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -326,7 +326,7 @@ public : if (txt2find && txt2find[0]) { // We got a valid search string - ::SendMessage(hCombo, CB_SETCURSEL, -1, 0); // remove selection - to allow using down arrow to get to last searched word + ::SendMessage(hCombo, CB_SETCURSEL, (WPARAM)-1, 0); // remove selection - to allow using down arrow to get to last searched word ::SetDlgItemText(_hSelf, IDFINDWHAT, txt2find); } ::SendMessage(hCombo, CB_SETEDITSEL, 0, MAKELPARAM(0, -1)); // select all text - fast edit @@ -376,7 +376,6 @@ public : void beginNewFilesSearch() { _pFinder->beginNewFilesSearch(); - bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit; _pFinder->addSearchLine(getText2search().c_str()); } @@ -551,11 +550,12 @@ public : }; virtual void destroy(); virtual void display(bool toShow = true) const; - - void setSearchText(const TCHAR * txt2find, bool isUTF8 = false) { #ifdef UNICODE + void setSearchText(const TCHAR * txt2find, bool) { ::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find); + }; #else + void setSearchText(const TCHAR * txt2find, bool isUTF8 = false) { if (!isUTF8) { ::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find); @@ -573,8 +573,9 @@ public : } else { ::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars); } + }; #endif - } + void setFindStatus(FindStatus iStatus) { static TCHAR *findStatus[] = { TEXT(""), // FSFound TEXT("Phrase not found"), //FSNotFound diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp index 9f6c4aee2..ecd65c8d0 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp @@ -175,7 +175,7 @@ bool FunctionCallTip::getCursorFunction() { valueVec.push_back(newValue); //store the current settings, so when this new function doesnt happen to be the 'real' one, we can restore everything curValue.scopeLevel = scopeLevel; - if (i > 0 && curValue.lastIdentifier == i-1) { //identifier must be right before (, else we have some expression like "( x + y() )" + if (i > 0 && curValue.lastIdentifier == int(i)-1) { //identifier must be right before (, else we have some expression like "( x + y() )" curValue.lastFunctionIdentifier = curValue.lastIdentifier; curValue.param = 0; } else { //some expression @@ -369,8 +369,10 @@ void FunctionCallTip::showCalltip() { int highlightstart = 0; int highlightend = 0; - for(size_t i = 0; i < nrParams; i++) { - if (i == _currentParam) { + for(size_t i = 0; i < nrParams; i++) + { + if (int(i) == _currentParam) + { highlightstart = lstrlen(textBuffer); highlightend = highlightstart + lstrlen(params.at(i)); } diff --git a/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp b/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp index 9d35027e1..fd5c066c2 100644 --- a/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp @@ -18,7 +18,7 @@ #include "GoToLineDlg.h" -BOOL CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { switch (message) { @@ -98,7 +98,6 @@ BOOL CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPara default : return FALSE; } - return FALSE; } diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index c1ed5d80c..83e3ca824 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -112,6 +112,28 @@ LanguageName ScintillaEditView::langNames[L_EXTERNAL+1] = { //const int MASK_GREEN = 0x00FF00; //const int MASK_BLUE = 0x0000FF; +int getNbDigits(int aNum, int base) +{ + int nbChiffre = 1; + int diviseur = base; + + for (;;) + { + int result = aNum / diviseur; + if (!result) + break; + else + { + diviseur *= base; + nbChiffre++; + } + } + if ((base == 16) && (nbChiffre % 2 != 0)) + nbChiffre += 1; + + return nbChiffre; +} + void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) { if (!_hLib) @@ -987,7 +1009,6 @@ void ScintillaEditView::defineDocType(LangType typeDoc) } execute(SCI_STYLECLEARALL); - int oldBits = execute(SCI_GETSTYLEBITSNEEDED); Style *pStyle; Style defaultIndicatorStyle; @@ -1092,7 +1113,6 @@ void ScintillaEditView::defineDocType(LangType typeDoc) pStyle = &(stylers.getStyler(iFind)); } setSpecialIndicator(*pStyle); - int caretWidth = 1; // Il faut surtout faire un test ici avant d'exécuter SCI_SETCODEPAGE // Sinon y'aura un soucis de performance! @@ -1154,8 +1174,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc) case L_NFO : { LexerStyler *pStyler = (_pParameter->getLStylerArray()).getLexerStylerByName(TEXT("nfo")); - COLORREF bg = black; - COLORREF fg = liteGrey; + Style nfoStyle; nfoStyle._styleID = STYLE_DEFAULT; nfoStyle._fontName = TEXT("MS LineDraw"); @@ -1454,7 +1473,6 @@ void ScintillaEditView::activateBuffer(BufferID buffer) char numLineStr[32]; itoa(numLines, numLineStr, 10); - int nbDigit = strlen(numLineStr); runMarkers(true, 0, true, false); return; //all done @@ -1606,9 +1624,10 @@ void ScintillaEditView::getGenericText(TCHAR *dest, int start, int end) const // "mstart" and "mend" are pointers to indexes in the read string, // which are converted to the corresponding indexes in the returned TCHAR string. + +#ifdef UNICODE void ScintillaEditView::getGenericText(TCHAR *dest, int start, int end, int *mstart, int *mend) const { -#ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); char *destA = new char[end - start + 1]; getText(destA, start, end); @@ -1616,10 +1635,14 @@ void ScintillaEditView::getGenericText(TCHAR *dest, int start, int end, int *mst const TCHAR *destW = wmc->char2wchar(destA, cp, mstart, mend); lstrcpy(dest, destW); delete [] destA; -#else - getText(dest, start, end); -#endif } +#else +void ScintillaEditView::getGenericText(TCHAR *dest, int start, int end, int *, int *) const +{ + getText(dest, start, end); +} +#endif + void ScintillaEditView::insertGenericTextFrom(int position, const TCHAR *text2insert) const { @@ -1657,10 +1680,10 @@ char * ScintillaEditView::getSelectedText(char * txt, int size, bool expand) } TCHAR * ScintillaEditView::getGenericSelectedText(TCHAR * txt, int size, bool expand) -{ +{ +#ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); unsigned int cp = execute(SCI_GETCODEPAGE); -#ifdef UNICODE char *txtA = new char[size + 1]; getSelectedText(txtA, size, expand); @@ -1712,17 +1735,20 @@ void ScintillaEditView::addGenericText(const TCHAR * text2Append) const #endif } +#ifdef UNICODE void ScintillaEditView::addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const { -#ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); unsigned int cp = execute(SCI_GETCODEPAGE); const char *text2AppendA =wmc->wchar2char(text2Append, cp, mstart, mend); execute(SCI_ADDTEXT, strlen(text2AppendA), (LPARAM)text2AppendA); -#else - execute(SCI_ADDTEXT, strlen(text2Append), (LPARAM)text2Append); -#endif } +#else +void ScintillaEditView::addGenericText(const TCHAR * text2Append, long *, long *) const +{ + execute(SCI_ADDTEXT, strlen(text2Append), (LPARAM)text2Append); +} +#endif int ScintillaEditView::replaceTarget(const TCHAR * str2replace, int fromTargetPos, int toTargetPos) const { @@ -1735,9 +1761,9 @@ int ScintillaEditView::replaceTarget(const TCHAR * str2replace, int fromTargetPo WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); unsigned int cp = execute(SCI_GETCODEPAGE); const char *str2replaceA = wmc->wchar2char(str2replace, cp); - return execute(SCI_REPLACETARGET, -1, (LPARAM)str2replaceA); + return execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)str2replaceA); #else - return execute(SCI_REPLACETARGET, -1, (LPARAM)str2replace); + return execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)str2replace); #endif } @@ -1752,9 +1778,9 @@ int ScintillaEditView::replaceTargetRegExMode(const TCHAR * re, int fromTargetPo WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); unsigned int cp = execute(SCI_GETCODEPAGE); const char *reA = wmc->wchar2char(re, cp); - return execute(SCI_REPLACETARGETRE, -1, (LPARAM)reA); + return execute(SCI_REPLACETARGETRE, (WPARAM)-1, (LPARAM)reA); #else - return execute(SCI_REPLACETARGETRE, -1, (LPARAM)re); + return execute(SCI_REPLACETARGETRE, (WPARAM)-1, (LPARAM)re); #endif } @@ -1783,9 +1809,9 @@ void ScintillaEditView::showCallTip(int startPos, const TCHAR * def) } +#ifdef UNICODE void ScintillaEditView::getLine(int lineNumber, TCHAR * line, int lineBufferLen) { -#ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); unsigned int cp = execute(SCI_GETCODEPAGE); char *lineA = new char[lineBufferLen]; @@ -1793,10 +1819,14 @@ void ScintillaEditView::getLine(int lineNumber, TCHAR * line, int lineBufferLen) const TCHAR *lineW = wmc->char2wchar(lineA, cp); lstrcpy(line, lineW); delete [] lineA; -#else - execute(SCI_GETLINE, lineNumber, (LPARAM)line); -#endif } +#else +void ScintillaEditView::getLine(int lineNumber, TCHAR * line, int) +{ + execute(SCI_GETLINE, lineNumber, (LPARAM)line); +} +#endif + void ScintillaEditView::addText(int length, const char *buf) @@ -2083,7 +2113,7 @@ void ScintillaEditView::convertSelectedTextTo(bool Case) execute(SCI_SETTARGETSTART, start); execute(SCI_SETTARGETEND, end); - execute(SCI_REPLACETARGET, -1, (LPARAM)srcStr); + execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)srcStr); } delete [] srcStr; @@ -2264,9 +2294,9 @@ void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, const TCHAR *str) WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); unsigned int cp = execute(SCI_GETCODEPAGE); const char *strA = wmc->wchar2char(str, cp); - execute(SCI_REPLACETARGET, -1, (LPARAM)strA); + execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)strA); #else - execute(SCI_REPLACETARGET, -1, (LPARAM)str); + execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)str); #endif totalDiff += diff; cmi[i].second += diff; @@ -2299,8 +2329,8 @@ void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int inc base = 2; int endNumber = initial + incr * (cmi.size() - 1); - int nbEnd = getNbChiffre(endNumber, base); - int nbInit = getNbChiffre(initial, base); + int nbEnd = getNbDigits(endNumber, base); + int nbInit = getNbDigits(initial, base); int nb = max(nbInit, nbEnd); const int stringSize = 512; @@ -2323,9 +2353,9 @@ void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int inc WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); unsigned int cp = execute(SCI_GETCODEPAGE); const char *strA = wmc->wchar2char(str, cp); - execute(SCI_REPLACETARGET, -1, (LPARAM)strA); + execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)strA); #else - execute(SCI_REPLACETARGET, -1, (LPARAM)str); + execute(SCI_REPLACETARGET, (WPARAM)-1, (LPARAM)str); #endif initial += incr; totalDiff += diff; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 5012abac7..dd362345f 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -110,27 +110,7 @@ const int MARK_HIDELINESEND = 22; // 15 - 0 are free to use for plugins -static int getNbChiffre(int aNum, int base) -{ - int nbChiffre = 1; - int diviseur = base; - - for (;;) - { - int result = aNum / diviseur; - if (!result) - break; - else - { - diviseur *= base; - nbChiffre++; - } - } - if ((base == 16) && (nbChiffre % 2 != 0)) - nbChiffre += 1; - - return nbChiffre; -}; +int getNbDigits(int aNum, int base); TCHAR * int2str(TCHAR *str, int strLen, int number, int base, int nbChiffre, bool isZeroLeading); diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index 8ae036527..adc1cd429 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -930,7 +930,7 @@ void SymbolsStyleDialog::updateDlg() Style & delim2Style = _pUserLang->_styleArray.getStyler(STYLE_DELIM2_INDEX); // the compatibility with the old xml - if (delim2Style._styleID = -1) + if (delim2Style._styleID == -1) { delim2Style._styleID = SCE_USER_DELIMITER1; delim2Style._styleDesc = SymbolsStyleDialog::_delimTag1; @@ -941,7 +941,7 @@ void SymbolsStyleDialog::updateDlg() Style & delim3Style = _pUserLang->_styleArray.getStyler(STYLE_DELIM3_INDEX); // the compatibility with the old xml - if (delim3Style._styleID = -1) + if (delim3Style._styleID == -1) { delim3Style._styleID = SCE_USER_DELIMITER2; delim3Style._styleDesc = SymbolsStyleDialog::_delimTag2; @@ -1059,7 +1059,6 @@ BOOL CALLBACK SymbolsStyleDialog::run_dlgProc(UINT Message, WPARAM wParam, LPARA default : return SharedParametersDialog::run_dlgProc(Message, wParam, lParam); } - return FALSE; } int SymbolsStyleDialog::getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.h b/PowerEditor/src/ScitillaComponent/UserDefineDialog.h index ba4cef97d..57c8c7a99 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.h +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.h @@ -277,7 +277,7 @@ public : void updateDlg(); protected : BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); - void setKeywords2List(int ctrlID) {}; + void setKeywords2List(int) {}; int getGroupIndexFromCombo(int ctrlID, bool & isFontSize) const { switch (ctrlID) { @@ -426,10 +426,10 @@ private : void enableLangAndControlsBy(int index); protected : - void setKeywords2List(int ctrlID){}; - int getGroupIndexFromCombo(int ctrlID, bool & isFontSize) const {return -1;}; - int getStylerIndexFromCP(HWND hWnd, bool & isFG, ColourPicker **ppCP) const {return -1;}; - int getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const {return -1;}; + void setKeywords2List(int){}; + int getGroupIndexFromCombo(int, bool &) const {return -1;}; + int getStylerIndexFromCP(HWND, bool &, ColourPicker **) const {return -1;}; + int getGroupeIndexFromCheck(int, int &) const {return -1;}; void updateDlg(); }; @@ -452,7 +452,7 @@ public : virtual void destroy() {}; protected : - BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) + BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { switch (Message) @@ -490,8 +490,6 @@ protected : default : return FALSE; } - - return FALSE; } private : diff --git a/PowerEditor/src/ScitillaComponent/columnEditor.cpp b/PowerEditor/src/ScitillaComponent/columnEditor.cpp index e18999884..06efb7693 100644 --- a/PowerEditor/src/ScitillaComponent/columnEditor.cpp +++ b/PowerEditor/src/ScitillaComponent/columnEditor.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "columnEditor.h" -BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { switch (message) { @@ -152,8 +152,8 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l int nbLine = endLine - cursorLine + 1; int endNumber = initialNumber + increaseNumber * (nbLine - 1); - int nbEnd = getNbChiffre(endNumber, base); - int nbInit = getNbChiffre(initialNumber, base); + int nbEnd = getNbDigits(endNumber, base); + int nbInit = getNbDigits(initialNumber, base); int nb = max(nbInit, nbEnd); diff --git a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp index 9a4198cad..26ed3da27 100644 --- a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp @@ -171,7 +171,7 @@ bool XmlMatchedTagsHighlighter::getMatchedTagPos(int searchStart, int searchEnd, XmlMatchedTagsPos pos; if (direction == search2Right && getTagCategory(pos,ltTag+1) == inSingleTag) { - while (true) + for(;;) { ltTag = getFirstTokenPosFrom(ltTag, e, oppositeTag2find, oppositeTagPos); @@ -201,7 +201,7 @@ bool XmlMatchedTagsHighlighter::getMatchedTagPos(int searchStart, int searchEnd, if (isInList(ltTag, oppositeTagFound)) { - while (true) + for(;;) { ltTag = getFirstTokenPosFrom(ltTag, e, oppositeTag2find, oppositeTagPos); if (ltTag == -1) diff --git a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp index 1a13817d9..0e2007f84 100644 --- a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp +++ b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp @@ -174,7 +174,7 @@ const char* TiXmlBaseA::SkipWhiteSpace( const char* p ) int c = in->peek(); if ( !IsWhiteSpace( c ) ) return true; - *tag += in->get(); + *tag += (char)in->get(); } } @@ -187,7 +187,7 @@ const char* TiXmlBaseA::SkipWhiteSpace( const char* p ) return true; in->get(); - *tag += c; + *tag += (char)c; } return false; } @@ -238,19 +238,23 @@ const char* TiXmlBaseA::GetEntity( const char* p, char* value ) if ( *(p+4) == ';' ) { // Short, one value entity. - if ( isalpha( *(p+3) ) ) *value += ( tolower( *(p+3) ) - 'a' + 10 ); - else *value += ( *(p+3) - '0' ); + if ( isalpha( *(p+3) ) ) + *value += ( (char)tolower( *(p+3) ) - 'a' + 10 ); + else + *value += ( (char)*(p+3) - '0' ); return p+5; } else { // two value entity - if ( isalpha( *(p+3) ) ) *value += ( tolower( *(p+3) ) - 'a' + 10 ) * 16; - else *value += ( *(p+3) - '0' ) * 16; + if ( isalpha( *(p+3) ) ) *value += ((char) tolower( *(p+3) ) - 'a' + 10 ) * 16; + else *value += ((char) *(p+3) - '0' ) * 16; - if ( isalpha( *(p+4) ) ) *value += ( tolower( *(p+4) ) - 'a' + 10 ); - else *value += ( *(p+4) - '0' ); + if ( isalpha( *(p+4) ) ) + *value += ((char) tolower( *(p+4) ) - 'a' + 10 ); + else + *value += ((char) *(p+4) - '0' ); return p+6; } @@ -650,7 +654,7 @@ void TiXmlElementA::StreamIn (TIXMLA_ISTREAM * in, TIXMLA_STRING * tag) if ( c == '>' ) break; - *tag += c; + *tag += (char)c; in->get(); if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) ) @@ -666,7 +670,7 @@ void TiXmlElementA::StreamIn (TIXMLA_ISTREAM * in, TIXMLA_STRING * tag) { int c = in->get(); assert( c == '>' ); - *tag += c; + *tag += (char)c; // We are done, once we've found our closing tag. return; @@ -875,7 +879,7 @@ void TiXmlUnknownA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += c; + (*tag) += (char)c; if ( c == '>' ) { @@ -927,7 +931,7 @@ void TiXmlCommentA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += c; + (*tag) += (char)c; if ( c == '>' && tag->at( tag->length() - 2 ) == '-' @@ -1046,7 +1050,7 @@ void TiXmlTextA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag ) if ( c == '<' ) return; - (*tag) += c; + (*tag) += (char)c; in->get(); } } @@ -1076,7 +1080,7 @@ void TiXmlDeclarationA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += c; + (*tag) += (char)c; if ( c == '>' ) { diff --git a/PowerEditor/src/TinyXml/tinyxmlparser.cpp b/PowerEditor/src/TinyXml/tinyxmlparser.cpp index d177d057e..f603353f1 100644 --- a/PowerEditor/src/TinyXml/tinyxmlparser.cpp +++ b/PowerEditor/src/TinyXml/tinyxmlparser.cpp @@ -174,7 +174,7 @@ const TCHAR* TiXmlBase::SkipWhiteSpace( const TCHAR* p ) int c = in->peek(); if ( !IsWhiteSpace( c ) ) return true; - *tag += in->get(); + *tag += (TCHAR)in->get(); } } @@ -187,7 +187,7 @@ const TCHAR* TiXmlBase::SkipWhiteSpace( const TCHAR* p ) return true; in->get(); - *tag += c; + *tag += (TCHAR)c; } return false; } @@ -234,7 +234,7 @@ const TCHAR* TiXmlBase::GetEntity( const TCHAR* p, TCHAR* value ) int val; if (generic_sscanf(p+3, TEXT("%x"), &val) == 1) { - *value = val; + *value = (TCHAR)val; return end + 1; } } @@ -634,7 +634,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) if ( c == '>' ) break; - *tag += c; + *tag += (TCHAR)c; in->get(); if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) ) @@ -650,7 +650,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) { int c = in->get(); assert( c == '>' ); - *tag += c; + *tag += (TCHAR)c; // We are done, once we've found our closing tag. return; @@ -859,7 +859,7 @@ void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += c; + (*tag) += (TCHAR)c; if ( c == '>' ) { @@ -911,7 +911,7 @@ void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += c; + (*tag) += (TCHAR)c; if ( c == '>' && tag->at( tag->length() - 2 ) == '-' @@ -1030,7 +1030,7 @@ void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) if ( c == '<' ) return; - (*tag) += c; + (*tag) += (TCHAR)c; in->get(); } } @@ -1060,7 +1060,7 @@ void TiXmlDeclaration::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += c; + (*tag) += (TCHAR)c; if ( c == '>' ) { diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp index 623c60011..02a2a6968 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp @@ -67,7 +67,7 @@ void ColourPicker::drawBackground(HDC hDC) void ColourPicker::drawForeground(HDC hDC) { RECT rc; - HBRUSH hbrush; + HBRUSH hbrush = NULL; if(!hDC || _isEnabled) return; diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index a0387d962..7cff46093 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -116,7 +116,7 @@ void DockingCont::doDialog(bool willBeShown, bool isFloating) } -tTbData* DockingCont::createToolbar(tTbData data, Window **ppWin) +tTbData* DockingCont::createToolbar(tTbData data) { tTbData *pTbData = new tTbData; @@ -147,8 +147,6 @@ tTbData* DockingCont::createToolbar(tTbData data, Window **ppWin) void DockingCont::removeToolbar(tTbData TbData) { - INT iItemCnt = 0; - // remove from list for (size_t iTb = 0; iTb < _vTbData.size(); iTb++) { @@ -479,7 +477,6 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct) ::FillRect(hDc, &rc, bgbrush); // draw grid lines - HPEN hOldPen = (HPEN)::SelectObject(hDc, hPen); MoveToEx(hDc, rc.left , rc.top , NULL); LineTo (hDc, rc.right, rc.top ); @@ -522,8 +519,6 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct) ::FillRect(hDc, &rc, bgbrush); // draw grid lines - HPEN hOldPen = (HPEN)::SelectObject(hDc, hPen); - MoveToEx(hDc, rc.left , rc.top , NULL); LineTo (hDc, rc.right, rc.top ); LineTo (hDc, rc.right, rc.bottom ); @@ -1162,7 +1157,7 @@ INT DockingCont::hideToolbar(tTbData *pTbData, BOOL hideClient) tcItem.mask = TCIF_PARAM; - if (iItem == iItemCnt) + if ((unsigned int)iItem == iItemCnt) { iItem--; } @@ -1285,7 +1280,7 @@ void DockingCont::SelectTab(INT iTab) ::ShowWindow(((tTbData*)tcItem.lParam)->hClient, SW_SHOW); ::SetFocus(((tTbData*)tcItem.lParam)->hClient); - if (iTab != _prevItem) + if ((unsigned int)iTab != _prevItem) { // hide previous dialog ::SendMessage(_hContTab, TCM_GETITEM, _prevItem, (LPARAM)&tcItem); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h index 42b7e6c56..347d31e28 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h @@ -71,7 +71,7 @@ public: return _hSelf; }; - tTbData* createToolbar(tTbData data, Window **ppWin); + tTbData* createToolbar(tTbData data); void removeToolbar(tTbData data); tTbData* findToolbarByWnd(HWND hClient); tTbData* findToolbarByName(TCHAR* pszName); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h index 93d1b1259..6339c29d6 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h @@ -74,7 +74,7 @@ public: }; protected : - virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) + virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM, LPARAM lParam) { switch (message) { diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index e4b0495bf..8f2b505d3 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -611,7 +611,7 @@ void DockingManager::createDockableDlg(tTbData data, int iCont, bool isVisible) } /* attach toolbar */ - _vContainer[iCont]->createToolbar(data, _ppMainWindow); + _vContainer[iCont]->createToolbar(data); /* notify client app */ if (iCont < DOCKCONT_MAX) @@ -658,7 +658,7 @@ DockingCont* DockingManager::toggleActiveTb(DockingCont* pContSrc, UINT message, if ((bNew == FALSE) || (!pContSrc->isFloating())) TbData.iPrevCont = iContSrc; - pContTgt->createToolbar(TbData, _ppMainWindow); + pContTgt->createToolbar(TbData); _vContainer.push_back(pContTgt); } else @@ -670,7 +670,7 @@ DockingCont* DockingManager::toggleActiveTb(DockingCont* pContSrc, UINT message, if ((pContSrc->isFloating()) != (pContTgt->isFloating())) TbData.iPrevCont = iContSrc; - pContTgt->createToolbar(TbData, _ppMainWindow); + pContTgt->createToolbar(TbData); } } else @@ -680,7 +680,7 @@ DockingCont* DockingManager::toggleActiveTb(DockingCont* pContSrc, UINT message, /* change data normaly */ TbData.iPrevCont = iContSrc; - pContTgt->createToolbar(TbData, _ppMainWindow); + pContTgt->createToolbar(TbData); } /* notify client app */ @@ -725,7 +725,7 @@ DockingCont* DockingManager::toggleVisTb(DockingCont* pContSrc, UINT message, LP pContTgt->doDialog(true, true); TbData.iPrevCont = iContSrc; - pContTgt->createToolbar(TbData, _ppMainWindow); + pContTgt->createToolbar(TbData); _vContainer.push_back(pContTgt); /* now container exists */ @@ -738,7 +738,7 @@ DockingCont* DockingManager::toggleVisTb(DockingCont* pContSrc, UINT message, LP pContTgt = _vContainer[iContPrev]; TbData.iPrevCont = iContSrc; - pContTgt->createToolbar(TbData, _ppMainWindow); + pContTgt->createToolbar(TbData); } SendNotify(TbData.hClient, MAKELONG(message==DMM_DOCK?DMN_DOCK:DMN_FLOAT, GetContainer(pContTgt))); @@ -796,7 +796,7 @@ void DockingManager::toggleTb(DockingCont* pContSrc, DockingCont* pContTgt, tTbD SendNotify(TbData.hClient, MAKELONG(DMN_FLOAT, iContTgt)); /* create new toolbar */ - pContTgt->createToolbar(TbData, _ppMainWindow); + pContTgt->createToolbar(TbData); /* remove toolbar from source */ _vContainer[iContSrc]->removeToolbar(TbData); diff --git a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp index 59e737d1b..32d57eaa4 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp @@ -107,10 +107,6 @@ Gripper::Gripper() void Gripper::startGrip(DockingCont* pCont, DockingManager* pDockMgr, void* pRes) { - MSG msg = {0}; - BOOL bIsRel = FALSE; - HWND hWnd = NULL; - _pDockMgr = pDockMgr; _pCont = pCont; _pRes = pRes; @@ -216,7 +212,6 @@ LRESULT Gripper::runProc(UINT message, WPARAM wParam, LPARAM lParam) { POINT pt = {0,0}; POINT ptBuf = {0,0}; - RECT rc = {0}; ::GetCursorPos(&pt); getMousePoints(&pt, &ptBuf); @@ -284,7 +279,7 @@ void Gripper::create() ::GetCursorPos(&pt); // get tab informations - initTabInformation(pt); + initTabInformation(); if (_pCont->isFloating() == true) { @@ -434,11 +429,10 @@ void Gripper::doTabReordering(POINT pt) if (::PtInRect(&rc, pt) == TRUE) { TCHITTESTINFO info = {0}; - TCITEM tcItem = {0}; if (_hTab == NULL) { - initTabInformation(pt); + initTabInformation(); hTabOld = _hTab; iItemOld = _iItem; } @@ -761,7 +755,7 @@ DockingCont* Gripper::workHitTest(POINT pt, RECT *rc) } -void Gripper::initTabInformation(POINT pt) +void Gripper::initTabInformation() { /* for tab reordering */ diff --git a/PowerEditor/src/WinControls/DockingWnd/Gripper.h b/PowerEditor/src/WinControls/DockingWnd/Gripper.h index 51d71810f..3a6923f09 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Gripper.h +++ b/PowerEditor/src/WinControls/DockingWnd/Gripper.h @@ -75,7 +75,7 @@ protected : DockingCont* contHitTest(POINT pt); DockingCont* workHitTest(POINT pt, RECT *rcCont = NULL); - void initTabInformation(POINT pt); + void initTabInformation(); void CalcRectToScreen(HWND hWnd, RECT *rc) { ClientRectToScreenRect(hWnd, rc); diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp index b238a791d..c09fd0f78 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp @@ -1168,7 +1168,7 @@ void GetVisibleColumns(HWND hWnd,int SI) SetScrollRange(hWnd,SB_HORZ,1,value,TRUE); } -int GetNthVisibleColumn(HWND hWnd,int SI,int n) +int GetNthVisibleColumn(HWND, int SI, int n) { int j,count; int value; @@ -2650,7 +2650,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) NotifyEditBegin(hWnd,SelfIndex); } BGHS[SelfIndex].EDITING = TRUE; - tstring[0]=wParam; + tstring[0]= (TCHAR)wParam; tstring[1]=0x00; DisplayEditString(hWnd,SelfIndex,tstring); break; @@ -3107,12 +3107,11 @@ int AddGrid( UINT menuid) { //if grid doesn't exist, add it. otherwise return existing index + MAX_GRIDS //if trying to add more than MAX_GRIDS, return -1; - int empty_space; - int returnvalue; + int empty_space = -1; + int returnvalue = 0; int j; BOOL MATCH; MATCH=FALSE; - empty_space = -1; for(j=0;j_pAccelArray[row-1].cmd; + DWORD cmdID = 0;// = _pAccel->_pAccelArray[row-1].cmd; // Menu data - size_t posBase; - size_t nbElem; - HMENU hMenu; + size_t posBase = 0; + size_t nbElem = 0; + HMENU hMenu = NULL; - switch(_currentState) { + switch(_currentState) + { case STATE_MENU: case STATE_PLUGIN: - case STATE_SCINTILLA: { + case STATE_SCINTILLA: + { return FALSE; //this is bad - break; } - case STATE_MACRO: { + break; + } + case STATE_MACRO: + { vector & theMacros = nppParam->getMacroList(); vector::iterator it = theMacros.begin(); cmdID = theMacros[shortcutIndex].getID(); @@ -317,8 +321,10 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP theMacros[i] = ms; } //::SendMessage(_hParent, NPPM_INTERNAL_MACROLIST_MODIFIED, 0, 0); - break; } - case STATE_USER: { + break; + } + case STATE_USER: + { vector & theUserCmds = nppParam->getUserCommandList(); vector::iterator it = theUserCmds.begin(); cmdID = theUserCmds[shortcutIndex].getID(); @@ -337,15 +343,19 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP } //::SendMessage(_hParent, NPPM_INTERNAL_USERCMDLIST_MODIFIED, 0, 0); - break; } + break; + } } // remove from menu ::RemoveMenu(hMenu, cmdID, MF_BYCOMMAND); cmdID++; - if (nbElem == 0) { + if (nbElem == 0) + { ::RemoveMenu(hMenu, posBase-1, MF_BYPOSITION); //remove separator - } else { + } + else + { for (size_t i = shortcutIndex ; i < nbElem ; i++) //lower the IDs of the remaining menu items so there are no gaps { const int commandSize = 64; diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 33edc2a8a..9572e8d74 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -367,10 +367,9 @@ UINT_PTR CALLBACK FileDialog::OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, L return pFileDialog->run(hWnd, uMsg, wParam, lParam); } } - return FALSE; } -BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM, LPARAM lParam) { switch (uMsg) { @@ -407,3 +406,52 @@ BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam return FALSE; } } + +void goToCenter(HWND hwnd) +{ + RECT rc; + HWND hParent = ::GetParent(hwnd); + ::GetClientRect(hParent, &rc); + + //If window coordinates are all zero(ie,window is minimised),then assign desktop as the parent window. + if(rc.left == 0 && rc.right == 0 && rc.top == 0 && rc.bottom == 0) + { + //hParent = ::GetDesktopWindow(); + ::ShowWindow(hParent, SW_SHOWNORMAL); + ::GetClientRect(hParent,&rc); + } + + POINT center; + center.x = rc.left + (rc.right - rc.left)/2; + center.y = rc.top + (rc.bottom - rc.top)/2; + ::ClientToScreen(hParent, ¢er); + + RECT _rc; + ::GetWindowRect(hwnd, &_rc); + int x = center.x - (_rc.right - _rc.left)/2; + int y = center.y - (_rc.bottom - _rc.top)/2; + + ::SetWindowPos(hwnd, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW); +} + +generic_string changeExt(generic_string fn, generic_string ext) +{ + if (ext == TEXT("")) + return fn; + + generic_string fnExt = fn; + + int index = fnExt.find_last_of(TEXT(".")); + generic_string extension = TEXT("."); + extension += ext; + if (size_t(index) == generic_string::npos) + { + fnExt += extension; + } + else + { + int len = (extension.length() > fnExt.length() - index + 1)?extension.length():fnExt.length() - index + 1; + fnExt.replace(index, len, extension); + } + return fnExt; +} diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h index abe1a3ff2..2a6187a6a 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h @@ -62,54 +62,9 @@ struct OPENFILENAMENPP { }; -static generic_string changeExt(generic_string fn, generic_string ext) -{ - if (ext == TEXT("")) - return fn; +generic_string changeExt(generic_string fn, generic_string ext); +void goToCenter(HWND hwnd); - generic_string fnExt = fn; - - int index = fnExt.find_last_of(TEXT(".")); - generic_string extension = TEXT("."); - extension += ext; - if (index == generic_string::npos) - { - fnExt += extension; - } - else - { - int len = (extension.length() > fnExt.length() - index + 1)?extension.length():fnExt.length() - index + 1; - fnExt.replace(index, len, extension); - } - return fnExt; -}; - -static void goToCenter(HWND hwnd) -{ - RECT rc; - HWND hParent = ::GetParent(hwnd); - ::GetClientRect(hParent, &rc); - - //If window coordinates are all zero(ie,window is minimised),then assign desktop as the parent window. - if(rc.left == 0 && rc.right == 0 && rc.top == 0 && rc.bottom == 0) - { - //hParent = ::GetDesktopWindow(); - ::ShowWindow(hParent, SW_SHOWNORMAL); - ::GetClientRect(hParent,&rc); - } - - POINT center; - center.x = rc.left + (rc.right - rc.left)/2; - center.y = rc.top + (rc.bottom - rc.top)/2; - ::ClientToScreen(hParent, ¢er); - - RECT _rc; - ::GetWindowRect(hwnd, &_rc); - int x = center.x - (_rc.right - _rc.left)/2; - int y = center.y - (_rc.bottom - _rc.top)/2; - - ::SetWindowPos(hwnd, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW); -}; class FileDialog { diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 347b7bf70..29ca2d1d2 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -125,7 +125,7 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa return FALSE; } -BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); switch (Message) @@ -392,7 +392,7 @@ void MarginsDlg::changePanelTo(int index) } -BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); @@ -586,7 +586,7 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam return FALSE; } -BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); @@ -856,7 +856,7 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara return FALSE; } -BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); @@ -1182,7 +1182,7 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara pDestLst->push_back(lmi); ::SendDlgItemMessage(_hSelf, list2Add, LB_SETCURSEL, iAdd, 0); - ::SendDlgItemMessage(_hSelf, list2Remove, LB_SETCURSEL, -1, 0); + ::SendDlgItemMessage(_hSelf, list2Remove, LB_SETCURSEL, (WPARAM)-1, 0); ::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE); ::EnableWindow(::GetDlgItem(_hSelf, idButton2Disable), FALSE); @@ -1228,7 +1228,7 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara return FALSE; } -BOOL CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); @@ -1348,7 +1348,7 @@ void trim(generic_string & str) else str.erase(str.begin(), str.end()); }; -BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); @@ -1391,9 +1391,9 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM ::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTNAME, CB_SETCURSEL, index, 0); wsprintf(intStr, TEXT("%d"), nppGUI._printSettings._headerFontSize); - ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTSIZE, CB_SELECTSTRING, -1, (LPARAM)intStr); + ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTSIZE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)intStr); wsprintf(intStr, TEXT("%d"), nppGUI._printSettings._footerFontSize); - ::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTSIZE, CB_SELECTSTRING, -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_HITALIC, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE, 0); @@ -1478,8 +1478,8 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM //_colourHooker.setColour(RGB(0, 0, 0xFF)); ::SendDlgItemMessage(_hSelf, IDC_VIEWPANEL_STATIC, WM_SETTEXT, 0, (LPARAM)str); - int focusedEditStatic; - int groupStatic; + int focusedEditStatic = 0; + int groupStatic = 0; switch (_focusedEditCtrl) { case IDC_EDIT_HLEFT : focusedEditStatic = IDC_HL_STATIC; groupStatic = IDC_HGB_STATIC; break; @@ -1593,7 +1593,7 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM return FALSE; } -BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index e04a08d16..8279d0d55 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -196,7 +196,7 @@ HINSTANCE Command::run(HWND hWnd) return res; } -BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { switch (message) { diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index d91e2b4de..35957efe0 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -103,29 +103,33 @@ void TabBar::getCurrentTitle(TCHAR *title, int titleLen) ::SendMessage(_hSelf, TCM_GETITEM, getCurrentTabIndex(), reinterpret_cast(&tci)); } -void TabBar::deletItemAt(int index) { - if ((index == _nbItem-1)) { - //prevent invisible tabs. If last visible tab is removed, other tabs are put in view but not redrawn - //Therefore, scroll one tab to the left if only one tab visible - if (_nbItem > 1) { - RECT itemRect; - ::SendMessage(_hSelf, TCM_GETITEMRECT, (WPARAM)index, (LPARAM)&itemRect); - if (itemRect.left < 5) { //if last visible tab, scroll left once (no more than 5px away should be safe, usually 2px depending on the drawing) - //To scroll the tab control to the left, use the WM_HSCROLL notification - //Doesn't really seem to be documented anywhere, but the values do match the message parameters - //The up/down control really is just some sort of scrollbar - //There seems to be no negative effect on any internal state of the tab control or the up/down control - int wParam = MAKEWPARAM(SB_THUMBPOSITION, index - 1); - ::SendMessage(_hSelf, WM_HSCROLL, wParam, 0); +void TabBar::deletItemAt(size_t index) +{ + if ((index == _nbItem-1)) + { + //prevent invisible tabs. If last visible tab is removed, other tabs are put in view but not redrawn + //Therefore, scroll one tab to the left if only one tab visible + if (_nbItem > 1) + { + RECT itemRect; + ::SendMessage(_hSelf, TCM_GETITEMRECT, (WPARAM)index, (LPARAM)&itemRect); + if (itemRect.left < 5) //if last visible tab, scroll left once (no more than 5px away should be safe, usually 2px depending on the drawing) + { + //To scroll the tab control to the left, use the WM_HSCROLL notification + //Doesn't really seem to be documented anywhere, but the values do match the message parameters + //The up/down control really is just some sort of scrollbar + //There seems to be no negative effect on any internal state of the tab control or the up/down control + int wParam = MAKEWPARAM(SB_THUMBPOSITION, index - 1); + ::SendMessage(_hSelf, WM_HSCROLL, wParam, 0); - wParam = MAKEWPARAM(SB_ENDSCROLL, index - 1); - ::SendMessage(_hSelf, WM_HSCROLL, wParam, 0); - } + wParam = MAKEWPARAM(SB_ENDSCROLL, index - 1); + ::SendMessage(_hSelf, WM_HSCROLL, wParam, 0); } } - ::SendMessage(_hSelf, TCM_DELETEITEM, index, 0); - _nbItem--; - }; + } + ::SendMessage(_hSelf, TCM_DELETEITEM, index, 0); + _nbItem--; +} void TabBar::reSizeTo(RECT & rc2Ajust) { diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.h b/PowerEditor/src/WinControls/TabBar/TabBar.h index a53759cd6..80528e593 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.h +++ b/PowerEditor/src/WinControls/TabBar/TabBar.h @@ -93,7 +93,7 @@ public: int getCurrentTabIndex() const { return ::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0); }; - void deletItemAt(int index); + void deletItemAt(size_t index); void deletAllItem() { ::SendMessage(_hSelf, TCM_DELETEALLITEMS, 0, 0); diff --git a/PowerEditor/src/WinControls/TaskList/TaskList.cpp b/PowerEditor/src/WinControls/TaskList/TaskList.cpp index 830628c29..574d733b4 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskList.cpp +++ b/PowerEditor/src/WinControls/TaskList/TaskList.cpp @@ -240,6 +240,5 @@ LRESULT TaskList::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) default : return ::CallWindowProc(_defaultProc, hwnd, Message, wParam, lParam); } - return FALSE; } diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp index 9d598947b..f928927a9 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp @@ -62,7 +62,7 @@ bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, _pTBB[i].iBitmap = (cmd != 0?bmpIndex:0); _pTBB[i].idCommand = cmd; _pTBB[i].fsState = TBSTATE_ENABLED; - _pTBB[i].fsStyle = style; + _pTBB[i].fsStyle = (BYTE)style; _pTBB[i].dwData = 0; _pTBB[i].iString = 0; } diff --git a/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.cpp index ff3583099..c2b9d8058 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.cpp @@ -16,7 +16,7 @@ BOOL SizeableDlg::onInitDialog() return TRUE; } -void SizeableDlg::onSize(UINT nType, int cx, int cy) +void SizeableDlg::onSize(UINT, int cx, int cy) { _winMgr.CalcLayout(cx,cy,_hSelf); _winMgr.SetWindowPositions(_hSelf); @@ -27,7 +27,7 @@ void SizeableDlg::onGetMinMaxInfo(MINMAXINFO* lpMMI) _winMgr.GetMinMaxInfo(_hSelf, lpMMI); } -LRESULT SizeableDlg::onWinMgr(WPARAM wp, LPARAM lp) +LRESULT SizeableDlg::onWinMgr(WPARAM, LPARAM) { return 0; } diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp index 88cc623cd..90bb85e40 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp @@ -60,7 +60,8 @@ void CWinMgr::GetWindowPositions(HWND hWnd) HWND HChild = GetDlgItem(hWnd, wrc->GetID()); if (HChild) { GetWindowRect(HChild, &wrc->GetRect()); - ::ScreenToClient(hWnd, &RectToPoint(wrc->GetRect())); + POINT p = RectToPoint(wrc->GetRect()); + ::ScreenToClient(hWnd, &p); } } } @@ -117,11 +118,11 @@ int CWinMgr::CountWindows() ////////////////// // Find the entry for a given control ID // -WINRECT* CWinMgr::FindRect(UINT nID) +WINRECT* CWinMgr::FindRect(int nID) { assert(m_map); for (WINRECT* w=m_map; !w->IsEnd(); w++) { - if (w->GetID()==nID) + if (w->GetID()==(UINT)nID) return w; } return NULL; diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h index 30421805c..68c15e334 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h @@ -113,7 +113,7 @@ protected: LONG param; // arg depends on type public: - WINRECT(WORD f, UINT id, LONG p); + WINRECT(WORD f, int id, LONG p); static WINRECT* InitMap(WINRECT* map, WINRECT* parent=NULL); @@ -271,7 +271,7 @@ public: void SetRect(UINT nID, const RECT& rc) { FindRect(nID)->SetRect(rc); } // get WINRECT corresponding to ID - WINRECT* FindRect(UINT nID); + WINRECT* FindRect(int nID); // Calculate MINMAXINFO void GetMinMaxInfo(HWND hWnd, MINMAXINFO* lpMMI); diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinRect.cpp b/PowerEditor/src/WinControls/WindowsDlg/WinRect.cpp index 2ae1cbf67..6ca95b165 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinRect.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WinRect.cpp @@ -13,11 +13,11 @@ ////////////////// // Construct from args // -WINRECT::WINRECT(WORD f, UINT id, LONG p) +WINRECT::WINRECT(WORD f, int id, LONG p) { memset(this, 0, sizeof(WINRECT)); flags = f; - nID = id; + nID = (UINT)id; param = p; } diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index 2eea8146f..199f3aad1 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -598,7 +598,7 @@ void WindowsDlg::doSave() nmdlg.code = WDN_NOTIFY; nmdlg.nItems = ListView_GetSelectedCount(_hList); nmdlg.Items = new UINT[nmdlg.nItems]; - for (UINT i=-1, j=0;;++j) { + for (int i=-1, j=0;;++j) { i = ListView_GetNextItem(_hList, i, LVNI_SELECTED); if (i == -1) break; nmdlg.Items[j] = _idxMap[i]; @@ -651,7 +651,7 @@ void WindowsDlg::doClose() nmdlg.Items = new UINT[nmdlg.nItems]; vector key; key.resize(n, 0x7fffffff); - for(UINT i=-1, j=0;; ++j) { + for(int i=-1, j=0;; ++j) { i = ListView_GetNextItem(_hList, i, LVNI_SELECTED); if (i == -1) break; ListView_SetItemState(_hList, i, 0, LVIS_SELECTED); // deselect @@ -678,12 +678,12 @@ void WindowsDlg::doClose() } delete[] nmdlg.Items; - if (_pTab->nbItem() != _idxMap.size()) + if (_pTab->nbItem() != (int)_idxMap.size()) doRefresh(true); else { // select first previously selected item (or last one if only the last one was removed) - if (index == _idxMap.size()) index --; + if (index == (int)_idxMap.size()) index --; if (index >= 0) { ListView_SetItemState(_hList, index, LVIS_SELECTED, LVIS_SELECTED); @@ -710,7 +710,7 @@ void WindowsDlg::doSortToTabs() nmdlg.Items = new UINT[nmdlg.nItems]; vector key; key.resize(n, 0x7fffffff); - for(UINT i=-1, j=0;; ++j) { + for(int i=-1, j=0;; ++j) { i = ListView_GetNextItem(_hList, i, LVNI_ALL); if (i == -1) break; nmdlg.Items[j] = _idxMap[i]; diff --git a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.cpp b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.cpp index 4cf0bad38..ebc9b20af 100644 --- a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.cpp +++ b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.cpp @@ -23,7 +23,7 @@ //#include "constant.h" -BOOL CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { switch (message) { diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index 1b1041925..d22749c50 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -341,7 +341,7 @@ void getNameStrFromCmd(DWORD cmd, generic_string & str) return; } -BOOL CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { switch (Message) { @@ -434,7 +434,6 @@ BOOL CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) default : return FALSE; } - return FALSE; } // return true if one of CommandShortcuts is deleted. Otherwise false. @@ -636,7 +635,6 @@ void ScintillaAccelerator::updateKeys() void ScintillaAccelerator::updateMenuItemByID(ScintillaKeyMap skm, int id) { - NppParameters *pNppParam = NppParameters::getInstance(); const int commandSize = 64; TCHAR cmdName[commandSize]; ::GetMenuString(_hAccelMenu, id, cmdName, commandSize, MF_BYCOMMAND); @@ -704,7 +702,7 @@ void ScintillaKeyMap::updateListItem(int index) { ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_DELETESTRING, index+1, 0); } -BOOL CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { switch (Message) @@ -712,7 +710,6 @@ BOOL CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l case WM_INITDIALOG : { ::SetDlgItemText(_hSelf, IDC_NAME_EDIT, _name); - int textlen = (int)::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, WM_GETTEXTLENGTH, 0, 0); _keyCombo = _keyCombos[0]; for (size_t i = 0 ; i < nrKeys ; i++) @@ -769,7 +766,7 @@ BOOL CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l int res = addKeyCombo(_keyCombo); if (res > -1) { if (res == oldsize) { - ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_INSERTSTRING, -1, (LPARAM)toString(res).c_str()); + ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)toString(res).c_str()); }else { //update current generic_string, can happen if it was disabled updateListItem(res); } @@ -785,7 +782,7 @@ BOOL CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0); removeKeyComboByIndex(i); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_DELETESTRING, i, 0); - if (i == size) + if (i == (int)size) i = size - 1; ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, i, 0); showCurrentSettings(); diff --git a/PowerEditor/src/lastRecentFileList.cpp b/PowerEditor/src/lastRecentFileList.cpp index 7098c1137..89c947da9 100644 --- a/PowerEditor/src/lastRecentFileList.cpp +++ b/PowerEditor/src/lastRecentFileList.cpp @@ -139,12 +139,14 @@ std::generic_string & LastRecentFileList::getItem(int id) { return _lrfl.at(i)._name; //if not found, return first }; -std::generic_string & LastRecentFileList::getIndex(int index) { +std::generic_string & LastRecentFileList::getIndex(int index) +{ return _lrfl.at(index)._name; //if not found, return first -}; +} -void LastRecentFileList::setUserMaxNbLRF(int size) { +void LastRecentFileList::setUserMaxNbLRF(int size) +{ _userMax = size; if (_size > _userMax) { //start popping items int toPop = _size-_userMax; @@ -158,11 +160,12 @@ void LastRecentFileList::setUserMaxNbLRF(int size) { updateMenu(); _size = _userMax; } -}; +} -void LastRecentFileList::saveLRFL() { +void LastRecentFileList::saveLRFL() +{ NppParameters *pNppParams = NppParameters::getInstance(); if (pNppParams->writeNbHistoryFile(_userMax)) { @@ -171,21 +174,23 @@ void LastRecentFileList::saveLRFL() { pNppParams->writeHistory(_lrfl.at(i)._name.c_str()); } } -}; +} - -int LastRecentFileList::find(const TCHAR *fn) { - int i = 0; - for(int i = 0; i < _size; i++) { - if (!lstrcmpi(_lrfl.at(i)._name.c_str(), fn)) { +int LastRecentFileList::find(const TCHAR *fn) +{ + for(int i = 0; i < _size; i++) + { + if (!lstrcmpi(_lrfl.at(i)._name.c_str(), fn)) + { return i; } } return -1; -}; +} -int LastRecentFileList::popFirstAvailableID() { +int LastRecentFileList::popFirstAvailableID() +{ for (int i = 0 ; i < NB_MAX_LRF_FILE ; i++) { if (_idFreeArray[i]) @@ -195,9 +200,10 @@ int LastRecentFileList::popFirstAvailableID() { } } return 0; -}; +} -void LastRecentFileList::setAvailable(int id) { +void LastRecentFileList::setAvailable(int id) +{ int index = id - _idBase; _idFreeArray[index] = true; -}; +} diff --git a/PowerEditor/src/lesDlgs.h b/PowerEditor/src/lesDlgs.h index 8eb4d9336..e8c46633e 100644 --- a/PowerEditor/src/lesDlgs.h +++ b/PowerEditor/src/lesDlgs.h @@ -77,7 +77,7 @@ public : virtual void destroy() {}; protected : - BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { + BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM) { switch (Message) { @@ -116,8 +116,6 @@ protected : default : return FALSE; } - - return FALSE; }; private : diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 829a56f3b..e70c9f086 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -40,7 +40,7 @@ void parseCommandLine(TCHAR * commandLine, ParamVector & paramVector) { //params.erase(params.begin()); //remove the first element, since thats the path the the executable (GetCommandLine does that) TCHAR stopChar = TEXT(' '); - int i = 0; + if (commandLine[0] == TEXT('\"')) { stopChar = TEXT('\"'); commandLine++; @@ -161,7 +161,7 @@ const TCHAR FLAG_NOTABBAR[] = TEXT("-notabbar"); void doException(Notepad_plus & notepad_plus_plus); -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdShow) +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { LPTSTR cmdLine = ::GetCommandLine(); ParamVector params; @@ -227,8 +227,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdSh if ((!isMultiInst) && (!TheFirstOne)) { HWND hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL); - for (int i = 0 ;!(hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL)) && i < 5 ; i++) + for (int i = 0 ;!hNotepad_plus && i < 5 ; i++) + { Sleep(100); + hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL); + } if (hNotepad_plus) { diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index 425489dd1..e504ce01f 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -142,7 +142,8 @@ RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" - WarningLevel="3" + WarningLevel="4" + WarnAsError="true" Detect64BitPortabilityProblems="false" DebugInformationFormat="3" />