Leaked source code of windows server 2003
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.

207 lines
6.3 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. /* File: yntoall.cpp
  3. Description: Implements the YesNoToAll dialog.
  4. Revision History:
  5. Date Description Programmer
  6. -------- --------------------------------------------------- ----------
  7. 05/28/97 Initial creation. BrianAu
  8. */
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #include "pch.h"
  11. #pragma hdrstop
  12. #include "yntoall.h"
  13. #include "resource.h"
  14. ///////////////////////////////////////////////////////////////////////////////
  15. /* Function: YesNoToAllDialog::YesNoToAllDialog
  16. Description: Class constructor.
  17. Arguments:
  18. idDialogTemplate - ID number for the dialog's resource template.
  19. Returns: Nothing.
  20. Revision History:
  21. Date Description Programmer
  22. -------- --------------------------------------------------- ----------
  23. 05/28/97 Initial creation. BrianAu
  24. */
  25. ///////////////////////////////////////////////////////////////////////////////
  26. YesNoToAllDialog::YesNoToAllDialog(
  27. UINT idDialogTemplate
  28. ) : m_idDialogTemplate(idDialogTemplate),
  29. m_hwndCbxApplyToAll(NULL),
  30. m_hwndTxtMsg(NULL),
  31. m_bApplyToAll(FALSE),
  32. m_pszTitle(NULL),
  33. m_pszText(NULL)
  34. {
  35. DBGTRACE((DM_VIEW, DL_HIGH, TEXT("YesNoToAllDialog::YesNoToAllDialog")));
  36. //
  37. // Do nothing.
  38. //
  39. }
  40. ///////////////////////////////////////////////////////////////////////////////
  41. /* Function: YesNoToAllDialog::~YesNoToAllDialog
  42. Description: Class destructor.
  43. Arguments: None.
  44. Returns: Nothing.
  45. Revision History:
  46. Date Description Programmer
  47. -------- --------------------------------------------------- ----------
  48. 05/28/97 Initial creation. BrianAu
  49. */
  50. ///////////////////////////////////////////////////////////////////////////////
  51. YesNoToAllDialog::~YesNoToAllDialog(
  52. VOID
  53. )
  54. {
  55. DBGTRACE((DM_VIEW, DL_HIGH, TEXT("YesNoToAllDialog::YesNoToAllDialog")));
  56. //
  57. // Call the Destroy() function to destroy the progress dialog window.
  58. //
  59. delete[] m_pszTitle;
  60. delete[] m_pszText;
  61. }
  62. ///////////////////////////////////////////////////////////////////////////////
  63. /* Function: YesNoToAllDialog::Create
  64. Description: Creates the dialog.
  65. Arguments:
  66. hInstance - Instance handle for the DLL containing the dialog
  67. resource template.
  68. hwndParent - Parent window for dialog.
  69. lpszTitle - Title for dialog.
  70. lpszText - Text message for dialog.
  71. Returns:
  72. TRUE = Dialog was created.
  73. FALSE = Dialog was not created.
  74. Revision History:
  75. Date Description Programmer
  76. -------- --------------------------------------------------- ----------
  77. 05/28/97 Initial creation. BrianAu
  78. */
  79. ///////////////////////////////////////////////////////////////////////////////
  80. INT_PTR
  81. YesNoToAllDialog::CreateAndRun(
  82. HINSTANCE hInstance,
  83. HWND hwndParent,
  84. LPCTSTR pszTitle,
  85. LPCTSTR pszText
  86. )
  87. {
  88. DBGASSERT((NULL != pszTitle));
  89. DBGASSERT((NULL != pszText));
  90. //
  91. // Set these in member variables so that the text can be set in the
  92. // dialog in response to WM_INITDIALOG.
  93. //
  94. m_pszTitle = StringDup(pszTitle);
  95. m_pszText = StringDup(pszText);
  96. return DialogBoxParam(hInstance,
  97. MAKEINTRESOURCE(m_idDialogTemplate),
  98. hwndParent,
  99. DlgProc,
  100. (LPARAM)this);
  101. }
  102. ///////////////////////////////////////////////////////////////////////////////
  103. /* Function: YesNoToAllDialog::DlgProc [static]
  104. Description: Message procedure for the dialog.
  105. Arguments: Standard Win32 message proc arguments.
  106. Returns: Standard Win32 message proc return values.
  107. Revision History:
  108. Date Description Programmer
  109. -------- --------------------------------------------------- ----------
  110. 05/28/97 Initial creation. BrianAu
  111. */
  112. ///////////////////////////////////////////////////////////////////////////////
  113. INT_PTR CALLBACK
  114. YesNoToAllDialog::DlgProc(
  115. HWND hwnd,
  116. UINT uMsg,
  117. WPARAM wParam,
  118. LPARAM lParam
  119. )
  120. {
  121. //
  122. // Retrieve the dialog object's ptr from the window's userdata.
  123. // Place there in response to WM_INITDIALOG.
  124. //
  125. YesNoToAllDialog *pThis = (YesNoToAllDialog *)GetWindowLongPtr(hwnd, DWLP_USER);
  126. switch(uMsg)
  127. {
  128. case WM_INITDIALOG:
  129. //
  130. // Store "this" ptr in window's userdata.
  131. //
  132. SetWindowLongPtr(hwnd, DWLP_USER, (INT_PTR)lParam);
  133. pThis = (YesNoToAllDialog *)lParam;
  134. //
  135. // Center popup on the desktop.
  136. //
  137. ::CenterPopupWindow(hwnd, GetDesktopWindow());
  138. pThis->m_hwndTxtMsg = GetDlgItem(hwnd, IDC_TXT_YNTOALL);
  139. pThis->m_hwndCbxApplyToAll = GetDlgItem(hwnd, IDC_CBX_YNTOALL);
  140. SetWindowText(pThis->m_hwndTxtMsg, pThis->m_pszText);
  141. SetWindowText(hwnd, pThis->m_pszTitle);
  142. SendMessage(pThis->m_hwndCbxApplyToAll,
  143. BM_SETCHECK,
  144. pThis->m_bApplyToAll ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED,
  145. 0);
  146. return TRUE;
  147. case WM_COMMAND:
  148. switch(LOWORD(wParam))
  149. {
  150. case IDCANCEL:
  151. case IDYES:
  152. case IDNO:
  153. DBGASSERT((NULL != pThis));
  154. pThis->m_bApplyToAll = (BST_CHECKED == SendMessage(pThis->m_hwndCbxApplyToAll, BM_GETCHECK, 0, 0));
  155. EndDialog(hwnd, LOWORD(wParam));
  156. break;
  157. }
  158. break;
  159. }
  160. return FALSE;
  161. }