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.

126 lines
3.2 KiB

  1. // File: CplMain.cpp
  2. #include "precomp.h"
  3. #include "resource.h"
  4. #include "Conf.h"
  5. #include "ConfCpl.h"
  6. #include "confwnd.h"
  7. #include "ConfPolicies.h"
  8. //*** Global Data *****************************************************
  9. // Global flag keeps setting that changed for windows msg broadcast
  10. DWORD g_dwChangedSettings = 0;
  11. BOOL g_fInOptionsDialog = FALSE;
  12. static const int nMaxPropPages = 7;
  13. INT_PTR CreatePropSheet(HWND hwndOwner, HINSTANCE hInst, int nStartPage)
  14. {
  15. int pageMap[nMaxPropPages];
  16. ZeroMemory(&pageMap, sizeof(pageMap));
  17. PROPSHEETPAGE psp[nMaxPropPages];
  18. ZeroMemory(&psp, sizeof(psp));
  19. RegEntry rePol(POLICIES_KEY, HKEY_CURRENT_USER);
  20. RegEntry reAudio(AUDIO_KEY, HKEY_CURRENT_USER);
  21. ASSERT(nStartPage < nMaxPropPages);
  22. int nPages = 0;
  23. if (!rePol.GetNumber( REGVAL_POL_NO_GENERALPAGE,
  24. DEFAULT_POL_NO_GENERALPAGE ))
  25. {
  26. pageMap[OPTIONS_GENERAL_PAGE] = nPages;
  27. FillInPropertyPage(&psp[nPages++], IDD_OPT_GENERAL,
  28. UserDlgProc);
  29. ASSERT(nPages <= nMaxPropPages);
  30. }
  31. if (!rePol.GetNumber( REGVAL_POL_NO_SECURITYPAGE,
  32. DEFAULT_POL_NO_SECURITYPAGE ))
  33. {
  34. pageMap[OPTIONS_SECURITY_PAGE] = nPages;
  35. FillInPropertyPage(&psp[nPages++], IDD_SECURITY,
  36. SecurityDlgProc);
  37. ASSERT(nPages <= nMaxPropPages);
  38. }
  39. if (!rePol.GetNumber( REGVAL_POL_NO_AUDIOPAGE,
  40. DEFAULT_POL_NO_AUDIOPAGE ) &&
  41. !rePol.GetNumber( REGVAL_POL_NO_AUDIO,
  42. DEFAULT_POL_NO_AUDIO) &&
  43. ISSOUNDCARDPRESENT(reAudio.GetNumber( REGVAL_SOUNDCARDCAPS,
  44. SOUNDCARD_NONE)) )
  45. {
  46. pageMap[OPTIONS_AUDIO_PAGE] = nPages;
  47. FillInPropertyPage(&psp[nPages++], IDD_AUDIO,
  48. AudioDlgProc);
  49. ASSERT(nPages <= nMaxPropPages);
  50. }
  51. if (!rePol.GetNumber( REGVAL_POL_NO_VIDEOPAGE,
  52. DEFAULT_POL_NO_VIDEOPAGE ) &&
  53. (!rePol.GetNumber( REGVAL_POL_NO_VIDEO_SEND,
  54. DEFAULT_POL_NO_VIDEO_SEND) ||
  55. !rePol.GetNumber( REGVAL_POL_NO_VIDEO_RECEIVE,
  56. DEFAULT_POL_NO_VIDEO_RECEIVE)))
  57. {
  58. pageMap[OPTIONS_VIDEO_PAGE] = nPages;
  59. FillInPropertyPage(&psp[nPages++], IDD_VIDEO,
  60. VideoDlgProc);
  61. ASSERT(nPages <= nMaxPropPages);
  62. }
  63. // If no pages are allowed, tell the user and get out
  64. if ( !nPages ) {
  65. ConfMsgBox ( hwndOwner, (LPCTSTR)IDS_ALLPAGESDISABLED );
  66. return 0;
  67. }
  68. PROPSHEETHEADER psh;
  69. InitStruct(&psh);
  70. psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
  71. psh.hwndParent = hwndOwner;
  72. psh.hInstance = hInst;
  73. ASSERT(NULL == psh.hIcon);
  74. psh.pszCaption = (LPSTR)IDS_CPLNAME;
  75. psh.nPages = nPages;
  76. psh.nStartPage = pageMap[nStartPage];
  77. psh.ppsp = (LPCPROPSHEETPAGE) &psp;
  78. return (PropertySheet(&psh));
  79. }
  80. /* L A U N C H C O N F C P L */
  81. /*-------------------------------------------------------------------------
  82. %%Function: LaunchConfCpl
  83. -------------------------------------------------------------------------*/
  84. VOID LaunchConfCpl(HWND hwnd, int nStartPage)
  85. {
  86. if (g_fInOptionsDialog)
  87. {
  88. return;
  89. }
  90. g_fInOptionsDialog = TRUE;
  91. CreatePropSheet(hwnd, GetInstanceHandle(), nStartPage);
  92. g_fInOptionsDialog = FALSE;
  93. // Broadcast change notification if anything changed
  94. if (g_dwChangedSettings)
  95. {
  96. HandleConfSettingsChange(g_dwChangedSettings);
  97. g_dwChangedSettings = 0;
  98. }
  99. }
  100. BOOL CanLaunchConfCpl()
  101. {
  102. return !g_fInOptionsDialog;
  103. }
  104.