From e3208e4ce26ffd7ff6e1222d698291030696c573 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 10 May 2014 01:12:44 +0000 Subject: [PATCH] [BUG_FIXED] Fix docking error messages displaying due to bad detection of windows version. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1236 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../src/MISC/PluginsManager/Notepad_plus_msgs.h | 2 +- PowerEditor/src/MISC/Process/Process.cpp | 5 ----- PowerEditor/src/Notepad_plus.cpp | 3 ++- PowerEditor/src/Notepad_plus_Window.cpp | 4 ++-- PowerEditor/src/Notepad_plus_Window.h | 7 +++---- PowerEditor/src/NppIO.cpp | 2 +- PowerEditor/src/Parameters.cpp | 8 +++++++- .../src/WinControls/DockingWnd/DockingCont.cpp | 3 +-- .../src/WinControls/DockingWnd/DockingManager.cpp | 2 +- .../src/WinControls/DockingWnd/DockingSplitter.cpp | 7 ++----- PowerEditor/src/WinControls/DockingWnd/Gripper.cpp | 6 +++--- PowerEditor/src/WinControls/TaskList/TaskList.cpp | 2 +- .../src/WinControls/TaskList/TaskListDlg.cpp | 3 +-- PowerEditor/src/winmain.cpp | 14 +++++--------- 14 files changed, 30 insertions(+), 38 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index b179bfa6b..26bf855e1 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -40,7 +40,7 @@ enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\ L_COFFEESCRIPT,\ // The end of enumated language type, so it should be always at the end L_EXTERNAL}; -enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8}; +enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81}; diff --git a/PowerEditor/src/MISC/Process/Process.cpp b/PowerEditor/src/MISC/Process/Process.cpp index 9fdd4b128..33c7818a5 100644 --- a/PowerEditor/src/MISC/Process/Process.cpp +++ b/PowerEditor/src/MISC/Process/Process.cpp @@ -34,11 +34,6 @@ void Process::run() { TCHAR *opVerb = TEXT("open"); -/* - winVer winVersion = (NppParameters::getInstance())->getWinVersion(); - if (winVersion == WV_VISTA || winVersion == WV_WIN7) - opVerb = TEXT("runas"); -*/ ::ShellExecute(NULL, opVerb, _command.c_str(), _args.c_str(), _curDir.c_str(), SW_SHOWNORMAL); } diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index ec4dda061..265159d81 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -155,7 +155,8 @@ Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(N // Determine if user is administrator. BOOL is_admin; - if(NppParameters::getInstance()->getWinVersion() >= WV_VISTA) + winVer ver = NppParameters::getInstance()->getWinVersion(); + if (ver >= WV_VISTA || ver == WV_UNKNOWN) { SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; PSID AdministratorsGroup; diff --git a/PowerEditor/src/Notepad_plus_Window.cpp b/PowerEditor/src/Notepad_plus_Window.cpp index 7e28340f6..7de788f01 100644 --- a/PowerEditor/src/Notepad_plus_Window.cpp +++ b/PowerEditor/src/Notepad_plus_Window.cpp @@ -232,11 +232,11 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin } } -bool Notepad_plus_Window::isDlgsMsg(MSG *msg, bool unicodeSupported) const +bool Notepad_plus_Window::isDlgsMsg(MSG *msg) const { for (size_t i = 0, len = _notepad_plus_plus_core._hModelessDlgs.size(); i < len; ++i) { - if (unicodeSupported?(::IsDialogMessageW(_notepad_plus_plus_core._hModelessDlgs[i], msg)):(::IsDialogMessageA(_notepad_plus_plus_core._hModelessDlgs[i], msg))) + if (::IsDialogMessageW(_notepad_plus_plus_core._hModelessDlgs[i], msg)) return true; } return false; diff --git a/PowerEditor/src/Notepad_plus_Window.h b/PowerEditor/src/Notepad_plus_Window.h index 39317f3b6..782756a5c 100644 --- a/PowerEditor/src/Notepad_plus_Window.h +++ b/PowerEditor/src/Notepad_plus_Window.h @@ -63,14 +63,13 @@ public: Notepad_plus_Window() {}; void init(HINSTANCE, HWND, const TCHAR *cmdLine, CmdLineParams *cmdLineParams); - bool isDlgsMsg(MSG *msg, bool unicodeSupported) const; + bool isDlgsMsg(MSG *msg) const; - HACCEL getAccTable() const{ + HACCEL getAccTable() const { return _notepad_plus_plus_core.getAccTable(); }; - bool emergency(generic_string emergencySavedDir) - { + bool emergency(generic_string emergencySavedDir) { return _notepad_plus_plus_core.emergency(emergencySavedDir); }; diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 0813f8ded..06514164b 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -1042,7 +1042,7 @@ bool Notepad_plus::fileDelete(BufferID id) winVer winVersion = (NppParameters::getInstance())->getWinVersion(); bool goAhead = true; - if (winVersion >= WV_WIN8) + if (winVersion >= WV_WIN8 || winVersion == WV_UNKNOWN) { // Windows 8 (and version afer?) has no system alert, so we ask user's confirmation goAhead = (doDeleteOrNot(fileNamePath) == IDYES); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 5cee84db2..cdca9e23e 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -567,11 +567,17 @@ winVer getWindowsVersion() pGNSI(&si); else GetSystemInfo(&si); - + //printInt(osvi.dwMajorVersion); + //printInt(osvi.dwMinorVersion); switch (osvi.dwPlatformId) { case VER_PLATFORM_WIN32_NT: { + if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 3 ) + { + return WV_WIN81; + } + if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2 ) { return WV_WIN8; diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index cff5b899f..8b54a07a1 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -293,8 +293,7 @@ LRESULT DockingCont::runProcCaption(HWND hwnd, UINT Message, WPARAM wParam, LPAR // start hooking hWndServer = _hCaption; - winVer ver = (NppParameters::getInstance())->getWinVersion(); - hookMouse = ::SetWindowsHookEx(ver >= WV_W2K?WH_MOUSE_LL:WH_MOUSE, (HOOKPROC)hookProcMouse, _hInst, 0); + hookMouse = ::SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)hookProcMouse, _hInst, 0); if (!hookMouse) { diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index 5cb0f2f6b..f93efb7b0 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -158,7 +158,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin) hWndServer = _hSelf; CoInitialize(NULL); if (!gWinCallHook) //only set if not already done - gWinCallHook = SetWindowsHookEx(WH_CALLWNDPROC, FocusWndProc, hInst, GetCurrentThreadId()); + gWinCallHook = ::SetWindowsHookEx(WH_CALLWNDPROC, FocusWndProc, hInst, GetCurrentThreadId()); if (!gWinCallHook) { diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp index 87e013924..1778042e4 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp @@ -150,11 +150,7 @@ LRESULT DockingSplitter::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM case WM_LBUTTONDOWN: { hWndMouse = hwnd; - - winVer ver = (NppParameters::getInstance())->getWinVersion(); - hookMouse = ::SetWindowsHookEx(ver >= WV_W2K?WH_MOUSE_LL:WH_MOUSE, (HOOKPROC)hookProcMouse, _hInst, 0); - - + hookMouse = ::SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)hookProcMouse, _hInst, 0); if (!hookMouse) { DWORD dwError = ::GetLastError(); @@ -168,6 +164,7 @@ LRESULT DockingSplitter::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM ::GetCursorPos(&_ptOldPos); _isLeftButtonDown = TRUE; } + break; } case WM_LBUTTONUP: diff --git a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp index fbe8b7a99..22bc6281c 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp @@ -258,7 +258,7 @@ void Gripper::create() ::SetWindowPos(_pCont->getHSelf(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); ::SetCapture(_hSelf); winVer ver = (NppParameters::getInstance())->getWinVersion(); - hookMouse = ::SetWindowsHookEx(ver >= WV_W2K?WH_MOUSE_LL:WH_MOUSE, (HOOKPROC)hookProcMouse, _hInst, 0); + hookMouse = ::SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)hookProcMouse, _hInst, 0); if (!hookMouse) { @@ -268,9 +268,9 @@ void Gripper::create() ::MessageBox(NULL, str, TEXT("SetWindowsHookEx(MOUSE) failed on Gripper::create()"), MB_OK | MB_ICONERROR); } - if (ver < WV_VISTA) + if (ver != WV_UNKNOWN && ver < WV_VISTA) { - hookKeyboard = ::SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)hookProcKeyboard, _hInst, ::GetCurrentThreadId()); + hookKeyboard = ::SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)hookProcKeyboard, _hInst, 0); if (!hookKeyboard) { DWORD dwError = ::GetLastError(); diff --git a/PowerEditor/src/WinControls/TaskList/TaskList.cpp b/PowerEditor/src/WinControls/TaskList/TaskList.cpp index af80492df..0006583b6 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskList.cpp +++ b/PowerEditor/src/WinControls/TaskList/TaskList.cpp @@ -132,7 +132,7 @@ RECT TaskList::adjustSize() reSizeTo(_rc); winVer ver = (NppParameters::getInstance())->getWinVersion(); - _rc.bottom += ver <= WV_XP?xpBottomMarge:w7BottomMarge; + _rc.bottom += (ver <= WV_XP && ver != WV_UNKNOWN)?xpBottomMarge:w7BottomMarge; return _rc; } diff --git a/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp b/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp index 89e3f9487..67dda3cc3 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp +++ b/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp @@ -84,8 +84,7 @@ BOOL CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara #ifndef WH_MOUSE_LL #define WH_MOUSE_LL 14 #endif - winVer ver = (NppParameters::getInstance())->getWinVersion(); - _hHooker = ::SetWindowsHookEx(ver >= WV_W2K?WH_MOUSE_LL:WH_MOUSE, (HOOKPROC)hookProc, _hInst, 0); + _hHooker = ::SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)hookProc, _hInst, 0); hook = _hHooker; return FALSE; } diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 7cf4b568e..a897c0f1c 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -390,14 +390,14 @@ DEVOMER*/ // Tell UAC that lower integrity processes are allowed to send WM_COPYDATA messages to this process (or window) // This allows opening new files to already opened elevated Notepad++ process via explorer context menu. - if(pNppParameters->getWinVersion() >= WV_VISTA) + winVer ver = pNppParameters->getWinVersion(); + if (ver >= WV_VISTA || ver == WV_UNKNOWN) { HMODULE hDll = GetModuleHandle(TEXT("user32.dll")); if (hDll) { // According to MSDN ChangeWindowMessageFilter may not be supported in future versions of Windows, // that is why we use ChangeWindowMessageFilterEx if it is available (windows version >= Win7). - if(pNppParameters->getWinVersion() == WV_VISTA) { typedef BOOL (WINAPI *MESSAGEFILTERFUNC)(UINT message,DWORD dwFlag); @@ -425,23 +425,19 @@ DEVOMER*/ } } - bool unicodeSupported = pNppParameters->getWinVersion() >= WV_NT; bool going = true; while (going) { - going = (unicodeSupported?(::GetMessageW(&msg, NULL, 0, 0)):(::GetMessageA(&msg, NULL, 0, 0))) != 0; + going = ::GetMessageW(&msg, NULL, 0, 0) != 0; if (going) { // if the message doesn't belong to the notepad_plus_plus's dialog - if (!notepad_plus_plus.isDlgsMsg(&msg, unicodeSupported)) + if (!notepad_plus_plus.isDlgsMsg(&msg)) { if (::TranslateAccelerator(notepad_plus_plus.getHSelf(), notepad_plus_plus.getAccTable(), &msg) == 0) { ::TranslateMessage(&msg); - if (unicodeSupported) - ::DispatchMessageW(&msg); - else - ::DispatchMessage(&msg); + ::DispatchMessageW(&msg); } } }