diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index a3cc4bd1..d52a3376 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -61,7 +61,7 @@ struct SortTaskListPred Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL), _pMainSplitter(NULL), _isfullScreen(false), _recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _isRTL(false), - _linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _isSaving(false), _hideMenu(true) + _linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _isSaving(false), _hideMenu(true), _sysMenuEntering(false) { _winVersion = getWindowsVersion(); @@ -7552,6 +7552,16 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa ::ShowWindow(hwnd, SW_HIDE); return TRUE; } + + if (wParam == SC_KEYMENU && lParam == VK_SPACE) + { + _sysMenuEntering = true; + } + else if (wParam == 0xF093) //it should be SC_MOUSEMENU. A bug? + { + _sysMenuEntering = true; + } + return ::DefWindowProc(hwnd, Message, wParam, lParam); } @@ -7585,10 +7595,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - case WM_INITMENUPOPUP: - _windowsMenu.initPopupMenu((HMENU)wParam, _pEditView); - return TRUE; - case NPPM_DMMSHOW: { _dockingManager.showDockableDlg((HWND)lParam, SW_SHOW); @@ -7737,17 +7743,30 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return (HWND)lParam == pMainTB; } + case NPPM_INTERNAL_GETMENU : + { + return (LRESULT)_mainMenuHandle; + } + + case WM_INITMENUPOPUP: + { + _windowsMenu.initPopupMenu((HMENU)wParam, _pEditView); + return TRUE; + } + case WM_ENTERMENULOOP: { - if (_hideMenu) + if (_hideMenu && !wParam && !_sysMenuEntering) ::SetMenu(_hSelf, _mainMenuHandle); - return FALSE; + + return TRUE; } case WM_EXITMENULOOP: { - if (_hideMenu) + if (_hideMenu && !wParam && !_sysMenuEntering) ::SetMenu(_hSelf, NULL); + _sysMenuEntering = false; return FALSE; } diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 422268e8..8f52ee29 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -220,6 +220,8 @@ private: WindowsMenu _windowsMenu; HMENU _mainMenuHandle; bool _hideMenu; + bool _sysMenuEntering; + LONG_PTR _prevStyles; // For FullScreen feature @@ -491,8 +493,6 @@ private: void MaintainIndentation(char ch); void addHotSpot(bool docIsModifing = false); - //void styleHotSpotForWholeDoc(); - //void styleHotSpotModifyMode(); void bookmarkAdd(int lineno) const { if (lineno == -1) diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index 04f9bcf9..845e8ebb 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -1387,7 +1387,7 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM //remove current language from langMenu HWND hNpp = ::GetParent(_hSelf); - ::RemoveMenu(::GetSubMenu(::GetMenu(hNpp), MENUINDEX_LANGUAGE), IDM_LANG_USER + i, MF_BYCOMMAND); + ::RemoveMenu(::GetSubMenu((HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), IDM_LANG_USER + i, MF_BYCOMMAND); ::DrawMenuBar(hNpp); ::SendMessage(_hParent, WM_REMOVE_USERLANG, 0, (LPARAM)langName); } @@ -1423,7 +1423,7 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM //rename current language name in langMenu HWND hNpp = ::GetParent(_hSelf); - ::ModifyMenu(::GetSubMenu(::GetMenu(hNpp), MENUINDEX_LANGUAGE), IDM_LANG_USER + i, MF_BYCOMMAND, IDM_LANG_USER + i, newName); + ::ModifyMenu(::GetSubMenu((HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), IDM_LANG_USER + i, MF_BYCOMMAND, IDM_LANG_USER + i, newName); ::DrawMenuBar(hNpp); ::SendMessage(_hParent, WM_RENAME_USERLANG, (WPARAM)newName, (LPARAM)langName); } @@ -1471,7 +1471,7 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM //add new language name in langMenu HWND hNpp = ::GetParent(_hSelf); - ::InsertMenu(::GetSubMenu(::GetMenu(hNpp), MENUINDEX_LANGUAGE), IDM_LANG_USER + newIndex /*+ 1*/, MF_BYCOMMAND, IDM_LANG_USER + newIndex + 1, newName); + ::InsertMenu(::GetSubMenu((HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), IDM_LANG_USER + newIndex /*+ 1*/, MF_BYCOMMAND, IDM_LANG_USER + newIndex + 1, newName); ::DrawMenuBar(hNpp); } diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index 55edc41f..21e0806d 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -304,7 +304,7 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP // preparing to remove from menu posBase = 6; nbElem = theMacros.size(); - hMenu = ::GetSubMenu(::GetMenu(_hParent), MENUINDEX_MACRO); + hMenu = ::GetSubMenu((HMENU)::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_MACRO); for (size_t i = shortcutIndex ; i < nbElem ; i++) //lower the IDs of the remaining items so there are no gaps { MacroShortcut ms = theMacros[i]; @@ -323,7 +323,7 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP // preparing to remove from menu posBase = 2; nbElem = theUserCmds.size(); - hMenu = ::GetSubMenu(::GetMenu(_hParent), MENUINDEX_RUN); + hMenu = ::GetSubMenu((HMENU)::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_RUN); for (size_t i = shortcutIndex ; i < nbElem ; i++) //lower the IDs of the remaining items so there are no gaps { UserCommand uc = theUserCmds[i]; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 05db1ccd..700d1455 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -36,7 +36,7 @@ IDD_PREFERENCE_BAR_BOX DIALOGEX 0, 0, 370, 180 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "Tool bar",IDC_TOOLBAR_GB_STATIC,17,5,131,68,BS_CENTER + GROUPBOX "Tool bar",IDC_TOOLBAR_GB_STATIC,17,5,145,68,BS_CENTER CONTROL "Hide",IDC_CHECK_HIDE,"Button",BS_AUTOCHECKBOX,24,15,94,10 CONTROL "Small icons",IDC_RADIO_SMALLICON,"Button",BS_AUTORADIOBUTTON,24,29,114,10 CONTROL "Big icons",IDC_RADIO_BIGICON,"Button",BS_AUTORADIOBUTTON,24,43,109,10 @@ -53,7 +53,9 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,118,133,10 CONTROL "Double click to close document",IDC_CHECK_DBCLICK2CLOSE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,133,133,10 - CONTROL "Show Status Bar",IDC_CHECK_SHOWSTATUSBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,133,130,10 + CONTROL "Show Status Bar",IDC_CHECK_SHOWSTATUSBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,140,130,10 + GROUPBOX "Menu bar",IDC_MENUBAR_GB_STATIC,16,77,147,49,BS_CENTER + CONTROL "Hide (Use Alt or F10 key to toggle it)",IDC_CHECK_HIDEMENUBAR,"Button",BS_AUTOCHECKBOX | BS_MULTILINE,24,87,135,26 END IDD_PREFERENCE_MARGEIN_BOX DIALOGEX 0, 0, 370, 180 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index cc7f28be..46a68ea3 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -942,11 +942,11 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara if (LOWORD(wParam)==IDC_BUTTON_REMOVE) { - ::DeleteMenu(::GetMenu(grandParent), lmi._cmdID, MF_BYCOMMAND); + ::DeleteMenu((HMENU)::SendMessage(grandParent, NPPM_INTERNAL_GETMENU, 0, 0), lmi._cmdID, MF_BYCOMMAND); } else { - ::InsertMenu(::GetSubMenu(::GetMenu(grandParent), MENUINDEX_LANGUAGE), iAdd-1, MF_BYPOSITION, lmi._cmdID, lmi._langName.c_str()); + ::InsertMenu(::GetSubMenu((HMENU)::SendMessage(grandParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), iAdd-1, MF_BYPOSITION, lmi._cmdID, lmi._langName.c_str()); } ::DrawMenuBar(grandParent); return TRUE; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 21b92efa..4a964654 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -43,6 +43,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define IDC_CHECK_TAB_HIDE (IDD_PREFERENCE_BAR_BOX + 18) #define IDC_CHECK_TAB_MULTILINE (IDD_PREFERENCE_BAR_BOX + 19) #define IDC_CHECK_TAB_VERTICAL (IDD_PREFERENCE_BAR_BOX + 20) + #define IDC_MENUBAR_GB_STATIC (IDD_PREFERENCE_BAR_BOX + 21) + #define IDC_CHECK_HIDEMENUBAR (IDD_PREFERENCE_BAR_BOX + 22) #define IDD_PREFERENCE_MARGEIN_BOX 6200 //(IDD_PREFERENCE_BOX + 200) #define IDC_FMS_GB_STATIC (IDD_PREFERENCE_MARGEIN_BOX + 1) diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index 6e1fe67d..a26ab882 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -207,7 +207,7 @@ BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) if (uc.doDialog() != -1) { - HMENU hRunMenu = ::GetSubMenu(::GetMenu(_hParent), MENUINDEX_RUN); + HMENU hRunMenu = ::GetSubMenu((HMENU)::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_RUN); int const posBase = 2; if (nbCmd == 0) diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index 704215c0..590b7fcb 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -310,7 +310,7 @@ void getNameStrFromCmd(DWORD cmd, string & str) { HWND hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL); char cmdName[64]; - int nbChar = ::GetMenuString(::GetMenu(hNotepad_plus), cmd, cmdName, sizeof(cmdName), MF_BYCOMMAND); + int nbChar = ::GetMenuString((HMENU)::SendMessage(hNotepad_plus, NPPM_INTERNAL_GETMENU, 0, 0), cmd, cmdName, sizeof(cmdName), MF_BYCOMMAND); if (!nbChar) return; bool fin = false; diff --git a/PowerEditor/src/contextMenu.xml b/PowerEditor/src/contextMenu.xml index 25a09a63..5397ec45 100644 --- a/PowerEditor/src/contextMenu.xml +++ b/PowerEditor/src/contextMenu.xml @@ -4,6 +4,7 @@ + diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 26aa2ccd..7cf65616 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -283,6 +283,8 @@ #define NPPM_INTERNAL_DOCSWITCHIN (NOTEPADPLUS_USER_INTERNAL + 11) #define NPPM_INTERNAL_ISTABBARREDUCED (NOTEPADPLUS_USER_INTERNAL + 12) #define NPPM_INTERNAL_ISFOCUSEDTAB (NOTEPADPLUS_USER_INTERNAL + 13) + #define NPPM_INTERNAL_GETMENU (NOTEPADPLUS_USER_INTERNAL + 14) + // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000) #define SCINTILLA_USER (WM_USER + 2000) diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index 6d3133b0..579ce00a 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -576,10 +576,6 @@ RelativePath="..\src\MISC\RegExt\regExtDlgRc.h" > - - @@ -588,6 +584,10 @@ RelativePath="..\src\WinControls\Preference\resource.h" > + +