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.

201 lines
4.5 KiB

  1. /* File: D:\WACKER\cncttapi\dialdlg.c (Created: 23-Mar-1994)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 3 $
  7. * $Date: 2/25/02 1:17p $
  8. */
  9. #define TAPI_CURRENT_VERSION 0x00010004 // cab:11/14/96 - required!
  10. #include <tapi.h>
  11. #pragma hdrstop
  12. #include <time.h>
  13. #include <tdll\stdtyp.h>
  14. #include <tdll\session.h>
  15. #include <tdll\tdll.h>
  16. #include <tdll\misc.h>
  17. #include <tdll\assert.h>
  18. #include <tdll\cnct.h>
  19. #include <tdll\globals.h>
  20. #include <term\res.h>
  21. #include "cncttapi.hh"
  22. #include "cncttapi.h"
  23. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  24. * FUNCTION:
  25. * DialingDlg
  26. *
  27. * DESCRIPTION:
  28. * Dialing dialog.
  29. *
  30. * ARGUMENTS:
  31. * Standard dialog arguments
  32. *
  33. * RETURNS:
  34. * BOOL
  35. *
  36. */
  37. INT_PTR CALLBACK DialingDlg(HWND hwnd, UINT uMsg, WPARAM wPar, LPARAM lPar)
  38. {
  39. #define TB_SESSION 103
  40. #define TB_TELEPHONE 104
  41. #define TB_MODEM 105
  42. #define TB_DIALICON 101
  43. #define TB_STATUS 110
  44. HHDRIVER hhDriver;
  45. TCHAR ach[256];
  46. TCHAR achFmt[100];
  47. switch (uMsg)
  48. {
  49. case WM_INITDIALOG:
  50. SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lPar);
  51. hhDriver = (HHDRIVER)lPar;
  52. mscCenterWindowOnWindow(hwnd, sessQueryHwnd(hhDriver->hSession));
  53. SendDlgItemMessage(hwnd, TB_DIALICON, STM_SETICON,
  54. (WPARAM)sessQueryIcon(hhDriver->hSession), 0);
  55. sessQueryName(hhDriver->hSession, ach, sizeof(ach));
  56. SetDlgItemText(hwnd, TB_SESSION, ach);
  57. SetDlgItemText(hwnd, TB_TELEPHONE, hhDriver->achDisplayableDest);
  58. SetDlgItemText(hwnd, TB_MODEM, hhDriver->achLineName);
  59. break;
  60. case WM_SHOWWINDOW:
  61. if (wPar == TRUE)
  62. EnableDialNow(hwnd, FALSE);
  63. break;
  64. case WM_USER+0x100: // Got connection. Close the dialog.
  65. EndModelessDialog(hwnd);
  66. break;
  67. case WM_USER+0x101: // Dialing message. Display requested string in status.
  68. hhDriver = (HHDRIVER)GetWindowLongPtr(hwnd, DWLP_USER);
  69. if (LoadString(glblQueryDllHinst(), (UINT)wPar, ach,
  70. sizeof(ach) / sizeof(TCHAR)) == 0)
  71. {
  72. assert(FALSE);
  73. break;
  74. }
  75. DbgOutStr("%s\r\n", ach, 0, 0, 0, 0);
  76. SetDlgItemText(hhDriver->hwndCnctDlg, TB_STATUS, ach);
  77. break;
  78. case WM_COMMAND:
  79. switch (wPar)
  80. {
  81. case IDOK: // Dial Now
  82. hhDriver = (HHDRIVER)GetWindowLongPtr(hwnd, DWLP_USER);
  83. hhDriver->iRedialCnt = 0;
  84. KillTimer(hwnd, 1);
  85. cnctdrvDisconnect(hhDriver,
  86. CNCT_DIALNOW | CNCT_NOCONFIRM | DISCNCT_NOBEEP);
  87. break;
  88. case IDCANCEL:
  89. hhDriver = (HHDRIVER)GetWindowLongPtr(hwnd, DWLP_USER);
  90. cnctdrvDisconnect(hhDriver, DISCNCT_NOBEEP);
  91. EndModelessDialog(hwnd);
  92. hhDriver->hwndCnctDlg = 0; // important, so we create another
  93. KillTimer(hwnd, 1);
  94. break;
  95. default:
  96. return FALSE;
  97. }
  98. break;
  99. case WM_TIMER:
  100. hhDriver = (HHDRIVER)GetWindowLongPtr(hwnd, DWLP_USER);
  101. if (--hhDriver->iRedialSecsRemaining > 0)
  102. {
  103. LoadString(glblQueryDllHinst(), IDS_DIAL_REDIAL_IN, achFmt,
  104. sizeof(achFmt) / sizeof(TCHAR));
  105. wsprintf(ach, achFmt, hhDriver->iRedialSecsRemaining);
  106. SetDlgItemText(hhDriver->hwndCnctDlg, TB_STATUS, ach);
  107. }
  108. else
  109. {
  110. PostMessage(sessQueryHwnd(hhDriver->hSession), WM_CNCT_DIALNOW,
  111. hhDriver->uDiscnctFlags, 0);
  112. }
  113. break;
  114. default:
  115. return FALSE;
  116. }
  117. return TRUE;
  118. }
  119. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  120. * FUNCTION:
  121. * DialingMessage
  122. *
  123. * DESCRIPTION:
  124. * Gets the given string ID from term's resource file and displays it
  125. * in the dialing dialog.
  126. *
  127. * ARGUMENTS:
  128. * hhDriver - private driver handle
  129. * resID - ID of resource.
  130. *
  131. * RETURNS:
  132. * void
  133. *
  134. */
  135. void DialingMessage(const HHDRIVER hhDriver, const int resID)
  136. {
  137. if (!IsWindow(hhDriver->hwndCnctDlg))
  138. return;
  139. PostMessage(hhDriver->hwndCnctDlg, WM_USER+0x101, (WPARAM)resID, 0);
  140. return;
  141. }
  142. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  143. * FUNCTION:
  144. * EnableDialNow
  145. *
  146. * DESCRIPTION:
  147. * Enables/Disables dial now button.
  148. *
  149. * ARGUMENTS:
  150. * hwndDlg - dial dialog window handle
  151. * fEnable - TRUE/FALSE
  152. *
  153. * RETURNS:
  154. * void
  155. *
  156. */
  157. void EnableDialNow(const HWND hwndDlg, const int fEnable)
  158. {
  159. if (IsWindow(hwndDlg))
  160. {
  161. EnableWindow(GetDlgItem(hwndDlg, IDOK), fEnable);
  162. if (fEnable == FALSE)
  163. SetFocus(GetDlgItem(hwndDlg,IDCANCEL));
  164. else
  165. SetFocus(GetDlgItem(hwndDlg, IDOK));
  166. }
  167. return;
  168. }