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.

157 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Modal Dialog
  5. Abstract:
  6. This contains the abstract class CModalDialog and the trivial sub class
  7. CModalOkDialog which does a simple ok dialog.
  8. Author:
  9. Marc Reyhner 8/28/2000
  10. --*/
  11. #include "stdafx.h"
  12. #include "ModalDialog.h"
  13. #include "eZippy.h"
  14. INT_PTR
  15. CModalDialog::DoModal(
  16. IN LPCTSTR lpTemplate,
  17. IN HWND hWndParent
  18. )
  19. /*++
  20. Routine Description:
  21. This does a modal dialog from the given template.
  22. Arguments:
  23. lpTemplate - Template to use see docs on DialogBoxParam
  24. hWndParent - Parent window for the dialog
  25. Return value:
  26. Dialog return code see docs on DialogBoxParam
  27. --*/
  28. {
  29. return DialogBoxParam(g_hInstance,lpTemplate,hWndParent,_DialogProc,(LPARAM)this);
  30. }
  31. INT_PTR CALLBACK
  32. CModalDialog::_DialogProc(
  33. IN HWND hwndDlg,
  34. IN UINT uMsg,
  35. IN WPARAM wParam,
  36. IN LPARAM lParam
  37. )
  38. /*++
  39. Routine Description:
  40. If this is a WM_INITDIALOG OnCreate is called. Otherwise the non-static
  41. DialogProc function is called.
  42. Arguments:
  43. See win32 DialogProc docs
  44. Return value:
  45. TRUE - Message was handles
  46. FALSE - We did not handle the message
  47. --*/
  48. {
  49. CModalDialog *rDialog;
  50. if (uMsg == WM_INITDIALOG) {
  51. rDialog = (CModalDialog*)lParam;
  52. SetWindowLongPtr(hwndDlg,DWLP_USER,lParam);
  53. return rDialog->OnCreate(hwndDlg);
  54. }
  55. rDialog = (CModalDialog*)GetWindowLongPtr(hwndDlg,DWLP_USER);
  56. if (!rDialog) {
  57. return FALSE;
  58. }
  59. return rDialog->DialogProc(hwndDlg,uMsg,wParam,lParam);
  60. }
  61. INT_PTR
  62. CModalDialog::OnCreate(
  63. IN HWND hWnd
  64. )
  65. /*++
  66. Routine Description:
  67. Empty OnCreate handler for subclasses which don't want to overide this.
  68. There is no need for a subclass to call this function if it does something
  69. in OnCreate
  70. Arguments:
  71. hWnd - the dialog window.
  72. Return value:
  73. TRUE - Always return success (sets keyboard focus).
  74. --*/
  75. {
  76. return TRUE;
  77. }
  78. INT_PTR CALLBACK
  79. CModalOkDialog::DialogProc(
  80. HWND hwndDlg,
  81. UINT uMsg,
  82. WPARAM wParam,
  83. LPARAM lParam
  84. )
  85. /*++
  86. Routine Description:
  87. The one override for CModalOkDialog simply terminates
  88. the dialog when an IDOK or IDCANCEL command is received
  89. Arguments:
  90. See win32 DialogProc docs
  91. Return value:
  92. TRUE - We handled the message
  93. FALSE - We didn't handle the message
  94. --*/
  95. {
  96. WORD command;
  97. if (uMsg == WM_COMMAND) {
  98. command = LOWORD(wParam);
  99. if (command == IDOK||command==IDCANCEL) {
  100. EndDialog(hwndDlg,command);
  101. return TRUE;
  102. }
  103. }
  104. return FALSE;
  105. }