Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
5.3 KiB

  1. /*
  2. * cmd - CMD.EXE settings
  3. */
  4. #include "tweakui.h"
  5. #include "winconp.h"
  6. #pragma message("Add help for CMD!")
  7. #pragma BEGIN_CONST_DATA
  8. KL const c_klFileComp = { phkCU, c_tszCmdPath, c_tszFileComp };
  9. KL const c_klDirComp = { phkCU, c_tszCmdPath, c_tszDirComp };
  10. KL const c_klWordDelim = { phkCU, TEXT("Console"), TEXT("WordDelimiters") };
  11. #define WORD_DELIM_MAX 32
  12. const static DWORD CODESEG rgdwHelp[] = {
  13. IDC_COMPLETIONGROUP, IDH_GROUP,
  14. IDC_FILECOMPTXT, IDH_CMDFILECOMP,
  15. IDC_FILECOMP, IDH_CMDFILECOMP,
  16. IDC_DIRCOMPTXT, IDH_CMDDIRCOMP,
  17. IDC_DIRCOMP, IDH_CMDDIRCOMP,
  18. 0, 0,
  19. };
  20. #pragma END_CONST_DATA
  21. /*****************************************************************************
  22. *
  23. * Cmd_OnCommand
  24. *
  25. * Ooh, we got a command.
  26. *
  27. *****************************************************************************/
  28. BOOL PASCAL
  29. Cmd_OnCommand(HWND hdlg, int id, UINT codeNotify)
  30. {
  31. switch (codeNotify) {
  32. case CBN_SELCHANGE:
  33. case EN_CHANGE:
  34. PropSheet_Changed(GetParent(hdlg), hdlg); break;
  35. }
  36. return 0;
  37. }
  38. /*****************************************************************************
  39. *
  40. * Cmd_InitComboBox
  41. *
  42. * Fill the combo box with stuff
  43. *
  44. *****************************************************************************/
  45. void PASCAL
  46. Cmd_InitComboBox(HWND hwnd, int idc, PKL pkl)
  47. {
  48. DWORD dwVal = GetDwordPkl(pkl, 0);
  49. DWORD dw;
  50. hwnd = GetDlgItem(hwnd, idc);
  51. for (dw = 0; dw < 32; dw++) {
  52. TCHAR tszName[127];
  53. if (LoadString(hinstCur, IDS_COMPLETION + dw, tszName, cA(tszName))) {
  54. int iItem = ComboBox_AddString(hwnd, tszName);
  55. ComboBox_SetItemData(hwnd, iItem, dw);
  56. if (dw == dwVal) {
  57. ComboBox_SetCurSel(hwnd, iItem);
  58. }
  59. }
  60. }
  61. }
  62. /*****************************************************************************
  63. *
  64. * Cmd_OnInitDialog
  65. *
  66. * Initialize the listview with the current restrictions.
  67. *
  68. *****************************************************************************/
  69. BOOL PASCAL
  70. Cmd_OnInitDialog(HWND hdlg)
  71. {
  72. Cmd_InitComboBox(hdlg, IDC_FILECOMP, &c_klFileComp);
  73. Cmd_InitComboBox(hdlg, IDC_DIRCOMP, &c_klDirComp);
  74. TCHAR szDelim[WORD_DELIM_MAX];
  75. HWND hwndDelim = GetDlgItem(hdlg, IDC_WORDDELIM);
  76. Edit_LimitText(hwndDelim, WORD_DELIM_MAX);
  77. GetStrPkl(szDelim, cA(szDelim), &c_klWordDelim);
  78. SetWindowText(hwndDelim, szDelim);
  79. return 1;
  80. }
  81. /*****************************************************************************
  82. *
  83. * Cmd_ForceConsoleRefresh
  84. *
  85. * Launch a dummy console to tickle the console subsystem into reloading
  86. * its settings.
  87. *
  88. *****************************************************************************/
  89. void
  90. Cmd_ForceConsoleRefresh()
  91. {
  92. WinExec("cmd.exe /c ver", SW_HIDE);
  93. }
  94. /*****************************************************************************
  95. *
  96. * Cmd_ApplyComboBox
  97. *
  98. *****************************************************************************/
  99. void PASCAL
  100. Cmd_ApplyComboBox(HWND hwnd, int idc, PKL pkl)
  101. {
  102. DWORD dw, dwVal = GetDwordPkl(pkl, 0);
  103. int iItem;
  104. hwnd = GetDlgItem(hwnd, idc);
  105. iItem = ComboBox_GetCurSel(hwnd);
  106. if (iItem >= 0) {
  107. dw = (DWORD)ComboBox_GetItemData(hwnd, iItem);
  108. if (dw != dwVal) {
  109. SetDwordPkl2(pkl, dw);
  110. }
  111. }
  112. }
  113. /*****************************************************************************
  114. *
  115. * Cmd_Apply
  116. *
  117. *****************************************************************************/
  118. void PASCAL
  119. Cmd_Apply(HWND hdlg)
  120. {
  121. Cmd_ApplyComboBox(hdlg, IDC_FILECOMP, &c_klFileComp);
  122. Cmd_ApplyComboBox(hdlg, IDC_DIRCOMP, &c_klDirComp);
  123. TCHAR szDelim[WORD_DELIM_MAX];
  124. TCHAR szDelimPrev[WORD_DELIM_MAX];
  125. GetStrPkl(szDelimPrev, cA(szDelim), &c_klWordDelim);
  126. GetDlgItemText(hdlg, IDC_WORDDELIM, szDelim, cA(szDelim));
  127. if (lstrcmp(szDelim, szDelimPrev) != 0) {
  128. if (szDelim[0]) {
  129. SetStrPkl(&c_klWordDelim, szDelim);
  130. } else {
  131. DelPkl(&c_klWordDelim);
  132. }
  133. Cmd_ForceConsoleRefresh();
  134. }
  135. }
  136. /*****************************************************************************
  137. *
  138. * Cmd_OnNotify
  139. *
  140. * Ooh, we got a notification.
  141. *
  142. *****************************************************************************/
  143. BOOL PASCAL
  144. Cmd_OnNotify(HWND hdlg, NMHDR FAR *pnm)
  145. {
  146. switch (pnm->code) {
  147. case PSN_APPLY:
  148. Cmd_Apply(hdlg);
  149. break;
  150. }
  151. return 0;
  152. }
  153. /*****************************************************************************
  154. *
  155. * Our window procedure.
  156. *
  157. *****************************************************************************/
  158. INT_PTR EXPORT
  159. Cmd_DlgProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam)
  160. {
  161. switch (wm) {
  162. case WM_INITDIALOG: return Cmd_OnInitDialog(hdlg);
  163. case WM_COMMAND:
  164. return Cmd_OnCommand(hdlg,
  165. (int)GET_WM_COMMAND_ID(wParam, lParam),
  166. (UINT)GET_WM_COMMAND_CMD(wParam, lParam));
  167. case WM_NOTIFY:
  168. return Cmd_OnNotify(hdlg, (NMHDR FAR *)lParam);
  169. case WM_HELP: Common_OnHelp(lParam, &rgdwHelp[0]); break;
  170. case WM_CONTEXTMENU: Common_OnContextMenu(wParam, &rgdwHelp[0]); break;
  171. default: return 0; /* Unhandled */
  172. }
  173. return 1; /* Handled */
  174. }