Source code of Windows XP (NT5)
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
3.7 KiB

  1. /*++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1981 - 1999
  4. Module Name:
  5. recvconf.cpp
  6. Abstract:
  7. Dialog which prompts the user for receive confirmation.
  8. Author:
  9. Rahul Thombre (RahulTh) 10/26/1999
  10. Revision History:
  11. 10/26/1999 RahulTh Created this module.
  12. --*/
  13. #include "precomp.hxx"
  14. CRecvConf::CRecvConf (CWnd * pParent /*= NULL*/)
  15. : CDialog (CRecvConf::IDD, pParent), m_bShowAllYes (TRUE),
  16. m_bDirectory (FALSE), m_pParent(pParent)
  17. {
  18. }
  19. void CRecvConf::ShowAllYes (BOOL bShow)
  20. {
  21. m_bShowAllYes = bShow;
  22. }
  23. void CRecvConf::InitNames (LPCTSTR szMachine, LPTSTR szFile, BOOL fDirectory)
  24. {
  25. TCHAR szCompactName [COMPACT_PATHLEN + 1];
  26. DWORD len;
  27. m_szMachine = szMachine;
  28. m_bDirectory = fDirectory;
  29. if (m_bDirectory)
  30. {
  31. len = wcslen (szFile);
  32. if (L'\\' == szFile[len - 1])
  33. {
  34. szFile[len - 1] = L'\0';
  35. len--;
  36. }
  37. }
  38. //compact the filename so that we do not overrun the text control
  39. if (COMPACT_PATHLEN < len &&
  40. PathCompactPathEx (szCompactName, szFile, COMPACT_PATHLEN + 1, 0))
  41. {
  42. m_szFileName = szCompactName;
  43. }
  44. else
  45. {
  46. m_szFileName = szFile;
  47. }
  48. }
  49. void CRecvConf::DoDataExchange(CDataExchange* pDX)
  50. {
  51. CDialog::DoDataExchange(pDX);
  52. //{{AFX_DATA_MAP(CRecvConf)
  53. DDX_Control(pDX, IDC_CONFIRMTEXT, m_confirmText);
  54. DDX_Control(pDX, IDYES, m_btnYes);
  55. DDX_Control(pDX, IDALLYES, m_btnAllYes);
  56. //}}AFX_DATA_MAP
  57. }
  58. BEGIN_MESSAGE_MAP(CRecvConf, CDialog)
  59. //{{AFX_MSG_MAP(CRecvConf)
  60. ON_BN_CLICKED(IDYES, OnYes)
  61. ON_BN_CLICKED(IDALLYES, OnAllYes)
  62. //}}AFX_MSG_MAP
  63. END_MESSAGE_MAP()
  64. BOOL CRecvConf::OnInitDialog()
  65. {
  66. AFX_MANAGE_STATE (AfxGetStaticModuleState());
  67. CString szFormat;
  68. CString szDisplay;
  69. CWnd * pDesktop = NULL;
  70. int newHeight, newWidth, xshift, yshift;
  71. RECT rc;
  72. CDialog::OnInitDialog();
  73. //display the confirmation text.
  74. szFormat.LoadString (m_bDirectory ? IDS_CONFIRM_FOLDER : IDS_CONFIRM_FILE);
  75. szDisplay.Format (szFormat, m_szMachine, m_szFileName);
  76. m_confirmText.SetWindowText (szDisplay);
  77. //hide the "Yes To All" button if necessary
  78. //also move the Yes button in that case.
  79. if (! m_bShowAllYes)
  80. {
  81. RECT rectAllYes;
  82. m_btnAllYes.ShowWindow (SW_HIDE);
  83. m_btnAllYes.GetWindowRect (&rectAllYes);
  84. ::MapWindowPoints (NULL, m_hWnd, (LPPOINT) &rectAllYes, 2);
  85. m_btnYes.SetWindowPos (NULL, rectAllYes.left, rectAllYes.top, -1, -1,
  86. SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOSIZE);
  87. }
  88. //reposition the window so that it is at the center of the screen
  89. //also push this window to the top after activating it
  90. GetClientRect (&rc);
  91. newHeight = rc.bottom;
  92. newWidth = rc.right;
  93. pDesktop = GetDesktopWindow();
  94. pDesktop->GetClientRect (&rc);
  95. yshift = (rc.bottom - newHeight)/2;
  96. xshift = (rc.right - newWidth)/2;
  97. //there might be a problem if someday the dialog should
  98. //get larger than the desktop. But then, there is no way
  99. //we can fit that window inside the desktop anyway.
  100. //So the best we can do is place it at the top left corner
  101. xshift = (xshift >= 0)?xshift:0;
  102. yshift = (yshift >= 0)?yshift:0;
  103. appController->SetForegroundWindow();
  104. SetActiveWindow();
  105. SetWindowPos (&wndTop, xshift, yshift, -1, -1,
  106. SWP_NOSIZE | SWP_NOOWNERZORDER);
  107. return TRUE; // return TRUE unless you set the focus to a control
  108. // EXCEPTION: OCX Property Pages should return FALSE
  109. }
  110. void CRecvConf::OnYes ()
  111. {
  112. EndDialog (IDYES);
  113. }
  114. void CRecvConf::OnAllYes ()
  115. {
  116. EndDialog (IDALLYES);
  117. }