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.

152 lines
4.1 KiB

  1. /* File: D:\WACKER\tdll\dodialog.c (Created: 30-Nov-1993)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 5 $
  7. * $Date: 3/22/01 11:27a $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include "stdtyp.h"
  12. #include "session.h"
  13. #include "tdll.h"
  14. #include "globals.h"
  15. #include "statusbr.h"
  16. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  17. * FUNCTION: DoDialog
  18. *
  19. * DESCRIPTION: Use this routine to call dialogs. It creates ProcInstance
  20. * of the dialog procedure automatically and destroys it on
  21. * exit.
  22. *
  23. * ARGUMENTS: hInstance - instance handle of template's module
  24. * lpTemplateName - name of dialog-box template
  25. * hwndParent - window thats get focus when done
  26. * lpProc - far pointer to the dialog procedure.
  27. * - Note: lpProc is NOT the pointer
  28. * obtained from MakeProcInstance...
  29. * lPar - Can be used to pass data to dlg proc.
  30. *
  31. * RETURNS: Whatever the dilogbox returns on exit.
  32. *
  33. */
  34. INT_PTR DoDialog(HINSTANCE hInstance, LPCTSTR lpTemplateName,
  35. HWND hwndParent, DLGPROC lpProc, LPARAM lPar)
  36. {
  37. INT_PTR sRetVal; // return value for DialogBox()
  38. HWND hwndFrame;
  39. HSESSION hSession;
  40. // Normal dialog box stuff...
  41. sRetVal = DialogBoxParam(hInstance, lpTemplateName, hwndParent,
  42. lpProc, lPar);
  43. #if !defined(NDEBUG)
  44. if (sRetVal == -1)
  45. {
  46. TCHAR str[128], awch[50];
  47. OemToChar("Couldn't load %s. (%s, %d)", awch);
  48. wsprintf(str, awch, lpTemplateName, (LPTSTR)__FILE__, __LINE__);
  49. OemToChar("Internal Error", awch);
  50. MessageBox(hwndParent, str, awch, MB_OK | MB_ICONHAND);
  51. }
  52. #endif
  53. // We should force the statusbar window ro refresh its display
  54. // here to reflect the state of the keys the user might have pressed while
  55. // the dialog was up.
  56. //
  57. // Yes, I know we are relying on the fact that the frame window is the
  58. // the session window. This may have to change in UPPER-WACKER.
  59. //
  60. hwndFrame = glblQueryHwndFrame();
  61. if (IsWindow(hwndFrame) && (hwndFrame == hwndParent))
  62. {
  63. hSession = (HSESSION)GetWindowLongPtr(hwndFrame, GWLP_USERDATA);
  64. PostMessage(sessQueryHwndStatusbar(hSession), SBR_NTFY_REFRESH,
  65. SBR_KEY_PARTS, 0);
  66. }
  67. return sRetVal;
  68. }
  69. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  70. * FUNCTION: DoModelessDialog
  71. *
  72. * DESCRIPTION: This is a verion of the previous function that differs
  73. * in that it creates and registers a modeless dialog
  74. *
  75. * ARGUMENTS: hInstance - instance handle of template's module
  76. * lpTemplateName - name of dialog-box template
  77. * hwndOwner - window thats get focus when done
  78. * lpProc - far pointer to the dialog procedure.
  79. * - Note: lpProc is NOT the pointer
  80. * obtained from MakeProcInstance...
  81. * lPar - Can be used to pass data to dlg proc.
  82. *
  83. * RETURNS:
  84. * The window handle of the dialog box that was created.
  85. *
  86. */
  87. HWND DoModelessDialog(HINSTANCE hInstance, LPCTSTR lpTemplateName,
  88. HWND hwndOwner, DLGPROC lpProc, LPARAM lPar)
  89. {
  90. HWND hwndBox;
  91. hwndBox = CreateDialogParam(hInstance,
  92. lpTemplateName,
  93. hwndOwner,
  94. lpProc,
  95. lPar);
  96. if (hwndBox)
  97. {
  98. glblAddModelessDlgHwnd(hwndBox);
  99. }
  100. #if !defined(NDEBUG)
  101. if (hwndBox == NULL)
  102. {
  103. TCHAR str[128], awch[50];
  104. OemToChar("Couldn't load %s. (%s, %d)", awch);
  105. wsprintf(str, awch, lpTemplateName, (LPTSTR)__FILE__, __LINE__);
  106. OemToChar("Internal Error", awch);
  107. MessageBox(hwndOwner, str, awch, MB_OK | MB_ICONHAND);
  108. }
  109. #endif
  110. return hwndBox;
  111. }
  112. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  113. * FUNCTION:
  114. * EndModelessDialog
  115. *
  116. * DESCRIPTION:
  117. * This function is used to remove a modeless dialog from whatever we are
  118. * doing with it.
  119. *
  120. * PARAMETERS:
  121. * hDlg -- the window handle of the modeless dialog
  122. *
  123. * RETURNS:
  124. * ZERO for now. Maybe something else later.
  125. *
  126. */
  127. INT EndModelessDialog(HWND hDlg)
  128. {
  129. if (IsWindow(hDlg))
  130. PostMessage(glblQueryHwndFrame(), WM_SESS_ENDDLG, 0, (LPARAM)hDlg);
  131. return 0;
  132. }