BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { switch (message) { case WM_COMMAND : { switch (wParam) { case IDCANCEL : display(false); return TRUE; case IDOK : { TCHAR cmd[MAX_PATH]; ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); _cmdLine = cmd; HINSTANCE hInst = run(_hParent); if (int(hInst) > 32) { addTextToCombo(_cmdLine.c_str()); display(false); } else { removeTextFromCombo(_cmdLine.c_str()); } return TRUE; } case IDC_BUTTON_SAVE : { std::vector<UserCommand> & theUserCmds = (NppParameters::getInstance())->getUserCommandList(); int nbCmd = theUserCmds.size(); int cmdID = ID_USER_CMD + nbCmd; TCHAR cmd[MAX_PATH]; ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); UserCommand uc(Shortcut(), cmd, cmdID); uc.init(_hInst, _hSelf); if (uc.doDialog() != -1) { HMENU hRunMenu = ::GetSubMenu((HMENU)::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_RUN); int const posBase = 2; if (nbCmd == 0) ::InsertMenu(hRunMenu, posBase - 1, MF_BYPOSITION, (unsigned int)-1, 0); theUserCmds.push_back(uc); ::InsertMenu(hRunMenu, posBase + nbCmd, MF_BYPOSITION, cmdID, uc.toMenuItemString().c_str()); if (nbCmd == 0) { // Insert the separator and modify/delete command ::InsertMenu(hRunMenu, posBase + nbCmd + 1, MF_BYPOSITION, (unsigned int)-1, 0); const char * nativeLangShortcutMapperRun = (NppParameters::getInstance())->getNativeLangMenuStringA(IDM_SETTING_SHORTCUT_MAPPER_RUN); const char * shortcutMapperRunStr = nativeLangShortcutMapperRun?nativeLangShortcutMapperRun:"Modify Shortcut/Delete Command..."; #ifdef UNICODE WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); const wchar_t * shortcutMapperRunStrW = wmc->char2wchar(shortcutMapperRunStr, ::SendMessage(_hParent, NPPM_GETCURRENTNATIVELANGENCODING, 0, 0)); ::InsertMenu(hRunMenu, posBase + nbCmd + 2, MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, shortcutMapperRunStrW); #else ::InsertMenu(hRunMenu, posBase + nbCmd + 2, MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, shortcutMapperRunStr); #endif } (NppParameters::getInstance())->getAccelerator()->updateShortcuts(); } return TRUE; } case IDC_BUTTON_FILE_BROWSER : { FileDialog fd(_hSelf, _hInst); fd.setExtFilter(TEXT("Executable file : "), TEXT(".exe"), TEXT(".com"), TEXT(".cmd"), TEXT(".bat"), NULL); fd.setExtFilter(TEXT("All files : "), TEXT(".*"), NULL); if (const TCHAR *fn = fd.doOpenSingleFileDlg()) addTextToCombo(fn); return TRUE; } default : break; } } } return FALSE; }
BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { switch (message) { case WM_COMMAND : { switch (wParam) { case IDCANCEL : display(false); return TRUE; case IDOK : { TCHAR cmd[MAX_PATH]; ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); _cmdLine = cmd; HINSTANCE hInst = run(_hParent); if (int(hInst) > 32) { addTextToCombo(_cmdLine.c_str()); display(false); } else { removeTextFromCombo(_cmdLine.c_str()); } return TRUE; } case IDC_BUTTON_SAVE : { std::vector<UserCommand> & theUserCmds = (NppParameters::getInstance())->getUserCommandList(); int nbCmd = theUserCmds.size(); int cmdID = ID_USER_CMD + nbCmd; TCHAR cmd[MAX_PATH]; ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); UserCommand uc(Shortcut(), cmd, cmdID); uc.init(_hInst, _hSelf); if (uc.doDialog() != -1) { HMENU hRunMenu = ::GetSubMenu((HMENU)::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_RUN); int const posBase = 2; if (nbCmd == 0) ::InsertMenu(hRunMenu, posBase - 1, MF_BYPOSITION, (unsigned int)-1, 0); theUserCmds.push_back(uc); ::InsertMenu(hRunMenu, posBase + nbCmd, MF_BYPOSITION, cmdID, uc.toMenuItemString().c_str()); if (nbCmd == 0) { // Insert the separator and modify/delete command ::InsertMenu(hRunMenu, posBase + nbCmd + 1, MF_BYPOSITION, (unsigned int)-1, 0); NativeLangSpeaker *pNativeLangSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); generic_string nativeLangShortcutMapperMacro = pNativeLangSpeaker->getNativeLangMenuString(IDM_SETTING_SHORTCUT_MAPPER_MACRO); if (nativeLangShortcutMapperMacro == TEXT("")) nativeLangShortcutMapperMacro = TEXT("Modify Shortcut/Delete Command..."); ::InsertMenu(hRunMenu, posBase + nbCmd + 2, MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_RUN, nativeLangShortcutMapperMacro.c_str()); } (NppParameters::getInstance())->getAccelerator()->updateShortcuts(); } return TRUE; } case IDC_BUTTON_FILE_BROWSER : { FileDialog fd(_hSelf, _hInst); fd.setExtFilter(TEXT("Executable file : "), TEXT(".exe"), TEXT(".com"), TEXT(".cmd"), TEXT(".bat"), NULL); fd.setExtFilter(TEXT("All files : "), TEXT(".*"), NULL); if (const TCHAR *fn = fd.doOpenSingleFileDlg()) { if(wcschr(fn, ' ') != NULL) { generic_string fn_quotes(fn); fn_quotes = TEXT("\"") + fn_quotes + TEXT("\""); addTextToCombo(fn_quotes.c_str()); } else { addTextToCombo(fn); } } return TRUE; } default : break; } } } return FALSE; }