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.

198 lines
6.3 KiB

  1. //
  2. // connectingdlg.cpp: connecting dialog box
  3. //
  4. #include "stdafx.h"
  5. #define TRC_GROUP TRC_GROUP_UI
  6. #define TRC_FILE "connectingdlg"
  7. #include <atrcapi.h>
  8. #include "connectingdlg.h"
  9. #include "sh.h"
  10. CConnectingDlg* CConnectingDlg::_pConnectingDlgInstance = NULL;
  11. CConnectingDlg::CConnectingDlg( HWND hwndOwner, HINSTANCE hInst,
  12. CContainerWnd* pContWnd, PDCTCHAR szServer) :
  13. CDlgBase( hwndOwner, hInst, UI_IDD_CONNECTING), _pContainerWnd(pContWnd)
  14. {
  15. DC_BEGIN_FN("CConnectingDlg");
  16. TRC_ASSERT((NULL == CConnectingDlg::_pConnectingDlgInstance),
  17. (TB,_T("Clobbering existing dlg instance pointer\n")));
  18. TRC_ASSERT(_pContainerWnd, (TB,_T("_pContainerWnd is NULL")));
  19. TRC_ASSERT(szServer, (TB,_T("szServer not set\n")));
  20. if(szServer)
  21. {
  22. DC_TSTRNCPY(_szServer, szServer, sizeof(_szServer)/sizeof(DCTCHAR));
  23. }
  24. else
  25. {
  26. DC_TSTRNCPY(_szServer, TEXT(""), sizeof(_szServer)/sizeof(DCTCHAR));
  27. }
  28. CConnectingDlg::_pConnectingDlgInstance = this;
  29. DC_END_FN();
  30. }
  31. CConnectingDlg::~CConnectingDlg()
  32. {
  33. CConnectingDlg::_pConnectingDlgInstance = NULL;
  34. }
  35. DCINT CConnectingDlg::DoModal()
  36. {
  37. DCINT retVal = 0;
  38. DC_BEGIN_FN("DoModal");
  39. retVal = DialogBox(_hInstance, MAKEINTRESOURCE(_dlgResId),
  40. _hwndOwner, StaticDialogBoxProc);
  41. if (retVal == -1)
  42. {
  43. TRC_ERR((TB, _T("DialogBoxParam failed\n")));
  44. }
  45. DC_END_FN();
  46. return retVal;
  47. }
  48. INT_PTR CALLBACK CConnectingDlg::StaticDialogBoxProc (HWND hwndDlg, UINT uMsg,WPARAM wParam, LPARAM lParam)
  49. {
  50. //
  51. // Delegate to appropriate instance (only works for single instance dialogs)
  52. //
  53. DC_BEGIN_FN("StaticDialogBoxProc");
  54. DCINT retVal = 0;
  55. TRC_ASSERT(_pConnectingDlgInstance, (TB, _T("Connecting dialog has NULL static instance ptr\n")));
  56. if(_pConnectingDlgInstance)
  57. {
  58. retVal = _pConnectingDlgInstance->DialogBoxProc( hwndDlg, uMsg, wParam, lParam);
  59. }
  60. DC_END_FN();
  61. return retVal;
  62. }
  63. /****************************************************************************/
  64. /* Name: DialogBoxProc */
  65. /* */
  66. /* Purpose: Handles Connecting Box dialog */
  67. /* */
  68. /* Returns: TRUE if message dealt with */
  69. /* FALSE otherwise */
  70. /* */
  71. /* Params: See window documentation */
  72. /* */
  73. /****************************************************************************/
  74. INT_PTR CALLBACK CConnectingDlg::DialogBoxProc (HWND hwndDlg, UINT uMsg,WPARAM wParam, LPARAM lParam)
  75. {
  76. INT_PTR rc = FALSE;
  77. DCUINT intRC;
  78. DCTCHAR connectingString[SH_VERSION_STRING_MAX_LENGTH];
  79. DC_BEGIN_FN("DialogProc");
  80. /************************************************************************/
  81. /* Handle dialog messages */
  82. /************************************************************************/
  83. switch(uMsg)
  84. {
  85. case WM_INITDIALOG:
  86. {
  87. _hwndDlg = hwndDlg;
  88. _pContainerWnd->SetStatusDialogHandle( hwndDlg);
  89. if(hwndDlg)
  90. {
  91. DCTCHAR temp[SH_DISPLAY_STRING_MAX_LENGTH+SH_MAX_ADDRESS_LENGTH];
  92. CenterWindow(_hwndOwner);
  93. ::ShowWindow( _hwndDlg, SW_RESTORE);
  94. SetDialogAppIcon(hwndDlg);
  95. intRC = LoadString( _hInstance,
  96. UI_IDS_CONNECTING_TO_SERVER,
  97. connectingString,
  98. SH_DISPLAY_STRING_MAX_LENGTH );
  99. if(0 == intRC)
  100. {
  101. TRC_ERR((TB,_T("Failed to find UI connecting string")));
  102. connectingString[0] = (DCTCHAR) 0;
  103. break;
  104. }
  105. _stprintf(temp, connectingString, _szServer);
  106. SetDlgItemText(hwndDlg, UI_IDC_CONN_STATIC, temp);
  107. SetCursor(LoadCursor(NULL, IDC_ARROW));
  108. }
  109. rc = TRUE;
  110. }
  111. break;
  112. case WM_COMMAND:
  113. {
  114. switch(DC_GET_WM_COMMAND_ID(wParam))
  115. {
  116. case IDCANCEL:
  117. case UI_ID_CANCELCONNECT:
  118. {
  119. TRC_NRM((TB, _T("User cancelled connection - ")
  120. _T("calling UIInitiateDisconnection")));
  121. _pContainerWnd->Disconnect();
  122. _pContainerWnd->SetStatusDialogHandle( NULL);
  123. EndDialog(hwndDlg, IDCANCEL);
  124. }
  125. break;
  126. default:
  127. {
  128. if(hwndDlg)
  129. {
  130. rc = CDlgBase::DialogBoxProc(hwndDlg,
  131. uMsg,
  132. wParam,
  133. lParam);
  134. }
  135. }
  136. break;
  137. }
  138. }
  139. break;
  140. #ifndef OS_WINCE
  141. case WM_WINDOWPOSCHANGING:
  142. {
  143. //Prevent the dialog from being
  144. //sized. This can happen if the app
  145. //is laucnhed with a .RDP shortcut that
  146. //specifies the app should be maximized
  147. LPWINDOWPOS lpwp;
  148. lpwp = (LPWINDOWPOS)lParam;
  149. lpwp->flags |= SWP_NOSIZE;
  150. }
  151. break;
  152. #endif
  153. default:
  154. {
  155. if(hwndDlg)
  156. {
  157. rc = CDlgBase::DialogBoxProc(hwndDlg,
  158. uMsg,
  159. wParam,
  160. lParam);
  161. }
  162. }
  163. break;
  164. }
  165. DC_END_FN();
  166. return(rc);
  167. } /* DialogBoxProc */