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.

104 lines
2.4 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1993 **
  4. //*********************************************************************
  5. #include "admincfg.h"
  6. extern BOOL fInfLoaded;
  7. INT_PTR CALLBACK TemplateOptDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  8. LPARAM lParam);
  9. VOID InitTemplateOptDlg(HWND hDlg);
  10. BOOL OnTemplateOptions(HWND hwndApp)
  11. {
  12. return (BOOL)DialogBoxParam(ghInst,MAKEINTRESOURCE(DLG_TEMPLATEOPT),hwndApp,
  13. TemplateOptDlgProc,(LPARAM) hwndApp);
  14. }
  15. INT_PTR CALLBACK TemplateOptDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  16. LPARAM lParam)
  17. {
  18. int i;
  19. switch (uMsg) {
  20. case WM_INITDIALOG:
  21. SetWindowLongPtr(hDlg,DWLP_USER,lParam);
  22. InitTemplateOptDlg(hDlg);
  23. return TRUE;
  24. case WM_COMMAND:
  25. switch (LOWORD(wParam)) {
  26. case IDD_TEMPLATELIST:
  27. if ((HIWORD(wParam) == LBN_SETFOCUS) && (dwAppState & AS_CANOPENTEMPLATE))
  28. EnableDlgItem(hDlg,IDD_CLOSETEMPLATE,TRUE);
  29. break;
  30. case IDOK:
  31. if (LoadTemplatesFromDlg(hDlg) == ERROR_SUCCESS)
  32. {
  33. EndDialog(hDlg, TRUE);
  34. }
  35. break;
  36. case IDCANCEL:
  37. EndDialog(hDlg,TRUE);
  38. break;
  39. case IDD_CLOSETEMPLATE:
  40. i = (int)SendDlgItemMessage(hDlg, IDD_TEMPLATELIST, LB_GETCURSEL,0,0);
  41. if (i != LB_ERR)
  42. SendDlgItemMessage(hDlg, IDD_TEMPLATELIST, LB_DELETESTRING, i, 0);
  43. EnableDlgItem(hDlg,IDD_CLOSETEMPLATE,FALSE);
  44. if (SendDlgItemMessage(hDlg, IDD_TEMPLATELIST, LB_GETCOUNT, 0,0) == 0)
  45. {
  46. fInfLoaded = FALSE;
  47. dwAppState &= ~AS_CANHAVEDOCUMENT;
  48. EnableMenuItems((HWND) GetWindowLongPtr(hDlg,DWLP_USER), dwAppState);
  49. }
  50. break;
  51. case IDD_OPENTEMPLATE:
  52. OnOpenTemplate(hDlg,(HWND) GetWindowLongPtr(hDlg,DWLP_USER));
  53. break;
  54. }
  55. break;
  56. }
  57. return FALSE;
  58. }
  59. VOID InitTemplateOptDlg(HWND hDlg)
  60. {
  61. // if template loaded, display the name in the dialog
  62. if (fInfLoaded)
  63. {
  64. TCHAR *p = pbufTemplates;
  65. while (*p)
  66. {
  67. SendDlgItemMessage(hDlg, IDD_TEMPLATELIST, LB_ADDSTRING, 0,(LPARAM) p);
  68. p += lstrlen(p)+1;
  69. }
  70. }
  71. if (dwAppState & AS_CANOPENTEMPLATE) {
  72. EnableDlgItem(hDlg,IDD_OPENTEMPLATE,TRUE);
  73. // hide the text telling you why button is disabled (since it isn't)
  74. ShowWindow(GetDlgItem(hDlg,IDD_TXTEMPLATE),SW_HIDE);
  75. }
  76. }